akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        CF_Reader in = new CF_Reader();

        int a = in.intNext(), b = in.intNext(), c = in.intNext();

        out.println(((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) ? "Yes" : "No");

        out.close();
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 21332
n = gets.to_i
a = gets.split.map(&:to_i)
ans = 0
sum = 0
l = 0
n.times do |r|
    while (sum+a[r]) != (sum^a[r])
        sum ^= a[l]
        l += 1
    end
    sum += a[r]
    ans += r-l+1
end
puts ans

Measured memory_bytes: 15364
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int t = x2 - x1;
    int s = y2 - y1;
    cout << x2 - s << " " << y2 + t << " " << x1 - s << " " << y1 + t << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int in;
	int a;	
	int count=0;
	cin>>in;
	a=in;
	while(a>0){
		count+=a%10;
		a/=10;
	}
	if(in%count==0) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  string ans;
  rep(i,N)
  {
    if(S[i]=='0') ans.pb('0');
    else if(S[i]=='1') ans.pb('1');
    else
    {
      if(ans.size()>0) ans.pop_back();
    }
    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
A,B,C,D,E=(int(input()) for _ in range(5))
X=[A,B,C,D,E]
time=0
rest=[]
for i in range(5):
    if X[i]%10!=0:
        time+=(X[i]//10+1)*10
    else:
        time+=X[i]
    rest.append((10-X[i]%10)%10)
time-=max(rest)
print(time)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

typedef pair<long long int, long long int> P;

int main() {
	long long int h, w, n;
	cin >> h >> w >> n;
	vector<P> d(n);
	for (long long int i = 0; i < n; i++) {
		long long int a, b;
		cin >> a >> b;
		d[i] = P(a, b);
	}
	sort(d.begin(), d.end());
	vector<long long int> r(10, 0);
	long long int dx[3][9] = {{0, 1, 2, 0, 1, 2, 0, 1, 2},
							  {-1, 0, 1, -1, 0, 1, -1, 0, 1},
							  {-2, -1, 0, -2, -1, 0, -2, -1, 0}};
	long long int dy[3][9] = {{0, 0, 0, 1, 1, 1, 2, 2, 2},
							  {-1, -1, -1, 0, 0, 0, 1, 1, 1},
							  {-2, -2, -2, -1, -1, -1, 0, 0, 0}};

	for (long long int i = 0; i < n; i++) {
		//cout << d[i].first << ' ' << d[i].second << endl;
		for (int j = 0; j < 9; j++) {
			int dxx = j%3;
			int dyy = j/3;
			int rr = 0;
			for (int k = 0; k < 9; k++) {
				P kk = P(d[i].first+dx[dxx][k], d[i].second+dy[dyy][k]);
				if (kk.first <= 0 || kk.second <= 0 || kk.first > h || kk.second > w) {
					rr = -1;
					break;
				} else {
					vector<P>::iterator ite = lower_bound(d.begin(), d.end(), kk);
					if (ite != d.end() && *(ite) == kk) {
						//cout << i << ' ' << j << ' ' << k << ' ' << kk.first << ' ' << kk.second << endl;
						rr++;
					}
				}
			}
			if (rr != -1) {
				//cout << rr << endl;
				r[rr]++;
			}
		}
	}
	r[0] = (w-2)*(h-2);
	for (long long int i = 1; i < 10; i++) {
		r[i] /= i;
		r[0] -= r[i];
	}

	for (int i = 0; i < 10; i++) {
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
                     
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
const ll mod = 1e9+7;
ll mult(ll a,ll b){return ((a%mod)*(b%mod))%mod;}
ll add(ll a,ll b){return ((a%mod)+(b%mod))%mod;}
ll sub(ll a,ll b){return ((a%mod)-(b%mod)+mod)%mod;} 
int n;
vector<vector<int>> a;
vector<vector<ll>> dp;
ll fun(int cidx, int mask){
    if(cidx==n) return 1;
    if(dp[cidx][mask]!=-1){
        return dp[cidx][mask];
    }
    ll ans = 0;
    for(int j=0;j<n;++j){
        if(a[cidx][j]==1 && ((mask & (1<<j))== 0)){
            ans = add(ans, fun(cidx+1,mask | (1<<j)));
        }
    }
    return dp[cidx][mask] = ans;
}
int solve(){
    cin>>n;
    a.resize(n, vector<int>(n));
    dp.resize(n+1, vector<ll>(1<<(n+1), -1));
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            cin >> a[i][j];
        }
    }
    cout<<fun(0, 0);

    return 0;
}
int main(){
    fast;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 756936
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

map<LL,LL> ma;

LL f(LL N){
    if(ma[N]) return ma[N];
    if(N==0) return 1;
    if(N==1) return 2;
    return ma[N]=(f(N/2)+f((N-1)/2)+f((N-2)/2))%mod;
}

int main(){
    LL N;
    cin >> N;
    cout << f(N) << endl;
    return 0;
}

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

int main(){
  int n;cin>>n;
  string s;cin>>s;
  int r = 0,b = 0;
  fol(i,n){
    if(s[i]=='B')b++;
    else r++;
  }
  if(r > b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
return 0;
}


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

main()
{
    int a,b;
    string op;
    do
        {
        cin >> a >> op >> b;
    
        if (op == "+")
            cout << a+b << endl;
        else if (op == "-")
            cout << a-b << endl;
        else if (op == "*")
            cout << a*b << endl;
        else if (op == "/")
            cout << a/b << endl;
        else if (op == "?")
            return 0;
        }
    while( op != "?");
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    
        int a, b ,c;
        cin >> a >> b >>c;
        cout << min(b/a, c) << "\n";

    return 0;
}

Measured memory_bytes: 256
using System;
class yoku
{
    public static string toku(double a)
    {
        string c;
        if (a <= 48.00)
            c ="light fly";
        else if (a <= 51.00)
            c ="fly";
        else if (a <= 54.00)
            c ="bantam";
        else if (a <= 57.00)
            c ="feather";
        else if (a <= 60.00)
            c ="light";
        else if (a <= 64.00)
            c ="light welter";
        else if (a <= 69.00)
			c="welter";
        else if (a <= 75.00)
			c="light middle";
        else if (a <= 81.00)
			c="middle";
        else if (a <= 91.00)
			c="light heavy";
        else if (a > 91.00)
			c="heavy";
		else
			c="ghgj";
        return c;
    }
}
class aoj
{
    static void Main()
    {
		string []g=new string[50];
        int i=0;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            double b = double.Parse(a);
            yoku yoku = new yoku();
            string c=yoku.toku(b);
			g[i]=c;
			i++;
        }
        for(int j=0;j<i;j++)
			Console.WriteLine(g[j]);     
        
    }
}

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	int N,ans=0;
	cin >> N;
	vector<int> B(N-1);
	FOR(i,0,N-1)cin >> B[i];
	ans += B[N-2];
	ans += B[0];
	FORR(i,1,N-1){
		ans += min(B[i],B[i-1]);
	}
	cout << ans << endl;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


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


int main(){
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;


  char c = s[0];
  ll cnt = 0;
  rep(i, n){
    if(c == s[i]) continue;

    cnt++;
    c = s[i];
  }

  cout << (n-1) - max(0ll, cnt - 2*k) << endl;


  return 0;
}


Measured memory_bytes: 512
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

char a[104];
char b[204];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scanf("%s", a);
    scanf("%s", b);
    int an = strlen(a);
    int bn = strlen(b);
    for (int i = 0; i < an; i++)
        b[bn++] = a[i];

    b[an+bn] = 0;
    printf("%s\n", b);

    return 0;
}


Measured memory_bytes: 256
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int n;
	cin >> n;
	vll ar(n);
	for(int i = 0; i < n; ++i) {
		cin >> ar[i];
	}
	// Compute prefix.
	for(int i = 1; i < n; ++i) {
		ar[i] += ar[i - 1];
	}
	ll dp[n][n];
	for(int L = n - 1; L >= 0; --L) {
		for (int R = L; R < n; ++R) {
			if(L == R) {
				dp[L][R] = 0;
			} else {
				dp[L][R] = 1e18 + 5;
				for(int i = L; i < R; ++i) {
					dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R] + ar[R] - ((L > 0) ? ar[L - 1] : 0));
				}
			}
		}
	}
	cout << dp[0][n - 1] << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x-r < 0||W<r+x||y-r<0||H<r+y) {
		cout << "No" << endl;
	}else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
   long long a,b,k;
   cin >> a >> b >> k;
   if((a+b)<k){
       cout << 0 << ' ' << 0 << endl;
   }
   else if(a==0 || a<k){
       cout << 0 << ' ' << a+b-k << endl;
   }
   else{
       cout << a-k << ' ' << b << endl;
   }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define INF 1000000
