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

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using namespace std;

/* function */
//  - none - 


/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int N;    // 飛行機の乗客数
  int C;    // バスの定員
  int K;    // 乗客の許容時間

  int i;    // subscript

  int capa;
  int times;
  int bus_count;


  /* Input, Array_Proclamation */
  cin >> N;
  cin >> C;
  cin >> K;
  vector<int> T(N);

  for(i=0; i<N; i++)
  {
    cin >> T.at(i);
  }


  /* Initialize */
  bus_count = 0;


  /* Calculation */
  sort( all(T) );

  for(i=0; i<N; i++)
  {
    if( capa <= 0 || times < T.at(i) )
    {
      bus_count++;

      capa     = C -1;
      times    = T.at(i) + K;
    }
    else
    {
      capa--;
    }
  }
  

  /* Output */
  cout << bus_count << endl;


  return 0;

}


/* entity */
//  - none -




Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    int n,k;cin>>n>>k;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }

    vector<ll> sum(n+1,0),sum_best(n+1,0);
    rep(i,n){
        sum[i+1]=sum[i]+a[i];

        sum_best[i+1]=sum_best[i]+max(a[i],0ll);
    }

    ll ans=0;
    rep(i,n-k+1){
        ll l=sum_best[i];
        ll r=sum_best[n]-sum_best[i+k];
        ll c=max(0ll,sum[i+k]-sum[i]);
        chmax(ans,l+r+c);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
bool used[520][520]={};
int main(){
  int h,w;cin>>h>>w;
  string Map[h];
  for(int i=0;i<h;i++)cin>>Map[i];
  int vx[4]={1,0,-1,0};
  int vy[4]={0,1,0,-1};
  ll ans=0;
  int cnt=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(Map[i][j]=='.')continue;
      ll cnt=0;
      ll blcnt=0;
      queue<pair<ll,ll> >que;
      que.push(mp(i,j));
      used[i][j]=true;
      blcnt++;
      while(!que.empty()){
	pair<ll,ll>aa=que.front();que.pop();
	for(int k=0;k<4;k++){
	  int x=aa.F+vx[k];
	  int y=aa.S+vy[k];
	  if(x>=0&&y>=0&&x<h&&y<w&&!used[x][y]){
	    if(Map[aa.F][aa.S]=='#'&&Map[x][y]=='.'){
	      used[x][y]=true;
	      cnt++;
	      que.push(mp(x,y));
	    }else if(Map[aa.F][aa.S]=='.'&&Map[x][y]=='#'){
	      blcnt++;
	      used[x][y]=true;
	      que.push(mp(x,y));
	    }
	  }
	}
      }
     
      ans+=cnt*blcnt;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 50;

bool compare(pair<ll,ll> a, pair<ll,ll> b){
    if(a.first==b.first)return a.second<b.second;
    else return false;;
}

int main(){
    
    map<pair<ll,ll>,int> m;
    set<pair<ll,ll> > s;
    int n;
    int cnt = 0;
    
    vector<pair<ll,ll> > v(maxn);
    
    cin >> n;
    rep(i,n)cin >> v[i].first>>v[i].second;
    
    sort(v.begin(),v.begin()+n);
    sort(v.begin(),v.begin()+n,compare);
    //reverse(v.begin(),v.begin()+n);
    
    //rep(i,n)cout << v[i].first<<space<<v[i].second<<endl;
    
    //rep(i,n)cout << v[i].first<<space<<v[i].second<<endl;
    
    rep(i,n){
        rep(j,n){
            if(i==j)continue;
            ll a = v[j].first-v[i].first;
            ll b = v[j].second-v[i].second;
            s.insert(make_pair(a,b));
            m[make_pair(a,b)]++;
        }
    }
    
    auto ite = s.begin();
    while(ite!=s.end()){
        if(m[*ite]>cnt)cnt = m[*ite];
        ite++;
    }
    
    cout << n-cnt<<endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;

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

    vector<ll> A(N), B(N), C(N);

    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    ll ret = 0;
    for(int i = 0; i < N; i++) {
        ll a = distance(A.begin(),  lower_bound(A.begin(), A.end(), B[i]));
        ll c = distance(upper_bound(C.begin(), C.end(), B[i]), C.end());
        //cout << *lower_bound(A.begin(), A.end(), B[i]) << endl;
        //cout << a << "," << c << endl;
        ret += a*c;

    }

    cout << ret << endl;
    
}

Measured memory_bytes: 2560
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {
	static int time = 0;

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();

		int[][] v = new int[n + 1][n];
		int[] d = new int[n + 1];

		for (int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			d[u] = -1;
			for (int j = 0; j < k; j++)
				v[u][j] = scan.nextInt();
		}

		d[1] = 0;
		list = new int[n + 1];
		list[0] = 1;

		Bsearch(v, d);

		for (int i = 1; i <= n; i++) {
			System.out.println(i + " " + d[i]);
		}

		scan.close();
		System.exit(0);
	}

	static int[] list;
	static int pp = 0, pn = 1;

	private static void Bsearch(int[][] v, int[] d) {
		for (; pp < pn; pp++) {
			int fr = list[pp];
			for (int i = 0; i < v[fr].length; i++) {
				int to = v[fr][i];
				if (d[to] == -1) {
					d[to] = d[fr] + 1;
					list[pn++] = to;
				}
			}
		}
	}

}

Measured memory_bytes: 27820
N, M, Q = map(int, input().split())

L = [[0 for x in range(N+1)] for x in range(N+1)]
for i in range(M):
    x, y = map(int,input().split())
    L[x][y] += 1
for x in range(N+1):
    for y in range(N):
        L[x][y+1] += L[x][y]  

for y in range(N+1):
    for x in range(N):
        L[x+1][y] += L[x][y]  
for _ in range(Q):
    x, y = map(int, input().split())
    print(L[N][y]-L[x-1][y])

Measured memory_bytes: 13428
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int h, w;
    cin >> h >> w;
    int flag = 0;
    char s[h+2][w+2];
    for(int j = 0; j < w+2; j++) {
        s[0][j] = '.';
        s[h+1][j] = '.';
    }
    for(int i = 0; i < h+2; i++) {
        s[i][0] = '.';
        s[i][w+1] = '.';
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            cin >> s[i][j];
        }
    }

    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if(s[i][j] == '#' && s[i-1][j] == '.' && s[i+1][j] == '.' && s[i][j-1] == '.' && s[i][j+1] == '.') {
                flag = 1;
                break;
            }
        }
        if(flag == 1) {
            break;
        }
    }

    if(flag == 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	set<int> dat;
	for (int i = 0; i < 3; ++i) {
		int tmp;
		sci(tmp);
		dat.insert(tmp);
	}
	puts(dat.size() == 2 ? "Yes" : "No");
	return 0;
}

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

