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

int main() {
  int N;
  cin>>N;
  if(N/10==111){
    cout<<"Yes"<<endl;
  }
  else if(N/10==222){
    cout<<"Yes"<<endl;
  }
  else if(N/10==333){
    cout<<"Yes"<<endl;
  }
  else if(N/10==444){
    cout<<"Yes"<<endl;
  }
  else if(N/10==555){
    cout<<"Yes"<<endl;
  }
  else if(N/10==666){
    cout<<"Yes"<<endl;
  }
  else if(N/10==777){
    cout<<"Yes"<<endl;
  }
  else if(N/10==888){
    cout<<"Yes"<<endl;
  }
  else if(N/10==999){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==111){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==222){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==333){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==444){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==555){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==666){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==777){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==888){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==999){
    cout<<"Yes"<<endl;
  }
  else if(N%1000==000){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;
import java.math.BigDecimal;

public class Main{
	
	public static void main(String[] args){
		
		double[] x = new double[3];
		double[] y = new double[3];
		
		Scanner s = new Scanner(System.in);
		
		int n = s.nextInt();
		
		for(int j = 0; j < n; j++){
			
			for(int i = 0; i < x.length; i++){
				
				x[i] = s.nextDouble();
				y[i] = s.nextDouble();
			}
			
			double px, py, r;
			
			px = ((y[0]-y[2])*(y[0]*y[0] - y[1]*y[1] + x[0]*x[0] - x[1]*x[1]) - (y[0]-y[1])*(y[0]*y[0] - y[2]*y[2] + x[0]*x[0] - x[2]*x[2])) / (2*(y[0]-y[2])*(x[0]-x[1]) - 2*(y[0]-y[1])*(x[0]-x[2]));
			py = ((x[0]-x[2])*(x[0]*x[0] - x[1]*x[1] + y[0]*y[0] - y[1]*y[1]) - (x[0]-x[1])*(x[0]*x[0] - x[2]*x[2] + y[0]*y[0] - y[2]*y[2])) / (2*(x[0]-x[2])*(y[0]-y[1]) - 2*(x[0]-x[1])*(y[0]-y[2]));
	
			r = Math.sqrt(Math.pow(px-x[0], 2)+Math.pow(py-y[0], 2));
			
			BigDecimal bd = new BigDecimal(px);
	        bd.setScale(2, BigDecimal.ROUND_HALF_UP);
			px = bd.doubleValue();
			
			bd = new BigDecimal(py);
	        bd.setScale(2, BigDecimal.ROUND_HALF_UP);
			py = bd.doubleValue();
			
			bd = new BigDecimal(r);
	        bd.setScale(2, BigDecimal.ROUND_HALF_UP);
			r = bd.doubleValue();
			
			System.out.printf("%.3f %.3f %.3f\n", px, py, r);
			
		}
		
	}
	
}


Measured memory_bytes: 29268
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int a;
int b;
int ar[N];

int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &ar[i]);
        if(ar[i] > a)
           a = ar[i];
    }
    sort(ar + 1 , ar + n + 1);
    for(int i = 1; i <= n; i++){
        if(ar[i] == a)
            continue;
        if(ar[i] <= a / 2 && a/2 - ar[i] < a/2 - b){
            b = ar[i];
        } else if( ar[i] >= ((a/2) + (a&1)) && ar[i] - ((a/2) + (a&1)) < abs(b - ((a/2) + (a&1))) ){
            b = ar[i];
        }
    }
    printf("%d %d\n" , a , b);
}

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

