akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;


int main()
{
	int x1,x2;
	cin>>x1>>x2;
	if(x1 == x2){
		cout<<0<<endl;
	}else if(x1 == 0 && x2 > 0){
		cout<<x2<<endl;
	}else if(x1 > 0 && x2 == 0){
		cout<<x1 + 1<<endl;
	}else if(x1 == 0 && x2 < 0){
		cout<<abs(x2)+1<<endl;
	}else if(x2 == 0 && x1 < 0){
		cout<<abs(x1)<<endl;
	}else if(x1 >= 0 && x2 >= 0 && x2 > x1){
		cout<<x2 - x1<<endl;
	}else if( x1 >= 0 && x2 >= 0 && x2 < x1){
		cout<<x1 - x2 + 2<<endl;
	}else if((x1 >= 0 && x2 < 0) || (x1 < 0 && x2 >= 0)){
		cout<<abs(abs(x1)-abs(x2))+1<<endl;
	}else if(x1 < 0 && x2 < 0 && x2 < x1){
		cout<<abs(x2)-abs(x1) + 2<<endl;
	}else{
		cout<<abs(abs(x2)-abs(x1))<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>  
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
i64 a,b;
cin>>a>>b;
if(b%a)
cout<<b-a;
else
cout<<a+b;



    return 0;
  }

Measured memory_bytes: 764
#include <stdio.h>
#include <stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

void initialize(void);
void printBoard(void);
void recursive(int);



int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool X[N][N];


int main(){
  initialize();
  int i,j,k,r,c;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j]=false;
    }
  }
    scanf("%d",&k);
     for(i=0;i<k;i++){
       scanf("%d%d",&r,&c);
       X[r][c]=true;
     }

     recursive(0);
     return 0;
  }

  void initialize(){
    int i;
    for(i=0;i<N;i++){
      row[i]=FREE;
      col[i]=FREE;
    }
    for(i=0;i<2*N-1;i++){
      dpos[i]=FREE;
      dneg[i]=FREE;
    }
  }

    void printBoard(){
      int i,j;
      for(i=0;i<N;i++){
	for(j=0;j<N;j++){
	  if(X[i][j]){
	    if(row[i]!=j)return;
	  }
	}
      }
      for(i=0;i<N;i++){
	for(j=0;j<N;j++){
	  if(row[i]==j){
	    printf("Q");
	  }else printf(".");
	}
	printf("\n");
      }
    }

    void recursive(int i){
      int j;
      if(i==N){
	printBoard();
	return ;
      }

      for(j=0;j<N;j++){
	if(NOT_FREE==col[j]|| NOT_FREE==dpos[i+j]||NOT_FREE==dneg[i-j+N-1])continue;
	row[i]=j;
	col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
	recursive(i+1);
	row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
      }
    }

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    // A = 66; Z = 91;
    int N;
    string S;
    cin >> N >> S;

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

    return 0;
}

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

int main() {
    int64_t n,k;
    cin >> n >> k;

    if(n-k <= 0){
        cout <<"0";
        return 0;
    }
    if(k==0){
        int64_t s=0;
        for(int i=0;i<n;i++){
            int64_t a;
            cin >> a;
            s += a;
        }
        cout << s;
        return 0;
    }
    vector<int> h;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        h.push_back(a);
    }
    h.resize(n);
    sort(h.begin(), h.end());
 
    int64_t c=0;
    for(int i=0;i<n-k;i++){
        c += h[i];
    }

    cout << c;

}