int f(int n){
	stringstream ss;
	ss << n;
	for(int j = 0 ; j < ss.str().size(); j++)
		if( ss.str()[ss.str().size()-j-1] != ss.str()[j] )
			return false;
	return true;
}
int main(){
	int n;
	cin >> n;
	for(int i = 0 ; i <= 10001; i++){
		if(n-i>=0){
			if(f(n-i)){cout << n-i << endl; return 0;}
		}
		if(f(n+i)){cout << n+i << endl; return 0;}
		
	}
}

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



int main() {
    int k, x;
    cin >> k >> x;
    
    if(500 * k >= x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = 0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            for(ll k=j+1;k<n;k++){
                set<ll> s;
                s.insert(a[i]);
                s.insert(a[j]);
                s.insert(a[k]);
                if(sz(s)==3){
                    auto it=s.begin();
                    ll x = (*it);
                    it++;
                    ll y = (*it);
                    it++;
                    ll z = (*it);
                    if(x+y>z){
                        ans++;
                    }
                }
            }
        }
    }
    cout <<ans<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3652
#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>;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m){
        int b;
        cin >> b; b--;
        a[i] = b;
    }
    int b = -1;
    if(m > 0)b = a[0];
    int j = 1;
    vector<mint> dp(3);
    dp[2] = 1;
    rep(i, n){
        vector<mint> p(3);
        swap(dp, p);
        dp[0] = p[1];
        dp[1] = p[2];
        if(b == i){
            dp[2] = 0;
            b = a[j];
            if(j < m - 1)j++;
        }else{
            dp[2] = dp[0] + dp[1];
        }
    }
    cout << dp[2].x << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;