vector<int> getPath(int u, int v, map<pair<int, int>, int>& mp, vector<vector<int>>& tree, vector<vector<int>>& dist) {
    vector<int> ret;
    int now = v;
    while (now != u) {
        for (int t : tree[now]) {
            if (dist[u][t] == dist[u][now] - 1) {
                ret.push_back(mp[{now, t}]);
                now = t;
                break;
            }
        }
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> tree(N, vector<int>());
    map<pair<int, int>, int> mp;
    vector<vector<int>> dist(N, vector<int>(N, 1e9));
    for (int i = 0; i < N; i++) {
        dist[i][i] = 0;
    }
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
        mp[{a, b}] = i;
        mp[{b, a}] = i;
        dist[a][b] = 1;
        dist[b][a] = 1;
    }

    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
            }
        }
    }

    int M;
    cin >> M;
    vector<pair<int, int>> UV(M);
    vector<vector<int>> st(M);
    for (int i = 0; i < M; i++) {
        cin >> UV[i].first >> UV[i].second;
        UV[i].first--;
        UV[i].second--;
        st[i] = getPath(UV[i].first, UV[i].second, mp, tree, dist);
    }

    ll ans = 0;
    for (int i = 1; i < (1 << M); i++) {
        int n = i;
        int cnt = 0;
        ll temp = 0;
        vector<bool> selected(N - 1, false);
        for (int j = 0; j < M; j++) {
            if (n % 2 == 1) {
                cnt++;
                for (int e : st[j]) {
                    selected[e] = true;
                }
            }
            n /= 2;
        }

        int selectedEdges = 0;
        for (int i = 0; i < N - 1; i++) {
            if (selected[i]) {
                selectedEdges++;
            }
        }
        temp = 1ll << (N - 1 - selectedEdges);
        ans += pow(-1, cnt + 1) * temp;
    }
    cout << (1ll << (N - 1)) - ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[101010];