Measured memory_bytes: 1656
#include <iostream>
using namespace std;
int N,W;
long long v[105],w[105],f[103][100005];
int main()
{
    cin>>N>>W;
    for (int i=1;i<=N;++i)
    {
        cin>>w[i]>>v[i];
    }
    for (int i=0;i<=N;++i)
        for (int j=0;j<=100003;++j)
            f[i][j]=1e18;
    f[0][0]=0;
    for (int i=1;i<=N;++i)
    {
        for (int j=0;j<=100000;++j)
        {
            if (j>=v[i])
            {
                f[i][j]=min(f[i-1][j-v[i]]+w[i],f[i-1][j]);
            } else f[i][j]=f[i-1][j];
        }
    }
    for (int i=100000;i>=0;--i)
    {
        if (f[N][i]<=W)
        {
            cout<<i;
            break;
        }
    }
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  string ans="No";
  for(int i=0;i<N/4+1;i++){
    if((N-4*i)%7==0){
      ans="Yes";
      break;
    }
  }
  cout << ans << endl;
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n, k; cin >> n >> k;
  vi a(n);

  rep(i, n) cin >> a[i];
  rep2(i, k, n-1) {
    if (a[i] > a[i-k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    vector<vector<int>> dist(n, vector<int>(3, -1));
    queue<pair<int, int>> q;
    q.push({s, 0});
    dist[s][0] = 0;
    while(!q.empty()) {
        pair<int, int> p = q.front(); q.pop();
        int a = (p.second + 1) % 3;
        int b = p.second % 3;
        for (auto e : g[p.first]) {
            if (dist[e][a] != -1) continue;
            dist[e][a] = dist[p.first][b] + 1;
            q.push({e, dist[e][a]});
        }
    }
    if (dist[t][0] == -1) cout << -1 << endl;
    else cout << (dist[t][0] / 3) << endl;
    return 0;
}


Measured memory_bytes: 11264
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a));
#define MINUS(a) memset(a,-1,sizeof(a));
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};

bool cmp( ll a, ll b ){
  return a>b;
}

bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

ll MOD=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    SIN(s)
		ll ans = 0;
		ll n = s.size();
		REP( i, 0, n ){
			REP( j, i, n ){
				set<char> st;
				REP( k, i, j + 1){
					st.insert( s[k] );
				}
				st.erase('A');
				st.erase('T');
				st.erase('G');
				st.erase('C');
				if( st.empty() ){
					ans = fmax( ans, j - i + 1 );
				}
			}
		}
		puta ( ans );
    return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '2') cnt++;
    }
    cout << cnt << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if(a+b>c+d) cout << "Left";
  else if(a+b<c+d) cout << "Right";
  else cout << "Balanced";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
