akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ret = 0;
    for(int i=0; i< n; i++){
        bool is = false;
        string input; cin >> input;
        for(int i=0; i< input.size(); i++){
            if(input[i] == s[0]){
                for(int j=i+1; j < input.size(); j++){
                    if(input[j] == s[1]){
                        int diff = j-i;
                        bool possible = true;
                        for(int k=2; k < s.size(); k++) if(input.size() <= i+diff*k || input[i+diff*k] != s[k]) possible = false;
                        if(possible){is = true; break;}
                    }
                }
            }
            if(is) break;
        }
        if(is) ret++;
    }
    cout << ret << endl;
}

Measured memory_bytes: 1208
/* ***********************************************
Author        :axp
Created Time  :2017/2/4 20:29:46
TASK		  :A.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
int n,m;
int x,ans;
int T;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>n;
	while(n--)
	{
		cin>>x;
		if(x&1)ans++;
	}
	if(ans&1)puts("NO");
	else puts("YES");
    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, X;
    cin >> K >> X;
    for (int i = X - K + 1; i <= X + K - 1; i++) {
        cout << i << " \n"[i == X + K - 1];
    } 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
int N;
ll xs, ys, xg, yg;
ll X[MAX_N], Y[MAX_N];
ll dp[MAX_N+1];

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

  cin >> xs >> ys >> xg >> yg;
  cin >> N;
  rep(i, N) cin >> X[i] >> Y[i];

  xg -= xs;
  yg -= ys;
  for (int i = 0; i < N; ++i) {
      X[i] -= xs;
      Y[i] -= ys;
  }

  if (xg < 0) {
      xg *= -1;
      for (int i = 0; i < N; ++i) {
          X[i] *= -1;
      }
  }
  if (yg < 0) {
      yg *= -1;
      for (int i = 0; i < N; ++i) {
          Y[i] *= -1;
      }
  }

  vector<Pii> vp;
  for (int i = 0; i < N; ++i) {
      if (0 <= X[i] && X[i] <= xg && 0 <= Y[i] && Y[i] <= yg) {
          vp.push_back(Pii(X[i], Y[i]));
      }
  }
  sort(all(vp));

  for (int i = 0; i < _size(vp)+1; ++i) {
      dp[i] = INFINT;
  }
  dp[0] = -1;

  for (int i = 0; i < _size(vp); ++i) {
      int idx = upper_bound(dp, dp+_size(vp)+1, vp[i].sc) - dp;
      dp[idx] = vp[i].sc;
  }

  ll K = 0;
  for (int i = 1; i < _size(vp)+1; ++i) {
      if (dp[i] < INFINT) {
          ++K;
      } else {
          break;
      }
  }

  ll s = xg + yg;
  ll q, p;
  if (K < min(xg, yg) + 1) {
      q = K;
      p = 0;
  } else {
      q = K-1;
      p = 1;
  }

  printf("%.15lf\n", 100.0*s - (20.0 - 5.0*M_PI)*q - (20.0 - 10.0*M_PI)*p);
  return 0;
}


Measured memory_bytes: 6640
#include "bits/stdc++.h"
using namespace std;

int main(){
//input
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &ref : a){
        cin >> ref;
    }
//input end

    int max1,max2;
    max1 = max2 = 0;
    int maxindex;
    for(int i = 0; i < n;i++){
        if(a[i] >= max1){
            max1 = a[i];
            maxindex = i;
        }
    }
    for(int i = 0; i < n;i++){
        if(a[i] >= max2 && i != maxindex){
            max2 = a[i];
        }
    }
    for(int i = 0;i < n;i++){
        if(i == maxindex){
            cout << max2 << endl;
        }else{
            cout << max1 << endl;
        }
    }
    return 0;
}

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

typedef long long ll;
inline int readInt() {
	int n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
	return n;
}

const int MAX_N = 100000 + 3;
int R, C, n, xx1[MAX_N], yy1[MAX_N], xx2[MAX_N], yy2[MAX_N];

struct Interval {
	int l, r;
	Interval(int l = 0, int r = 0) : l(l), r(r) {}

	bool operator < (const Interval &ano) const {
		return ano.l < l || (ano.l == l && r < ano.r);
	}
} intervals[MAX_N];

inline int getID(int x, int y) {
	if (x == 0) {
		return y;
	} else if (y == C) {
		return C + x;
	} else if (x == R) {
		return R + C + (C - y);
	} else if (y == 0) {
		return R + C * 2 + (R - x);
	} else return -1;
}

struct FenwickTree {
	static const int MAX_LEN = MAX_N * 4;
	int n, s[MAX_LEN];

	#define lowbit(x) ((x) & -(x))

	void init(int _n) {
		n = _n;
		memset(s, 0, sizeof s);
	}
	
	inline int query(int pos) const {
		int res = 0;
		for (int i = pos + 1; i > 0; i -= lowbit(i))
			res += s[i];
		return res;
	}

	inline void add(int pos, int val) {
		for (int i = pos + 1; i <= n; i += lowbit(i))
			s[i] += val;
	}
} bit;

int cnt = 0;

int compress() {
	vector<int> vs;
	vs.reserve(cnt * 2);
	for (int i = 0; i < cnt; ++i) vs.push_back(intervals[i].l), vs.push_back(intervals[i].r);
	sort(vs.begin(), vs.end());
	vs.erase(unique(vs.begin(), vs.end()), vs.end());
	for (int i = 0; i < cnt; ++i) {
		intervals[i].l = lower_bound(vs.begin(), vs.end(), intervals[i].l) - vs.begin();
		intervals[i].r = lower_bound(vs.begin(), vs.end(), intervals[i].r) - vs.begin();
	}
	return vs.size();
}

int main() {
//	freopen("test.in", "r", stdin);
	R = readInt(), C = readInt(), n = readInt();
	for (int i = 0; i < n; ++i) {
		xx1[i] = readInt(), yy1[i] = readInt(), xx2[i] = readInt(), yy2[i] = readInt();
		int l = getID(xx1[i], yy1[i]), r = getID(xx2[i], yy2[i]);
		if (l > r) swap(l, r);
		if (l != -1 && r != -1) intervals[cnt++] = Interval(l, r);
	}
	
	sort(intervals, intervals + cnt);
	
	bit.init(compress());

	for (int i = 0; i < cnt; ++i) {
		if (bit.query(intervals[i].r) - bit.query(intervals[i].l) != 0)
			return puts("NO"), 0;
		bit.add(intervals[i].l, 1);
		bit.add(intervals[i].r, -1);
	}
	puts("YES");

	return 0;
}


Measured memory_bytes: 4280
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>

using namespace std;

typedef long long int ll;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<ll> v(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  /*
   * a個先頭から選ぶ
   */
  ll total = 0;
  for (int i = 0; i < a; i++) {
    total += v[i];
  }
  double mean = total * (double) (1) / a;
  auto chose = [](ll n, ll m) {
    //nからm個選ぶ
    if (m > n)
      return 0ll;
    if (n == m || m == 0)
      return 1ll;
    ll mf = 1;
    for (int i = 1; i <= m; i++) {
      mf *= i;
    }
    ll p = 1;
    for (int i = n; i >= n - m + 1; i--) {
      p *= i;
    }
    return p / mf;
  };

  /*
   * パスカルの三角形をn段目まで生成する関数 0 indexed
   */
  auto generate_pascal = [](int n) {
    vector<vector<ll>> pascal(n + 1, vector<ll>(n + 1, 0));
    pascal[0][0] = 1;
    for(int i = 1; i <= n; i++)
    {
      pascal[i][0] = 1;
      pascal[i][i] = 1;
      for(int j = 1; j < n; j++)
      {
        pascal[i][j] = pascal[i - 1][j] + pascal[i - 1][j - 1];
      }
    }
    return pascal;
  };
  vector<vector<ll>> pascal = generate_pascal(n);
  ll count = 0;
  if (v[0] != v[a - 1]) {
    /*
     * v[a - 1]と等しい数の個数を[0~N - 1],[0~a - 1]の範囲で探す
     */
    int numb = 0;
    for (int i = 0; i < a; i++) {
      if (v[i] == v[a - 1]) {
        numb++;
      }
    }
    int numa = 0;
    for (int i = 0; i < n; i++) {
      if (v[i] == v[a - 1]) {
        numa++;
      }
    }
    //count = chose(numa, numb);
    count = pascal[numa][numb];
  } else {
    /*
     * v[a - 1]と等しい数の個数からa~b個選ぶやり方を計算する
     */
    int num = 0;
    for (int i = 0; i < n; i++) {
      if (v[i] == v[a - 1]) {
        num++;
      }
    }
    for (int i = a; i <= b; i++) {
      //count += chose(num, i);
      count += pascal[num][i];
    }
  }
  cout << fixed;
  cout << setprecision(6);
  cout << mean << endl;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	ll ans=0,c=0;
	for(int i=0;i<n;i++){
		ll a,b;cin>>a>>b;
		if(a==b){c+=1;}
		else{c=0;}
		ans=max(ans,c);
	}
	if(ans>=3){cout<<"Yes";}
	else{cout<<"No";}
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