ll k[101010];
ll b[101010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin>>N>>L;
    ans=0;
    rep(i,0,N){
        ans+=L+i;
    }
    if(L>=0){
        ans-=L;
    }else{
        if(abs(L)>=N){
            ans -= N-abs(L)-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

const int L = 10;

int n, m, c[9] = { 6, 7, 3, 6, 5, 4, 5, 5, 2 };
bool ava[9];
array<int, 10> dp[L][10010];

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a;
		cin >> a;
		ava[9 - a] = true;
	}
	
	dp[0][0] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
	inc(I, n) {
	inc(j, n) {
		int i = I % L;
		if(dp[i][j][9] == 0) { continue; }
		inc(k, 9) {
			if(! ava[k]) { continue; }
			auto x = dp[i][j];
			x[k]++;
			setmax(dp[(i + c[k]) % L][j + 1], x);
		}
		dp[i][j] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
	}
	}
	
	int D = -1;
	decII(j, 0, n) {
		if(dp[n % L][j][9] == 1) {
			D = j;
			break;
		}
	}
	assert(D != -1);
	
	// inc(i, 10) { cout << dp[n % L][D][i] << " "; } cout << endl;
	
	inc(i, 9) {
		inc(j, dp[n % L][D][i]) { cout << 9 - i; }
	}
	cout << endl;
	
	return 0;
}




Measured memory_bytes: 2304
import copy 

def resolve(List):
    # L[0]!=0を起点とする
    L = copy.deepcopy(List)
    cnt = 0
    s = L[0]
    for i in range(1,len(L)):
        a = L[i]
        if(s>0 and s+a>=0):
            L[i] = -s-1
            cnt += (s+a+1)
            s = -1
        elif(s<0 and s+a<=0):
            L[i] = -s+1
            cnt += (-s-a+1)
            s = 1
        else:
            s += a
    return cnt      

def ans(List):
    L = copy.deepcopy(List)
    a = L[0]
    c0,c1=0,0

    if (a>0):
        c0 = resolve(L)
        c1 = (a+1) + resolve([-1]+L[1:])
    elif (a<0):
        c0 = resolve(L)
        c1 = (-a+1) + resolve([1]+L[1:])
    else:
        c0 = 1 + resolve([1]+L[1:])
        c1 = 1 + resolve([-1]+L[1:])
    
    return(min(c0,c1))

N = int(input())
List = [int(x) for x in input().split(' ')]
print(ans(List))


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

int main() {
  int a, b, c, k;// 1, 0, -1, 選ぶ数
  cin >> a >> b >> c >> k;
  if(k <= a) { 
    cout << k << endl;
  }else if(k <= a + b){
  	cout << a << endl;
  }else {
  	cout << a - (k - a - b) << endl;
  }
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  vector<long> dp(n + k);
  for (int i = 0; i < n; i++) cin >> h[i];
  for (int i = 0; i < n; i++) dp[i] = 2000000000;
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
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));}
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";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
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 S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int ans=0,in;
	rep(i,5)cin>>in,ans+=max(in,40);
	cout<<ans/5<<endl;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll diff(ll p,ll q,ll r,ll s){
    ll ma = 0;
    ll mi = INF;

    chmax(ma,p);
    chmax(ma,q);
    chmax(ma,r);
    chmax(ma,s);
    chmin(mi,p);
    chmin(mi,q);
    chmin(mi,r);
    chmin(mi,s);
    return abs(ma-mi);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec a(n);
    rep(i,n){
        cin>>a[i];
    }
    Vec S(n+1);
    rep(i,n){
        S[i+1] = S[i]+a[i];
    }

    ll x=1;
    ll y=3;
    ll ans = INF;


    REP(i,2,n-1){
        ll pq = S[i];
        ll rs = S[n]-S[i];

        while(S[x]*2 < pq && x<i-1){
            x++;
        }
        while( (S[y]-pq) * 2 < rs && y<n-1){
            y++;
        }

//        ll p = S[x];
//        ll q = pq-p;
//        ll r = S[y]-pq;
//        ll s = rs-r;

        chmin(ans,diff(S[x],pq-S[x],S[y]-pq,rs-S[y]+pq));
        chmin(ans,diff(S[x-1],pq-S[x-1],S[y]-pq,rs-S[y]+pq));
        chmin(ans,diff(S[x],pq-S[x],S[y-1]-pq,rs-S[y-1]+pq));
        chmin(ans,diff(S[x-1],pq-S[x-1],S[y-1]-pq,rs-S[y-1]+pq));
    }

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


Measured memory_bytes: 3456
#include <iostream>
#include <assert.h>
#include <algorithm>
//#include <cmath>
#include <vector>

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

    int64_t N, M;
    std::cin >> N >> M;

    using item_type = std::pair<int64_t, int64_t>;
    using shop_vect_type = std::vector<item_type>;
    shop_vect_type shops(N);
    for(int32_t i = 0; i < N; i++){
        std::cin >> shops[i].first >> shops[i].second;
    }
    
    std::sort(shops.begin(), shops.end());

    int64_t res = 0;
    int32_t idx = 0;
    int64_t cnt = 0;
    while(cnt < M){
        if(idx == N){
            std::cout << "unexpected inputs" << std::endl;
            return -1;
        }
        if(shops[idx].second + cnt <= M){
            res += shops[idx].second * shops[idx].first;
            cnt += shops[idx].second;
        }
        else{
            res += (M - cnt) * shops[idx].first;
            cnt += (M - cnt);
        }
        idx++;
    }
    std::cout << res;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
template <typename CT, typename T> inline void reset_container(CT &c, int sz, T v){c.resize(sz); for(auto &x: c) x=v;}
#define taskname "B"
int n;
int p[200];
vector <int> ans;
void op(int k){
    ans.pb(k);
    FFOR(i, k, n) swap(p[i], p[i-k]);
}
int main(){
    #ifdef Aria
        if(fopen(taskname".in", "r"))
            freopen(taskname".in", "r", stdin);
    #endif // Aria
    read(n);
    FFOR(i, 0, n) read(p[i]);
    int done=n-1;
    while(done){
        while(p[0]!=done-1) op(1);
        while(p[1]!=done){
            op(1);
            op(n-1);
        }
        done--;
    }
    writeln(ans.size());
    FFOR(i, 0, n) assert(p[i]==i);
    for(auto x: ans) writeln(x);
}

Measured memory_bytes: 764
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
      
      int K = sc.nextInt();
      String S = sc.next();

        if(K<S.length()){
        System.out.print(S.substring(0,K)+"...");
        }
        else if (K>=S.length()){
        System.out.print(S);
        }
      
    }
}


Measured memory_bytes: 38420
S = input()

# 次の日曜日が何日後か求めよ
if S == "SUN":
    print(7)

if S == "SAT":
    print(1)

if S == "MON":
    print(6)

if S == "TUE":
    print(5)

if S == "WED":
    print(4)

if S == "THU":
    print(3)

if S == "FRI":
    print(2)

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

