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

signed main()
{
    int N; cin>>N;
    int ans=0;
    map<string,int> cnt;
    for(int i=0;i<N;i++){
        string s; cin>>s;
        sort(s.begin(),s.end());
        ans+=cnt[s];
        cnt[s]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

const ll MOD = 1000000007;

ll helper(vll& v) {
    ll n = (ll)(v.size());
    ll ret = 0;
    rep(i, n) {
        ll term1 = (i * v[i]) % MOD;
        ll term2 = ((n - i - 1) * v[i]) % MOD;
        ret = (ret + term1) % MOD;
        ret = (ret + MOD - term2) % MOD;
    }

    return ret;
}

void solve() {
    inl(n, m);
    vll x(n);
    rep(i, n) cin >> x[i];
    vll y(m);
    rep(i, m) cin >> y[i];

    out((helper(x) * helper(y)) % MOD); 
}


Measured memory_bytes: 4768
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=readln.split.to!(int[]);

  import std.typecons;
  alias T=Tuple!(int, "val", int, "id");
  auto data=new T[](n);
  foreach(int i; 0..n) data[i]=T(a[i], i);
  sort!"a.val<b.val"(data);

  auto med=new int[](n);
  int ml=data[n/2-1].val, mr=data[n/2].val;
  foreach(i; 0..n){
    if(i<n/2) med[data[i].id]=mr;
    else med[data[i].id]=ml;
  }

  writefln("%(%s\n%)", med);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 13164
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

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

    int A[3];
    for (int i = 0; i < 3; i++) 
        cin >> A[i];
    sort(A, A+3);

    int sum = 0;
    for (int i = 0; i < 2; i++) {
        sum += A[i+1] - A[i];
    }

    cout << sum << endl;
     
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

using namespace std;

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

    if(a/k == b/k && a%k != 0){
        cout<<"NG"<<endl;
    }else{
        cout<<"OK"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
	int i, n, debt=100000;
	float rate=1.05;

	scanf("%d", &n);

	for (i=1; i<=n; i++) {
		debt = debt * rate;
		if (debt % 1000 != 0) debt = debt - debt % 1000 + 1000;
	}

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

	return 0;
}

Measured memory_bytes: 592
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m,s = [int(i) for i in readline().split()]
g = [[] for _ in range(n)]
for i in range(m):
    u,v,a,b = [int(i) for i in readline().split()]
    u -= 1
    v -= 1
    g[u].append((v,a,b))
    g[v].append((u,a,b))


cd = [int(i) for i in read().split()]
c = cd[::2]
d = cd[1::2]


from heapq import *
INF = 1<<61
M = 2500
if s >= M: s = M-1
dist = [[INF]*M for _ in range(n)] #startからの最短距離
dist[0][s] = 0
q = [(0,s,0)] #(そこまでの距離、銀の枚数、点)

while q:
    dv,num,v = heappop(q)
    if dist[v][num] < dv: continue
    if num+c[v] < M and dv+d[v] < dist[v][num+c[v]]:
        dist[v][num+c[v]] = dv + d[v]
        heappush(q, (dv + d[v], num+c[v] ,v))
    for to,a,b in g[v]:
        if num >= a and dv + b < dist[to][num-a]:
            dist[to][num-a] = dv + b
            heappush(q, (dv + b, num-a ,to))
    #print(q)

for i in range(1,n):
    print(min(dist[i]))

#print(c)
#print(d)
#print(dist)




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

int main() {
   int n;
   cin >> n;
   vector<int> A(n);

   for(int i=0; i<n; i++) {
      cin >> A[i];
      if(A[i] % 2 == 0) {
         if(A[i] % 3 != 0 && A[i] % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
         }
      }
   }
   cout << "APPROVED" << endl;
}

Measured memory_bytes: 3628
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Measured memory_bytes: 51288
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var cnt = 0;
            for (int i = 1; i <=N; i++)
            {
                if (i.ToString().Length % 2 == 1) cnt++;
            }
            return cnt;
        }

        struct Point
        {
            public int x;
            public int y;
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> SplitString { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)

#define MAX_LEN 200000+1
char S[MAX_LEN];
int main(void) {
	scanf("%s", &S[0]);
	int len = strlen(S);
	char *s = NULL;
	for (int i = 0; i < len; ++i) {
		if (S[i] == 'A') {
			s = &S[i];
			break;
		}
	}
	for (int i = 0; i < len; ++i) {
		if (S[len - 1 - i] == 'Z') {
			S[len - 1 - i + 1] = '\0';
			break;
		}
	}
	printf("%d", strlen(s));
	return 0;
}


Measured memory_bytes: 384
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define maxn 1000009
#define LL long long
#define FK fa[cnt]=cnt,fa[l]=cnt,fa[find(v.z)]=cnt
#define ST dad[cnt]=dad[l],dad[v.z]=cnt,pt[cnt]=tmp,st.insert(tmp)
#define EP st.empty()
#define BEGIN {
#define END }
using namespace std;
struct node{
  LL x;int y,z;
  inline bool operator < (const node &h) const{
    if(x*h.y!=h.x*y) return x*h.y<h.x*y;
    else return z<h.z;
  }
}pt[maxn];
int head[maxn],edge=0,fa[maxn],dad[maxn],sz[maxn],w[maxn];
set<node>st;
int n;LL ans=0,sum[maxn];
int find(int x){if(fa[x]!=x) fa[x]=find(fa[x]);return fa[x];}
inline void work() BEGIN
  int cnt=n;LL Ans=0;
  while(!EP) BEGIN
    node v=*st.begin();st.erase(v);
    int l=find(dad[v.z]); if(!l) continue;
    Ans+=(v.y-v.x)*pt[l].x;
    st.erase(pt[l]);
    node tmp=v;
    tmp.x+=pt[l].x,tmp.y+=pt[l].y,tmp.z=++cnt;
    FK;ST;
  END printf("%lld",Ans);
END
int main(){
  scanf("%d",&n);
  for(int i=2;i<=n;i++)
    scanf("%d",&dad[i]);
  for(int i=1;i<=n;i++) scanf("%d",w+i);
  for(int i=1,x;i<=n;i++)
    pt[i]=(node){w[i],1,i},st.insert(pt[i]),fa[i]=i;
  work();
  return 0;
}


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

int N , a , b ;
int table[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1} ;

void func(){
	vector<int> V1 ;
	vector<int> V2 ;
	
	for( int i=0 ; i<15 ; i++ ){
		if( table[i] == a && V1.size() ){
			for( int j=i ; ; j++ ){
				V2.push_back( table[j%15] ) ;
				if( table[j%15] == b ) break ;
			}
		}
		else if( table[i] == a ){
			for( int j=i ; ; j++ ){
				V1.push_back( table[j%15] ) ;
				if( table[j%15] == b ) break ;
			}
		}
	}
	
	if( V2.empty() || V1.size() <= V2.size() ){
		for( int i=0 ; i<V1.size() ; i++ ) cout << (i?" ":"") << V1[i] ;
		cout << endl ;
	}else {
		for( int i=0 ; i<V2.size() ; i++ ) cout << (i?" ":"") << V2[i] ;
		cout << endl ;
	}
}

int main(){
	
	cin >> N ;
	while( N-- ){
		cin >> a >> b ;
		func() ;
	}
	
return 0 ;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	
	ll n;cin>>n;
	ll s=0,di=0;
	rep(i,0,n){
		ll d,c;cin>>d>>c;
		s+=d*c;
		di+=c;
	}
	ll f= (s-9)%9==0 ? (s-9)/9 : (s-9)/9+1; 
	if(s<9)f=0;
	cout<<(di-1)+f;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long m,n,a,d;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>m>>n;
    for (int i=1;i<=n;i++){
        cin>>a;
        d+=a;
    }
    if (d<=m)cout<<m-d;
        else cout<<-1;
}


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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }


int N;
string S;

string subSolve(const string &s) {
    if (s[0] == 'a') {
        string res = "";
        int prev_a = -1;
        int a_num = 0, b_num = 0;
        bool search_a = true;
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == 'a') {
                if (search_a) {
                    res += "a";
                    prev_a = a_num;
                    search_a = false;
                }
                ++a_num;
            }
            else {
                if (!search_a) {
                    if (b_num == prev_a) {
                        res += "b";
                        search_a = true;
                    }
                }
                ++b_num;
            }
        }
        return res;
    }
    else {
        string res = "";
        for (int i = 0; i*2 < s.size(); ++i) {
            string tmp = "";
            int a_num = 0, b_num = 0;
            for (int j = 0; j < s.size(); ++j) {
                if (s[j] == 'a') {
                    if (a_num >= i) tmp += s[j];
                    ++a_num;
                }
                else {
                    if (b_num >= i) tmp += s[j];
                    ++b_num;
                }
            }
            res = max(res, tmp);
        }
        return res;
    }
}

