akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#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 ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))


int main(){
    int N;
    string s;
    cin >> N >> s;

    string X,Y;
    int cnt,saidai=-1;
    for(int i = 1;i < N;i++){
        cnt = 0;
        X = s.substr(0,i);
        Y = s.substr(i,N-1);

        set<char>Xs,Ys;

        for(int j = 0;j < X.size();++j)
            Xs.insert(X.at(j));
        for(int j = 0;j < Y.size();++j)
            Ys.insert(Y.at(j));
        
        for(auto c:Xs){
            cnt += Ys.count(c);
        }
        
        if(cnt > saidai)
            saidai = cnt;
    }

    cout << saidai << endl;
}

Measured memory_bytes: 3616
main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),b|r|g|c|s|t;printf("%d\n",-3*t+95*b+63*r+7*g+2*c+3*s+100));}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  
  if(N == 1) {
    cout << 1 << endl;
    return 0;
  }
  
  int n = 0;
  rep(i, N+1) {
    n += i;
    if(n > N) {
      rep(j, i) {
        if(j+1 != n-N) cout << j+1 << endl;
      }
      return 0;
    }
  }
  
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n;
int a[100001];
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  ll ansa=0;
  ll ansb=0;
  bool flag=1;
  for(int i=0;i<n-1;){
    if(a[i]==a[i+1] && flag){ansa=a[i];flag=0;i+=2;}
    else if(a[i]==a[i+1]){ansb=a[i]; break;}
    else i++;
  }
  //cout<<ansa<<" "<<ansb<<endl;
  cout<<ansa*ansb<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define int long long
#define double long double
using namespace std;
signed main() {
  int N;
  cin >> N;
  int P[N];
  REP(i, N) cin >> P[i];
  sort(P, P+N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = 0; j < N; j++) {
      if (P[j] >= i+1) cnt++;
    }
    if (cnt >= i+1) ans = i+1;
  }
  cout << ans << endl;
}



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