#include <math.h>
using namespace std;
#define MAXSIZE 100005
#define PI 3.141592653589793
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
  int a, b;
  cin >> a >> b;
  int ans = (b - 1) / (a - 1) + ((b - 1) % (a - 1) > 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define NDEBUG
#include <cassert>
#include <cstdint>

template <template <class> class Container> class eratosthenes {
	using uint64 = ::std::uint_fast64_t;

public:
	using container_type = Container<uint64>;
	using size_type = typename container_type::size_type;

protected:
	container_type c;
	size_type s;

public:
	eratosthenes() : c(), s(0) {}
	explicit eratosthenes(const size_type size)
		: c((size >> 6) + 1, ~static_cast<uint64>(0)), s(size) {
		c[0] ^= 3;
		for (size_type i = 2; i * i < size; ++i)
			if (c[i >> 6] >> (i & 0x3F) & 1)
				for (size_type j = i * i; j < size; j += i)
					c[j >> 6] &= ~(static_cast<uint64>(1) << (j & 0x3F));
	}

	bool empty() const { return !s; }
	size_type size() const { return s; }

	bool test(const size_type i) const {
		assert(i < size());
		return c[i >> 6] >> (i & 0x3F) & 1;
	}
	bool operator[](const size_type i) const {
		assert(i < size());
		return c[i >> 6] >> (i & 0x3F) & 1;
	}
};

#include <cstdio>
#include <vector>

template <class T> using vec_alias = ::std::vector<T>;

int main() {
	using uint = unsigned int;

	constexpr uint N = 100000001;

	eratosthenes<vec_alias> pri(N);

	uint n;
	scanf("%u", &n);

	uint cnt = 0, x;
	while (n--) {
		scanf("%u", &x);
		cnt += pri[x];
	}

	printf("%u\n", cnt);

	return 0;
}



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

int main(){
  ll n;
  cin >> n;
  vector<long double>a(n),b(n);
  for(int i=0; i<n; i++) cin >> a[i] >> b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ll ans;
  if(n%2==0){
    ll x=n/2-1;
    ans=((b[x+1]+b[x])/2-(a[x+1]+a[x])/2)*2+1;
    //cout << (b[x+1]+b[x])/2 << " " << (a[x+1]+a[x])/2 << endl;
  }
  else{
    ll x=n/2;
    ans=b[x]-a[x]+1;
  }
  cout << ans << endl;
  
}
  
  
  


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

int main() {
    int N, K;
    cin >> N >> K;
    int l[N];
    int ans = 0;
    
    for(int i = 0; i < N; i++) {
        cin >> l[i];
    }
    
    sort(l, l+N);

    for(int i = N-1; N-K <= i; i--) {
        ans += l[i];
    } 

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;

	int d[k];
	int a[k][n];

	for(int i=0;i<k;i++){
		for(int j=0;j<n;j++){
			a[i][j] = 0;
		}
	}

	for(int i=0;i<k;i++){
		cin >> d[i];
		for(int j=0;j<d[i];j++){
			cin >> a[i][j];
		}
	}

	int b[n+1];
	for(int i=0;i<n+1;i++){
		b[i] = 0;
	}
	
	for(int i=0;i<k;i++){
		for(int j=0;j<n;j++){
			b[a[i][j]]++;
		}
	}

	int count = 0;
	for(int i=1;i<n+1;i++){
		if(b[i] != 0){
			count++;
		}
	}

	cout << n - count << endl;

	
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int n, q, k;
vector<vector<pair<int, ll>>> t;
vector<ll> cost;

void dfs(int v, int p, ll c) {
    cost[v] = c;
    
    rep(i, sz(t[v])) {
        pair<int, ll> e = t[v][i];
        
        if (e.first == p) {
            continue;
        }
        
        dfs(e.first, v, c + e.second);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    t.resize(n);
    cost.resize(n);
    
    rep(i, n - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        t[a].emplace_back(b, c);
        t[b].emplace_back(a, c);
    }
    
    cin >> q >> k;
    dfs(k - 1, -1, 0);
    
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << cost[x] + cost[y] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 15872
#include<iostream>

using namespace std;

int main(){
  int  N;
  int  M;
  int  L;

  cin >> N >> M >> L ;

  if(N+M==L){
    cout << "Yes" << endl ;
  }else if(M+L==N){
    cout << "Yes" << endl ;
  }else if(N+L==M){
    cout << "Yes" << endl ;
  }else{
    cout<< "No" << endl ;
  }
   
 
  return 0;
}
 


Measured memory_bytes: 256
S = input()
count = 0
c = [0]
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        count += 1
    else:
        c.append(count)
        count = 0
c.append(count)
print(max(c))

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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;


vector<short int> A(10);
int n,m,q;
vector<int> a(50);
vector<int> b(50);
vector<int> c(50);
vector<int> d(50);
ll out=0;
void dfs(short int cur,ll &out){
    if(cur==n){
        int sum=0;
        for(int i=0; i!=q; ++i){
            if(A[b[i]]-A[a[i]]==c[i]) sum+=d[i];
        }
        if(sum>out) out=sum;
    }else{
        for(int i=A[cur]; i <= m; ++i){
            A[cur+1]=i;
            dfs(cur+1,out);
        }
    }
}


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >>n >> m >> q;
    rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i] ;
    rep(i,q) --a[i], --b[i];

    for(short int init=1; init<=m;++init){
        A[0]=init;
        dfs(0,out);
    }
    cout << out << "\n";
}   




Measured memory_bytes: 3660
N,M = map(int,input().split())
MOD = 10**9+7
dp = [0] * (N+1)
dp[1] = 1
for _ in range(M):
  dp[int(input())] = -1
if N<2:
  print(dp[N])
  exit()

if dp[2] != -1:
  dp[2] = 1
for i in range(N+1):
  if dp[i] == -1: continue
  if i-1>=0 and dp[i-1] != -1:
    dp[i] += dp[i-1]
  if i-2>=0 and dp[i-2] != -1:
    dp[i] += dp[i-2]
  dp[i] %= MOD

print(dp[N])

Measured memory_bytes: 44888
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
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;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

ll res[2002][2002],res2[2002][2002];
signed main() {

    SS(int, H, W);
    SV(string, board, H);

    rep(h, H) {
        int cnt = 0;
        rep(w, W) {
            if (board[h][w] == '.') {
                cnt++;
            } else {
                if (cnt != 0) {
                    res[h][w - cnt] += cnt;
                    res[h][w] -= cnt;
                    //imos的な前処理
                }
                cnt = 0;
            }
        }
        if (cnt != 0) res[h][W - cnt] += cnt;
        
        rep(w, W - 1) res[h][w + 1] += res[h][w];//imos実行、横方向に照らせる距離が入る
    }

    rep(w, W) {
        int cnt = 0;
        rep(h, H) {
            if (board[h][w] == '.') {
                cnt++;
            } else {
                if (cnt != 0) {
                    res2[h - cnt][w] += cnt;
                    res2[h][w] -= cnt;
                }
                cnt = 0;
            }
        }
        if (cnt != 0)res2[H - cnt][w] += cnt;
        
        rep(h, H - 1) res2[h + 1][w] += res2[h][w];
    }

    ll ress = -MOD;

    rep(i, H) rep(j, W)chmax(ress, res[i][j] + res2[i][j] - 1);

    p(ress);
}

Measured memory_bytes: 67072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[MAXn];
vector<int> e[MAXn];
int dp[MAXn],mx;
bool inq[MAXn];
priority_queue<ii,vector<ii>,greater<ii> > pq[MAXn];
void dfs(int x,int p){
    if (x == 0) {
        pq[1].emplace(d[x],x);
        mx = 1;
        dp[x] = 1;
    }
    else {
        int l=1, r=mx+1;
        while (l != r-1) {
            int mid = (l+r)>>1;
            while (SZ(pq[mid]) && !inq[pq[mid].top().Y]) pq[mid].pop();
            if (d[x] > pq[mid].top().X) l = mid;
            else r = mid;
        }
        while (SZ(pq[l]) && !inq[pq[l].top().Y]) {
            pq[l].pop();
            if (mx == l && SZ(pq[l]) == 0) mx--;
        }
        if (d[x] > pq[l].top().X) {
            if (l == mx) mx++;
            pq[l+1].emplace(d[x],x);
            dp[x] = max(dp[p],l+1);
        }
        else {
            pq[l].emplace(d[x],x);
            dp[x] = max(dp[p],l);
        }
    }
    inq[x] = true;
    for (auto i:e[x]) {
        if (i == p) continue;
        dfs(i,x);
    }
    inq[x] = false;
    while (SZ(pq[mx]) && !inq[pq[mx].top().Y]) {
        pq[mx].pop();
        if (!SZ(pq[mx])) mx--;
    }
}
int main(){
    IOS();
    int n;
    cin >> n;
    REP (i,n) cin >> d[i];
    REP (i,n-1) {
        int u,v;
        cin >> u >> v;
        u--, v--;
        e[u].eb(v);
        e[v].eb(u);
    }
    dfs(0,0);
    REP (i,n) cout << dp[i] << endl;
}


Measured memory_bytes: 41620
#include<stdio.h>

#define MAX 1000000
int total[MAX];

int main(void){
	int i, n, cnt;
	
	total[0] = total[1] = 0;
	for (i = 2; i < MAX; i++)total[i] = 1;

	for (i = 2; i*i < MAX; i++){
		if (total[i] == 1){
			for (n = i*2; n < MAX; n += i){
				total[n] = 0;
			}
		}
	}
	while (scanf("%d", &n) != EOF){
		cnt = 0;
		for (i = 0; i <= n; i++){
			cnt += total[i];
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 4500
N = int(input())
H = list(map(int, input().split()))

height = H[-1]
for i in range(N-2, -1, -1):
    if H[i] <= height:
        height = H[i]
    elif H[i] == height + 1:
        pass
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 63984
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

int main()
{
    int id, ans;
    char ch;
    int num[101] = {0};
    vector< pair<int, int> > rank;

    while (cin >> id >> ch >> ans) {
        if (!id && !ans)
            break;
        pair<int, int> p(ans, id);
        rank.push_back(p);
    }
    sort(rank.begin(), rank.end(), greater< pair<int, int> >());

    int bf, r;
    r = 1; 

    num[rank[0].second] = r;
    for (int i = 1; i < rank.size(); i ++) {
        if (rank[i - 1].first != rank[i].first) 
            r++;
        num[rank[i].second] = r;
    }

    while (cin >> id) {
        cout << num[id] << endl;
    }

    return 0;
}

Measured memory_bytes: 1200
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      double result;
      if (N==1)
      {
        result=N/1;
        System.out.printf("%.10f",result);
      }
      else
      {        
        result=(N+1)/2;
        System.out.printf("%.10f",result/N);
      }
	}
}

Measured memory_bytes: 22740
n=int(input())
s = input()
l = []
w = 0
e =  0 
for  i in range(n):
    l.append(w)
    if s[i]=="W":
        w+=1
        
        
        
for  i in range(n-1 , -1  ,  -1):
    l[i]+=e
    if s[i]=="E":
        e+=1
print(min(l))


Measured memory_bytes: 15540
#include <bits/stdc++.h>
using namespace std;
struct Node
{
	int key;
	Node *p, *l, *r;
} *root = NULL;

void insert(Node *z){
	Node *x, *y;
	y = NULL;
	x = root;
	while(x!=NULL){
		y = x;
		if(z->key < x->key) x = x->l;
		else x = x->r;
	}
	z->p = y;
	if(y==NULL) root = z;
	else if(z->key < y->key) y->l = z;
	else y->r = z;
}
void preP(Node *x){
	if(x==NULL) return;
	printf(" %d",x->key);
	preP(x->l);
	preP(x->r);
}
void inP(Node *x){
	if(x==NULL) return;
	inP(x->l);
	printf(" %d",x->key);
	inP(x->r);
}
int main()  
{
	char cmd[10];
	int n; cin>>n;
	while(n--){
		scanf("%s",cmd);
		if(cmd[0]=='i'){
			Node *z = new Node;
			scanf("%d",&(z->key));
			z->l = z->r = NULL;
			insert(z);
		}
		else{
			inP(root);
			putchar('\n');
			preP(root);
			putchar('\n');
		}
	}
	return 0;
}




Measured memory_bytes: 26576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    set<int> st;
    st.insert(1);
    map<int,int> mp;
    REP(i,n+1) mp[i]++;
    rep(i,m) {
        int x, y; cin >> x >> y;
        if (st.count(x)) {
            if (mp[x] == 1) {
                st.erase(x);
                st.insert(y);
            }
            else {
                st.insert(y);
            }
        } 
        mp[x]--; mp[y]++;
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 12844
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }


int main () {
  int n;
  cin >> n;
  int c;
  std::vector<int> a(n),b(n);
  rep(i,n) {
    cin >> c;
    a[i] = c;
    b[i] = c;
  }
  VSORT(b);
  rep(i,n) {
    if(a[i] == b[n-1]) cout << b[n-2] << endl;
    else cout << b[n-1] << endl;
  }
}


Measured memory_bytes: 3200
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappush, heappop, heappushpop

Q = int(readline())
query = (tuple(map(int,line.split())) for line in readlines())

# 適当に番兵を入れておく
INF = 10**12
L = [INF] # -1倍していれる
R = [INF]
sumL = 0; sumR = 0 # 和
lenL = 0; lenR = 0 # 長さ

add = 0 # 全体に共通に加わってるもの

answer = []
for q in query:
    if len(q) == 1:
        # 値を求める
        x = -L[0]
        f = sumR - sumL + x * (lenL - lenR)
        answer.append('{} {}'.format(x,f+add))
        continue
    # 更新
    a,b = q[1:]
    add += b
    if lenL > lenR:
        sumL += a; a = -heappushpop(L,-a); sumL -= a
        heappush(R,a); sumR += a; lenR += 1
    else:
        sumR += a; a = heappushpop(R,a); sumR -= a
        heappush(L,-a); sumL += a; lenL += 1

print('\n'.join(answer))

Measured memory_bytes: 28080
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-04 16:19:24
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    string s;
    long k;
    cin >> s >> k;

    char ans;
    for (int i = 0; i < s.length(); i++) {
        int c = s[i] - '0';
        if (c <= 1) {
            if (k > 1) k--;
            else {
                ans = c + '0';
                break;
            }
        } else {
            ans = c + '0';
            break;
        }
    }

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


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

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

	for (; n > 0; --n) {
		if (n == 1) cout << N[0] << endl;
		else cout << N[n-1]<<" " << flush;
	}
}


Measured memory_bytes: 3084
#coding:utf-8
k, x = map(int,input().split())

# xにしか黒がない場合
if k == 1:
    print(x)
# 黒が複数いる場合
else:
    start = x - (k - 1)
    finish = x + k
    ans = []

    for i in range(start, finish):
        ans.append(i)

    print(' '.join(map(str, ans)))

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
bool cmp(long long a,long long b){
    if(a>b)return true;

    else return false;
}
int main(){
    long long n;
    cin>>n;

    vector<long long>A(n);
    rep(i,n)cin>>A[i];

    sort(A.begin(),A.end(),cmp);

    //rep(i,n)cout<<A[i]<<" ";

    long long ans=0;
    priority_queue<long long> q;
    q.push(A[0]);
    rep2(i,n-1){
        ans+=q.top();
        q.pop();
        q.push(A[i]);
        q.push(A[i]);
    }

    cout<<ans<<endl;
    return 0;

}
/*


*/


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

#define MIN -2000000001

typedef struct {
  int key;
  int p, r, l;
}TREE;

int main(){
  TREE *tree;
  int i, j, n;

  scanf("%d", &n);
  tree = (TREE *)malloc(sizeof(TREE)*n+1);
  
  for(i = 1; i <= n; i++){
    tree[i].p = tree[i].r = tree[i].l = MIN;
    scanf("%d", &tree[i].key);
    if(i != 1) {
      tree[i].p = tree[i/2].key;
      if(i % 2 == 0){
	tree[i/2].l = tree[i].key;
      }else{
	tree[i/2].r = tree[i].key;
      }
    }
  }
  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ", i, tree[i].key);
    if(tree[i].p != MIN) printf("parent key = %d, ", tree[i].p);
    if(tree[i].l != MIN) printf("left key = %d, ", tree[i].l);
    if(tree[i].r != MIN) printf("right key = %d, ", tree[i].r);
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,mo=998244353;
int n,i,j,k,z,ans,su,a[N];
char c[N],cc[N];bool b[N];
inline int getv(int l,int r){
	int ans=0;
	for(;l<=r;++l)ans=(2ll*ans+c[l]-'0')%mo;
	return ans+1;
}
inline bool cmp(char*p,char*q,int d){
	for(int i=0;i<d;++i)if(p[i]!=q[i])return p[i]<=q[i];
	return 1;
}
int main(){
	scanf("%d%s",&n,c+1);
	for(i=n-1;i;--i)if(z=__gcd(n,i),i/z==2){
		b[i]=1;
		a[i]=getv(1,z)-1;
		for(j=0;j<n*2;j+=i)for(k=0;k<z;++k)cc[j%n+k+1]=j>=n?c[k+1]^1:c[k+1];
		if(cmp(cc,c,n))++a[i];
	}
	for(i=1;i<n;++i)if(b[i])for(j=i*2;j<n;j+=i)if(b[j])a[j]=(a[j]+mo-a[i])%mo;
	for(i=1;i<n;++i)su=(su+a[i])%mo;
	ans=1ll*(getv(1,n)+mo-su)*n*2%mo;
	for(i=1;i<n;++i)ans=(ans+1ll*i*a[i])%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
h, w = map(int, input().split())
s = []
t = []
for i in range(h):
    s.append(input())

for i in range(h):
    t.append([])
    for j in range(w):
        mines = 0
        if s[i][j] == '.':
            if i > 0 and j > 0:
                if s[i - 1][j - 1] == '#':
                    mines += 1
            if i < h - 1 and j > 0:
                if s[i + 1][j - 1] == '#':
                    mines += 1
            if i > 0 and j < w - 1:
                if s[i - 1][j + 1] == '#':
                    mines += 1
            if i < h - 1 and j < w - 1:
                if s[i + 1][j + 1] == '#':
                    mines += 1
            if i > 0:
                if s[i - 1][j] == '#':
                    mines += 1
            if i < h - 1:
                if s[i + 1][j] == '#':
                    mines += 1
            if j > 0:
                if s[i][j - 1] == '#':
                    mines += 1
            if j < w - 1:
                if s[i][j + 1] == '#':
                    mines += 1
            t[i].append(str(mines))
        else:
            t[i].append('#')

for i in range(len(t)):
    print(''.join(t[i]))

Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long
const int M=1e9+7;

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

int expo(int x, int y) {int res=1;x=x%M;while(y>0){if(y&1)res=(1ll*res*x)%M;
	y=y>>1;x=(1ll*x*x)%M;} return res;}
	

signed main(){
	gearup;
	int t = 1;
	//cin >> t;
	while(t--){
		int n, cnt = 0;
		cin >> n; 
		int temp = 100;
		while(temp < n){
			temp += temp / 100;
			cnt++;
		}
		cout << cnt;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fi first
#define se second
#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(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    ll n;
    cin >> n;
    ll ans=0;
    if(n%2==0){
        n /= 2;
        while(n){
            n /= 5;
            ans += n;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, i, ans;
    ll d, x, y;

    ans = 0;

    scanf("%d%lld", &n, &d);
    for (i = 0; i < n; i++) {
        scanf("%lld%lld", &x, &y);
        if (x * x + y * y <= d * d) {
            ans++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 3804
s = gets.chomp.split("").map(&:to_s)
t = gets.chomp.split("").map(&:to_s)

s_count = Hash.new(0)
s.each do |elem|
  s_count[elem] += 1
end

t_count = Hash.new(0)
t.each do |elem|
  t_count[elem] += 1
end


s_num = s_count.values.sort!
t_num = t_count.values.sort!


if s_num == t_num
  puts "Yes"
else
  puts "No"
end


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

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (ll i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

void Main();
void DebugMain() {
	while (true) {
		Main();
	}
}

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

inline void Main() {
	vector<int> v(6);
	int count[4]{0,0,0,0};
	for (int i = 0; i < 6; ++i) {
		cin >> v[i];
		count[v[i] - 1]++;
	}
	for (int i = 0; i < 4; ++i) {
		if (count[i] >= 3) {
			cout << "NO\n";
			return;
		}
	}
	cout << "YES\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char a[200000];
  int i,len;
  scanf("%s",a);
  len=strlen(a);
  for(i=0;i<len;i++){
    if(a[i]=='?'){
      if(a[i-1]=='P'||a[i+1]=='P'||a[i+1]=='\0'){
        a[i]='D';
      }else{
        a[i]='P';
      }
    }
  }
  printf("%s\n",a);
  return 0;
}

Measured memory_bytes: 1800
x,n=map(int,input().split())
p=list(map(int,input().split()))
mins=103
ans=0
for i in range(102):
    d=0
    c=abs(x-i)
    for j in range(n):
        if p[j]==i:
            d=1
        else:
            op=0
    if d==0:
        if c<mins:
            mins=c
            ans=i
        else:
            op=0
print(ans)    

Measured memory_bytes: 9204
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        cout << "a < b" << endl;
    }
    else if(a>b){
        cout << "a > b" << endl;
    }
    else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	
	
	public static Set<Long> set=new HashSet<Long>();
	public static long T;
	public static long ans;
	

 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd(long a, long b) {
		if (b == 0) {
			return a;			
		}
		return gcd(b, a % b);
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
    public static boolean tree(long N,long r) {
    	ans = r;
    	if(N==T) {
    		return true;
    	}else if(2*N==T||2*N+1==T) {
    		ans = r+1;
    		return true;
    	}else if(2*N>T) {
    		return false;
    	}
    	return tree(2*N,r+1)||tree(2*N+1,r+1);
    	
    	
    }
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 String s=sc.next();
	 char[] c=s.toCharArray();
	 
	 int left = 0;
	 int right = 0;
	 
	 String ans=s;
	 
	 for(int i=0;i<N;i++) {
		 if(c[i]=='(') {
			 right++;
			 
		 }else {
			 if(right==0) {
				 left++;
			 }else {
				 right--;
			 }
		 }
		
			 
			
	 }
	 
	 for(int j=0;j<left;j++) {
		 ans="("+ans;
	 }
	 
	 for(int j=0;j<right;j++) {
		 ans+=")";
	 }
	 
	 System.out.println(ans);
	 
    
}
}



Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
//template <typename... Args>void IN(Args& ... args) {cin >>args;/*IN(args...)*/;return;} //まとめて入力　IN(a,b,c,d...)

void Main() {
	int a, b; cin >> a >> b;
	int c = a - 2 * b;
	if (c < 0)c = 0;
	cout << c;
}


signed main() {
	Main();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#define INF 1000000007
#define ll long long
using namespace std;

signed main(){
    ll x,y;
    cin>>x>>y;
    int count=1;
    while(1){
        x*=2;
        if(y>=x)count++;
        else break;
    }
    cout<<count<<endl;
    return 0;
}





Measured memory_bytes: 256
while True:
    n=int(input())
    if n==0:
        break
    a=list(map(int,input().split()))
    
    c=0
    ave=0
    for i in range(n):
        ave=ave+a[i]
    ave=ave//n
    for i in range(n):
        if ave>=a[i]:
            c=c+1
    
    print(c)


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

using namespace std;

int main()
{
    int n,ara[50],cnt=0;
    cin>>n;

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

    for(int i=1;i<n-1;i++){
        if((ara[i]>ara[i+1] && ara[i]<ara[i-1])||(ara[i]<ara[i+1] && ara[i]>ara[i-1])) cnt++;
    }
    cout << cnt<<endl;

    return 0;
}


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

int main(){
	string s;
	while(cin >> s, s != "0"){
		int sum=0;
		for(int i=0; i<s.length(); i++){
			int num = s[i] - '0';
			sum += num;
		}
		cout << sum << endl;
	}
	return 0;
}

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

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

#define vi vector<int>
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
    int n;
    while(cin >> n,n) {
        bool d[21][21] = {};
        int x,y;
        rep(i,n){
            cin >> x >> y;
            d[y][x] = true;
        }
        int m;
        cin >> m;
        int nx = 10,ny = 10;
        int cnt = 0;
        rep(i,m){
            char dig;
            int l;
            cin >> dig >> l;
            if(dig == 'N') {
                rep(j,l){
                    ny++;
                    if(d[ny][nx] == true) {
                        cnt++;
                        d[ny][nx] = false;
                    }
                }
            }else if(dig == 'S') {
                rep(j,l){
                    ny--;
                    if(d[ny][nx] == true) {
                        cnt++;
                        d[ny][nx] = false;
                    }
                }
            }else if(dig == 'E') {
                rep(j,l){
                    nx++;
                    if(d[ny][nx] == true) {
                        cnt++;
                        d[ny][nx] = false;
                    }
                }
            }else if(dig == 'W') {
                rep(j,l){
                    nx--;
                    if(d[ny][nx] == true) {
                        cnt++;
                        d[ny][nx] = false;
                    }
                }
            }
        }
        if(cnt == n) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 2968