Measured memory_bytes: 3632
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>

int main()
{
	std::stack<char> st;
	std::string s;

	std::cin >> s;

	int cnt = 0;
	for (auto& it : s) {
		if (st.size() && st.top() != it) {
			st.pop();
			cnt++;
		}
		else {
			st.push(it);
		}
	}
	std::cout << cnt*2;
	return 0;
}

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

struct Card { char suit, value;} ;

void bubble(struct Card A[], int N)
{
    for(int i=0;i<N;i++)
    {
        for(int j = N-1;j >= i+1;j--)
        {
            if(A[j].value < A[j-1].value)
            {
                Card t = A[j];
                A[j] = A[j-1];
                A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N)
{
    for(int i=0;i<N;i++)
    {
        int minj = i;
        for(int j = i; j<N;j++)
        {
            if(A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}

void print(struct Card A[], int N)
{
    for(int i=0;i<N;i++)
    {
        if(i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N)
{
    for(int i=0;i<N;i++)
    {
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main()
{
    Card C1[100],C2[100];
    int N;
    int i;
    char ch;

    cin >> N;
    for(i=0;i<N;i++)
    {
        cin >> C1[i].suit >> C1[i].value;
    }

    for(i=0;i<N;i++)
    {
        C2[i] = C1[i];
    }

    bubble(C1,N);
    selection(C2,N);

    print(C1,N);
    cout << "Stable" << endl;
    print(C2,N);
    if(isStable(C1,C2,N))
    {
        cout << "Stable" << endl;
    }
    else 
    {
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

int n, x, k, ans;

int work(int x, int k)
{
    if (x < k) return 0;
    if (x % k == 0) return x / k;
    int tmp = x / k, nxt = tmp * k;
    x -= (x - nxt) / (tmp + 1) * (tmp + 1);
    return !(x % k) ? x / k : work(x - tmp - 1, k);
}

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n)
    {
        scanf("%d%d", &x, &k);
        ans ^= work(x, k);
    }
    if (ans) puts("Takahashi"); else puts("Aoki");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s = to_string(n);
  int t = 0;
  rep(i, s.size()) t += s.at(i) - '0';
  if(n % t == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int p[10000];
int n;

int isPrime(int m){
  for(int i=0;i<n;i++){
    if(p[i]==m)return 1;
  }
  return 0;
}

int main(){
  int i,j,k,cnt=0;
  int h,w;
  cin>>h>>w;
  char s[h][w];
  for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>s[i][j];
  int b=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s[i][j]=='#')b++;
    }
  }
  ll d[h+2][w+2],t[h+2][w+2];
  for(i=0;i<=h+1;i++)for(j=0;j<=w+1;j++)d[i][j]=INT_MAX;
  d[h][w]=0;
  while(1){
    cnt=1;
    for(i=1;i<=h;i++)for(j=1;j<=w;j++)t[i][j]=d[i][j];
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
        if(s[i-1][j-1]=='.'){
          d[i][j]=min(min(min(d[i+1][j],d[i][j+1]),min(d[i-1][j],d[i][j-1]))+1,d[i][j]);
        }
      }
    }
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
        if(t[i][j]!=d[i][j]){
          cnt=0;
          break;
        }
      }
      if(cnt==0)break;
    }
    if(cnt==1)break;
  }
  if(d[1][1]>2500)cout<<-1;
  else cout<<h*w-b-(d[1][1]+1);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <map>

int main(){
    int n, m;

    std::cin >> n >> m;

    std::vector<std::vector<int> > v(n, std::vector<int>(m));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> v[i][j];
        }
    }

    std::vector<int> v2(m);
    for (int i = 0; i < m; i++) {
        std::cin >> v2[i];
    }

    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < m; j++) {
            sum += v2[j] * v[i][j];
        }
        std::cout << sum << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>

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

#define rep(i,a,b) for(int i = a;i <= b;++i)
#define per(i,a,b) for(int i = a;i >= b;--i)

const int mmax = 2e5;
int n,k;
int a[mmax + 10],l = 1e9,r = 0,ans;

bool check(int x){
	int num = 0,t;
	rep(i,1,n){
		t = a[i] / x;
		if(t * x == a[i]) num += t - 1;
		else num += t;
	}
	return (num <= k?1:0);
}

int main(){

	std::ios::sync_with_stdio(0);
	cin.tie(0);

	cin>>n>>k;

	rep(i,1,n){
		cin>>a[i];
		r = std::max(r,a[i]);
	}
	l = 1;
	ans = r;

	while(r - l >=1){
		int m = (l + r) / 2;
		if(check(m)){
			ans = m;
			r = m;
		}
		else{
			l = m + 1;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 4380
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int calc(string s)
{
    int res=0;
    int N=s.size();
    for(int i=0;i<N;){
        int i0=i;
        while(i<N and s[i]==s[i0]) i++;
        res+=(i-i0)/2;
    }
    return res;
}

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

    string s; cin>>s;
    int K; cin>>K;
    int N=s.size();

    if(s[0]!=s[N-1]){
        cout<<calc(s)*K<<endl;
        return 0;
    }

    string t=s;
    sort(t.begin(),t.end());
    if(t[0]==t[N-1]){
        cout<<N*K/2<<endl;
        return 0;
    }

    int l=0,r=N-1;
    while(l<N and s[l]==s[0]) l++;
    while(r>=0 and s[r]==s[N-1]) r--;
    // cout<<l<<' '<<r<<endl;
    // cout<<s.substr(l,r-l+1)<<endl;
    int ans=l/2+(l+N-1-r)/2*(K-1)+(N-1-r)/2+calc(s.substr(l,r-l+1))*K;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))

A={}
s=sum(X)
for i in range(1,101):
    A[i]=N*i**2-2*i*s

min_i=min(A, key=A.get)

a=0
for j in range(N):
   a+=(X[j]-min_i)**2 

print(a)

Measured memory_bytes: 3060
main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  [a,b] <- map read.words <$> getLine :: IO [Int]
  ps <- map read.words <$> getLine :: IO [Int]
  print $ minimum [length $ filter (<= a) ps, length $ filter (\p -> a < p && p <= b) ps, length $ filter (b <) ps]


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

int main(void) {
double a,b,c,d;
double e;
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
e=(a-c)*(a-c)+(b-d)*(b-d);
e=sqrt(e);
printf("%f",e);



return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

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

    int ans=1;
    for(int i=1; i<n; i++){
        bool valid = true;
        for(int j=0; j<i; j++){
            if(h[j] <= h[i]) continue;
            valid = false;
        }
        if(valid) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int count=0,i;
  for(i=0;i<(s.length())/2;i++){
    if(s[i]!=s[s.length()-i-1])count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define rep(i,n) for(int i=0;i<n;i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){

  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  vector<int> power(N);//0zahyo 1 power
  for(int i=0; i<N; i++){
    cin>>A[i];
  }
  rep(k,min(K,41)){
    rep(i,N)power[i]=0;
    rep(i,N){
      int l,r;
      l=max(0,i-A[i]);
      r=min(N-1,i+A[i]);
      power[l]++;
      if(r+1<N)power[r+1]--;
    }
    for(int i=1;i<N;i++){
    power[i]+=power[i-1];
    }
    A=power;
  }
  rep(i,N){
    cout<<A[i]<<" ";
  }
  cout<<endl;
  
}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int N, A, B, C, D;
string S;
bool flag;

void dfs(int cur, int goal) {
    // 終了条件
    if (cur > goal) {
        return;
    }
    if (cur == goal) {
        flag = true;
        return;
    }
    if (S[cur+1] == '#' && S[cur+2] == '#') {
        flag = false;
        return;
    }

    // next
    if (S[cur+1] == '.') dfs(cur+1, goal);
    if (S[cur+2] == '.') dfs(cur+2, goal);

    return;
}

int main() {
    cin >> N >> A >> B >> C >> D;
    cin >> S;

    S.push_back('#');

    if (C < D) {
        // B → D
        dfs(B-1, D-1);
        // 無理ならNo return 0;
        if (!flag) {
            no;
            return 0;
        }

        // A → C
        dfs(A-1, C-1);
        // 無理ならNo return 0;
        if (!flag) {
            no;
            return 0;
        }

        // Yes return 0;
        yes;
        return 0;

    } else { // D < C
        // B → D
        dfs(B-1, D-1);
        // 無理ならNo return 0;
        if (!flag) {
            no;
            return 0;
        }

        // 下準備
        bool flagt = false;
        REP(i, B-1, D) {
            if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
                S[i] = '#';
                flagt = true;
                break;
            }
        }
        if (!flagt) {
            no;
            return 0;
        }

        // A → C
        dfs(A-1, C-1);
        // 無理ならNo return 0;
        if (!flag) {
            no;
            return 0;
        }

        // Yes return 0;
        yes;
        return 0;
    }

}



Measured memory_bytes: 2948
n = input()

if n[0] == n[1] == n[2] :
    print(n)
else:
    if int(n) < int(n[0]) * 111:
        print(int(n[0]) * 111)
    elif int(n[0]) * 111 < int(n):
        print((int(n[0]) + 1) * 111)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define int long long
#define US unsigned
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define TWO(conditions, a, b) ((conditions) ? #a : #b)
using namespace std;
const double PI = acos(-1.0);

int max_n(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_o(int ary[], int length) {
	int max;
	max = max_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_n(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_o(int ary[], int length) {
	int min;
	min = min_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while (k != 0);
	return result;
}

int gcm_n(int ary[], int length) {
	int g = ary[0];
	for (int i = 0; i < length; i++)
		g = gcm(g, ary[i]);
	return g;
}

int lcm(int a, int b) {
	int g, n;
	g = gcm(a, b);
	n = gcm(a, g);
	a = a / n;
	b = b / (g / n);
	return a*b;
}

int lcm_n(int ary[], int length) {
	int l = ary[0];
	for (int i = 0; i < length; i++)
		l = lcm(l, ary[i]);
	return l;
}

signed main() {
	int n, t[100];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> t[i];
	cout << lcm_n(t, n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int calc(int num[],int right[],int left[],int z,int r,int l);

int main(void){
   int N;
   int i;
   
   scanf("%d",&N);
   
   for(i=0;i<N;i++){
      int num[10],right[11],left[11];
      int j,z = 0;
      //right,left »ÝÌvfÔ
      int r = 1;
      int l = 1;
      int flag;
      
      //ãü
      for(j=0;j<10;j++){
         scanf("%d",&num[j]);
         //right,left ú»
         right[j] = 0;
         left[j] = 0;
      }
      //ÅAãü·éÆ«³ðÅüêé½ßêÂâµ½©ç»Ìªú»
      right[10] = 0;
      left[10] = 0;
      
      flag = calc(num,right,left,z,r,l);
      
      (flag == 0) ? puts("YES") : puts("NO");
      
      //ú»
      flag = 0;
      z = 0;
   }
   return 0;
}

int calc(int num[],int right[],int left[],int z,int r,int l){
   //àµz==10Èç·×ÄüÁ½Æ¢¤±Æ¾©çI¹
   if(z == 10)
      return 0;
   
   if(right[r-1] < num[z]){
      right[r] = num[z];
      if(calc(num,right,left,z+1,r+1,l) == 0)
         return 0;
      else
         right[r] = 0;
   }
   if(left[l-1]< num[z]){
      left[l] = num[z];
      if(calc(num,right,left,z+1,r,l+1) == 0)
         return 0;
      else
         left[l] = 0;
   }
   
   return -1;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	String s = sc.next();
    char[] text = s.toCharArray();
    if(text[2] == text[3] && text[4] == text[5]){
      System.out.println("Yes");
    }
    else
    {
      System.out.println("No");
    }
    //HashMap<String,Integer> map = new HashMap<String,Integer>();
    //LinkedList<String> array = new LinkedList<String>();
    //int max = 1;
    /*
    for(int i = 0; i < n; i++){
      String s = sc.next();
      int tmp = 1;
      if(map.containsKey(s)){
        tmp = map.get(s)+1;
      }
      map.put(s, tmp);
      
      if(tmp == max){
        array.add(s);
      } 
      else if(tmp > max){
        max = tmp;
        array.clear();
        array.add(s);
      }
    }
    */
    //array.sort(Comparator.naturalOrder());
    //for(String value : array)
	//{
      //System.out.println(value);
	//}
  }
}

Measured memory_bytes: 21332
<?php
$day = trim(fgets(STDIN));
$c = explode(' ',trim(fgets(STDIN)));

for ($i = 0; $i < $day; $i++) {
     $scores = explode(' ',trim(fgets(STDIN)));
     foreach($c as $ck => $cv){
         $scores[$ck] += $cv;
     }
     arsort($scores);
     echo array_key_first($scores) +1;
     echo "\n";
}
?>




Measured memory_bytes: 16264
X, N = map(int, input().split())
*P, = map(int, input().split())
l = set([i for i in range(-200, 200)]) - set(P)
m = 100000000
ans = 0
for i in l:
    if abs(i-X) < m:
        ans = i
        m =abs(i - X)
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    if (N % 10 == 3){
        cout << "bon" << endl;
    } else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8){
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

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


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

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

    sort(n.begin(),n.end());
    if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'a' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n, a, b, c;
int l[10];
int ans = INF;

int calc(string s) {
    int mp = 0;
    int cnt[3] = {};
    int suml[3] = {};
    rep(i, 0, s.size()) {
        int c = s[i] - '0';
        if (c == 3) continue;
        cnt[c]++;
        suml[c] += l[i];
    }
    rep(i, 0, 3) mp += (cnt[i] - 1) * 10;
    mp += abs(suml[0] - a) + abs(suml[1] - b) + abs(suml[2] - c);
    return mp;
}

void dfs(string s, int a, int b, int c) {
    if ((int)s.size() == n) {
        if (a && b && c) ans = min(ans, calc(s));
        return;
    }
    dfs(s + '0', 1, b, c);
    dfs(s + '1', a, 1, c);
    dfs(s + '2', a, b, 1);
    dfs(s + '3', a, b, c);
}

int main() {
    cin >> n >> a >> b >> c;
    rep(i, 0, n) cin >> l[i];
    dfs("", 0, 0, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	ans := 1000 - n%1000
	if ans == 1000 {
		ans = 0
	}
	fmt.Println(ans)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1772
using System;
using System.Linq;

public class ALDS1_10_A
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int n = int.Parse(Console.ReadLine());

        Solve(n);
    }

    private static void Solve(int n)
    {
        int[] dp = new int[45];
        for (int i = 0; i < dp.Length; i++)
        {
            dp[i] = -1;
        }
        dp[0] = 1;
        dp[1] = 1;
        Console.WriteLine(Fib(n, dp).ToString());
    }

    private static int Fib(int n, int[] dp)
    {
        if (dp[n] != -1)
        {
            return dp[n];
        }
        dp[n - 1] = Fib(n - 1, dp);
        dp[n - 2] = Fib(n - 2, dp);
        dp[n] = dp[n - 1] + dp[n - 2];
        return dp[n];
    }
}



Measured memory_bytes: 15976
n, w = map(int, raw_input().split())
items = []
for _ in range(n):
    wi, vi = map(int, raw_input().split())
    items.append((wi, vi))

dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    wi, vi = items[i - 1]
    for j in range(1, w + 1):
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
        if j >= wi:
            dp[i][j] = max(dp[i][j], vi + dp[i - 1][j - wi])
print(dp[n][w])


Measured memory_bytes: 111852
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CADDI_1 solver = new CADDI_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class CADDI_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String[] Narr = String.valueOf(in.nextInt()).split("");
            int count = 0;
            for (String n : Narr) {
                if (n.compareTo("2") == 0) {
                    count++;
                }

            }
            out.println(count);
        }

    }
}



Measured memory_bytes: 23252
#include <stdio.h>

int main(void)
{
	int i,j,k;
	int buf;
	int num;
	int ary[100]={0};
	
	scanf("%d",&num);
	for(i=0;i<num;i++)
	{
	scanf("%d",&ary[i]);
	}
	
		for(k=0;k<num;k++)
	{
		printf("%d",ary[k]);
		if(k!=num-1)
		{
			printf(" ");
		}
	}
	
	printf("\n");
	
	for(i=1;i<num;i++)
	{
		buf = ary[i];
		j = i-1;
		while( (j>=0) && (ary[j]>buf) )
		{
			ary[j+1] = ary[j];
			j--;
		}
		ary[j+1]=buf;
		
		for(k=0;k<num;k++)
		{
			printf("%d",ary[k]);
			if(k!=num-1)
			{
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 604
from collections import defaultdict


def PrimeFactorization(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf


def main():
    n = int(input())
    d = defaultdict(int)
    for i in range(n + 1):
        for k, v in PrimeFactorization(i).items():
            d[k] += v
    ans = 1
    for v in d.values():
        ans *= (v + 1)
        ans %= 1000000007
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  string s;
  while(cin >> s && s!="0") {
    int dp[2][11];
    memset(dp,0,sizeof(dp));
    dp[0][s[0]-'0']=1;
    int ans=0;
    for(int i=1; i<s.size(); i++) {
      for(int j=0; j<11; j++) dp[1][(j*10+s[i]-'0')%11]=dp[0][j];
      for(int j=0; j<11; j++) dp[0][j]=dp[1][j];
      if(s[i]!='0') dp[0][s[i]-'0']++;
      ans+=dp[0][0];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[110];
int B[110];
int vv[110];
int ord[110];
int tree[110];

void update(int tmp,int v)
{
    while(tmp){
        tree[tmp]+=v;
        tmp>>=1;
    }

    return;
}

int getans(int L,int R)
{
    int res = 0;

    while(L<=R){
        if(L&1){res+=tree[L]; L++;}
        if(!(R&1)){res+=tree[R]; R--;}
        L>>=1; R>>=1;
    }

    return res;
}


int solve(int n,int x)
{
    int cnt = 0;

    for(int i=0;i<n;i++){
        if((1<<i)&x)cnt++;
    }

    if(cnt!=(n>>1))return INF;

    vector<pii> even;
    vector<pii> odd;

    for(int i=0;i<n;i++){
        if((1<<i)&x){
            if(i&1)odd.push_back(pii(A[i],i));
            else odd.push_back(pii(B[i],i));
        }
    }

    for(int i=0;i<n;i++){
        if(!((1<<i)&x)){
            if(!(i&1))even.push_back(pii(A[i],i));
            else even.push_back(pii(B[i],i));
        }
    }

    sort(odd.begin(),odd.end());
    sort(even.begin(),even.end());

    for(int i=0;i<even.size();i++){
        vv[(i<<1)] = even[i].f;
    }

    for(int i=0;i<odd.size();i++){
        vv[(i<<1)|1] = odd[i].f;
    }

    bool judge = true;

    for(int i=1;i<n;i++){
        judge&=(vv[i]>=vv[i-1]);
    }

    if(!judge)return INF;

    for(int i=0;i<even.size();i++)
        ord[even[i].s] = (i<<1);

    for(int i=0;i<odd.size();i++)
        ord[odd[i].s] = (i<<1)|1;

    int base = 1;
    int res =0;

    for(;base<n;base<<=1);

    for(int i=1;i<(base<<1);i++)
        tree[i] = 0;

    for(int i=0;i<n;i++){
        res+=getans(base+ord[i],(base<<1)-1);
        update(base+ord[i],1);
    }
    return res;
}


int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

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

    for(int i=0;i<n;i++)
        cin>>B[i];

    if(n==1){
        cout<<"0\n";
        return 0;
    }

    int res = INF;

    for(int i=0;i<(1<<n);i++){
        res = min(res,solve(n,i));
    }

    if(res==INF)cout<<"-1\n";
    else cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << min(a, b) + min(c, d) << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110


signed main()
{
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
    int ans = 0;
    REP(i, S.length()) {
        if(S[i] == 'I') { x++; }
        else { x--; }
        ans = max(ans, x);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::Read;
use std::collections::HashMap;

fn main() -> io::Result<()>{

    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer)?;

    let split: Vec<&str> = buffer.split_ascii_whitespace().collect();
    let N: usize = split[0].parse().unwrap();
    let K: usize = split[1].parse().unwrap();
    let S: usize = split[2].parse().unwrap();

    let max= 1000000000usize;

    if S == max {
        for i in 0..N {
            if i < K {
                print!("{} ", S);
            } else {
                print!("{} ", 1);
            }
        }
        return Ok(())
    }
    if S == 1 {
        for i in 0..N {
            if i < K {
                print!("{} ", 1);
            } else {
                print!("{} ", max);
            }
        }
        return Ok(())
    }

    if K == 0 {
        for i in 0..N {
            print!("{} ", max);
        }
        return Ok(())
    }

    if K == N {
        for i in 0..N {
            print!("{} ", S);
        }
        return Ok(())
    }

    for i in 0..N {
        if i < K-1 {
            print!("{} ", S);
        } else if i == K-1 {
            print!("{} ", S-1)
        } else if i == K {
            print!("{} ", 1);
        } else {
            print!("{} ", max);
        }
    }
    Ok(())
}


Measured memory_bytes: 2176
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *A = map(int, read().split())

    vec = [A[-1]]
    for a in reversed(A[:-1]):
        if a >= vec[-1]:
            vec.append(a)
        else:
            vec[bisect_right(vec, a)] = a

    print(len(vec))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 14092
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      a: [usize; n]
   }
   let mut ans = 0;
   for i in 0..n {
      if i % 2 == 0 && a[i] % 2 == 1 {
         ans += 1;
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 2196
from copy import copy

ans = 0

def main():
  n, m = map(int, input().split())

  table = [None] * m
  for i in range(m):
    S = map(lambda x: int(x) - 1, input().split())
    next(S)
    table[i] = tuple(S)

  P = tuple(map(int, input().split()))

  def check(switchs):
    global ans
    for i in range(m):
      S = table[i]
      total = 0
      for s in S:
        total += switchs[s]

      if total % 2 != P[i]:
        return False

    ans += 1
    return True

  default = [0 for _ in range(n)]
  dp = [default]
  check(dp[0])

  for i in range(n):
    for j in range(len(dp)):
      switchs = dp[j]
      new_switchs = copy(switchs)
      new_switchs[i] = 1
      check(new_switchs)
      dp.append(new_switchs)

  print(ans)


main()


Measured memory_bytes: 3676
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

#define int ll

vector<int> next_go[500000];
int dp[500000];

int seg_tree[seg_size * 2];
int seg_find(int now, int n_l, int n_r, int w_l, int w_r) {
    if (w_l <= n_l && n_r <= w_r) return seg_tree[now];
    if (w_r <= n_l || n_r <= w_l) return 0;
    return max(seg_find(now * 2, n_l, (n_l + n_r) / 2, w_l, w_r),
        seg_find(now * 2 + 1, (n_l + n_r) / 2, n_r, w_l, w_r));
}
void seg_set(int now) {
    seg_tree[now] = max(seg_tree[now * 2], seg_tree[now * 2 + 1]);
    if (now > 1) seg_set(now / 2);
    return;
}

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> inputs;
    map<int, int> zip;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        zip[a] = 1;
        zip[a + b] = 1;
        inputs.push_back(mp(a, a + b));
    }
    int cnt = 0;
    for (auto i = zip.begin(); i != zip.end(); ++i) {
        i->second = cnt;
        cnt++;
    }
    REP(i, inputs.size()) {
        next_go[zip[inputs[i].first]].push_back(zip[inputs[i].second]);
    }
    for (int q = 400000; q >= 0; --q) {
        int now_max = q;
        for (auto x : next_go[q]) {
            now_max = max(now_max, seg_find(1, 0, seg_size, q, x));
            now_max = max(now_max, x);
        }
        seg_tree[seg_size + q] = now_max;
        seg_set((seg_size + q) / 2);
    }
    dp[0] = 1;
    for (int i = 0; i < 500000 - 1; ++i) {
        dp[i + 1] += dp[i];
        dp[i + 1] %= MOD;
        for (auto x : next_go[i]) {
            int hoge = seg_find(1, 0, seg_size, i, x);
            dp[hoge] += dp[i];
            dp[hoge] %= MOD;
        }
    }
    cout << dp[499999] << endl;
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 58732
from sys import stdin

N = int(stdin.readline().rstrip())
s_lst = []
count_dict = {}

for _ in range(N):
  a = ''.join(sorted(stdin.readline().rstrip()))
  if a in count_dict:
    count_dict[a] += 1
  else:
    count_dict[a] = 1
  
result = sum([x * (x-1) / 2 for x in count_dict.values() if x > 1])
print(int(result))

Measured memory_bytes: 17852
import java.util.*;

class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int n1 = n / 100;
    int n2 = n % 100;
    if (1 <= n1 && n1 <= 12 && (n2 == 0 || 13 <= n2))
      System.out.println("MMYY");
    else if (1 <= n2 && n2 <= 12 && (n1 == 0 || 13 <= n1))
      System.out.println("YYMM");
    else if ((n1 == 0 || 13 <= n1) && (n2 == 0 || 13 <= n2))
      System.out.println("NA");
    else
      System.out.println("AMBIGUOUS");
  }
}


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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define ALL(v) (v).begin(), (v).end()

int main() {
    bitset<64> a(0);
    int Q; cin >> Q;
    while (Q--) {
        int q; cin >> q;
        if (q == 0) {
            int i; cin >> i;
            cout << a.test(i) << endl;
        } else if (q == 1) {
            int i; cin >> i;
            a.set(i);
        } else if (q == 2) {
            int i; cin >> i;
            a.reset(i);
        } else if (q == 3) {
            int i; cin >> i;
            a.flip(i);
        } else if (q == 4) {
            cout << a.all() << endl;
        } else if (q == 5) {
            cout << a.any() << endl;
        } else if (q == 6) {
            cout << a.none() << endl;
        } else if (q == 7) {
            cout << a.count() << endl;
        } else if (q == 8) {
            cout << a.to_ulong() << endl;
        }
    }
    
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std; 
const long long MOD = 1e9+7;

int main(){
	long long a,b;
	scanf("%lld %lld",&a,&b);
	
	int dif = a-b;
	if(dif<0) dif*=-1;
	
	if(dif>=2) printf("0\n");
	else{
		long long res;
		long long az = 1;
		long long bz = 1;
		
		for(int i=1;i<=a;i++) az = (az*i)%MOD;
		for(int i=1;i<=b;i++) bz = (bz*i)%MOD;
		
		if(a==b) printf("%llu\n",(az%MOD*bz%MOD*2)%MOD);
		else printf("%llu\n",(az%MOD*bz%MOD)%MOD);
	}	
	return 0;
}

Measured memory_bytes: 256