#define W 0
#define B 1


int main(){

  int i,j,n,count=0;
  int u,k,a,c,v,mincost;
  int G[N][N],color[N],d[N],pi[N];

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      G[i][j]=-1;
    }
  }

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      G[u][v]=c;
    }
  }

  for(i=0;i<n;i++){
    color[i]=W;
    pi[i]=-1;
    d[i]=INF;
  }

  d[0]=0;

  while(1){

    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=2 && d[i]<mincost){
	mincost=d[i];
	a=i;
      }
    }
    
    if(mincost==INF){
      break;
    }

    color[a]=2;

    for(i=0;i<n;i++){
      if(G[a][i]!=-1 && color[i]!=2 && (G[a][i]+d[a])<d[i]){
	pi[i]=a;
	d[i]=G[a][i]+d[a];
	color[i]=B;
      }
    }
  }

  for(i=0;i<n;i++)printf("%d %d\n",i,d[i]);

  return 0;

}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;
int main()
{
    int k, x;
    cin >> k >> x;

    for (int i = max(x - k + 1, -1000'000); i <= min(x + k - 1, 1000'000); i++)
    {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
using namespace std;
int N, W; int dp[101][10001];
struct Item
{
  int v, w;
  Item() {}
  Item(int v, int w): v(v), w(w) {}
};
vector<Item> items;

void solve()
{
  int maxv = 0;
  for(int i=1; i<=items.size(); i++)
  {
    Item item = items[i-1];
    for(int j=1; j<=W; j++)
    {
      if(j - item.w >= 0)
      {
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-item.w] + item.v);
        //maxv = dp[i][j];
      }
      else
      {
        dp[i][j] = dp[i-1][j];
        //maxv = dp[i][j];
      }
    }
  }
  maxv = dp[N][W];
  printf("%d\n", maxv);
}
int main()
{
  scanf("%d%d", &N, &W);
  int v, w;
  for(int i=0; i<N; i++)
  {
    scanf("%d%d", &v, &w);
    items.push_back(Item(v, w));
  }
  memset(dp, 0, sizeof(dp));
  solve();
  return 0;
}



