akhauriyash/Code-Regression huggingface dataset:
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-03 17:07:09
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=2000010,mod=1000000007;
i64 n,m,flag,l,Flag;
i64 f[N],F[N],ans;
char s[N];
namespace std
{
	int main()
	{
		i64 i,j,t;
		for(i=1;i<=m;i++) if(s[i]!=s[1]) break;
//		if(i-1+((i-1)%2==0)!=l) exit(1);
		l=i-1;
		if(l%2==0) l++;
		for(t=0;i<=m;i++)
		{
			if(s[i]==s[1]) t++;
			else
			{
				if(t&1) l=min(l,t);
				t=0;
			}
		}
		n/=2,l=(l+1)/2;
		return 0;
	}
}
int main()
{
	n=read(); m=read();
	scanf("%s",s+1);
	fr(i,2,m) if(s[i]!=s[1]) flag=1;
	if(!flag)
	{
		f[0]=1; f[1]=1; f[2]=2;
		fr(i,3,n) f[i]=(f[i-1]+f[i-2])%mod;
		printf("%d\n",int((f[n]+f[n-2])%mod));
		return 0;
	}
	for(int i=1,j;i<=m;)
		if(s[i]==s[1])
		{
			j=i;
			while(s[j]==s[1]) j++;
			if(j>n) break;
			if(i!=1&&!Flag) return 1;
			if(!Flag) l=j-i+((j-i)%2==0);
			else if((j-i)&1) l=std::min(l,(i64)(j-i));
			i=j+1; Flag=1;
		}
		else i++;
	if(n&1){ printf("0\n"); return 0; }
	std::main();
//	printf("%d %d\n",int(n),int(l));
	f[0]=F[0]=1;
	fr(i,1,n)
	{
		f[i]=(F[i-1]+mod-(i-l-1>=0?F[i-l-1]:0))%mod;
		F[i]=(F[i-1]+f[i])%mod;
//		printf("%d%c",int(f[i]),i==n?'\n':' ');
	}
	ans=f[n];
	fr(i,1,l) ans=(ans+f[n-i]*(2*i-1))%mod;
	printf("%d\n",int(ans));
	return 0;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main()
{
    ll n;
  	cin>>n;
  	vector<string> vs(n);
	for(ll i=0;i<n;i++) 
		cin>>vs[i];

	map<string, int> cnt;
	ll ans=0;

	for(auto s:vs){
	    sort(s.begin(),s.end());

	    ans+=cnt[s];

	    cnt[s]++;
	}
	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 18176
a, b = map(int, input().split())
s = input()
s1=[]
for k in s:
    s1.append(k)
x=0
if s1[a+1-1]=='-':
    s1.remove(s1[a])
    for i in s1:
        if i not in ('0','1','2','3','4','5','6','7','8','9'):
            x=0
            break
        else:
            x=1
else:
    x=0
if x==0:
    print('No')
elif x==1:
    print('Yes')


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;


const ll mod = 1e9+7;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  vector<vector<ll>> dp(N, vector<ll>(K+1));

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

  for (int j = 0; j <= K; j++) {
    if (j <= a[0]) {
      dp[0][j] = 1;
    }
  }
  for (int i = 1; i < N; i++) {
    int sum[K+2];
    sum[0] = 0;
    for (int j = 1; j <= K+1; j++) {
      sum[j] = (sum[j - 1] + dp[i - 1][j - 1]) % mod;
    }
    for (int j = 1; j <= K; j++) {
      dp[i][j] = (sum[j+1] - sum[max(0, j-a[i])] + mod) % mod;
    }
  }
  cout << dp[N - 1][K] << endl;
}


Measured memory_bytes: 79488
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1]*n

for i in range(m):
    ai, bi = map(int, input().split())
    if h[ai-1] >= h[bi-1]:
        ans[bi-1] = 0
    if h[ai-1] <= h[bi-1]:
        ans[ai-1] = 0
print(sum(ans))