int main() {
    cin >> N >> S;
    int iter = 0;
    vector<string> vec;
    string tmp = "";
    bool exist = false;
    for (int i = (int)S.size()-1; i >= 0; --i) {
        tmp += S[i];
        if (S[i] == 'a') ++iter;
        else --iter;
        if (iter == 0) {
            reverse(tmp.begin(), tmp.end());
            if (tmp[0] == 'a' && exist) { tmp = ""; continue; }
            if (tmp[0] == 'b') exist = true;
            string ma = subSolve(tmp);
            vec.push_back(ma);
            tmp = "";
        }
    }

    //COUT(vec);
    
    vector<string> dp; dp.assign(N+1, "");
    for (int i = 0; i < vec.size(); ++i) {
        dp[i+1] = max(dp[i+1], dp[i]);
        dp[i+1] = max(dp[i+1], vec[i] +dp[i]);
    }
    cout << dp[vec.size()] << endl;
}


Measured memory_bytes: 10624
module ABC110

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_A
  private :: calculate_maximum_allowance

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! variables for this <subroutine>
    integer(INT8) :: A, B, C

    ! STEP.01
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*) A, B, C

    ! STEP.02
    ! calculate & output the answer of the task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') calculate_maximum_allowance (A, B, C)

    ! STEP.END
    return

  end subroutine task_A

  pure function calculate_maximum_allowance (A, B, C) result(allowance)

    ! arguments for this <function>
    integer(INT8), intent(in) :: A, B, C

    ! return value of this <function>
    integer(INT8) :: allowance

    allowance =     10_INT8 * A + B + C
    allowance = max(10_INT8 * B + C + A, allowance)
    allowance = max(10_INT8 * C + A + B, allowance)

    return

  end function calculate_maximum_allowance