int main(){
    int x;
    cin>>x;
    int y,z,l,m,s,p;
    y=x/500;
    p=x%500;
    z=p/5;
    l=y*1000;
    m=z*5;
    s=l+m;
    cout<<s;

   return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
A = [input() for i in range(h)]

flag = 0
for a in A:
    X = a.split('.')
    cnt = 0
    for x in X:
        if '#' in x:
            cnt += 1
    if cnt > 1:
        flag = 1
        
if flag:
    ans = 'Impossible'
else:
    ans = 'Possible'
    posi = 0
    for i in range(h):
        B = []
        for j in range(w):
            if A[i][j] == '#':
                B.append(j)
        if B[0] > posi or B[0] < posi:
            ans = 'Impossible'
            break
        else:
            posi = B[-1]

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<' '<<y<<' '<<z<<endl;
}

Measured memory_bytes: 3600
N = int(input())
A = list(map(int, input().split()))
A_sum = sum(A)
MOD = 10**9 + 7
ans = 0
A_cum = 0
for a in A:
    A_cum += a
    ans += a  * (A_sum - A_cum) % MOD
print(ans % MOD)

Measured memory_bytes: 94264
#include<bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define pb                push_back
#define pf                push_front
#define ppb               pop_back
#define ppf               pop_front
#define sz                size()
#define pi                acos(-1.0)
#define mod               1000000007
#define F                 first
#define S                 second
#define C                 continue
#define G                 goto done
#define maxe              max_element
#define mine              min_element
#define min3(a,b,c)       min(a,min(b,c))
#define max3(a,b,c)       max(a,max(b,c))
#define min4(a,b,c,d)     min(a,min(b,min(c,d)))
#define max4(a,b,c,d)     max(a,max(b,max(c,d)))
#define mem(a,b)          memset(a,b,sizeof(a))
#define all(a)            (a).begin(),(a).end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          ((a)*((b)/gcd(a,b)))
#define case(a)           cout<<"Case "<<(a)<<": "
#define point(a)          fixed<<setprecision(a)
#define get(a)            for(auto &x:a) cin>>x
#define print(a)          for(auto x:a) cout<<x<<" "; cout<<endl
#define see(x)            cout<<#x<<" = "<<x<<endl
#define uniq(a)           sort(all(a)); (a).erase(unique((a).begin(),(a).end()),(a).end())
#define big(a)            transform((a).begin(),(a).end(),(a).begin(),::toupper)
#define small(a)          transform((a).begin(),(a).end(),(a).begin(),::tolower)
#define ischar(a)         (('a'<=a&&a<='z')('A'<=a&&a<='Z'))
#define isvowel(a)        (a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
#define fast              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define tc                int test; cin>>test; while(test--)
using namespace std;

#define ok1(ch) (ch=='R' || ch=='U' || ch=='D')
#define ok2(ch) (ch=='L' || ch=='U' || ch=='D')

int main()
{
    string s; cin>>s;
    ll c1=0,c2=0;
    for(ll i=1;i<s.sz;i+=2) if(ok2(s[i])==false) c1=1;
    for(ll i=0;i<s.sz;i+=2) if(ok1(s[i])==false) c2=1;
    if(c1==0 && c2==0) cout<<"Yes";
    else cout<<"No";
}




