int main() {
	int n = 0,ans=0;
	string s = "";
	char a1='x',a2='x',a3='x';
	cin >> n >> s;
	for (int i = 0; i < n-1; i++) {
		a1 = s[i];
		a2 = s[i+1];
		a3 = s[i + 2];

		if (a1 == 'A') {
			if (a2 == 'B') {
				if (a3 == 'C') {
					ans += 1;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  int n;
  cin>>n;
  if(n/100!=7 && (n%100)/10 != 7 && (n%100)%10 != 7)
    cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 1001
#define MAX_M 1001
#define MOD 1000000007
#define rep(i, n) for(ll i=0; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m, a[MAX_N], b[MAX_M], g[MAX_N][MAX_M];

bool check(vector<ll> v){

    rep(i, n){
        ll max_i = 0;
        rep(j, m) max_i = max(max_i, v[i*m + j]);
        if(max_i != a[i]) return false;
    }
    rep(j, m){
        ll max_j = 0;
        rep(i, n){
            max_j = max(max_j, v[i*m + j]);
        }
        if(max_j != b[j]) return false;
    }
    return true;
}

void solve(){
    vector<ll> c(n*m+1, 0);
    rep(i, n) c[a[i]]+=3;
    rep(j, m) c[b[j]]+=1;

    ll ret = 1;
    for(ll i=n*m; i>0; i--){
        if(c[i] == 4) 
            // 両方に現れる場合
            ret *= 1;
        else if(c[i] == 3){
            // aに現れる場合
            ll tmp = 0;
            rep(j, m) if(b[j]>=i) tmp++;
            ret *= tmp;
            ret %= MOD;
        }else if(c[i] == 1){
            // bに現れる場合
            ll tmp = 0;
            rep(j, n) if(a[j]>=i) tmp++;
            ret *= tmp;
            ret %= MOD;
        }else if(c[i] == 0){
            ll tmp1 = 0;
            rep(j, m) if(b[j]>=i) tmp1++;
            ll tmp2 = 0;
            rep(j, n) if(a[j]>=i) tmp2++;
            ret *= (tmp1*tmp2%MOD - n*m + i);
            ret %= MOD;
        }else{
            cout << 0 << endl;
            return;
        }
    }
    cout << ret << endl;
}

signed main(){
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    solve();

    // vector<ll> v(n*m);
    // iota(v.begin(), v.end(), 1);
    // ll ret = 0;
    // while(next_permutation(v.begin(), v.end())){

    //     if(check(v)){
    //         rep(i, n){
    //             rep(j, m) cout << v[i*m + j] << " ";
    //             cout << endl;
    //         }
    //         ret++;
    //     }
    // }
    // cout << ret << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   ll n;
   cin>>n;

   map<string,ll> mp;
   rep(i,n){
      string  s;
      cin>>s;
      map<string,ll>::iterator it=mp.find(s);
      if(it==mp.end()){
         mp.emplace(s,1);
      }
      else{
         it->second++;
      }
   }
   ll v=0;
   auto begin2 = mp.begin(), end2 = mp.end();
    for (auto itr = begin2; itr != end2; itr++) {
       v=max(itr->second,v);
           }
    for(auto iter=begin2;iter!=end2;iter++){
       if(iter->second==v){
          cout<<iter->first<<endl;
       }
    }
   
      return 0;
}

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

int main() {
  vector<int> n(4);
  for(int i=0;i<4;i++) {
    cin >> n.at(i);
  }
  sort(n.begin(), n.end());
  vector<int> ans={1,4,7,9};
  bool flag=true;
  for(int i=0;i<4;i++) {
    if(ans.at(i)!=n.at(i)) {
      flag=false;
      break;
    }
  }
  if(flag) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 100001;
ll red[MAX] = {};
ll num[MAX];

int main() {
    

    ll n,m;
    cin >> n >> m;
    for (ll i=1;i<=n;i++){
        num[i] = 1;
    }
    red[1] = 1;
    for (ll i = 1;i<=m;i++){
        ll a,b;
        cin >> a >> b;
        if(red[a] == 1){
            red[b] = 1;
        }
        num[a] -= 1;
        if(num[a] == 0){
            red[a] = 0;
        }
        num[b] += 1;
    }
    ll ans = 0;
    for (ll i=1;i<=n;i++){
        ans += red[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a[10000];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int sum=1,ans=0;
	a[n+1]=-1;
	for(int i=2;i<=n+1;i++)
		if(a[i]==a[i-1])sum++;else
			ans+=sum/2,sum=1;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
	long long int n, a, b;
	cin >> n >> a >> b;
	vector<long long int> h(n);
	
	for (long long int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end(), greater<long long int>());
	long long int l = 0;
	long long int r = h[0]+ 2;
	long long int ans = 0;
	//cout << r << endl;
	while (r > l + 1) {
		long long int mid = (l + r) / 2;
		//cout << mid << endl;
		long long int ans = 0;
		for (long long int i = 0; i < n; i++) {
			long long int k = h[i] - b*mid;
			if (k <= 0) {
				break;
			}
			else {
				ans += k / (a-b);
				//cout << k << ' ' << ans << ' ' << (a - b) << endl;
				if (k % (a-b) != 0) {
					ans++;
				}
			}
		}
		if (ans <= mid) {
			r = mid;
		}
		else {
			l = mid;
		}
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
    #define debug(...) printf(__VA_ARGS__)
#else
    #define debug(...) (void)0
#endif
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>

#define F first
#define S second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
//const int inf = 0x7fffffff; //beware overflow
//const LL INF = 0x7fffffffffffffff; //beware overflow
#define mem(x, y) memset(x, (y), sizeof(x) );
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
     return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
    s << "[ ";
    for (auto it : c) s << it << " ";
    s << "]";
    return s;
}
template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    o << "{";
    for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it;
    return o << "}";
}
template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se;
    }
    o << "}";
    return o;
}
inline LL getint(){
   LL _x=0,_tmp=1; char _tc=getchar();
   while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
   if( _tc == '-' ) _tc=getchar() , _tmp = -1;
   while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
   return _x*_tmp;
}
#define maxn
constexpr int mod = 1e9+7;
int fac_inv[1005], fac[1005];
void add(int &l, int r) {
    l = (LL)(l+r)%mod;
}
void mul(int &l, int r) {
    l = (l*1LL*r)%mod;
}
int mypow(int a, int b) {
    int ret=1;
    int base=a;
    while(b) {
        if(b&1) mul(ret, base);
        b >>= 1;
        mul(base, base);
    }
    return ret;
}
int C(int n, int k) {
    if( k > n ) return 0;
    return fac[n]*1LL*fac_inv[k]%mod*fac_inv[n-k]%mod;
}
int f(int n, int k, int i) {
    if( n < k*i ) return 0;

    int ret = C(n, n-k*i);
    for(int ii=k*i;ii;ii-=i) mul(ret, C(ii,i));
    mul(ret, fac_inv[k]);
    return ret;
}
int dp[1005][1005];
int main() {
    fac[0] = 1;
    for(int i=1;i<=1000;i++) fac[i] = fac[i-1]*1LL*i%mod;
    fac_inv[1000] = mypow(fac[1000], mod-2);
    for(int i=999; i >=0 ;i--) fac_inv[i] = fac_inv[i+1]*1LL*(i+1)%mod;
    for(int i=1;i<=1000;i++) assert( fac_inv[i]*1LL*fac[i]%mod == 1);


    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for(int i=a; i<=b; i++) {

       if( i==a ) {
           dp[i][0] = 1;
            for(int k=c; k<=d && k*i <= n;k++) {
                dp[i][k*i] = f(n, k, i);
            }
            continue;
        }

        for(int j=0; j<=n;j ++) {
            if( !j ) {
                dp[i][j] = 1;
                continue;
            }

            dp[i][j]=dp[i-1][j];
            for(int k=c; k <= d && j  >= k*i ; k++)
                add(dp[i][j], (dp[i-1][j-k*i])*1LL*f(n-j+k*i, k, i)%mod );
        }
    }
    cout << dp[b][n] << endl;
}



Measured memory_bytes: 4224
d[1<<22],i,M=1e9+7,N,p;w[99];main(j){for(*d=1;~scanf("%d",w+i++););for(N=*w;p<N<<N;d[i]+=(j<i)*d[j]*w[__builtin_popcount(j)*N+p++%N+1],d[i]%=M)i=(j=p/N)|1<<p%N;printf("%d",d[j]);}

Measured memory_bytes: 10368
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007



int main(){

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

    string x, y;
    cin >> x >> y;
    int n = x.length();
    int m = y.length();
    int mi = n + 1;
    for(int i = 0; i < n; i++) {
        if(n - i < m) break;
        int curr = 0;
        for(int j = 0; j < m; j++) {
            if(y[j] != x[j + i]) curr++;
        }
        mi = min(mi, curr);
    }

    cout << mi << endl;

    return 0;
}

Measured memory_bytes: 3580
n = int(input())
xlist = []
ylist = []
hlist = []
for _ in range(n):
    x, y, h =list(map(int, input().split()))
    xlist.append(x)
    ylist.append(y)
    hlist.append(h)

def cond(cx, cy):
    same = None
    for i in range(n):
        if hlist[i] == 0:
            continue
        h = hlist[i] + abs(xlist[i] - cx) + abs(ylist[i] - cy)
        if same == None:
            same = h
            continue
        if same != h:
            return False
    for i in range(n):
        if hlist[i] == 0:
            if same - abs(xlist[i] - cx)  - abs(ylist[i] - cy) > 0:
                return False
    return True
        
rescx, rescy = 0, 0
label = False
for cx in range(101):
    for cy in range(101):
        if cond(cx, cy):
            rescx = cx
            rescy = cy
            label = True
            break
    if label:
        break

resh = 0
for i in range(n):
    if hlist[i] > 0:
        resh = abs(xlist[i] - rescx) + abs(ylist[i] - rescy) + hlist[i]
        break

print(rescx, rescy, resh)

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

const int MAX = 510000;
const int MOD = 1000000007;
bool flag = false;
vector<int> D;
vector<vector<int>> G;

int dfs(int v){
    //cout << v << endl;
    if(flag) return 0;
    for(auto u : G[v]){
        if(D[u] == -1) {
            D[u] = D[v]+1;
            dfs(u);
        }
        else {
            if( (D[u] - D[v] + 1)%2 == 1){
                flag = true;
                return 0;
            }
        }
    }
    return 0;
}


int main() {
    int N; cin >> N;
    G.resize(N);
    for(int i = 0; i < N; i++){
        string S; cin >> S;
        for(int j = 0; j < N; j++){
            if(S[j] == '1'){
                G[i].push_back(j);
            }
        }
    }
    int M=0;
    D.resize(N);
    for(int i = 0; i < N; i++) D[i] = -1;
    D[0] = 0;
    dfs(0);
    for(int i = 0; i < N; i++){
        //cout << i << endl;
        if(!flag){
            for(int j = 0; j < N; j++) D[j] = -1;
            D[i] = 0;
            queue<int> Q;Q.push(i);
            while(!Q.empty()){
                int v = Q.front();Q.pop();
                //cout << v << endl;
                for(auto u : G[v]){
                    if(D[u] == -1) {
                        //cout << " " << u << endl;
                        D[u] = D[v]+1;
                        Q.push(u);
                    }
                }
            }
            int temp =0;
            for(int j = 0; j < N; j++)temp= max(temp,D[j]);
            M = max(M, temp);
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << M+1 << endl;

}






Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}

int main(){
    int ans = 0;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(to_string(i).size()%2)ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    int n = 0;
    cin >> n;
    vector<pair<int,int>> p(n);
    for(int i = 0;i < n;i++){
        cin >> p[i].first >> p[i].second;
    }
    /*
    for(int i = 0;i < n;i++){
        cout << p[i].first << " " << p[i].second << endl;
    }
    */
   vector<int> v(n);
   for(int i = 0;i < n;i++){
       v[i] = i;
   }
   double sum = 0;
   double cnt = 0;
   do{
       cnt ++;
       for(int i = 0;i < n - 1;i++){
           sum += sqrt((pow((double)p[v[i]].first - (double)p[v[i + 1]].first,2) + pow((double)p[v[i]].second - (double)p[v[i + 1]].second,2)));
       }
   }while(next_permutation(v.begin(),v.end()));
   cout << fixed << setprecision(7) <<sum / cnt << endl;
    return 0;
}

Measured memory_bytes: 256
// Author: Wenxing Mei
//   File: a.cpp
//   Date: 2019-03-10 23:31
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define per(i, b, a) for (int i = (int)b - 1; i >= (int)a; --i)
#define repv(ele, cont) for (auto &ele : cont)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<ll> vll;
// END OF TEMPLATE

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - h * W - H * w + h * w << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  int k=1;
  rep(i,1000) {
    
    if(2*k/25==a && k/10==b) break;
    k++;
  }
  if(2*k/25==a && k/10==b) cout << k << endl;
  else {k=-1;
        cout << k << endl;}
  return 0;
}
    
    
    
    
    

  

Measured memory_bytes: 256
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <time.h>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, tmp, A[200005], B[200005], a[200005], b[200005], cnt, Alst[200005], Bbeg[200005], maxlen;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    fill(Bbeg + 1, Bbeg + 1 + n, INF);
    for (int i = 1; i <= n; ++i)
    {
        cin >> A[i];
        Alst[A[i]] = i;
        ++a[A[i]];
    }
    for (int i = 1; i <= n; ++i)
    {
        cin >> B[i];
        if (Bbeg[B[i]] == INF)
        {
            Bbeg[B[i]] = i;
        }
        ++b[B[i]];
    }
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] + b[i] > n)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    A[0] = A[n];
    B[0] = B[n];
    for (int i = 1; i <= n; ++i)
    {
        maxlen = max(maxlen, Alst[i] - Bbeg[i] + 1);
    }
    for (int i = 1; i <= n; ++i)
    {
        cout << B[(i - maxlen + n) % n] << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 12988
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n,ans=1;
    cin>>n;
    lvec a(n),b(n),c(n);
    plvec p(n);
    rep(i,n) cin>>a[i];
    rep(i,n) b[i]=a[i];
    rep(i,n) c[i]=abs(i-(n-i-1));
    sort(all(b));
    sort(all(c));
    bool flag=true;
    rep(i,n){
        if(b[i]!=c[i]){
            flag=false;
            break;
        }
    }
    if(flag){
        rep(i,n/2) ans=ans*2%mod;
    }
    if(flag) cout<<ans<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;
typedef pair<llong, ld> pld;

int n, L;
deque<pld> q;
llong offx;
ld offy;

int ccw(pld a, pld b, pld c) {
    ld x1 = b.fs - a.fs, y1 = b.se - a.se;
    ld x2 = c.fs - b.fs, y2 = c.se - b.se;
    ld v = x1 * y2 - x2 * y1;
    if (v < 0) return -1;
    if (v > 0) return 1;
    return 0;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.precision(20);
    cout << fixed;
    cin >> n >> L;
    q.emplace_front(0, 0);
    while (n--) {
        llong t, v;
        cin >> t >> v;
        offx += v;
        offy += t * v;
        llong lx;
        ld ly;
        while (!q.empty() && L < q.back().fs + offx) {
            tie(lx, ly) = q.back();
            q.pop_back();
        }
        if (q.back().fs + offx < L)
            q.emplace_back(L - offx, (q.back().se * ((lx + offx) - L) + ly * (L - (q.back().fs + offx))) / (lx - q.back().fs));
        int sz;
        while ((sz = q.size()) > 1 && ccw(pld(-offx, -offy), q[0], q[1]) > 0)
            q.pop_front();
        q.emplace_front(-offx, -offy);
        cout << (q.back().se + offy) / L << '\n';
    }
    return 0;
}

Measured memory_bytes: 31804
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main(){
    int n;cin >>n;
    V a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    Sieve sieve(1001001);
    bool flg=true;
    Vl cnt(1001001,0);
    for (int i = 0; i < n; ++i) {
        for(auto p:sieve.factor(a[i])){
            cnt[p.first]++;
        }
    }

    for (int i = 0; i < 1001001; ++i) {
        if(cnt[i]>=2){
            flg=false;
        }
    }
    if(flg)puts("pairwise coprime");
    else {
        int g=0;
        for (int i = 0; i < n; ++i) {
            g=__gcd(g,a[i]);
        }
        if(g==1){
            puts("setwise coprime");
        }
        else puts("not coprime");
    }
}


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

int main()
{
    int a, b, c, x, y;
    vector<int> m;

    cin >> a >> b >> c >> x >> y;

    int diffAns = a * x + b * y;
    int sameAns = c * max(x, y) * 2;
    
    int diffPrice = (x > y) ? a : b;
    int mergeAns = c * min(x, y) * 2 + (max(x, y) - min(x, y)) * diffPrice;

    cout << min(min(diffAns, sameAns), mergeAns) << endl;
    
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  ll ans = 0;
  
  for(ll i=1; i<s.size(); i++){
    if(s[i] != s[i-1]) ++ans;
  }
  
  cout << ans << endl;
}

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

int main()
{
	int a;
	string s;
	
	cin >> a;
	cin >> s;
	
	if (a >= 3200)
	{
		cout << s;
	}
	else{
		cout << "red";	
	}
	cout << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, 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();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    int N;
    cin >> N;
    vector<double> a(N);
    double sum = 0;
    rep(i, N)
    {
        cin >> a[i];
        sum += a[i];
    }
    double ave = sum / N;
    int A = ceil(ave), B = floor(ave);
    ll sumA = 0, sumB = 0;
    rep(i, N)
    {
        sumA += (A - a[i]) * (A - a[i]);
        sumB += (B - a[i]) * (B - a[i]);
    }
    cout << min(sumA, sumB);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e9+10;
#define what_is(x) cerr << #x << " is " << x << endl;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;

ll n, mod = 998244353;
const ll MAX = 1e7 + 1;
vector<ll> v(MAX);

ll inv[MAX];

int main()
{
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;
    for (int i = 0; i < N; i++){
        cout << S[i] << T[i];
    }
    cout << endl;
    return 0;    
}


Measured memory_bytes: 78336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cassert>
#define input std::cin

using lint = long long int;
using namespace std;

struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

int main() {
  std::ios_base::sync_with_stdio(0);
  int n, m; input >> n >> m;
  dsu graph (n);
  for (int i=0; i<m; i++) {
	int a, b; input >> a >> b;
	graph.merge(a-1, b-1);
  }
  std::cout << graph.groups().size() - 1 << std::endl;
}




Measured memory_bytes: 8940
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
// #define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
const int mod = 1'000'000'007;
const int N = 3e5, M = N;

void solve()
{
    ll i, j, n, m;
    cin >> n >> m;
    ll dp[n];
    fo(i, n) { dp[i] = INT_MAX; }
    ll a[n];
    ll cost = 0;
    fo(i, n)
    {
        cin >> a[i];
    }

        dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (i = 2; i < n; i++)
    {
        ll it = m;
        j = i - 1;
        while (it > 0 && j >= 0)
        {

            cost = dp[j] + abs(a[i] - a[j]);
            dp[i] = min(dp[i], cost);
            j--;
            it--;
        }
    }

    cout << dp[n - 1];
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}


Measured memory_bytes: 5232
n=gets.chomp.to_i
a=[]
for i in 0..n-1
  a[i]=[gets.chomp.to_i,i]
end
max,nma=a.sort!.reverse![0],a[1]
for i in 0..n-1
  unless i==max[1]
    puts max[0]
  else
    puts nma[0]
  end
end

Measured memory_bytes: 28392
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int R;
	cin>>R;

	cout<<R*2* M_PI<<endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
using namespace std;

struct Process {
    string id;
    int time;
};

int main() {
    int i, n, q, t=0;
    Process p;
    queue<Process> que;
    cin >> n >> q;
    
    for(i=0; i<n; i++) {
        cin >> p.id >> p.time;
        que.push(p);
    }
    
    while(!que.empty()) {
        if(que.front().time <= q) {
            t+=que.front().time;
            cout << que.front().id << " " << t << endl;
            que.pop();
        } else { 
            t += q;
            p = que.front();
            p.time -= q;
            que.pop();
            que.push(p);
        }
    }
 }


Measured memory_bytes: 6312
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int n;
    scanf("%d",&n);
    int a[n],count1=0,count2=0,count4=0;
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if (a[i]%4==0){
            count4++;
        } else if (a[i]%2==0){
            count2++;
        } else {
            count1++;
        }
    }
    if (count2 + count4 ==n){
        printf("Yes\n");
    } else if (count2!=0 && count4>=count1){
        printf("Yes\n");
    } else if (count2==0 && count4+1>=count1){
        printf ("Yes\n");
    } else {
        printf ("No\n");
    }
	return 0 ;
}

Measured memory_bytes: 512
program main
    integer :: n, mem, ans = 0
    integer :: a(200)
    logical :: flag = .true.

    read *, n
    read *, (a(i), i=1,n)

    do while(flag)
        do i = 1,n
            mem = mod(a(i),2)
            if(mem == 1) then
                flag = .false.
            end if
            a(i) = a(i) / 2
        end do
        if(flag) then
            ans = ans + 1
        end if
    end do
    print *, ans
end program main

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

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.2")

#define all(x) (x).begin(),(x).end()

int inp(){
    int x;
    cin >> x;
    return x;
}

int get_compos(const int &key, const vector<int> &comp){
    return lower_bound(all(comp), key) - comp.begin();
}

void compress(vector<int> &comp){
    sort(all(comp));
    comp.resize(unique(all(comp)) - comp.begin());
}

void opting(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
}

const int maxn = 2e5 + 69, delta = 1e9 + 7;

vector<int> comp, A, B;
unordered_map<int, int> cnt;
int n;

void input(){
    cin >> n;

    int x1 = 0;
    for(int i = 0; i < n; i++){
        int tmp = inp();
        x1 ^= tmp;
        cnt[tmp] ++;
        A.push_back(tmp);

        comp.push_back(tmp);
    }
    cnt[x1]++;
    A.push_back(x1);

    comp.push_back(x1);

    int x2 = 0;
    for(int i = 0; i < n; i++){
        int tmp = inp();
        x2 ^= tmp;
        cnt[tmp]--;
        B.push_back(tmp);

    }
    cnt[x2]--;
    B.push_back(x2);

    for(auto e : cnt)
        if(e.second != 0){
            cout << -1;
            exit(0);
        }
}

int E = 0;
bool inside[maxn];
vector<int> adj[maxn];
void add_edge(int u, int v){
    adj[u].push_back(v);
    adj[v].push_back(u);
    E++;

    inside[u] = inside[v] = inside[A[n]] = inside[B[n]] = true;
}

bool mark[maxn];
void dfs(int v){
    mark[v] = true;
    for(auto u : adj[v])
        if(!mark[u])
            dfs(u);
}
void solve(){
    compress(comp);

    for(int i = 0; i <= n; i++){
        A[i] = get_compos(A[i], comp);
        B[i] = get_compos(B[i], comp);
    }
    for(int i = 0; i <n; i++)
        if(A[i] != B[i])
            add_edge(A[i], B[i]);

    int comp_cnt = 0;
    for(int i = 0; i <= n; i++)
        if(!mark[i] and inside[i])
            comp_cnt++, dfs(i);


    cout << max(0,E + comp_cnt - 1);
}


int main(){
    opting();

    input();
    solve();

}


Measured memory_bytes: 21268
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< std::string, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

inline int read() {
    int res = 0;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar());
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res;
}

int n, m;
std::priority_queue<double> q;

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        double x;
        scanf("%lf", &x);
        q.push(x);
    }
    while (m--) {
        double tmp = q.top();
        q.pop();
        tmp = tmp / 2.0;
        q.push(tmp);
    }
    ll ans = 0;
    while (!q.empty()) {
        double tmp = q.top();
        q.pop();
        ans += (long long)(tmp);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1400
import sys

def get_bit_order(b):
  bo = format(b, 'b')
  return len(bo) - 1


def dp(A, N, K, start):
  ans = 0
  K_order = get_bit_order(K)
  if (K_order - start) < 0:
    return 0
  S = 1 << (K_order - start)
  for b in range(40, -1, -1):
    power = 1 << b
    bit_count = sum([a & power != 0 for a in A])
    
    if (power <= min(S,K)) and (N - bit_count >  bit_count):
      opt_count = N - bit_count
      K -= power
    else:
      opt_count = bit_count
    
    ans += power * opt_count
  return ans


def main():
  input = sys.stdin.readline
  N, K = map(int, input().split())
  A = [int(a) for a in input().split()]
  
  dp_from_1st_Kbit = dp(A, N, K, 0)
  dp_from_2nd_Kbit = dp(A, N, K, 1)

  ans = max(dp_from_1st_Kbit, dp_from_2nd_Kbit)
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 14820
D, G = map(int, input().split())
PC = [list(map(int, input().split())) for i in range(D)]


def solve(G, i):
    if i <= 0:
        return float('inf')
    n = min(int(G/(100*i)), PC[i-1][0])
    score = 100 * i * n
    if n == PC[i-1][0]:
        score += PC[i-1][1]
    if G > score:
        n += solve(G-score, i-1)
    return min(n, solve(G, i-1))


print(solve(G, D))

Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n = 0, r = 0, c = 0;
pair<int, int> hav[100500];
pair<int, int> bat[100500];
bool vis[100500];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> r >> c >> n;
	for(int i = 1; i <= n; i++)
	{
		int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
		cin >> x1 >> y1 >> x2 >> y2;
		if(x1 != 0 && x1 != r && y1 != 0 && y1 != c) { i--, n--; continue; }
		if(x2 != 0 && x2 != r && y2 != 0 && y2 != c) { i--, n--; continue; }
		int t1 = 0, t2 = 0;
		if(y1 == 0) t1 = x1; else if(x1 == r) t1 = r + y1; else if(y1 == c) t1 = 2 * r + c - x1; else t1 = 2 * (r + c) - y1;
		if(y2 == 0) t2 = x2; else if(x2 == r) t2 = r + y2; else if(y2 == c) t2 = 2 * r + c - x2; else t2 = 2 * (r + c) - y2;
		if(t1 > t2) swap(t1, t2);
		hav[i] = make_pair(t1, t2);
	}
	for(int i = 1, j = 0; i <= n; i++)
		bat[++j] = make_pair(hav[i].first, i), bat[++j] = make_pair(hav[i].second, i);
	sort(bat + 1, bat + n * 2 + 1);
	stack<int> whi;
	for(int j = 1; j <= 2 * n; j++)
	{
		pair<int, int> x = bat[j];
		if(not vis[x.second]) whi.push(x.second), vis[x.second] = true;
		else
		{
			if(whi.top() != x.second) return (puts("NO"), 0);
			else whi.pop();
		}
	}
	puts("YES");
	return 0;
}

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

int main() {
    int n, r;
    cin >> n >> r;
    int ans = r + 100*max(0,10-n);
    cout << ans << endl;

    return 0;
}

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

int main() {
  int n; cin >> n;
  // 与えられた数列の合計値
  ll sum=0;
  vector<int> a(n);
  // 1~100000までの数が、それぞれ出てくる回数を記録しておく
  vector<int> times(1e5+1,0);
  for(int i=0; i<n; i++) {
    cin >> a[i];
    sum+=a[i];
    times[a[i]]++;
  }
  int q; cin >> q;
  vector<int> b(q), c(q);
  for(int i=0; i<q; i++) cin >> b[i] >> c[i];
  // q個のテストケースについてそれぞれ処理
  for(int i=0; i<q; i++) {
    sum+=(c[i]-b[i])*times[b[i]];
    times[c[i]]+=times[b[i]];
    times[b[i]]=0;
    cout << sum << endl;
  }
}


Measured memory_bytes: 4796
#include<bits/stdc++.h> 
using namespace std; 
int main(){
  long long a, v, b, w, t; 
  cin>>a>>v>>b>>w>>t;
  long long x=a-b; 
  if(x<0){ x*=-1;}
  if((x<=t*(v-w)) && (v-w)>0)
    cout<<"YES"; 
  else{ cout<<"NO";}
  
  
  }


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

using namespace std;

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

        vector<vector<int>> v;
        v.push_back({-1, 1});
        int current_color = a[0];
        int len = 0;
        for (int i = 0; i < n; i++) {
            if (current_color == a[i])len++;
            else {
                v.push_back({current_color, len});
                current_color = a[i];
                len = 1;
            }
        }
        v.push_back({current_color, len});
        v.push_back({-2, 1});

        int max_remove = 0;
        for (int i = 1; i < v.size() - 1; i++) {
            int l, r;
            int current_remove;
            if (v[i][1] == 1 && v[i - 1][0] == v[i + 1][0]) {
                l = i;
                r = i;
                current_remove = 0;

                v[i - 1][1]++;
                while (v[l - 1][0] == v[r + 1][0] && v[l - 1][1] + v[r + 1][1] >= 4) {
                    l--;
                    r++;
                    current_remove += v[l][1] + v[r][1];
                }
                v[i - 1][1]--;

                max_remove = max(max_remove, current_remove);
            }
            if (v[i - 1][1] >= 3) {
                l = i - 1;
                r = v[i][1] == 1 ? i : i - 1;
                current_remove = v[i - 1][1] + 1;

                v[i][1]--;
                while (v[l - 1][0] == v[r + 1][0] && v[l - 1][1] + v[r + 1][1] >= 4) {
                    l--;
                    r++;
                    current_remove += v[l][1] + v[r][1];
                }
                v[i][1]++;

                max_remove = max(max_remove, current_remove);
            }
            if (v[i + 1][1] >= 3) {
                l = v[i][1] == 1 ? i : i + 1;
                r = i + 1;
                current_remove = v[i + 1][1] + 1;

                v[i][1]--;
                while (v[l - 1][0] == v[r + 1][0] && v[l - 1][1] + v[r + 1][1] >= 4) {
                    l--;
                    r++;
                    current_remove += v[l][1] + v[r][1];
                }
                v[i][1]++;

                max_remove = max(max_remove, current_remove);
            }
        }

        cout << n - max_remove << endl;
    }
    return 0;
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














double R;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> R;
	double ans = 2 * R * 3.14;
	printf("%.10f\n", ans);
}