end module ABC110


program main

  ! <module>s to import
  use, non_intrinsic :: ABC110

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
c, d = C, D
while d != 0:
  c, d = d, c % d
L = (C * D) // c
AX, AY, AZ = (A - 1) // C, (A - 1) // D, (A - 1) // L
BX, BY, BZ = B // C, B // D, B // L

ACS = A - 1 - AX - AY + AZ
BCS = B - BX - BY + BZ

print(BCS - ACS)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
string s,t;
int cnt;
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>s>>t;
    for(int i=0;i<3;i++) if(s[i]==t[i]) ++cnt;
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
struct ran {
	int x, le, ri;
	bool operator<(const ran &r)const {
		if (r.x != x)return r.x < x;
		if (r.le != le)return r.le < le;
		return r.ri < ri;
	}
};
int n, p[1 << 18];

const int intmax = 1000000;
struct SegT {
private:
	int n; vector<int> node;
public:
	SegT(int sz) {
		n = 1;
		while (n < sz)n <<= 1;
		//nodeの初期化
		node.resize(2 * n - 1, intmax);
	}
	int f(int a, int b) {
		return min(a, b);
	}
	void init(vector<int> v) {
		rep(i, v.size()) {
			node[i + n - 1] = v[i];
		}
		per(i, n - 1) {
			node[i] = f(node[2 * i + 1], node[2 * i + 2]);
		}
	}
	void update(int x, int val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) >> 1;
			node[x] = f(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	int query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		if (r <= a || b <= l)return intmax;
		if (a <= l && r <= b)return node[k];
		int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return f(vl, vr);
	}
};
priority_queue<ran> q;