Measured memory_bytes: 3604
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=gets.chomp
T=gets.chomp
a=("a".."z").to_a
flag=false
a.each do|a_|
    if S+a_==T
        flag=true
        break
    end
end
puts yn_judge(flag)

Measured memory_bytes: 14244
import sys
input = sys.stdin.buffer.readline

from collections import deque, defaultdict

#以下０オリジンで考える

n, u, v = map(int, input().split())
u, v = u-1, v-1

G = defaultdict(lambda:deque([])) #連結リスト

#以下０オリジンで考える
for _ in range(n-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    
#start位置から繋がる全ノードへの距離を求める関数、幅優先探索
#dst_dict[player][node]がplayerとnodeの距離
def bfs(start, player):
    que = deque([(start, -1, 0)])
    while que:
        node, par, dst = que.popleft() #par:親, dst:距離
        if len(G[node]) == 1:
            dst_dict[player][node] = dst
            
        for nxt in G[node]:
            if nxt == par:
                continue
            que.append((nxt, node, dst+1))
            
dst_dict = [{}, {}]

bfs(u, 0)
bfs(v, 1)

max_time = 0
for k in dst_dict[0]:
    if dst_dict[0][k] < dst_dict[1][k]:
        max_time = max(max_time, dst_dict[1][k]-1)
    
print(max_time)


Measured memory_bytes: 127448
import math
a, b, c, d = map(int,input().split())
#AB=[]
#N = int(input())
#C = input()
#D, T, S=map(int,input().split())
#C = []
#for i in range(N):
#    C.append(list(map(int,input().split())))
print(max(max(max(a*c, a*d),b*c),b*d))

Measured memory_bytes: 9160
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n, i = LI()
    print(n-i+1)
    return

#B
def B():
    x1, y1, x2, y2 = LI()
    a = x2 - x1
    b = y2 - y1
    print(x2 - b, y2 + a, x1 - b, y1 + a)
    return

#C
def C():
    n, k = LI()
    if k % 2:
        print((n // k)** 3)
    else:
        print(int((n//k)**3 + ((n-k/2)//k+1)**3))
        
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
//
// tested with : g++ (GCC) 8.3.0
//

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

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

    int slength = s.length();
    int firsta = 0, lastz = 0;
    for (int i = 0; i < slength; i++) {
        if (s[i] == 'A') {
            firsta = i;
            break;//先頭のAを見つけたらすぐ抜ける。
        }
    }
    for (int i = 1; i <= slength; i++) {
        if (s[slength - i] == 'Z') {
            lastz = slength - i;
            break;//末尾のZを見つけたらすぐ抜ける。
        }
    }

    int result = (lastz - firsta + 1);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h> 
 
 
 int main(){ 
 int a, b, c; 
     int tmp; 
     scanf("%d %d %d", &a, &b, &c); 
     if(a>b){ 
         tmp=a; 
         a=b; 
         b=tmp; 
     } 
     if(b>c){ 
         tmp=b; 
         b=c; 
         c=tmp; 
     } 
     if(a>b){ 
         tmp=a; 
         a=b; 
         b=tmp; 
     } 
     printf("%d %d %d\n", a, b, c); 
     return 0; 
 } 



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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

	string s;

	cin >> s;

	if (s[0] != 'A')
	{
		cout << "WA";
		return 0;
	}
	if (s[1] <= 'Z')
	{
		cout << "WA";
		return 0;
	}
	
	int len = s.size();
	bool flag = false;
	for (int i = 2; i < len - 1; i++)
	{
		if (s[i] == 'C')
		{
			if (flag)
			{
				cout << "WA";
				return 0;
			}
			flag = true;
		}
		else if (s[i] <= 'Z')
		{
			cout << "WA";
			return 0;
		}
	}
	if (s.back() <= 'Z')
		cout << "WA";
	else 
	{
		if (!flag) cout << "WA";
		else cout << "AC";
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace beginner_contest047_3
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().ToCharArray();
            Int32 ans = 0;
            if (!inputs.All(x => x == inputs[0]))
            {
                for (Int32 i = 0; i < inputs.Length - 1; ++i)
                {
                    if (inputs[i] != inputs[i + 1])
                        ++ans;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 3416
#!/usr/bin/env python3
from collections import deque

H, W = list(map(int, input().split()))
ch, cw = list(map(int, input().split()))
dh, dw = list(map(int, input().split()))

ch -= 1
cw -= 1
dh -= 1
dw -= 1

S = [list((str(input()))) for i in range(H)]


def check(h, w):
    if h < 0 or h >= H:
        return False
    if w < 0 or w >= W:
        return False
    if S[h][w] == "#":
        return False
    return True


def main():

    map_ = [[10**10]*W for i in range(H)]
    # map_[ch][cw] = 0

    dq = deque([[ch, cw, 0]])

    while(len(dq) > 0):
        # print(dq)
        h, w, value = dq.popleft()
        map_value = map_[h][w]
        if map_value <= value:
            continue
        map_[h][w] = value

        for i in [-2, -1, 0, 1, 2]:
            for j in [-2, -1, 0, 1, 2]:
                if i == 0 and j == 0:
                    continue
                if abs(i)+abs(j) == 1:
                    if check(h+i, w+j):
                        # print(h+i, w+)
                        if map_[h+i][w+j] > value:
                            dq.appendleft([h+i, w+j, value])
                else:
                    if check(h+i, w+j):
                        if map_[h+i][w+j] > value+1:
                            dq.append([h+i, w+j, value+1])
    # for i in map_:
        # print(i)
    ans = map_[dh][dw]
    if ans == 10**10:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 235812
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String tmp = scanner.nextLine();
		char line[] = tmp.toLowerCase().toCharArray();

		scanner.close();
		int startIndex =0;
		int lastIndex =0;
		//先頭が　\ の番号をチェック
		for(int i = 0; i < line.length; i++) {
			if("\\".equals(String.valueOf(line[i]))) {
				startIndex = i;
				break;
			}
		}
		//最後が　/ の番号をチェック
		for(int i = line.length -1; i >= 0; i--) {
			if("/".equals(String.valueOf(line[i]))) {
				lastIndex = i;
				break;
			}
		}

		//現在は面積計算対象かどうか
		boolean isLake = false;
		int depth = 0;
		//トータル水量
		double floods = 0;
		double flood = 0;
		//水たまり数
		int lakeNumber = 0;
		//各水たまりの面積
		double [] l = new double[3000];
		for (int j = startIndex; j <= lastIndex; j++) {
			String moji = String.valueOf(line[j]);
			//前から断面が変更になった場合 計算開始
			if("\\".equals(moji) && !isLake) {
				//同じ高さがあとから出てくる場合
				if(isSameHight(j,line)) {
 				    isLake = true;
				    //水量0.5+
				    floods += 0.5;
				    flood = 0.5;
				    lakeNumber++;
				    depth++;
				}
			} else if("\\".equals(moji) && isLake) {
				//水量0.5+
				floods += depth + 0.5;
				flood += depth + 0.5;
				depth++;
			} else if ("/".equals(moji) && (depth == 1)) {
			//下り断面と同等の高さになる場合
				isLake = false;
			    //次は0固定
				depth = 0;
				//水量0.5+
				floods += 0.5;
				flood += 0.5;
				l[lakeNumber - 1] = flood;
			} else if ("/".equals(moji) && (depth > 1)) {
				//先に１上昇
				depth--;
				//水量0.5+
				floods += depth + 0.5;
				flood += depth + 0.5;
			} else if ("_".equals(moji) && (depth > 0)) {
				//水量水深分+
				floods += depth;
				flood += depth;
			}

		}
		System.out.println((int)floods);
		System.out.print(lakeNumber);
		for (int x=0; x < lakeNumber; x++){
			System.out.print(" " + (int) l[x]);
		}
		System.out.println();
	}

	static boolean isSameHight(int fromvalue,char line[]) {
		int hight = 0;
		for (int i = fromvalue; i < line.length; i++) {
			String moji2 = String.valueOf(line[i]);
			if("\\".equals(moji2)) {
				hight ++;
			} else if ("/".equals(moji2)) {
				hight --;
				if(hight == 0) {
					return true;
				}
   		    }
		}
		return false;
	}
}




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

typedef struct {
	long double key;
	int id;
} data;

void merge_sort(data x[], int n)
{
	static data y[51] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, j, k, N, x[51], y[51];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(x[i]), &(y[i]));
	if (N == 2) {
		printf("%f\n", sqrt((double)(x[1] - x[2]) * (x[1] - x[2]) + (double)(y[1] - y[2]) * (y[1] - y[2])) / 2.0);
		fflush(stdout);
		return 0;
	}
	
	for (i = 1, x[0] = 0, y[0] = 0; i <= N; i++) {
		x[0] += x[i];
		y[0] += y[i];
	}
	long double cx = (long double)x[0] / N, cy = (long double)y[0] / N;
	data d[51];
	for (i = 1; i <= N; i++) {
		d[i-1].key = sqrtl((cx - x[i]) * (cx - x[i]) + (cy - y[i]) * (cy - y[i]));
		d[i-1].id = i;
	}
	merge_sort(d, N);
	
	long double l, r, m, tx, ty;
	while (1) {
		if (d[N-1].key - d[N-2].key > 1e-7) {
			if (fabsl(x[d[N-1].id] - cx) > 1e-7) cx += (x[d[N-1].id] - cx) * (d[N-1].key - d[N-2].key) / fabsl(x[d[N-1].id] - cx) / 2.0;
			if (fabsl(y[d[N-1].id] - cy) > 1e-7) cy += (y[d[N-1].id] - cy) * (d[N-1].key - d[N-2].key) / fabsl(y[d[N-1].id] - cy) / 2.0;
		} else if (sqrtl((cx - (x[d[N-1].id] + x[d[N-2].id]) / 2.0) * (cx - (x[d[N-1].id] + x[d[N-2].id]) / 2.0) + (cy - (y[d[N-1].id] + y[d[N-2].id]) / 2.0) * (cy - (y[d[N-1].id] + y[d[N-2].id]) / 2.0)) > 1e-7) {
			l = 0.0;
			r = 1.0;
			while (r - l > 1e-10) {
				m = (l + r) / 2.0;
				tx = cx * m + (x[d[N-1].id] + x[d[N-2].id]) / 2.0 * (1.0 - m);
				ty = cy * m + (y[d[N-1].id] + y[d[N-2].id]) / 2.0 * (1.0 - m);
				for (i = 1; i <= N; i++) if (sqrtl((tx - x[i]) * (tx - x[i]) + (ty - y[i]) * (ty - y[i])) > d[N-1].key) break;
				if (i > N) r = m;
				else l = m;
			}
			tx = cx * l + (x[d[N-1].id] + x[d[N-2].id]) / 2.0 * (1.0 - l);
			ty = cy * l + (y[d[N-1].id] + y[d[N-2].id]) / 2.0 * (1.0 - l);
			if (sqrtl((tx - cx) * (tx - cx) + (ty - cy) * (ty - cy)) < 1e-7) break;
			cx = tx;
			cy = ty;
		} else break;
		for (i = 1; i <= N; i++) {
			d[i-1].key = sqrtl((cx - x[i]) * (cx - x[i]) + (cy - y[i]) * (cy - y[i]));
			d[i-1].id = i;
		}
		merge_sort(d, N);
	}
	
	printf("%.10Lf\n", d[N-1].key);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2148
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  string s, t;
  cin >> s >> t;
  int n = s.length();
  map<char,char> mc, tc;
  for(int i = 0; i < 26; i++){
    mc[i + 'a'] = 'A';
    tc[i + 'a'] = 'A';
  }

  for(int i = 0; i < n; i++) {
    if(mc[s[i]] == 'A') {
      mc[s[i]] = t[i];
      // mc[t[i]] = s[i];
      // s[i] = mc[s[i]];
      // t[i] = mc[t[i]];
    } else {
      // s[i] = mc[s[i]];
      // t[i] = mc[t[i]];
      if(mc[s[i]] != t[i]) {
        cout << "No\n";
        return 0;
      }
    }
    if(tc[t[i]] == 'A') {
      tc[t[i]] = s[i];
    } else {
      if(tc[t[i]] != s[i]) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 776
def solve():
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            h_cand = None
            for x, y, h in xyh:
                if h == 0:
                    continue
                h_calced = h + abs(x - cx) + abs(y - cy)
                if (h_cand is None) or (h_cand == h_calced):
                    h_cand = h_calced
                else:
                    h_cand = None
                    break

            if h_cand is None:
                continue

            for x, y, h in xyh:
                if h != 0:
                    continue
                if h_cand - abs(x - cx) - abs(y - cy) > 0:
                    h_cand = None
                    break

            if h_cand is None:
                continue

            return cx, cy, h_cand
    return None


n = int(input())
xyh = tuple(tuple(map(int, input().split())) for _ in range(n))

print(*solve())


Measured memory_bytes: 3064
package main

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

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	h := nextInts(n)
	sort.Sort(sort.IntSlice(h))

	ans := 1000000000
	for i := 0; i+k-1 < n; i++ {
		ans = min(ans, h[i+k-1]-h[i])
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
ll INV(ll a){
    return RS(a,MOD-2,MOD);
}
ll c(ll n,ll a){
    ll bunbo=1;
    ll bunshi=1;
    
    REP1(i,a){
        bunbo*=i;
        bunbo%=MOD;
        bunshi*=n+1-i;
        bunshi%=MOD;
    }
    return (bunshi*INV(bunbo)%MOD);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> vec(3);
    REP(i,3){
        cin>>vec[i];
    }
    sort(all(vec));

    if(vec[0]==vec[1]&&vec[1]!=vec[2]){
        cout<<"Yes"<<endl;
        return 0;
    }
    
    if(vec[2]==vec[1]&&vec[1]!=vec[0]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                          
using namespace std;
long long a,b,c,k,ans,x,y;
int main(){
    cin>>a>>b>>c>>k;
    x=max(a,max(b,c));
    y=x;
    for(int i=1;i<=k;i++)
        x*=2;
    ans+=x;
    cout<<ans+a+b+c-y;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
    a: String,
    );
    println!("{}", a.chars().map(|c| c.to_digit(10).unwrap()).sum::<u32>());
}

Measured memory_bytes: 4352
import java.util.Scanner;

class Main {
    private static int[] calcPrimes(int n) {
        boolean[] table = new boolean[n + 1];
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (!table[i]) {
                for (int j = i + i; j <= n; j += i) {
                    table[j] = true;
                }
            }
        }
        int counter = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                counter++;
            }
        }
        int[] result = new int[counter];
        int index = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                result[index++] = i;
            }
        }
        return result;
    }

    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int[] primes = calcPrimes(10000);
        while (true) {
            int n = scanner.nextInt();
            if (n == 0) {
                break;
            }
            int maximum = 0;
            for (int i = 0; i + 1 < primes.length ; i++) {
                if (primes[i + 1] > n) {
                    break;
                } else if (primes[i + 1] - primes[i] == 2) {
                    maximum = primes[i + 1];
                }
            }
            System.out.println(String.format("%d %d", maximum - 2, maximum));
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

#define MAX_N 1000
#define MAX_M 1000


int main(){
	int x;
    cin >> x;
    int ans = 0;
    int tmp = 0;
    if(x < 5) tmp = 0;
    else if (x >= 5 && x < 500){
        tmp = x / 5;
        tmp *= 5;
    }else{
        int tmp2 = x / 500;
        tmp2 *= 1000;
        int tmp3 = x % 500;
        int tmp4 = tmp3 / 5;
        tmp4 *= 5;
        tmp = tmp2 + tmp4;
    }
    cout << tmp << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int num=1,cnt=1;
	while(true){
		cin >> num;
		if(num==0){
			break;
		}
		printf("Case %d: %d\n",cnt,num);
		cnt++;
	}
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 105
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,m,in[M],a[M],b[M],c[M];
int dp[M][M][M];
int go(int x,int l,int r)
{
	int &res = dp[x][l][r];
	if(res!=-1) return res;
	if(l==r)
	{
		if(a[x]==in[l]) res=1;
		else res=0;
		return res;
	}

	res = 0;
	int rx,ry;
	//[l,i] [i+1,r]
	REP(i,l,r-1)
	{
		rx = go(b[x], l, i);
		ry = go(c[x], i+1, r);
		if(rx && ry)
		{
			res=1;
			break;
		}
	}
	return res;
}
int main()
{
	RI(n);
	REP(i,1,n) RI(in[i]);
	RI(m);
	REP(i,1,m) RI(a[i], b[i], c[i]);
	MSET(dp, -1);
	//
	//
	
	puts(go(1,1,n) ? "Yes":"No");
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define present(i, c) ((c).find(i) != (c).end())

#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define fora(i, a, b) for(int i = (a); i < (b); i++)
#define ford(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
	
#define INF 0x3F3F3F3F

//=========================

int N, _W;
int W[101], V[101];
ll dp[100001];

void run_test() {
	cin >> N >> _W;
    for1(i, N) cin >> W[i] >> V[i];

    ini(dp, 0x3F);
    dp[0] = 0;
    for1(i, N) 
        for(int v = 1e5; v >= V[i]; v--) 
            dp[v] = min(dp[v], dp[v - V[i]] + W[i]);
    
    int ans = 0;
    for0(v, 100001) if(dp[v] <= _W) ans = v;
    cout << ans << endl;
}

//=========================

ifstream infile;
clock_t start__;
void open_func();
void close_func();

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	open_func();
	//int t; cin >> t; while(t--) run_test();
	run_test();
	close_func();
	return 0;	
}

void open_func() {
	//infile = ifstream("input.in"); if(infile.good()) cin.rdbuf(infile.rdbuf());
	start__ = clock();
	cerr << "---" << endl;
}

void close_func() {
	clock_t elapsed = clock()-start__;
	cerr << "---" << endl << "(time " << fixed << setprecision(2) << elapsed * (1.0/CLOCKS_PER_SEC) << "s)" << endl;	
	//if(infile.good()) infile.close();
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
shops = sorted([tuple(map(int,input().split())) for _ in range(N)])

remain = M
price = 0
for a,b in shops:
  if b > remain:
    price += remain*a
    remain = 0
  else:
    price += a*b
    remain -= b
  if remain == 0:
  	break
print(price)

Measured memory_bytes: 17756
N,m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
wa = 0
for i in range(N):
  wa += a[i]
count = 0
x = wa /(m*4)
for i in range(N):
  if a[i] >= x:
    count += 1
if count >= m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	bool ans = false;
	ll k, a, b; cin >> k >> a >> b;
	rep(i, a, b){
		if(i%k == 0){
			ans = true;
		}
	}
	
	print(ans? "OK" : "NG")
	return 0;
}

Measured memory_bytes: 3652
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;
import java.util.regex.Pattern;





public class Main {

	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long)(1e9+7);
	public static void main(String[] args) {
		 FastReader sc = new FastReader();
		int n = sc.nextInt();
		Integer[] p = new Integer[n];
		for(int i=0;i<n;++i) p[i] = new Integer(sc.nextInt());
		Arrays.sort(p);
		int l = p[n/2-1];
		int r =  p[n/2];
		
		int ans = r-l;
		
		out.println(ans);
		out.close();
		 
	}
	

}


Measured memory_bytes: 35676