int main() {
  int N,M; cin >> N >> M; map<int,int> map; bool check = true; int ans =0;
  if (N == 1 && M == 0) {
    ans = 0; check = false;
  } else {
    for (int i =0; i<M; i++) {
      int a,b; cin >> a >> b; 
      if (map.count(a)) {
        if (map[a] != b) { ans = -1; check = false; } 
      } else { map[a] = b; }
      if (N != 1 && a == 1 && b == 0) {ans =-1; check = false;}
    }
  }
  
  if (!check) { cout << ans << endl; } 
  else {
    for (int i =1; i<=N; i++) {
      if (map.count(i)) {cout << map[i]; } 
      else { i ==1 ? cout << 1 : cout << 0; }
    }
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e5 + 5;

int solve(int x, int k){
    int kam = x / k;
    if(x % k) kam++;
    return kam;
}
int n, k, start, a[N];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 1){
            start = i + 1;
        }
    }
    int mn = 2e9;
    for(int i = start - k + 1; i <= start; i++){
        if(i <= 0) continue;
        int kam = solve(i - 1, k - 1) + solve(n - (i + k - 1), k - 1);
        mn = min(mn, kam);
    }
    cout << mn + 1;



    return 0;
}


Measured memory_bytes: 640
import collections
n = int(input())
v = list(map(int, input().split()))
v1 = [v[i*2+1] for i in range(n//2)]
v2 = [v[i*2] for i in range(n//2)]
c1 = collections.Counter(v1).most_common()
c2 = collections.Counter(v2).most_common()

if len(set(v1)) == len(set(v2)) == 1:
  if c1[0][0] != c2[0][0]:
    print(0)
  else:
    print(min(len(v1), len(v2)))
elif len(set(v1))==1:
  if c1[0][0] != c2[0][0]:
    print(sum([i[1] for i in c2])-c2[0][1])
  else:
    print(sum([i[1] for i in c2])-c2[1][1])
elif len(set(v2))==1:
  if c1[0][0] != c2[0][0]:
    print(sum([i[1] for i in c1])-c1[0][1])
  else:
    print(sum([i[1] for i in c1])-c1[1][1])
else:
  if c1[0][0] != c2[0][0]:
    print((sum([i[1] for i in c1])-c1[0][1]) + (sum([i[1] for i in c2])-c2[0][1]))
  else:
    print(min((sum([i[1] for i in c1])-c1[0][1])+(sum([i[1] for i in c2])-c2[1][1]),
              (sum([i[1] for i in c1])-c1[1][1])+(sum([i[1] for i in c2])-c2[0][1])))

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	string s;
	cin>>a>>b>>s;
	for(int i=0;i<a;i++){
		if(s[i]=='-'){
			cout<<"No";
			return 0;
		}
	}
	if(s[a]!='-'){
		cout<<"No";
		return 0;
	}
	for(int j=a+1;j<a+1+b;j++){
		if(s[j]=='-'){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
N = int(input())
people = []
for _ in range(N):
    A = int(input())
    ts = []
    for _ in range(A):
        x, y = map(int, input().split())
        x -= 1
        ts.append((x, y))
    people.append(ts)

ans = 0
for bit in range(1, (1 << N)):
    ok = True
    count = 0
    for i in range(N):
        if bit & (1 << i):
            count += 1
            for x, y in people[i]:
                if (bit & (1 << x) > 0) != (y == 1):
                    ok = False
                    break
            if not ok:
                break
    if ok and ans < count:
        ans = count
print(ans)


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

int main(){
	int a;
	int b;
	cin >> a;
	cin >> b;

	if (a < b){
		swap(a, b);
	}

	if ((a == 2) && (b == 1)){
		cout << 3 << endl;
	}else if ((a == 3) && (b == 1)) {
		cout << 2 << endl;
	}else if ((a == 3) && (b == 2)) {
		cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
l = []
r = []
for _ in range(Q):
    l1, r1 = map(int, input().split())
    l.append(l1)
    r.append(r1)
    

m = S.count("AC")
S = "a" + S
ll = [0 for _ in range(N+1)]
rr = [0 for _ in range(N+1)]
for i in range(1,N+1):
    ll[i] = ll[i-1]
    if S[i-1] == "A" and S[i] == "C":
       ll[i] -= 1
    rr[i] = -m - ll[i]
       
for i in range(Q):
    print(m + rr[r[i]] + ll[l[i]])

Measured memory_bytes: 18204
#include<bits/stdc++.h>
using namespace std;
vector<int> w[10];
const int n=4;
int vis[10];
void dfs(int u)
{
	vis[u]=1;
	for(int v:w[u])
		if(!vis[v]){dfs(v);break;}
}
int main()
{
	for(int i=1,x,y;i<n;i++)cin>>x>>y,w[x].push_back(y),w[y].push_back(x);
	for(int i=1;i<=n;i++)
	{
		memset(vis,0,sizeof vis);
		dfs(i);
		bool f=1;
		for(int j=1;j<=n;j++)f&=vis[j];
		if(f)cout<<"YES\n",exit(0);
	}
	cout<<"NO\n";
}


Measured memory_bytes: 256
# include <cstdio>
# include <iostream>
# include <algorithm>
# define R register int
# define nl (n<<1)
# define nr (n<<1|1)

using namespace std;

const int maxn=200005;
int n,m,delta[maxn<<2],t[maxn<<2],ans=0,qg;
struct peo { int l,r; }a[maxn];

bool cmp (peo a,peo b) { if(a.l!=a.r) return a.l<b.l; return a.r<b.r; }

void pushdown (int n)
{
    int x=delta[n];
    delta[nl]+=x;
    delta[nr]+=x;
    t[nl]+=x;
    t[nr]+=x;
    delta[n]=0;
}

void add (int n,int l,int r,int ll,int rr,int v)
{
    if(ll<=l&&r<=rr)
    {
        t[n]+=v; delta[n]+=v;
        return;
    }
    int mid=(l+r)>>1;
    if(delta[n]) pushdown(n);
    if(ll<=mid) add(nl,l,mid,ll,rr,v);
    if(rr>mid) add(nr,mid+1,r,ll,rr,v);
    t[n]=max(t[nl],t[nr]);
}

void build (int n,int l,int r)
{
	if(l==r)
	{
		t[n]=r-m-1;
		return;
	}
	int mid=(l+r)>>1;
	build(nl,l,mid);
	build(nr,mid+1,r);
	t[n]=max(t[nl],t[nr]);
}

int ask (int n,int l,int r,int ll,int rr)
{
    if(ll<=l&&r<=rr)
        return t[n];
    int mid=(l+r)>>1,ans=-10000;
	if(delta[n]) pushdown(n);
    if(ll<=mid) ans=max(ans,ask(nl,l,mid,ll,rr));
    if(rr>mid) ans=max(ans,ask(nr,mid+1,r,ll,rr));
	return ans;
}

int main()
{
    scanf("%d%d",&n,&m);
    for (R i=1;i<=n;++i)
		scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+1+n,cmp);
	build(1,0,m+1);
    int p=1;
	for (R i=0;i<=m;++i)
	{
		while(a[p].l<=i&&p<=n) add(1,0,m+1,1,a[p].r,1),p++;
		ans=max(ans,ask(1,0,m+1,i+1,m+1)-i);
	}
	ans=max(ans,n-m);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(ll i=0;i<(n);i++)
int main() {
	ll a, b, c, x, y;
	ll ans = 1e18;
	cin >> a >> b >> c >> x >> y;
	for (ll i = 0; i <= max(x, y) * 2; i += 2) {
		ll num = i * c + max(0ll, x - i / 2)*a + max(0ll, y - i / 2)*b;
		ans = min(ans, num);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int K;
  cin >> K;
  
  vector<int> a(K);
  
  bool exist = false;
  for(int i=0; i<K; i++){
    if(i==0){
      a.at(i) = 7%K;
    }else{
      a.at(i) = (10*a.at(i-1)+7)%K;
    }
    if(a.at(i) == 0){
      cout << i+1;
      exist = true;
      break;
    }
  }
  if (!exist) cout << -1;
      

}

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

int main(){

	int a,b,s,d;
	while(cin>>a>>b)
	{		
		s = a + b;
		d = 0;
		{
			while(s)
			{
				s /= 10;
				d ++;
			}
			cout<<d<<endl;
		}
	}

return 0;
}

Measured memory_bytes: 1160
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000003

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))

//#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int maxn = 100001;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
long long  gcd(long long  a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    fast;
    int n,m,k;
    cin>>n>>m>>k;
    cout<<min((n*m),k)<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
dydx4 = ((-1,0),(0,-1),(0,1),(1,0))

h,w = map(int,input().split())
A = [list(input()) for i in range(h)]
dis = [[inf] * w for i in range(h)]
import heapq
def bfs(start_set):
  que = collections.deque()
  for si,sj in start_set:
    que.append((0,si,sj))
    dis[si][sj] = 0
  while que:
    cost,i,j =que.popleft()
    if dis[i][j] < cost: continue
    for di,dj in dydx4:
      ni = i + di
      nj = j + dj
      if not (0 <= ni < h and 0 <= nj < w):continue
      if A[ni][nj] == "#":continue
      # if A[ni][nj] == "#" and dis[ni][nj] == inf:
      #   dis[ni][nj] = 0
      #   heapq.heappush(que,(0,ni,nj))
      if cost + 1 < dis[ni][nj]: 
        dis[ni][nj] = cost+1
        que.append((cost+1,ni,nj))

start_set = []
for i in range(h):
  for j in range(w):
    if A[i][j] == "#":
      start_set.append((i,j))
bfs(start_set)
      
print(max(map(max,dis)))





Measured memory_bytes: 217564
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}
 
int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    puti(arr[m]);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1632
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N; cin >> N;
	vector<int> a(N);
	rep(i, N)cin >> a[i];

	sort(a.begin(), a.end(), greater<int>());
	vector<int> tmp;


	ll ans = 0;
	tmp.push_back(a[0]);

	for (int i = 1; i < N; i++) {
		int x = a[i];
		ans += tmp[i - 1];
		tmp.push_back(x); tmp.push_back(x);
	}

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


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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N;
   cin >> N;
   vector<double> v(N);
   rep(i, N) cin >> v.at(i);

   sort(v.begin(), v.end());

   double ans = v.at(0);
   for (int i = 1; i < N; i++) {
     ans = (ans + v.at(i)) / 2.0;
   }
   cout << ans << endl;

 }


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------


long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}




int main(void)
{
	int a, b;
	cin >> a >> b;
	int ab=0;
	int ba=0;

	rep(i, b)
	{
		ab *= 10;
		ab += a;
	}
	rep(i, a)
	{
		ba *= 10;
		ba += b;
	}

	cout << max(ab, ba) << endl;
}



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

int main(){
    int a,b,c;

 scanf("%d%d%d",&a,&b,&c);
for(int i=0;i<c;i++) {
    if (i % 2 == 0) {
        if (a % 2 == 1) a -= 1;
        b += a / 2;
        a /= 2;
    } else {
        if (b % 2 == 1) {
            b -= 1;
        }
        a += b / 2;
        b /= 2;
    }
}
printf("%d %d\n",a,b);
return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <map>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int amount, coin;
    cin >> amount >> coin;
    int remainder = amount % 500;
    if (coin >= remainder)
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pl = pair<ll, ll>;
using Tl = tuple<ll, ll, ll>;

const ll INF = 1e15;
const ld eps = 1e-6;

int main(){
  ll N, W;
  cin >> N >> W;
  ll V = 100099;
  vector<ll> dp(100100, INF);
  dp[0] = 0;
  ll ans = 0;
  for(int i=0;i<N;i++){
    ll w,v;
    cin >> w >> v;
    for(int from=V;from>=0;from--){
      if(from + v > V)
	continue;
      dp[from + v] = min(dp[from + v], dp[from] + w);
      if(dp[from + v] <= W)
	ans = max(ans, from + v);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
from bisect import *
from itertools import accumulate
n, m, k = map(int, input().split())
a = [0]+list(map(int, input().split()))
b = [0]+list(map(int, input().split()))
a = list(accumulate(a))
b = list(accumulate(b))
ans = 0
for i in range(n+1):
    if a[i] > k:
        continue
    ind = bisect_right(b, k-a[i])
    ans = max(ans, ind+i-1)

print(ans)


Measured memory_bytes: 129804
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a,b = [0],[0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0,M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i + j)
print(ans)

Measured memory_bytes: 47312
from itertools import *

def main():
    N = input()
    #print(N[::-1])
    #print(N[:(len(N)-1)//2])
    #print(N[(len(N)+3)//2:-1])
    
    if N != N[::-1]:
        print("No")
    elif N[:(len(N)-1)//2] != N[:(len(N)-1)//2][::-1]:
        print("No")
    elif N[(len(N)+3)//2:-1] != N[(len(N)+3)//2:-1][::-1]:
        print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()

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

int main(){
	
	string s;
	
	cin >> s;
	
	if (s[2] == s[3] && s[4] == s[5]){
		cout << "Yes";
	} else {
		cout << "No";
	}
	
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  char a,b;
  int x[] = {1,0,0};
  while(scanf("%c,%c\n", &a,&b)!=EOF) {
    swap(x[a-'A'], x[b-'A']);
  }
  for(int i=0;i<(int)3;++i){
    if (x[i]){
      cout << (char)('A' + i) << endl;
}
} 
}


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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

const int maxn=int(1e6)+1;
int a[maxn];

int main(){
	IOS;
	int n,i,temp;
	cin>>n;
	REP(i,0,n-1) cin>>temp,a[temp]++;
	if(a[1]==1){
		cout<<1;
		return 0;
	} else if(a[1]>1){
		cout<<0;
		return 0;
	}
	vector<bool> ch(maxn);
	REP(i,1,maxn-1){
		ch[i]=1;
		if(!a[i]) continue;
		ch[i]=0;
		if(a[i]>1){
			ch[i]=1;
			continue;
		}
		for(int j=2;j*j<=i;j++){
			if(i%j==0){
				if(a[j]||a[i/j]){
					ch[i]=1;
					break;
				}
			}
		}
	}
	int ans=0;
	REP(i,1,maxn-1) ans+=ch[i]==0;
	cout<<ans;
 	return 0; 	
}




Measured memory_bytes: 7672
def main():
    B = input()
    B = B.split()
    B = [int(i) for i in B]
    n = B[0]
    m = B[1]
    if m * n == 0:
        return 0
    if min(n, m) == 1:
        if max(n, m) == 1:
            return 1
        else:
            return max(n, m) - 2
    else:
        nc = n - 2
        mc = m - 2
        return nc * mc
          
print(main())

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll n,k;
	cin >> n >> k;
	vector<pair<ll,ll>> a(k);
	REP(i,k){
		cin >> a[i].first >> a[i].second;
	}
	
	const ll MOD = 998244353;
	vector<ll> dp(n+1,0),s(n+1,0);
	REP(j,k){
		if(1 + a[j].first <= n){
			s[1 + a[j].first] += 1;
			s[1 + a[j].first] %= MOD;
		}

		if(1 + a[j].second + 1 <= n){
			s[1 + a[j].second + 1] -= 1;
			s[1 + a[j].second + 1] =  (s[1+a[j].second+1]+MOD)%MOD;
		}
	}	
	FOR(i,2,n+1){
		dp[i] = (dp[i-1]+s[i]) % MOD;
		
		REP(j,k){
			if(i + a[j].first <= n){
				s[i + a[j].first] += dp[i];
				s[i + a[j].first] %= MOD;
			}
			
			if(i + a[j].second + 1 <= n){
				s[i + a[j].second + 1] -= dp[i];
				s[i + a[j].second + 1] =  (s[i+a[j].second+1]+MOD)%MOD;
			}
		}
		
	}
	
	cout << dp[n] << endl;
	
	return 0;
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
  ll n, w;
  cin >> n >> w;
  ll value[n];
  ll weight[n];
  for(ll x = 0; x < n; x++) {
  	cin >> weight[x] >> value[x];
  }
  
  ll dp[n][w+1];
  for(ll y = 0; y <= w; y++) {
  	if(y >= weight[0]) {
      dp[0][y] = value[0];
    }
    else {
      dp[0][y] = 0;
    }
  }
  
  for(ll x = 1; x < n; x++) {
  	for(ll y = 0; y <= w; y++) {
      if(weight[x] > y) {
        dp[x][y] = dp[x-1][y];
      }
      else {
        dp[x][y] = max(dp[x-1][y], value[x] + dp[x-1][y-weight[x]]);
      }
    }
  }
  
  cout << dp[n-1][w];
}

Measured memory_bytes: 81696
def main():
	H, W = [int(n) for n in input().split(" ")]
	iniBlack = 0
	S = []
	S.append(["X"] * (W + 2))
	for i in range(H):
		row = list(input())
		iniBlack += row.count("#")
		S.append(["X"] + row + ["X"])
	S.append(["X"] * (W + 2))

	to_visit = [{"row": 1, "col": 1, "step": 1}]
	checked = [[0] * (W + 2) for i in range(H + 2)]
	checked[1][1] = 1

	while len(to_visit) > 0:
		visiting = to_visit.pop(0)
		r0 = visiting["row"]
		c0 = visiting["col"]
		s0 = visiting["step"]
		for d in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
			r = r0 + d[0]
			c = c0 + d[1]
			if S[r][c] == "." and checked[r][c] == 0:
				to_visit.append({"row": r, "col": c, "step": s0 + 1})
				checked[r][c] = s0 + 1

	if checked[H][W] == 0:
		print(-1)
		return 0
	print(H * W - iniBlack - checked[H][W])

main()

Measured memory_bytes: 9284
n = int(input())
p = list(map(int,input().split()))
left = 0
for i in range(len(p)):
    if p[i] == i+1:
        left += 1
        if i == len(p)-1:
            break
        tmp = p[i]
        p[i] = p[i+1]
        p[i+1] = tmp

print(left)


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

//
#define int long long
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, Q;
  cin >> N >> Q;

  int a[101010];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < Q; i++) {
    int x;
    cin >> x;

    int r = 0;
    int sum = 0, ans = 0;
    for (int l = 0; l < N; l++) {

      while (r < N && sum + a[r] <= x) {
        sum += a[r++];
      }

      ans += r - l;
      if (l == r) {
        r++;
      } else {
        sum -= a[l];
      }
    }

    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> t(n), a(n);
    int tmaxid, amaxid;
    ll tmax=0, amax=0;
    for(int i=0; i<n; i++){
        cin>>t[i];
        if(tmax<t[i]){
            tmax=t[i];
            tmaxid=i;
        }
    }
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(amax<=a[i]){
            amax=a[i];
            amaxid=i;
        }
    }

    if(t[tmaxid]!=a[tmaxid] || t[amaxid]!=a[amaxid]){
        cout << 0 << endl;
        return 0;
    }

    ll ans=1;
    int th=t[0];
    for(int i=1; i<tmaxid; i++){
        if(th<t[i]) th=t[i];
        else ans*=th;
        ans%=MOD;
    }

    for(int i=tmaxid+1; i<amaxid; i++){
        ans*=tmax;
        ans%=MOD;
    }

    int ah=a[n-1];
    for(int i=n-2; i>amaxid; i--){
        if(ah<a[i]) ah=a[i];
        else ans*=ah;
        ans%=MOD;
    }
    cout << ans << endl;
}

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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[220000],b[220000];
map<ll,ll> c;
main(){
    ll n,k,s,ans=0;
    cin>>n>>k>>s;
    rep(i,0,k)cout<<s<<" ";
    rep(i,0,n-k)cout<<"49256"<<" ";
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool ok=true;
  for(int i=0;i<3;++i) {
    if(s[i]==s[i+1]) ok=false;
  }
  if(ok) cout << "Good" << endl;
  else cout << "Bad" << endl;
}


Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int f ( int x ){
int ret =0  ;
 while ( x ){
    ret++ ;
    x /= 10 ;
 }
 return ret ;
}
int main ( ){
    cin >> n ;
    int cnt = 0;
    for ( int i = 1 ; i <= n ; i++ ){

        if (  f(i) &1 ) cnt++;
    }
    cout << cnt <<endl;
return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>

using namespace std;

size_t Noperand = 100;
size_t Noperator = 99;

size_t top;
vector<int> v1(Noperand + 1);
string s;

void initialize() {
	top = 0;
}

bool isEmpty() {
	if (top == 0) return true;
	else return false;
}

bool isFull() {
	if (top >= Noperand + Noperator) return true;
	else return false;
}

void push(const int& x) {
	if (isFull()) {
		cout << "stack is full\n";
	}
	else v1[++top] = x;
}

int pop() {
	if (isEmpty()) {
		cout << "stack is empty\n";
	}
	else return v1[top--];
}

int main(){
	initialize();
	int a;
	int b;
	int s2;
	while(cin>>s) {
		if (s == "+") {
			a = pop();
			b = pop();
			push(b + a);
		}
		else if (s == "-") {
			a = pop();
			b = pop();
			push(b - a);
		}
		else if (s == "*") {
			a = pop();
			b = pop();
			push(b*a);
		}
		else {
			s2 = stoi(s);
			push(s2);
		}
	}
	cout << v1[top] << endl;
}



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

int main(){
    int n;
    cin >> n;
    int ans;
    for (int i = n;i > 0;i--){
        ans = i;
        double ans_1 = sqrt(i);
        int ans_2 = sqrt(i);
        if (ans_1 - ans_2 == 0){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256