int inv[1 << 18];

vector<int> ans;
int main() {
	cin >> n; 
	SegT even(n), odd(n);
	rep(i, n) {
		cin >> p[i]; inv[p[i]] = i;
		if (i % 2 == 0) {
			even.update(i, p[i]);
		}
		else {
			odd.update(i, p[i]);
		}
	}
	int c = even.query(0, n);
	q.push({ c,0,n });
	rep(i, n / 2) {
		ran r = q.top(); q.pop();
		ans.push_back(r.x);
		int le = r.le, ri = r.ri;
		int id = inv[r.x];
		//cout << r.x << " " << le << " " << ri << endl;
		int z = id % 2;
		int y = 0;
		if (z == 0) {
			y = odd.query(id + 1, ri);
		}
		else {
			y = even.query(id + 1, ri);
		}
		ans.push_back(y);
		int rri = inv[y];
		int nex;
		if (id - le > 1) {
			if (z == 0) {
				nex = even.query(le, id);
			}
			else {
				nex = odd.query(le, id);
			}
			q.push({ nex,le,id });
		}
		if (rri - id > 1) {
			if (z == 0) {
				nex = odd.query(id + 1, rri);
			}
			else {
				nex = even.query(id + 1, rri);
			}
			q.push({ nex,id + 1,rri });
		}
		if (ri - rri > 1) {
			if (z == 0) {
				nex = even.query(rri + 1, ri);
			}
			else {
				nex = odd.query(rri + 1, ri);
			}
			q.push({ nex,rri + 1,ri });
		}
	}
	rep(i, n) {
		if (i > 0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long W, std::vector<std::string> s){
    REP(i, H) {
        REP(j, W) {
            if(s[i][j] == '#') {
                bool flag = false;

                REP(m, 4) {
                    int mx = j+DX[m];
                    int my = i+DY[m];

                    if(RANGE(mx, my, W, H) && s[my][mx] == '#') {
                        flag = true;
                    }
                }

                if(!flag) {
                    cout << NO << endl;
                    return;
                }
            }
        }
    }

    cout << YES << endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> s(H);
    for(int i = 0 ; i < H ; i++){
        std::cin >> s[i];
    }
    solve(H, W, std::move(s));
    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#define EVAL 1
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 1048576
#define PI 3.1415926535
//#define DEBUG 1
uint32_t xor128(void) {
	static uint32_t x = 123456789;
	static uint32_t y = 362436069;
	static uint32_t z = 521288629;
	static uint32_t w = 88675123;
	uint32_t t;

	t = x ^ (x << 11);
	x = y; y = z; z = w;
	return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}
long long grid[110][110] = {};
long long now_grid[110][110] = {};
long long now_data[110][110] = {};
long long perf_grid[110][110] = {};
long long perf_data[110][110] = {};
long long perf_ans = 0;
vector<pair<int, int>> yama;
long long now_ans = 0;
int main() {
	int n, a;
	cin >> n >> a;
	n %= 500;
	if (n <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

	public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int h=a/3600;
        int m=a%3600/60;
        int s=a%3600%60;
        System.out.println(h+":"+m+":"+s);
			
	}
}



Measured memory_bytes: 26348
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int ();
        int M = Int ();
        int[] A = Ints ();

        var pq = new PriorityQueue<int> (N, true);
        for (int i = 0; i < N; i++) {
            pq.Push (A[i]);
        }

        for (int i = 0; i < M; i++) {
            var tmp = pq.Pop ();
            pq.Push (tmp / 2);
        }

        long ret = 0;
        for (int i = 0; i < N; i++) {
            var tmp = pq.Pop ();
            ret += tmp;
        }

        Console.WriteLine (ret);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 30684
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int P = 4e6;
bitset<2 * P + 1> b;

int main() {
	#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	#endif
	int n;
	cin >> n;
	b[P] = 1;
	int s = 0;
	rep (i, 0, n) {
		int x;
		cin >> x;
		s += x;
		b = (b << x) | (b >> x);
	}
	int d = -1;
	rep (i, P, 2 * P + 1) {
		if (b[i]) {
			d = i - P;
			break;
		}
	}
	cout << (s + d) / 2;
	
}


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

main(){
    int n, k;
    int T[30];
    while( cin >>k && k ){
	for ( int i = 0; i < k; i++ ) cin >> T[i];
	n = 32;
	int r = 0;
	while( n ){
	    n -= (n-1)%5;
	    cout << n << endl;
	    if ( n == 0 ) break;
	    n -= min(n, T[r%k]);
	    r++;
	    cout << n << endl;
	}
    }
}

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

int main(void){
	long i,n,min=2,ans=0,a;
	cin >> n;
	cin >> a;
	ans+=a-1;
	for(i=1;i<n;i++){
		cin >> a;
		if(a==min){
			min++;
			continue;
		}
		ans+=(a-1)/min;
	}
	cout << ans;
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	long long k;
	cin>>n>>k;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	int next[n],memo[200005],first[200005];
	for (int i = 0; i < n; ++i)
	{
		next[i]=-1;
	}
	for (int i = 0; i < 200005; ++i)
	{
		memo[i]=-1;
		first[i]=-1;
	}
	for (int i = 0; i < n; ++i)
	{
		if (memo[a[i]]!=-1)
		{
			next[memo[a[i]]]=i;
		}
		if (first[a[i]]==-1)
		{
			first[a[i]]=i;
		}
		memo[a[i]]=i;
	}
	for (int i = 0; i < n; ++i)
	{
		if (next[i]==-1)
		{
			next[i]=first[a[i]];
		}
	}

	int loop[n],group[n];
	for (int i = 0; i < n; ++i)
	{
		memo[i]=0;
		group[i]=-1;
	}
	for (int i = 0; i < n; ++i)
	{
		if (memo[i]==1)
		{
			continue;
		}
		int now=i,nloop=0;
		memo[i]=1;
		group[i]=i;
		while (1)
		{
			if (now>=next[now])
			{
				++nloop;
			}
			now=(next[now]+1)%n;
			memo[now]=1;
			group[now]=i;
			if (i==now)
			{
				if (i==0)
				{
					++nloop;
				}
				loop[i]=nloop;
				break;
			}
		}
	}

	long long r=(long long)n*(k%loop[0]);
	int now=0;
	vector<int> ans;
	while (r>0)
	{
		int u=next[now]-now+1;
		if (next[now]<=now)
		{
			u+=n;
		}
		if (u>r)
		{
			ans.emplace_back(a[now]);
			now=(now+1)%n;
			--r;
		}
		else
		{
			r-=(long long)u;
			now=(next[now]+1)%n;
		}
	}
	for (auto i = ans.begin(); i != ans.end(); ++i)
	{
		if (i!=ans.begin())
		{
			cout<<" ";
		}
		cout<<*i;
	}
	cout<<endl;
	return 0;
}


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

string str1, str2;
int main(){
	cin >> str1 >> str2;
	sort(str1.begin(), str1.end());
	sort(str2.begin(), str2.end(), greater<char>());
	if(str1 < str2)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using long_t = int64_t;

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		map<string, int> m;
		int q;
		cin >> q;
		while( q-- ) {
			int op;
			cin >> op;

			if( op == 0 ) {
				string key;
				int x;
				cin >> key >> x;
				m[key] = x;
			}
			else if( op == 1 ) {
				string key;
				cin >> key;
				cout << (m.count( key ) ? m[key] : 0) << '\n';
			}
			else if( op == 2 ) {
				string key;
				cin >> key;
				m.erase( key );
			}
			else if( op == 3 ) {
				string L, R;
				cin >> L >> R;
				auto i1 = m.lower_bound( L );
				auto i2 = m.upper_bound( R );
				for( ; i1 != i2; ++i1 ) {
					cout << i1->first << ' ' << i1->second << '\n';
				}
			}
		}
	}
};

int main() {
	Solver().solve();
	return 0;
}



Measured memory_bytes: 25764
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

struct mint { // auto MOD int
  ll x;
  mint(ll x=0) : x((x%MOD+MOD)%MOD){}  //コンストラクタ
  mint operator-() const { return mint(-x); } //符号変換
  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 operator/(const mint &a) const { return mint(*this) /= a; }
  mint pow(ll n) const {  //繰り返し累乗
    if (!n) return 1;
    mint a = pow(n>>1);
    a *= a;
    if (n&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD-2); } // for prime mod
  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){ return (*this) *= a.inv(); }
  friend ostream& operator<<(ostream &stout, const mint &tmp){ stout << tmp.x; return stout; }
};

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  set<int> st;
  rep(i,m){
    int a; cin >> a;
    st.insert(a);
  }
  vector<mint> dp(n+1);
  dp[0] = 1;
  for(int i = 1; i <= n; i++){
    if(st.count(i)) continue;
    dp[i] += dp[i-1];
    if(0 <= i-2) dp[i] += dp[i-2];
  }
  cout << dp[n];
  cout << "\n";
  return 0;
}


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