Measured memory_bytes: 7176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e9

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

int ey[] = {0, 1, 0, -1};
int ex[] = {1, 0, -1, 0};

void solve(void) {
  int h, w;
  cin >> h >> w;
  int ch, cw, dh, dw;
  cin >> ch >> cw >> dh >> dw;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  --ch, --cw, --dh, --dw;
  vector<vi> f(h, vi(w, INF));
  f[ch][cw] = 0;
  deque<pii> q;
  q.emplace_back(ch, cw);
  while (!q.empty()) {
    int y = q.front().fi;
    int x = q.front().se;
    int d = f[y][x];
    q.pop_front();
    if (f[y][x] != d) continue;
    rep(v, 4) {
      int ny = y + ey[v];
      int nx = x + ex[v];
      if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
      if (s[ny][nx] == '#') continue;
      if (f[ny][nx] <= d) continue;
      f[ny][nx] = d, q.emplace_front(ny, nx);
    }
    for (int i = -2; i < 3; ++i) {
      for (int j = -2; j < 3; ++j) {
        int ny = y + i;
        int nx = x + j;
        if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
        if (s[ny][nx] == '#') continue;
        if (f[ny][nx] <= d + 1) continue;
        f[ny][nx] = d + 1, q.emplace_back(ny, nx);
      }
    }
  }
  ll ans = f[dh][dw];
  if (ans == INF) ans = -1;
  cout << ans << endl;
}
int main(void) { solve(); }


Measured memory_bytes: 9444
n = int(input())

def depth_first_search(s):
    if int(s) > n:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        #print(c)
        #print(s + c)
        ret += depth_first_search(s + c)
        #print(ret)
    return ret

print(depth_first_search('0'))

Measured memory_bytes: 9172
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
bool isPrime(ll x){
    if(x < 2) return false;
    if(x == 2) return true;
    if(x % 2 == 0) return false;
    for(ll i = 3;i <= sqrt(x) + 1;i += 2) if(x % i == 0) return false;
    return true;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    while(1){
        if(isPrime(X)){
            print(X);
            return 0;
        }
        X++;
    }


    

}

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