Measured memory_bytes: 84756
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int X[110];
    rep(i, N) cin >> X[i];
    int ans = INF;
    REP(i, 0, 100) {
        int tmp = 0;
        rep(j, N) {
            tmp += (X[j] - i) * (X[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


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

ll check (ll a) {
    vector<bool> check(3,false);
    while (a) {
        ll num = a % 10;
        if (num == 3) check[0] = true;
        else if (num == 5) check[1] = true;
        else if (num == 7) check[2] = true;
        else return 0;
        a /= 10;
    }
    return (check[0] && check[1] && check[2] ? 1ll : 0ll);
}

ll dfs(ll a, ll n) {
    if (a > n) return 0;
    ll res = check(a);
    res += dfs(a * 10 + 3, n);
    res += dfs(a * 10 + 5, n);
    res += dfs(a * 10 + 7, n);
    return res;
}

int main() {
    ll n; cin >> n;
    cout << dfs(0ll, n) << endl;
    return 0;
}

Measured memory_bytes: 3644
def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist

n, x = [ int(v) for v in input().split() ]
candy_list = sorted([ int(v) for v in input().split() ])
candy_list_2 = cumsum(candy_list)

ans = 0
for i in range(n):
    if i != n-1 and candy_list_2[i] <= x:
        ans += 1
    elif i == n-1 and candy_list_2[i] == x:
        ans += 1
print(ans)


Measured memory_bytes: 38384
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
int main() {
string S;
	cin>>S;
	for(int i=0;i<S.size();i++){
		if((i%2==0 && S[i]=='L') || (i%2==1 && S[i]=='R')){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}


Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Chars, Bytes};
#[allow(unused_imports)]
use num::integer::gcd;

#[allow(dead_code)]
type Pi = (i32, i32);
#[allow(dead_code)]
fn pri<T: std::fmt::Display>(x: T) {println!("{}", x);}

#[fastout]
fn main() {
    input!{
        n: u64, s: Chars,
    }
    let mut r = 0; let mut g = 0; let mut b = 0;
    for c in &s {
        if *c == 'R' {r += 1;} else if *c == 'G' {g += 1;} else {b += 1;}
    }
    let mut ans:u64 = r*g*b;
    for i in 1..n as usize {
        for j in 0..i {
            let k = 2*i-j;
            if k < n as usize && s[k] != s[i] && s[k] != s[j] && s[j] != s[i] {ans -= 1;}
        }
    }
    pri(ans);
}

Measured memory_bytes: 2132
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int ans=0;
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                for(int k=0;k<10;k++){
                    for(int l=0;l<10;l++){
                        if((i+j+k+l)==n)ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
//typedef pair<ll, ll> p_ll;
//typedef vector<pair<ll, ll>> vec_p;

/*const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;*/


int main()
{
    ll N,sum=0;

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

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

    for (ll i = 0; i < N; i++) {
        sum+=vec.at(i);
    }

    cout << vec.at(0) << " " << vec.at(N-1) << " " << sum << endl;


}


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

using namespace std;
using ll = long long;

int main() {
	
	int N, tmp;
	vector<int> A;
	ll ans = 0;
	int k;
	
	cin >> N;
	for(int i=0; i<N+1; i++) {
		cin >> tmp;
		A.push_back(tmp);
	}
	for(int i=0; i<N; i++) {
		cin >> tmp;
		k = min(A[i] + A[i+1], tmp);
		A[i+1] -= max(k - A[i], 0);
		ans += k;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main()
{
    int A, B, C, K,sum;
    sum = 0;
    cin >> A >> B >> C >> K;
    for (int i = 0; i < K;i++)
    {
        if(A>0)
        {
            sum++;
            A -= 1;
        }else if(B>0)
        {
            B -= 1;
        }
        else if (C > 0)
        {
            sum--;
            C -= 1;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

ll MOD = 1000000007;

vector<ll> mfact(1,1);

ll extGCD(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    ll g = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return g;
}

ll minv(ll a){
    ll x;ll y;
    extGCD(a, MOD, x, y);
    if(x<0){
        x+= ((-x)/MOD+1)*MOD;
        x %= MOD;
    }
    return x;
}

ll mpow(ll a,ll b){
    ll res = 1;
    while(b > 0){
        if(b%2==1)res=(res*a)%MOD;
        b/=2;
        a = (a*a)%MOD;
    }
    return res;
}

ll mfactorial(ll a){
    if(mfact.size()-1 >= a)return mfact[a];
    for(ll i = mfact.size();i<=a;i++){
        mfact.push_back((i * mfact[i-1])%MOD);
    }
    return mfact[a];
}

ll mcomb(ll n, ll r){
    return (((mfactorial(n) * minv(mfactorial(r)))%MOD) * minv(mfactorial(n-r)))%MOD;
}

ll gcd(ll a, ll b){
    if(b == 0)return a;
    return gcd(b, a%b);
}

int main(){
    int N;cin>>N;
    ll zero_zero = 0, zero_n = 0, n_zero = 0;
    map<pair<ll,ll>, pair<ll,ll>> numBunsu;
    for(int i = 0;i < N;i++){
        ll a,b;cin>>a>>b;
        if(a == b && b == 0){
            zero_zero++;
            continue;
        }else if(a == 0){
            zero_n++;
            continue;
        }else if(b == 0){
            n_zero++;
            continue;
        }
        ll d = gcd(abs(a),abs(b));
        a /= d;
        b /= d;
        if(b < 0){
            a = -a;
            b = -b;
        }
        if(a > 0){
            if(numBunsu.find(pair{a,b}) == numBunsu.end()){
                numBunsu[pair{a,b}] = pair{0,0};
            }
            numBunsu[pair{a,b}].first++;
        }else{
            a = -a;
            if(numBunsu.find(pair{b,a}) == numBunsu.end()){
                numBunsu[pair{b,a}] = pair{0,0};
            }
            numBunsu[pair{b,a}].second++;
        }

    }
    ll result = 1;
    for(auto itr = numBunsu.begin();itr != numBunsu.end();itr++){
        pair<ll,ll> p = itr->second;
        ll a = (mpow(2, p.first) + mpow(2,p.second) - 1LL+MOD)%MOD;
        result = result * a % MOD;
    }
    ll a = (mpow(2, n_zero) + mpow(2,zero_n) - 1LL+MOD)%MOD;
    result = result * a % MOD;
    result = (result + zero_zero) % MOD;
    cout<<(result-1LL+MOD)%MOD<<endl;
}


Measured memory_bytes: 19188
#include<stdio.h>

int main(void){
    int r;
    int g;
    int b;
    scanf("%d",&r);
    scanf("%d",&g);
    scanf("%d",&b);
    int X;
    X=100*r+10*g+b;
    if(X%4==0){
    printf("YES\n");}
    else{
    printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
N, T = map(int,input().split())

TL = list(map(int,input().split()))

ans = 0

for i in range(N-1):
  stop = TL[i] + T
  if stop >= TL[i+1]:
    ans += TL[i+1]-TL[i]
  else:
    ans += T
ans += T
print(ans)

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

int main(){
  int n,m; cin >> n >> m;
  int ans[m]={0};
  for(int i=0;i<n;i++){
    int k,a;
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> a;
      ans[a-1] +=1;
    }
  }
  int ret=0;
  for(int l=0;l<m;l++){
    //cout << ans[l] << endl;
    if(ans[l] == n)
      ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	int A, B, C;
	cin >> A >> B >> C;

	int ans = 0;
	if (B >= A * C) {
		ans = C;
	}
	else {
		ans = B / A;
	}
	 


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define INF 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int k,x;
  cin >> k >> x;
  x = x - k + 1;
  for(int i = 0; i < k * 2 - 1; i++)cout << x + i << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m,n,k;
	cin>>m>>n>>k;
	vector<string> s(m);
	for(int i=0;i<m;i++)
	cin>>s[i];
	int ans=0;
	for(int i=0;i<(1<<m);i++)
	for(int j=0;j<(1<<n);j++)
	{
		int c=0;
		for(int o=0;o<m;o++)
		for(int p=0;p<n;p++){
			if (i>>o&1) continue;
			if (j>>p&1) continue;
			if (s[o][p]=='#') c++;
		}
		if(c==k)
		ans++;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 3652
#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 chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct Edge {
    int to, c;
};

void dfs(int v, int p, vector<vector<Edge>> &G, vector<int> &color, int c) {
    color[v] = c;
    for (int i = 0; i < G[v].size(); i++) {
        if (G[v][i].to == p) continue;
        if (color[G[v][i].to] != -1) continue;
        if (G[v][i].c == 0) {
            dfs(G[v][i].to, v, G, color, c);
        } else {
            dfs(G[v][i].to, v, G, color, 1 - c);
        }
    }
}

void solve() {
    int N;
    cin >> N;
    vector<vector<Edge>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, c % 2});
        G[b].push_back({a, c % 2});
    }
    vector<int> color(N, -1);
    dfs(0, -1, G, color, 0);

    for (int i = 0; i < N; i++) {
        cout << color[i] << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

int main() {
	
	int n; cin >> n;
	const int p = 26;
	vector<vector<int>> num(n, vector<int>(p, 0));
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		for (int j = 0; j < s.size(); j++) {
			num[i][s[j] - 'a']++;
		}
	}
	vector<int> ans(p, 1000);
	string res = "";
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < n; j++) {
			ans[i] = min(ans[i], num[j][i]);
		}
		for (int j = 0; j < ans[i]; j++) {
			string tmp{ (char)(i + 'a') };
			res += tmp;
		}
	}
	cout << res << endl;
	return 0;
}

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

int main() {
	int K, S;
	cin >> K >> S;

	int res = 0;
	for (int X = 0; X <= K; X++) {
		for (int Y = 0; Y <= K; Y++) {
			int Z = S - (X + Y);
			if ((0 <= Z) && (Z <= K)) res++;
		}
	}
	cout << res << endl;
}

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

int a, b, c;

int main() {
  cin >> a >> b >> c;
  bool flag = false;
  for (int i=a; i<b*b; i+=a) {
    if (i % b == c) {
      cout << "YES" << endl;
      flag = true;
      break;
    }
  }
  if (!flag) cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,num=0;

  cin>>n;
  num=n%10;

  if(num==3) cout<<"bon"<<endl;
  else if(num==0 || num==1 || num==6 || num==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define ld long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
#define MOD 1000000007
#define INF 1000000000000000007LL


const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int n; cin>>n;
    vector<int> a(n), b(n);
    For(i, 0, n){
        cin>>a[i]>>b[i];
    }
    sort(all(a));
    sort(all(b));
    if(n%2){
        int a1 = a[n/2];
        int b1 = b[n/2];
        cout<<(b1-a1+1);
    }
    else{
        int a1 = a[n/2-1]+a[n/2];
        int b1 = b[n/2-1]+b[n/2];
        cout<<(b1-a1+1);
    }
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 6364
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());


int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s,p;
	while(t--)
	{
		cin>>s>>p;
		n=s.length();
		// ll a[n];
		rep(i,n)
		{
			c+=(s[i]!=p[i]);
		}
		// c=n+(n*n)+(n*n*n);
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

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

#if 0
所用時間:

感想:

#endif

int N, buff, M = 0, SUM = 0, A[101][101], cost[5000], dpt[5000], dst[5000], P[100001]; //A[Y][X]
vector<pair<int, int> > edges;

void init(int N){ //木構造の初期化
  for(int i = 0; i <= N; ++i){
    P[i] = i;
  }
}

int root(int a){ //根の参照
  if(P[a] == a) return a;
  return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b){ //同じ根か?
  return root(a) == root(b);
}

void unite(int a, int b){
  P[root(a)] = root(b); //aのrootをbの子にする
}

void preprocess(){//辺の前処理
  for(int r = 0; r < N; ++r){
    for(int c = r+1; c < N; ++c){
      if (A[r][c] > -1) {
        cost[M] = A[r][c];
        dpt[M] = r;
        dst[M] = c;
        M++;
      }
    }
  }

  //for(int i = 0; i < M; ++i) cout << cost[i] << endl;

  for(int i = 0; i < M; ++i){
    edges.push_back(make_pair(cost[i], i));
  }
  // for(int i = 0; i < M; ++i) cout << edges[i].first << " " << edges[i].second << endl;

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

  // for(int i = 0; i < M; ++i) cout << edges[i].first << " " << edges[i].second << endl;

}

void solve(){
  int ans = 0;
  preprocess();

  init(N);

  for(int i = 0; i < M; ++i){
    int index = edges[i].second;
    if(is_same_set(dpt[index], dst[index])) continue;
    else {
      unite(dpt[index], dst[index]);
      ans += cost[index];
    }
  }
  cout << ans << endl;
}

int main(){

cin >> N;

for(int i = 0; i < N; ++i){
  for(int j = 0; j < N; ++j){
    cin >> buff;
    A[i][j] = buff;
    }
  }

  //行列の表示
  // cout << "Matrix:" << endl;
  // for(int row=0; row < N; ++row){
  //   for(int col = 0; col < N; ++col){
  //     cout << A[row][col];
  //   }
  //   cout << endl;
  // }

  solve();
}



Measured memory_bytes: 3232
N = int(input())
A = list(map(int,input().split()))

Amax = 0
ans = 0

for i in range(len(A)):
  if (Amax - A[i]) >= 0:
    ans += (Amax-A[i])
  elif (Amax - A[i])<0:
    Amax = A[i]
print(ans)

Measured memory_bytes: 32376
x, y, z = map(int, input().split())

ret = 0
while not(x % 2 == 1 or y % 2 == 1 or z % 2 == 1):
    ret += 1
    x, y, z = y//2+z//2, z//2+x//2, x//2+y//2
    if ret > 10000:
        ret = -1
        break;

print(ret)

Measured memory_bytes: 2940
#include<stdio.h>

int main(){
  int n,q,count=0;

  scanf("%d",&n);
  int S[n],right=n,left=0,mid,i;
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);

  for(i=0;i<q;i++){
    right=n;
    left=0;
    while(left < right){
      mid = (right + left)/2;
      if(S[mid] == T[i]){
        count++;
        break;
      }
      else if(T[i] < S[mid])
        right = mid;
      else left = mid + 1;
    }
  }

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

 return 0;
}



Measured memory_bytes: 2440
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    N -= K;
    cout << (K == 1 ? 0 : N) << '\n';
    return 0;
}


Measured memory_bytes: 892
n = int(input())
S = [str(a+1) for a in range(13)]
H = S.copy()
C = S.copy()
D = S.copy()
while n != 0:
    design, rank = input().split()
    if design == 'S':
        S.remove(rank)
    if design == 'H':
        H.remove(rank)
    if design == 'C':
        C.remove(rank)
    if design == 'D':
        D.remove(rank)
    n -= 1

for a in S:
    print('S {}'.format(a))
for a in H:
    print('H {}'.format(a))
for a in C:
    print('C {}'.format(a))
for a in D:
    print('D {}'.format(a))



Measured memory_bytes: 5600
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;

#define all(x)  x.begin(), x.end()
#define pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/

void sol() {

}

int main() {
    cin.tie(nullptr)->ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    
    string s;
    cin >> s;
    int n(s.size());
    if(n%2 ==1) cout << "No\n";
    else{
        for(int i=0; i<n;i+=2){
            if(s[i]=='h' && s[i+1]=='i') continue;
            else {cout << "No\n"; return 0;}
        }
        cout << "Yes\n";
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <climits>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

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

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

	int ans1 = 0, ans2 = 0;

	{
		int sum = 0;
		vector<int> b = a;
		rep(i, n) {
			if (sum <= 0 and sum + b[i] <= 0) {
				ans1 += abs(b[i] - (1 - sum));
				b[i] = 1 - sum;
			} else if (sum > 0 and sum + b[i] >= 0) {
				ans1 += abs(b[i] - (-sum - 1));
				b[i] = -sum - 1;
			}

			sum += b[i];
			//printf("sum=%lld, ans1=%lld\n",sum,ans1);
		}
	}

	{
		int sum = 0;
		vector<int> b = a;
		rep(i, n) {
			if (sum < 0 and sum + b[i] <= 0) {
				ans2 += abs(b[i] - (1 - sum));
				b[i] = 1 - sum;
			} else if (sum >= 0 and sum + b[i] >= 0) {
				ans2 += abs(b[i] - (-sum - 1));
				b[i] = -sum - 1;
			}

			sum += b[i];
			//printf("sum=%lld, ans1=%lld\n",sum,ans1);
		}
	}

	//rep(i, n) printf("a[%lld] = %lld\n", i, a[i]);

	cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 1804
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();
 


    unsigned long long n, a, b; cin >> n >> a >> b;
    
    if (a == 0 && b == 0)
    	  cout << 0 << endl;
    
    else if (a == 0)
          cout << 0 << endl;

    else if(b == 0)
          cout << n << endl;

    else {
    unsigned long long  q = (n / (a + b));
    unsigned long long  r = (n % (a + b));

    if (r > a)
         r = a;

    cout << (q * a + r) << endl;	
    }

    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

Measured memory_bytes: 256
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
pair<llong, llong> Reduction(pair<llong, llong> A) {
	llong tmp = gcd(A.first, A.second);
	auto p = make_pair(A.first / tmp, A.second / tmp);
	return p;
}
//ここまで共通
llong X, K, D;
int main() {
	cin >> X >> K >> D;
	X = abs(X);
	if (X / D > K) {
		cout << X - K * D << endl;
		return 0;
	}
	else {
		if ((K - X / D) % 2 == 0) {
			cout << X % D << endl;
			return 0;
		}
		else {
			cout << D - X % D << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3624
import java.util.Scanner;

/**
 * 2018-04-08
 * https://beta.atcoder.jp/contests/abc085/tasks/abc085_a
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        //System.out.println(s.replaceAll("2017","2018"));
        StringBuilder sb = new StringBuilder(s);
        sb.setCharAt(3,'8');
        System.out.println(sb);

    }
}


Measured memory_bytes: 25044
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define mod 998244353
using namespace std;
typedef long long ll;
ll n,a[100005];
int main()
{
	while(scanf("%lld",&n)!=EOF)
	{
		memset(a,0,sizeof(a));
		for(int i=1;i<=n;i++)
			cin>>a[i];
		if(a[1]!=0){
			cout<<"0"<<endl;
			continue;
		}
		sort(a+1,a+n+1);
		int f=0;
		for(int i=2;i<=n;i++){
			if(abs(a[i]-a[i-1])!=0&&abs(a[i]-a[i-1])!=1){
				f=1;
				break;
			}
		}
		if(f){
			cout<<"0"<<endl;
			continue;
		}
		ll i=2,sum=1,t=0;
		for(;a[i]==1;i++) t++;
		for(;i<=n;){
			ll d=a[i],s=1,tt=0;
			for(;a[i]==d&&i<=n;i++){
				tt++;
				s=(s*t)%mod;
			}
			sum=(sum*s)%mod;
			t=tt;
		}
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1152
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

const int N_MAX = 100010;
ll parent[N_MAX];
ll num[N_MAX]; // グループごとの人数
ll N, M;

ll findRoot(ll a){
    if(parent[a]==a){
        return a;
    }
    return parent[a] = findRoot(parent[a]);
}

void unite(ll a, ll b){
    ll rootA = findRoot(a);
    ll rootB = findRoot(b);

    if(rootA == rootB){
        // do nothing
    }
    else{
        // Bに統合
        parent[rootA] = rootB;

        num[rootB] += num[rootA];
    }
}

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

    // input
    cin >> N >> M;

    vector<ll> A(M);
    vector<ll> B(M);
    FOR(i, 0, M){
        cin >> A.at(i);
        cin >> B.at(i);
    }

    reverse(ALL(A));
    reverse(ALL(B));

    FOR(i, 1, N+1){
        parent[i] = i;
        num[i] = 1;
    }

    vector<ll> answer;

    ll inconvenience = N * (N-1) / 2;
    answer.push_back(inconvenience);

    FOR(i, 0, M-1){
        ll rootA = findRoot(A[i]);
        ll rootB = findRoot(B[i]);

        if(rootA != rootB){
            
            // 不便の減少量
            ll decrease = num[rootA] * num[rootB];

            unite(A[i], B[i]);

            inconvenience -= decrease;
        }
        
        answer.push_back(inconvenience);
    }

    reverse(ALL(answer));
    for(ll ans : answer){
        p(ans);
    }
    
    return 0;
}

Measured memory_bytes: 5364
n, k = gets.chomp.split.map(&:to_i)

num = 1000000007

k_1 = k - 1
n_k_1 = n - k + 1

answer = n - k + 1
p answer
(2..k).each do |i|
  if n_k_1 < i
    p 0
  else
    answer = (answer * (k_1 - (i - 2)) / (i - 1) * (n_k_1 - (i - 1)) / i)
    p answer % num
  end
end


Measured memory_bytes: 2172
#include<iostream>
using namespace std;
int main()
{
    int w,n,a,b;
    char c;
    cin>>w;
    cin>>n;
    int arr[w];
    for(int i=1;i<=w;i++)
    {
        arr[i]=i;
    }
    for(int i=1;i<=n;i++)
        {
            cin>>a>>c>>b;
            int temp=arr[a];
            arr[a]=arr[b];
            arr[b]=temp;
        }
    for(int i=1;i<=w;i++)
    {
        cout<<arr[i]<<endl;
    }
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll n,a,b,c;
  cin>>n>>a>>b>>c;
  vector<ll>v(n,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  ll ans=999999999;
  for(ll i=0;i<(1<<(n*2));i++){
    ll an=0;
    vector<ll>v2(n,0);
    ll aa=0;
    ll bb=0;
    ll cc=0;
    for(ll j=0;j<n;j++){
      if(i&(1<<(j*2))) v2[j]+=1;
      if(i&(1<<(j*2+1))) v2[j]+=2;
    }
    for(ll j=0;j<n;j++){
      if(v2[j]==1) aa+=v[j],an+=10;
      if(v2[j]==2) bb+=v[j],an+=10;
      if(v2[j]==3) cc+=v[j],an+=10;
    }
    an-=30;
    if(aa==0||bb==0||cc==0) continue;
    ll zz=999999999;
    zz=min(zz,abs(aa-a)+abs(bb-b)+abs(cc-c));
    zz=min(zz,abs(aa-a)+abs(bb-c)+abs(cc-b));
    zz=min(zz,abs(aa-b)+abs(bb-a)+abs(cc-c));
    zz=min(zz,abs(aa-b)+abs(bb-c)+abs(cc-a));
    zz=min(zz,abs(aa-c)+abs(bb-b)+abs(cc-a));
    zz=min(zz,abs(aa-c)+abs(bb-a)+abs(cc-b));
    an+=zz;
    ans=min(an,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String str =s.next();
    int sum = 0;

    for(int i =0;i<str.length();i++){
      char splitstr = str.charAt(i);
      if(splitstr == '1'){
        sum += 1;
      }else{
      }


    }
System.out.println(sum);




  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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;
}

int main(){
  cout << fixed << setprecision(15);
  //ll ans = 0;
  string ans = "Yes";

  int n; cin >> n;
  vector<int> tenpo(n + 1), sewi(n + 1), poka(n + 1);
  tenpo[0] = sewi[0] = poka[0] = 0;
  rep(i, n) cin >> tenpo[i + 1] >> poka[i + 1] >> sewi[i + 1];
  rep(i, n){
    int wekatenpo = tenpo[i + 1] - tenpo[i];
    int wekaweka = abs(poka[i + 1] - poka[i]) + abs(sewi[i + 1] - sewi[i]);
    if (wekatenpo < wekaweka) ans = "No";
    if (wekatenpo % 2 != wekaweka % 2) ans = "No";
  }
  
  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 1408
// 2013/11/10 Tazoe

#include <iostream>
using namespace std;

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

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

	long long DP[99][21];
	for(int i=0; i<N-1; i++){
		for(int j=0; j<21; j++){
			DP[i][j] = 0;
		}
	}

	DP[0][n[0]] = 1;

	for(int i=1; i<N-1; i++){
		for(int j=0; j<21; j++){
			if(j-n[i]>=0){
				DP[i][j] += DP[i-1][j-n[i]];
			}
			if(j+n[i]<=20){
				DP[i][j] += DP[i-1][j+n[i]];
			}
		}
	}

	cout << DP[N-2][n[N-1]] << endl;

	return 0;
}

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

struct state{ int lx,ly,rx,ry; };

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

int main(){
	int h,w;
	while(cin >> w >> h,w){
		int ax,ay,bx,by,mi = 101;
		bool used[50][50][50][50] = {},field[50][50];
		cin >> ay >> ax >> by >> bx; ax--;ay--;bx--;by--;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++) cin >> field[i][j];
		}
		queue<state> que;
		que.push({ax,ay,bx,by});
		used[ax][ay][bx][by] = true;
		for(int i = 0;i < 100;i++){
			int siz = que.size();
			if(!siz) break;
			for(int j = 0;j < siz;j++){
				state s = que.front();que.pop();
				if(s.lx == s.rx && s.ly == s.ry) mi = min(i,mi);
				for(int k = 0;k < 4;k++){
					int nlx = s.lx + dx[k],nly = s.ly + dy[k],nrx = s.rx + dx[(k + 2) % 4],nry = s.ry + dy[(k + 2) % 4];
					bool move = false;
					if(nlx >= 0 && nlx < h && nly >= 0 && nly < w && !field[nlx][nly]) move = true;
					else{
						nlx = s.lx;
						nly = s.ly;
					}
					if(nrx >= 0 && nrx < h && nry >= 0 && nry < w && !field[nrx][nry]) move = true;
					else{
						nrx = s.rx;
						nry = s.ry;
					}
					if(move && !used[nlx][nly][nrx][nry]){
						used[nlx][nly][nrx][nry] = true;
						que.push({nlx,nly,nrx,nry});
					}
				}
			}
		}
		if(mi == 101) cout << "NA" << endl;
		else cout << mi << endl;
	}
	return 0;
}

Measured memory_bytes: 9848
X = int(input())

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1
  
for i in range(X, 10 ** 7):
  if is_prime(i):
    print(i)
    break

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}
int char_to_int(char val) {
    return val - '0';
}

int main() {
    ll X, Y; cin >> X >> Y;

    int cnt = 1;
    while(true) {
      X = X * 2;
      if(X > Y) break;
      cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <queue>
#include <cstdio>
typedef long long LL ;
using namespace std ;
int main()
{
    int M,N;
    while(scanf("%d %d",&N,&M)!=EOF)
    {
        int sum=1;
        for(int i=1;i<=M;i++)
            sum=sum*2;
        int K;
        K=sum*M*1900+(N-M)*sum*100;
        printf("%d\n",K);
    }
    return 0;
}


Measured memory_bytes: 128
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  bool flg = true;
  while(true){
    if(n < 4) {
      flg = false;
      break;
    } else if(n%7==0 || n%4==0) {
      break;
    } else {
      n-=4;
    }
  }
  Yes(flg);
}

Measured memory_bytes: 256
#include	<stdio.h>
int	main(void)
{
	int a,b,d,r;
	double f;
//	scanf("%d,%d",&a,&b);
	scanf("%d",&a);
	scanf("%d",&b);
	d=(int)a/b;
	r=(int)a%b;
	f=(double)a/b;
	printf("\n%d %d %lf",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	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(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
ll n;
cin>>n;
ll a[n+1];
rep(i, n){
	cin>>a[i];
}

ll ans=0;
ll cnt=0;
rep(i, n){
if(a[i]>=1){
	cnt+=a[i];
}
if(a[i]==0 || i==n){
	ans+=cnt/2;
	cnt=0;
}
}


cout<<ans<<endl;
return 0;


}





Measured memory_bytes: 1024
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);//XLipÌÏ
	static double time_of_500m, time_of_1000m;//^Cði[·éÏ
	public static void main(String[] args) {
		while(sc.hasNextDouble()){//Ìsª éÈçÇÝæèÆ»èðÀs
			read();//ÇÝæè
			slove();//»è
		}
		
	}
	static boolean read(){
		time_of_500m = sc.nextDouble();//ÇÝæè
		time_of_1000m = sc.nextDouble();//ÇÝæè
		return true;
	}
	static void slove(){
		//System.out.println(time_of_500m);fobOpÈÌÅCÉµÈ¢Å­¾³¢
		//System.out.println(time_of_1000m);fobOpÈÌÅCÉµÈ¢Å­¾³¢
		//±±©çÍüÍÉÎµÄif¶Åðð»èµÄ¢Ü·B
		if(time_of_500m < 35.5 && time_of_1000m < 71.0){
			System.out.println("AAA");
		}else if(time_of_500m < 37.5 && time_of_1000m < 77.0){
			System.out.println("AA");
		}else if(time_of_500m < 40.0 && time_of_1000m < 83.0){
			System.out.println("A");
		}else if(time_of_500m < 43.0 && time_of_1000m < 89.0){
			System.out.println("B");
		}else if(time_of_500m < 50.0 && time_of_1000m < 105.0){
			System.out.println("C");
		}else if(time_of_500m < 55.0 && time_of_1000m < 116.0){
			System.out.println("D");
		}else if(time_of_500m < 70.0 && time_of_1000m < 148.0){
			System.out.println("E");
		}else{
			System.out.println("NA");
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, a, ans = 0;

	cin >> N;
	rep(i, N) {
		cin >> a;
		ans += a - 1;
	}

	cout << ans << endl;

	return 0;
}


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

#define M 1000000007

long rec(long m, long n) {
   if(n == 1) return m % M;
   long long m2 = rec((m % M) * (m % M), n / 2);
   if(n % 2 == 1) {
       m2 = (m2 * (m % M));
   }
   return m2 % M;
}

int main(){
  long m,n;
  cin >> m >> n;
  cout << rec(m, n)<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>
int main(){
int N,T,i,a,b;
int t[200001];
scanf("%d%d",&N,&T);
for(i=0;i<N;i++){
scanf("%d",&t[i]);
}
a=0;
for(i=0;i<N-1;i++){
b=T;
if(t[i+1]-t[i]<T){
b=t[i+1]-t[i];
}
a+=b;
}
a+=T;
printf("%d\n",a);
return 0;
}

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

int main(void)
{
  vector<string> S(3);
  for(int i=0;i<3;i++)cin>>S[i];
  cout<<S[0][0]<<S[1][1]<<S[2][2]<<endl;

  return 0;
}


Measured memory_bytes: 256