int n, m, arr[100];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	int sum = 0;
	for(int i = 0; i < n; i++) cin >> arr[i], sum += arr[i];
	int cnt = 0;
	for(int i = 0; i < n; i++)
		if((double)arr[i] >= (double)sum / (4 * m)) cnt++;
	cout << ((cnt >= m) ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
// Author: πα

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

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

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for(int i = 0; i < n; ++i)
        cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end(), fight);
    long cur = 0;
    for(auto it : v)
    {
        cur += it.first;
        if(cur > it.second)
            return cout << "No", 0;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 1792
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

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

vector<ll> T, A;
ll H[100001];
const int mod = 1e9+7;

void solve() {
    int N;
    ll conb=1;
    cin >> N;
    rep(i, N) {
        ll t; cin >> t;
        T.push_back(t);
    }

    rep(i, N) {
        ll t; cin >> t;
        A.push_back(t);
    }

    if (N == 1) {
        if (T[0] == A[0]) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
        return;
    }

    ll max_t = T[0], max_a = A[N-1];
    REP(i, 1, N) {
        int t = T[i];
        if (T[i] > max_t) {
            H[i] = T[i];
            max_t = T[i];
        } else {
            H[i] = (-1) * T[i];
        }
    }

    RREP(i, N-2, 1) {
        int a = A[i];
        if (A[i] > max_a) {
            if (H[i] < 0) {
                ll h = -H[i];
                if (A[i] > h) {
                    cout << 0 << endl;
                    return;
                }
            } else {
                if (A[i] != H[i]) {
                    cout << 0 << endl;
                    return;
                }
            }
            max_a = A[i];
        } else {
            if (H[i] < 0) {
                ll h = -H[i];
                H[i] = -min(h, max_a);
                conb = conb * (-H[i]) % mod;
            } else {
                if (H[i] > max_a) {
                    cout << 0 <<endl;
                    return;
                }
            }
        }
    }

    cout << conb << endl;
}

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


Measured memory_bytes: 2676
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long N;
	//cin >> N;

	string s;
	cin >> s;

	//int A[5]
	//sort(A, A + 5);

	if (s >= "A" && s <= "Z")
	{
		cout << "A" << endl;
	}
	else
	{
		cout << "a" << endl;
	}

}