Measured memory_bytes: 3796
///   Journey to the End of earth   ///
/// Gunjan Kumar ///
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// using namespace __gnu_pbds; 
using namespace std;
#define ll  long long
#define s(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define p(n) printf("%d",n)
// #define ln() printf("\n")
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          LONG_MAX
#define ninf         LONG_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const   ll mod=1e9+7;
const ll N=1e5+5;



int main()
{

        
         int n,k;
         cin >> n>>k;
         ll arr[n];
         rep(i,0,n)
         cin >> arr[i];

         ll dp[n];
         rep(i,0,n)
         dp[i]=0;
         
         ll mini=inf;
         rep(i,1,n){
          mini=inf;
         for(int j=1;j<=k;j++)
         {

             if((i-j)<0)
              break;
            else{
              ll temp=dp[i-j]+abs(arr[i]-arr[i-j]);
              if(mini>temp)
                mini=temp;
            }
         }
         dp[i]=mini;
       }
         // rep(i,0,n)
         // cout <<dp[i]<<" ";
         cout<<dp[n-1];

         
     return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

int table[SIZE];


int main(){

	int N,M;
	scanf("%d %d",&N,&M);

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

		table[i] = 0;
	}

	int L,R;
	for(int i = 0; i < M; i++){

		scanf("%d %d",&L,&R);
		table[L]++;
		table[R+1]--;
	}

	int ans = 0;
	for(int i = 1; i <= N; i++){

		table[i] += table[i-1];
		if(table[i] == M){

			ans++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 640
object Main {
  def main(args: Array[String]): Unit = {
    val rs = io.Source.stdin
      .getLines()
      .toStream
      .filter(_.matches("\\d+"))
      .map(_.trim.toInt)
      .tail
      .toList

    val minRs = rs.scan(rs.head)(_ min _).drop(1)
    val maxRs = (rs.tail, minRs.init).zipped.map(_ - _)
    println(maxRs.max)
  }
}



Measured memory_bytes: 241800
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  2 21:02:53 2020

@author: naoki
"""

N,D = map(int, input().split())
place = [list(map(int, input().split()))for i in range (N)]
count = 0 
for i in range(N):
    if (place[i][0])**2+(place[i][1])**2 <= D**2:
        count +=1
print(count)
        

Measured memory_bytes: 45352
__author__ = 'CIPHER'
_project_ = 'PythonLehr'

class BoundingBox:
    def __init__(self, width, height):
        self.width = width;
        self.height = height;

    def CalculateBox(self, x, y, r):
        if x>= r and x<=(self.width-r) and y>=r and y<=(self.height-r):
            print("Yes")
        else:
            print("No")
'''
width = int(input("Width of the Box: "))
height = int(input("Height of the Box: "))
x = int(input("location of x: "))
y = int(input("location of y: "))
r = int(input("radius of the circle; "))
'''

# alternative input
inputList = input()
inputList = inputList.split(' ')
inputList = [int(x) for x in inputList]
# print(inputList)
width = inputList[0]
height = inputList[1]
x = inputList[2]
y = inputList[3]
r = inputList[4]

Box = BoundingBox(width, height)
Box.CalculateBox(x, y, r)

Measured memory_bytes: 7740