int main () {
	string s;
	cin>>s;
	if (s == "MON") {
		cout<<6<<endl;
	} else if (s == "TUE") {
		cout<<5<<endl;
	} else if (s == "WED") {
		cout<<4<<endl;
	} else if (s == "THU") {
		cout<<3<<endl;
	} else if (s == "FRI") {
		cout<<2<<endl;
	} else if (s == "SAT") {
		cout<<1<<endl;
	} else if (s == "SUN"){
		cout<<7<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//055
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1; i<=n; i++)
using namespace std;
int main(void){
    int n;
    int A = pow(10,9)+7;
    long p=1;
    cin >> n;
    rep(i, n){
        p = p*i; // p = AX + p%A
        p = p%A; 
        
        //cout << p << ' ' << i << endl;
    }
    cout << p << endl;
}

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

int main () {

	set <int> s;
	int a, b, c;
	cin >> a >> b >> c;

	s.insert (a);
	s.insert (b);
	s.insert (c);


	if (s.size() == 2) {
		cout << "Yes" << endl;
	} else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
k = int(input())

x = [int(num) for num in input().split()]

l = 0
for i in range(n):
    if x[i] <= k - x[i]:
        l += 2 * x[i]
    else:
        l += 2 * (k - x[i])

print(l)

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

#define INF 1.1e9
#define LINF 1.1e18
#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 pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,ll> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int N,Q;
ll L;
vector<ll> x;
int nxt[20][100000];

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

	REP(i,20) REP(j,100000) nxt[i][j]=INF;

	cin>>N;
	x.resize(N);
	REP(i,N) cin>>x[i];
	cin>>L>>Q;

	REP(i,N-1) {
		nxt[0][i]=upper_bound(ALL(x),x[i]+L)-x.begin()-1;
	}
	REP(k,17) {
		REP(i,N) {
			if(nxt[k][i]==INF) nxt[k+1][i]=INF;
			else nxt[k+1][i]=nxt[k][nxt[k][i]];
		}
	}

	/*for(int k=0;k*k<=N;k++) {
		REP(i,N) cout<<(nxt[k][i]==INF?0:nxt[k][i])<<' ';
		cout<<endl;
	}*/

	REP(i,Q) {
		int a,b;cin>>a>>b;a--,b--;
		if(a>b) swap(a,b);
		int p=a,ans=0;

		for(int i=17;i>=0;i--) {
			if(nxt[i][p]<b) {
				p=nxt[i][p],ans+=1<<i;
				//cout<<p<<' '<<ans<<endl;
			}
		}
		if(p<b) ans++;

		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 9472
while True:
    a,op,b = input().split()
    a=int(a)
    b=int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(int(a/b))
    elif op == "?":
        break


Measured memory_bytes: 5596
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
#define MAXN 100010
LL sum[MAXN],posi[MAXN],ans;
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		posi[i]=posi[i-1];
		scanf("%lld",&sum[i]);
		if(sum[i]>0) posi[i]+=sum[i];
		sum[i]+=sum[i-1];
	}
	for(int i=1;i+k-1<=n;i++)
	{
		LL tmp=posi[n]-posi[i+k-1]+posi[i-1]+max(0LL,sum[i+k-1]-sum[i-1]);
		ans=max(ans,tmp);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1664
// ABC142A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;

	double ans;
	if (N%2==1)
	{
		ans = double(N / 2 + 1) / double(N);
		printf("%1.10f\n", ans);
	}
	if (N%2==0)
	{
		ans = 0.5;
		printf("%1.10f\n", ans);
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
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; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


const long long MOD = 1000000007;
int N;
vector<int> c;

vector<int> last[210000];
long long dp[210000];


int main() {
    while (cin >> N) {
        c.resize(N);
        for (int i = 0; i < N; ++i) cin >> c[i];

        for (int i = 0; i < 210000; ++i) last[i].clear();
        for (int i = 0; i < N; ++i) {
            last[c[i]].push_back(i);
        }

        memset(dp, 0, sizeof(dp));
        dp[0] = 1;
        for (int i = 0; i <= N; ++i) {
            //cout << i << ": " << dp[i] << endl;
            if (i == N) continue;
            
            dp[i+1] += dp[i]; dp[i+1] %= MOD;

            int color = c[i];
            int it = lower_bound(last[color].begin(), last[color].end(), i)
                - last[color].begin();

            if (it + 1 < last[color].size()) {
                int j = last[color][it + 1];
                if (j - i > 1) {
                    dp[j] += dp[i]; dp[j] %= MOD;
                }
            }
        }
        cout << dp[N] << endl;
    }
}


Measured memory_bytes: 13824
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	while (cin >> n, n) {
		vi num(n);
		REP(i, n) {
			cin >> num[i];
		}
		vvi dp(n, vi(n, 0));
		FOR(i, 2, n + 1) {
			if (i == 2) {
				REP(j, n - 1)
					if (abs(num[j] - num[j + 1]) <= 1) {
						dp[j][j + 1] = 2;
					}
			}
			else {
				REP(j, n - (i - 1)) {
					REP(k, i - 1) {
						dp[j][j + i - 1] = max(dp[j][j + i - 1], dp[j][j + k] + dp[j + k + 1][j + i - 1]);
					}
					if ((i % 2 == 0) && (dp[j + 1][j + i - 2] == i - 2) && (abs(num[j] - num[j + i - 1]) <= 1))
						dp[j][j + i - 1] = i;
				}
			}
		}
		cout << dp[0][n - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


typedef pair<int, int> P;
struct Point{
	int x, y;
};
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = {1,0,-1,0};


int main(){

	int N;
	cin >> N;
	for (int i = 0; i < 100; i++){
		for (int j = 0; j < 100; j++){
			if (i * 4 + j * 7 == N){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] q = new int[n];
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
			q[i] = i + 1;
		}
		for(int i = 0; i < n; i++) {
			if (p[i] != q[i])
				cnt++;
		}
		if (cnt == 0 || cnt == 2)
			out.println("YES");
		else
			out.println("NO");
	}
}

Measured memory_bytes: 23124
#include  "bits/stdc++.h"
//#include  <iostream>
 using namespace std;
 
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define mem(a,v)    memset((a), (v), sizeof (a))
#define FOR(i,a,n)  for(int i = (a); i<(n); ++i) 
#define FORE(i,a,n) for(int i = (a); i<=(n); ++i)
#define mp(a , b)   make_pair(a , b)
#define pb(a)       push_back(a)

#define anal         '\n'

#define M 1000000007 
typedef long long ll;


int main(){
     
    IOS;
    
 //   freopen("input.in", "r", stdin);
  //  freopen("output.in", "w", stdout);
    
   int n;
    cin>>n;
  
   printf("%0.3f",2*3.14*n);


 

  return  0 ;
   	    
}


Measured memory_bytes: 3756
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(a > k) ans = k;
    else {
        ans = a;
        if (a + b  <= k ) ans -= (k - a - b);
    }
    // else if ( a + b  <= k && a + b + c > k) ans -= c -a -b;
    cout << ans << endl;
    
    
    return 0;
}

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

int n,m,res;

int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	if(n>m) res+=n,n--;
	else res+=m,m--; 
	if(n>m) res+=n,n--;
	else res+=m,m--; 
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
// Mon Aug 24 16:24:09 IST 2020        
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7; 
const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
int n,m;
bool vis[N];
int c;
vector <int> g[N];
void dfs(int node){
    if(vis[node])
        return ;
    c++;
    vis[node] = true;
    for(auto child : g[node])
        if(!vis[child])
            dfs(child);
}
int tests(){ 
    cin >> n >> m;
    int a,b;
    forn(i,0,m){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans =0;
    forn(i,1,n+1)
        if(!vis[i]){
            c = 0;
            dfs(i); 
            ans = max(ans,c);
        }
    cout << ans  << '\n';
    return 0;
}
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    string S[3];
    cin >> S[0] >> S[1] >> S[2];
    int n[3];
    n[0] = n[1] = n[2] = 0;
    int next = 0;
    int ans = 0;
    while (true) {
        char c = S[next][n[next]];
        n[next]++;
        if (c == 'a') {
            next = 0;
        } else if (c == 'b') {
            next = 1;
        } else {
            next = 2;
        }
        if (n[next] == S[next].length()) {
            ans = next;
            break;
        }
    }
    if (ans == 0) {
        cout << "A" << endl;
    } else if (ans == 1) {
        cout << "B" << endl;
    } else {
        cout << "C" << endl;
    }
}


Measured memory_bytes: 256
import  sys

t = input()

for i in range(len(t)):
    if i % 2 == 0:
        if t[i] == "R" or t[i] == "U" or t[i] == "D":
            continue
        else:
            print("No")
            sys.exit()
    else:
        if  t[i] == "L" or t[i] == "U" or t[i] == "D":
            continue
        else:
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int A[MAX],B[MAX];
int AC[MAX],BC[MAX];
set<pair<int,int> > S;
set<pair<int,int> >::iterator it;
int main()
{
    int N,inp,i;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&A[i]);
        AC[A[i]]++;
    }
    for(i=0;i<N;i++)
    {
        scanf("%d",&inp);
        BC[inp]++;
    }
    for(i=1;i<=N;i++)
    {
        if(AC[i]+BC[i]>N)
        {
            printf("No");
            return 0;
        }
        if(BC[i]>0) S.insert(make_pair(N-BC[i]-AC[i],i));
    }
    pair<int,int> p;
    printf("Yes\n");
    for(i=0;i<N;i++)
    {
        it=S.begin();
        //--it;
        if((*it).second==A[i]) ++it;
        p=(*it);
        S.erase(p);
        printf("%d ",p.second);
        p.first++;
        BC[p.second]--;
        if(BC[p.second]>0) S.insert(p);
        if(BC[A[i]]>0)
        {
            p=make_pair(N-BC[A[i]]-AC[A[i]],A[i]);
            S.erase(p);
            p.first++;
            S.insert(p);
        }
        AC[A[i]]--;
    }
    return 0;
}


Measured memory_bytes: 15360
#include <stdio.h>
#include <string.h>

int main(){
	int min,max,i,n,z;
	char s[10];
	char m[]="Male";
	char f[]="Female";
	char v[]="Vacant";
	char b[10];

	scanf("%d",&n);
	printf("0\n");
	fflush(stdout);
	scanf("%s",s);
	if(strncmp(s,v,1)==0){
		return 0;
	}
	if(strncmp(s,m,1)==0){
	  strcpy(b,m);
	}else{
		strcpy(b,f);
	}
	min=0;
	max=n-1;
	for(i=1;i<20;i++){
		z=(min+max+1)/2;
		printf("%d\n",z);
		fflush(stdout);
		scanf("%s",s);
		if(strncmp(s,v,1)==0){
			return 0;
		}
		if((z-min+1)%2==0){
  		if(strncmp(s,b,1)==0){
	  		max=z;
	  	}else{
		  	min=z;
				strcpy(b,s);
		  }
		}else{
			if(strncmp(s,b,1)!=0){
	  		max=z;
	  	}else{
		  	min=z;
				strcpy(b,s);
		  }
		}
		//strcpy(b,s);
	}
	return 0;
}


Measured memory_bytes: 756
#include <iostream>
#include <queue>
#include <cstdio>
#include <string.h>
using namespace std;
bool flag[52][52][52][52]={};
int Rv[]={0,1,0,-1};
int Lv[]={0,-1,0,1};
int Yv[]={1,0,-1,0};
int main(){
	int W,H;
	while(cin>>W>>H,W){
		char Len[52][52],Rin[52][52];
		memset(flag,0,sizeof(flag));
		for(int i=0;i<52;i++)for(int j=0;j<52;j++)Len[i][j]=Rin[i][j]='#';
		queue<int>LxQ;
		queue<int>LyQ;
		queue<int>RxQ;
		queue<int>RyQ;
		
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				cin>>Len[j][i];
				if(Len[j][i]=='L')LxQ.push(j),LyQ.push(i);
			}
			for(int j=1;j<=W;j++){
				cin>>Rin[j][i];
				if(Rin[j][i]=='R')RxQ.push(j),RyQ.push(i);
			}
		}
		int ans=0;
		
		while(LxQ.empty()==0){
			int Lx,Ly,Rx,Ry;
			Lx=LxQ.front();
			Ly=LyQ.front();
			Rx=RxQ.front();
			Ry=RyQ.front();
			
			if(Len[Lx][Ly]=='%'&&Rin[Rx][Ry]=='%'){
				ans=1;
				break;
			}
			else if(Len[Lx][Ly]=='%'||Rin[Rx][Ry]=='%'){
				
			}
			else{
				for(int i=0;i<4;i++){
					Lx=LxQ.front();
					Ly=LyQ.front();
					Rx=RxQ.front();
					Ry=RyQ.front();
					if(Len[Lx+Lv[i]][Ly+Yv[i]]!='#')Lx+=Lv[i],Ly+=Yv[i];
					if(Rin[Rx+Rv[i]][Ry+Yv[i]]!='#')Rx+=Rv[i],Ry+=Yv[i];
					if(flag[Lx][Ly][Rx][Ry]==0){
						flag[Lx][Ly][Rx][Ry]=1;
						LxQ.push(Lx);
						LyQ.push(Ly);
						RxQ.push(Rx);
						RyQ.push(Ry);
						
					}
				}
			}
			
			LxQ.pop();
			LyQ.pop();
			RxQ.pop();
			RyQ.pop();
		}
		
		if(ans)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 9296
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i+j)%2 == 0) printf("#");
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2588
from collections import deque
n, m = map(int, input().split())
neighbor = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    neighbor[a].append(b)
    neighbor[b].append(a)

minv = [-1] * n
minv[0] = 0
length = [-1] * n
length[0] = 0


def dfs():
    global neighbor, length
    queue = deque([[0, 0]])
    while len(queue) > 0:
        v = queue.popleft()

        for nv in neighbor[v[0]]:
            if length[nv] == -1:
                length[nv] = v[1] + 1
                minv[nv] = v[0] + 1
                queue.append([nv, v[1] + 1])


dfs()

f = True
for i in minv:
    f &= i != -1

if not f:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print(minv[i])

Measured memory_bytes: 40508
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    string N;
    cin >> N;
    int count = 0;
    for(int i = 0; i < N.size(); ++i){
        count += N[i] - '0';
    }
    if(count % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 1e6+7;
ll read(){
    ll c = getchar(),Nig = 1,x = 0;
    while(!isdigit(c))
        c = getchar();
    if(c == '-')
        Nig = -1,c = getchar();
    while(isdigit(c))
        x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
    return Nig*x;
}
#define read read()
int prim[maxn],cnt;
bool vis[maxn];
void init(){
    for(int i=2;i<maxn;i++){
        if(vis[i])continue;
        prim[cnt++] = i;
        for(int j=i+i;j<maxn;j+=i)
            vis[j] = 1;
    }
}
ll Pow(ll a,int b){
    ll ans = 1;
    while(b){
        if(b&1)
            ans *= a;
        a = a*a;
        b >>= 1;
    }
    return ans;
}
int main(){
    init();
    ll n = read, p = read,ans = 1;
    for(int i=0;i<cnt && prim[i]<=p ;i++){
        if(p%prim[i]==0){
            int c = 0;
            while(p%prim[i]==0)
                p/=prim[i],c++;
            if(c>=n)
                ans*=Pow(1ll*prim[i],c/n);
        }
    }
    if(p!=1){
        if(n == 1)
            ans *= p;
    }
    printf("%lld\n",ans);
	return 0;
}


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

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

const int N=200010;
struct Edge{int to,capa,next;} e[N];
int h[N],sum=0,n,m;
bool vis[N];
int cmt,cnt,col[N],c[3];
bool falun;

inline int color(const int &x)
{
    if(x>=3) return x-3;
    if(x<0) return x+3;
    return x;
}

void add_edge(int u,int v,int w)
{
    e[++sum].to=v;
    e[sum].capa=w;
    e[sum].next=h[u];
    h[u]=sum;
}

void dfs(int u)
{
    c[col[u]]++;vis[u]=1;cnt++;
    for(int tmp=h[u];tmp;tmp=e[tmp].next)
    {
        cmt+=(e[tmp].capa==1);
        int v=e[tmp].to;
        if(!vis[v]) col[v]=color(col[u]+e[tmp].capa),dfs(v);
        else if(col[v]!=color(col[u]+e[tmp].capa)) falun=0;
    }
}

int main()
{
    int u,v;
    n=read();m=read();
    for(int i=1;i<=m;i++)
    {
        u=read();v=read();
        add_edge(u,v,1);
        add_edge(v,u,-1);
    }
    long long ans=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i]) continue;
        memset(c,0,sizeof(c));
        cmt=cnt=0;falun=1;
        dfs(i);
        if(!falun) ans+=1ll*cnt*cnt;
        else if(c[0]&&c[1]&&c[2]) ans+=1ll*c[0]*c[1]+1ll*c[1]*c[2]+1ll*c[2]*c[0];
        else ans+=cmt;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
vector<int> v1(114514),v2(114514);
int main(){
	int n,max1=0,max2=0,m1=0,m2=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(i%2==0){
			v1[x]++;
			if(v1[x]>max1){m1=x;max1=v1[x];}
		}
		else{
			v2[x]++;
			if(v2[x]>max2){m2=x;max2=v2[x];}
		}
	}
	sort(v1.begin(),v1.end(),greater<int>() );
	sort(v2.begin(),v2.end(),greater<int>() );
	if(m1!=m2){
		cout<<n-(v1[0]+v2[0])<<endl;
	}
	else{
		cout<<n-(max(v1[0]+v2[1], v1[1]+v2[0]))<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
using namespace std;
#define N 158
int n,s,p,dp1[N],dp2[N][N][N],pw[N];
int solve(int m)
{
	dp1[0]=1;
	for(int i=1;i<=m;i++)
	{
		if(i>s/2+1)dp1[i]=(2ll*dp1[i-1]-dp1[i-s/2-2]+p)%p;
		else if(i==s/2+1)dp1[i]=(2ll*dp1[i-1]-1+p)%p;
		else dp1[i]=2ll*dp1[i-1]%p;
	}
	return dp1[m];
}
int main()
{
	scanf("%d%d%d",&n,&s,&p);
	pw[0]=1;for(int i=1;i<=150;i++)pw[i]=pw[i-1]*2%p;
	if(~s&1)printf("%lld\n",1ll*solve(n/2)*solve(n-n/2)%p);
	else 
	if(s==1) s=4,printf("%d\n",solve(n));
	else 
	{
		int l2=n/2,l1=n-n/2;
		if(n<=s){int as=1;for(int i=1;i<=n;i++)as=as*2%p;printf("%d\n",as);return 0;}
		for(int i=0;i<=(s+1)/2;i++)dp2[0][0][i]=(s+1)/2==i?1:pw[(s+1)/2-i-1];
		for(int i=0;i<l1-(s+1)/2;i++)
		for(int j=0;j<=s+1;j++)
		for(int k=0;k<=n;k++)
		if(dp2[i][j][k])
		{
			dp2[i+1][0][0]=(dp2[i+1][0][0]+dp2[i][j][k])%p;
			dp2[i+1][0][k+1]=(dp2[i+1][0][k+1]+dp2[i][j][k])%p;
			if(j<s+1)
			{
				dp2[i+1][j==0?0:j+1][0]=(dp2[i+1][j==0?j:j+1][0]+dp2[i][j][k])%p;
				int st=j<k+1?k+2:j+1;
				if(st<=s+1)dp2[i+1][st][k+1]=(dp2[i+1][st][k+1]+dp2[i][j][k])%p;
			}
		}
		int as=0,ls=l2-(l1-(s+1)/2);
		for(int i=0;i<=s+1;i++)
		for(int j=0;j<=n;j++)
		{
			int tp=dp2[l1-(s+1)/2][i][j],s1=pw[ls];
			if(ls-(s+2-i)>=0)
			s1=(s1-pw[ls-(s+2-i)]+p)%p;
			as=(as+1ll*tp*s1)%p;
		}
		printf("%d\n",as);
	}
}//

Measured memory_bytes: 6528
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
a = 0
t = 1
d = 0
hoge_list = []
visit = [False for _ in range(n+1)]
while a < k:
  hoge_list.append(t)
  t = a_list[t-1]
  a += 1
  if visit[t]:
    b = hoge_list.index(t)
    d += 1
    break
  visit[t]=True
if d == 0:
  print(t)
else:
  e = (k-b)%(a-b)
  print(hoge_list[b+e])


Measured memory_bytes: 32376
#include<bits/stdc++.h>//万能库
using namespace std;
unsigned long long int n,fn,f0=2,f1=1;
int main()
{
    cin>>n;
    if(n==0) cout<<2;
    if(n==1) cout<<1;
    else 
    {
    for(int i=2;i<=n;i++)
    {
    	fn=f0+f1;
    	f0=f1;
    	f1=fn;
	}
    cout<<fn;
    } 
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String s=reader.readLine();
			if(s==null)break;
			String[] t=s.split(" ");
			int a,b;
			a=Integer.parseInt(t[0]);
			b=Integer.parseInt(t[1]);
			int sum=a+b;
			int co=0;
			while(sum>0){
				co++;
				sum/=10;
			}
			System.out.println(co);
		}
	
	}
}

Measured memory_bytes: 16988
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()

mod=10**9+7

dp=[-1 for i in range(n+1)]
dp[0]=1
dp[1]=1
for i in range(m):
  a=int(input())
  dp[a]=0

for i in range(2,n+1):
  if dp[i]==0:
    continue
  num=dp[i-2]+dp[i-1]
  num%=mod
  dp[i]=num

print(dp[-1])

Measured memory_bytes: 79136