Measured memory_bytes: 3624
//
//  main.cpp
//  DayOfTakahashi
//
//  Created by XsC on 2018/5/5.
//  Copyright © 2018年 夏思聪. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    if(b>=a)
        a++;
    printf("%d",a-1);
    return 0;
}


Measured memory_bytes: 256
import sys
from operator import itemgetter
input = sys.stdin.readline
N = int(input())
A_B = [list(map(int,input().split())) for i in range(N)]
A_B = sorted(A_B,key=itemgetter(1))
#print(A_B)
s=0
for a_b in A_B:
  s+=a_b[0]
  lim = a_b[1]
  if s > lim:
    print("No")
    exit()
print("Yes")




Measured memory_bytes: 55288
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int D,G;
  cin >> D>>G;
  vec<vec<int>>a(D,vec<int>(2,0));
  REP(i,D){
    cin>>a[i][0]>>a[i][1];
  }
  int minans=INF;
  REPB(i,D){
   int score=0,ans=0,maxJ=0;
   REP(j,D){
     if (i & BIT(j)){
       score+=(j+1)*100*a[j][0]+a[j][1];
       ans+=a[j][0];
     }else{
         maxJ=max(maxJ,j);
     }
   }
   if (score<G){
    int scoreadd = (maxJ+1)*100*(a[maxJ][0]-1);
    if (score+scoreadd>=G){
        ans+=ceil(1.0*(G-score)/((maxJ+1)*100));
    }else{
        continue;
    }
   }
    minans = min(ans,minans);
 }
  print(minans);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long K, A, B;
	long long ans = 1;


	cin >> K >> A >> B;

	long long i = 0;
	if(B <= A){
		cout << K + 1<< endl;
		return 0;
	}

	double x = (double)(2*A)/(B-A);
	i = ceil(x)-1;
	i = max(i, A-1);
	if(i >= K) {
		cout << K + 1<< endl;
		return 0;
	}
	ans+=i;

	if((K-i) % 2 == 1){
		ans++;
		i++;
	}	
	ans += (ans/A)*(B-A) * (K-i)/2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
string s;
cin >>s;
if(s.size()==3){
    reverse(s.begin(),s.end());
    cout << s;
}
else{
    cout << s << endl;
}
 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

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

bool is_msprime(int n) {
	if ( n%7 == 1 || n%7 == 6 ) {
		return true;
	}
	return false;
}

int main(void) {
	int N = 300000;
	int n;
	cin >> n;

	std::vector<bool> msp(N+1);
	for (int i = 0; i < N+2; i++) {
		msp[i] = is_msprime(i);
	}
	msp[0] = false;
	msp[1] = false;
	for (int i = 2; i <= sqrt(N); i++) {
		if (is_msprime(i)) {
			for (int j = 2; i*j < N+2; j++) {
				msp[i*j] = false;
			}
		}
	}

	while ( n != 1 ) {
		cout << n << ":";
		for (int i = 1; i < N+2; i++) {
			if (msp[i]) {
				if (n%i == 0) {
					cout << " " << i;
				}
			}
		}
		cout << endl;
		cin >> n;
	}

	return 0;
}

Measured memory_bytes: 3048
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] p = nextIntArray1origin(sc, N);

		sc.close();

		int ans = 0;

		for (int i = N; i >= 2; i--) {
			// 後ろから確定させていく(i==2まで)
			if (p[i] == i) {
				ans++;
				int tmp = p[i];
				p[i] = p[i - 1];
				p[i - 1] = tmp;
			}
		}

		if (p[1] == 1) {
			ans++;
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 50484
#include<bits/stdc++.h>
using namespace std;
#define max1 100005
#define siz 1000005
#define mod 998244353
#define inf 1e18
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
#define jam(x) cout<<"Case #"<<x<<": "
#define hackercup(x) cout<<"Case #"<<x<<": "
ll tt;
#define run_time cout << "\nTIME = " << clock() - tt << endl; tt = clock();
typedef pair<ll,ll> pr;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  tt = clock();
  #endif*/
  ll n, d;
  cin >> n >> d;
  ll ans = 0;
  for(ll i = 0; i < n; i++)
  {
    ll x, y;
    cin >> x >> y;
    double dist;
    x = x*x + y*y;
    dist = (double)sqrt(x);
    if(dist <= d)
    {
      ans++;
    }
  }
  cout << ans << endl;
} 

Measured memory_bytes: 3696
n = int(input())
h = list(map(int, input().split(' ')))
dp = [-1 for _ in range(n)]

dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2,n):
    dp[i] = min(abs(h[i] - h[i-2]) + dp[i-2],
                abs(h[i] - h[i-1]) + dp[i-1])

print(dp[n-1])
        


Measured memory_bytes: 13980
# 購入する数字N
# 嫌いな数字の個数K
N,K = map(int,input().split())

# 嫌いな数字をリストに入力
D = input().split()

# Lから1づつ増やしていき、嫌いな数字が含まれていない事をチェックする
# 最大計算量はNの10倍
# N=9999のときは、9999から99999まで計算すれば良い
for n in range(N,10*N):
    # 数字nを一度文字列にする
    # setを使ってnとDを集合の要素にする
    # isdisjointは集合同士を比較して、
    # 要素が1つもかぶらなければTrueを返す
    if set(str(n)).isdisjoint(set(D)):
        print(n)
        # 1個見つかったら終了
        break

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 1000000;

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

typedef long long ll;

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/


int length(int a[])
{
	int res = 0, len = 0;
	REP(14)
	{
		if (a[i]) len++;
		else len = 0;
		res = max(res, len);
	}
	return res;
}


int main()
{
	int a[14], n;
	string ans;
	
	while (scanf("%d", &n) != EOF)
	{
		fill(a, a + 14, 0);
		a[n - 1]++;
		if (n == 1) a[13]++;
		for (int i=1; i<5; i++)
		{
			scanf(",%d", &n);
			a[n - 1]++;
			if (n == 1) a[13]++;
		}
		ans = "null";
		if (count(a, a + 13, 4) == 1) ans = "four card";
		else if (count(a, a + 13, 3) == 1 && count(a, a + 13, 2) == 1) ans = "full house";
		else if (length(a) == 5) ans = "straight";
		else if (count(a, a + 13, 3) == 1) ans = "three card";
		else if (count(a, a + 13, 2) == 2) ans = "two pair";
		else if (count(a, a + 13, 2) == 1) ans = "one pair";
		
		cout << ans << endl;
	}
	
	return 0;
}

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

using namespace std;

string s;

int main() {
	cin >> s;
	if (s.length() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') printf("Yes\n"); else printf("No\n");
}


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

int main(){
    int H,N; cin >> H >> N;
    int sum=0;
    for(int i=0;i<N;i++){
        int A;
        cin >> A;
        sum += A;
    }
    if(sum>=H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int64_t X, ans = 0, now = 100;
    cin >> X;
    while(now < X){
        now *= 1.01;
        ans ++;
    }
    cout << ans << endl;
}

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

int main(int argc, char* argv[]) {
	int a, b;
	cin >> a >> b;

	int d, r;
	double f;

	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	printf("%d %d %lf ", d, r, f);

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  int res = a % b;
  if(res == 0){
    return b;
  }
  return gcd(b, a % b);
}

int lcm(int a,int b){
  return a / gcd(a,b) * b;
}
int main(){
  int x;
  cin >> x;
  // int ans;
  // ans = 360 / x;
  // // if(ans * x < 360){
  // //   ans += 1;
  // // }
  // // cout << ans << endl;
  int l = lcm(360,x);

  cout << l / x << endl;
}


Measured memory_bytes: 3672
#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 n, k; cin >> n >> k;
    map<int,int> mp;
    rep(i, n) {
        int a; cin >> a;
        mp[a]++;
    }
    vector<int> stack;
    for(auto it=mp.begin();it!=mp.end();it++) {
        stack.push_back(it->second);
    }
    sort(stack.begin(), stack.end());
    int ans = 0;
    for(int i=0;i<stack.size()&&(stack.size()-i)>k;i++) {
        ans += stack[i];
    }
    cout << ans;
}


Measured memory_bytes: 10748
#include<iostream>
#include<vector>

int main()
{
    int N ;
    std::cin >> N ;
    std::vector<int> A(N) ;
    for(int i = 0 ; i<N ; ++i)
    {
        std::cin >> A.at(i) ;
    }

    bool flag = 1 ;
    int count = 0 ;
    while(flag)
    {
        flag = 0 ;
        for( int i = A.size()-1 ; i > 0 ; --i)
        {
            if(A.at(i) < A.at(i-1) )
            {
                std::swap(A.at(i),A.at(i-1)) ;
                flag = 1 ;
                ++count ;
            }
        }
    }
    

    for(std::size_t i = 0 ; i != A.size() ; ++i)
    {
        if(i == A.size() - 1)
        {
            std::cout << A.at(i) << std::endl ;
        }
        else
        {
            std::cout << A.at(i) << " " ;
        }
        
    }
    std::cout << count << std::endl ;


}


Measured memory_bytes: 3084