akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#include <map>

#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define Abs(a) (a)>0?(a):(-(a))
template <typename QvQ> inline QvQ Min2(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max2(QvQ a,QvQ b){if(a>b) return a;return b;}
template <typename QvQ> inline QvQ Abs2(QvQ a){if(a>0) return a;return -a;}

#define n1kw 10000000
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f

#define ll __int128
#define rei register int
#define inv inline void
#define inb inline bool
#define ini inline int

#define bl putchar(' ')
#define ed putchar('\n')
#define test std::cout<<"this:"
#define card system("pause")

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

//char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)

template <typename QvQ>inv read(QvQ &x)
{
    x=0;int f=1;
    char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
    x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
    if(x<0) x=-x,putchar('-');
    if(x>9) write(x/10);
    putchar(x%10+48);
}
using namespace std;
#define MAXN 300005
int n,a[MAXN];
int main()
{
    read(n);
    for(rei i=1;i<=n;++i) read(a[i]);
    int tp=a[1];
    for(rei i=2;i<=n;++i) tp^=a[i];
    if(tp==0) puts("Yes");
    else puts("No");
    return 0;
}

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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b && b == c) cout << 1 << endl;
	else if(a == b || b == c || c == a) cout << 2 << endl;
	else cout << 3 << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  map<string, int> m;
  for(int i = 0; i < N; i++){
    string s; cin >> s;
    m[s]++;
  }
  int ma = 0;
  for(auto p : m){
    ma = max(p.second, ma);
  }
  vector<string> res;
  for(auto p : m){
    if(p.second == ma) res.push_back(p.first);
  }
  sort(res.begin(), res.end());
  for(string s : res){
    cout << s << endl;
  }
}


Measured memory_bytes: 26868
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define REP(i,n) for(A[i+1]=A[i];i<=(n);i++)

const double PI=acos(-1.0);

int N,M,Q; vi a,b,c,d; int A[11],dis[100]; 
void input()
{
    cin>>N>>M>>Q;
    for(int i=0;i<Q;++i){
        int p,q,r,s; cin>>p>>q>>r>>s;
        a.emplace_back(p);
        b.emplace_back(q);
        c.emplace_back(r);
        d.emplace_back(s);
    }
}

int check(){
    int res=0;
    for(int i=0;i<Q;++i){
        if(A[b[i]]-A[a[i]]==c[i]) res+=d[i];
    }
    return res;
}

void dfs(int n, int pre, int &ans){
    if(n>N){
        for(int i=0;i<Q;++i) ans=max(check(),ans);
    } else {
        for(int i=pre;i<=M;++i){
            A[n]=i;
            dfs(n+1,i,ans);
        }
    }
}

void solve()
{
    int ans=0;
    dfs(1,1,ans);
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  while(true){
    LL n, k;
    cin >> n >> k;
    if(n==0&&k==0){
      break;
    }

    bool flag = false;
    vector<bool> v(n, false);

    REP(i,k){
      LL a;
      cin >> a;
      if(a==0){
        flag = true;
      }else{
        v[a - 1] = true;
      }
    }

    LL max = 0;

    LL num0 = 0;
    LL num1 = 0;

    REP(i,n){
      if(v[i]){
        num0++;
        num1++;
      }
      else
      {
        num1 = 0;
        if (flag)
        {
          num1 = num0 + 1;
        }
        num0 = 0;
      }

      if(num0>max){
        max = num0;
      }
      if(num1>max){
        max = num1;
      }
    }
    cout << max << endl;
  }
}



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

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

  int Sum = 0;

  for(int i = 0; i < N; i++) {
    int I, R;
    cin >> I >> R;
    Sum += R - I + 1;
  }

  cout << Sum << endl;
}


Measured memory_bytes: 256
#include <bitset>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main()
{
    auto computePrimes = [](int n) {
        vector<int> r;
        bitset<500'000> b;
        auto t = b;
        t.set();
        t[0] = false;
        t[1] = false;
        int i = 0;
        while (true) {
            bool done = false;
            while (!t[i]) {
                ++i;
                if (i == t.size()) {
                    done = true;
                    break;
                }
            }
            if (done) {
                break;
            }

            b[i] = true;
            if (i > n) {
                r.push_back(i);
                if (r.size() >= 25) {
                    break;
                }
            }
            for (int j = i; j < t.size(); j += i) {
                t[j] = false;
            }
        }
        return r;
    };

    while (true) {
        int n, p;
        cin >> n >> p;
        if (n == -1 && p == -1) {
            return 0;
        }

        const auto primes = computePrimes(n);
        priority_queue<int, vector<int>, greater<>> q;
        for (int i = 0; i < primes.size(); ++i) {
            for (int j = i; j >= 0; --j) {
                q.push(primes[i] + primes[j]);
            }
        }
        for (int i = 0; i < p - 1; ++i) {
            q.pop();
        }
        cout << q.top() << endl;
    }
}


Measured memory_bytes: 3168
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> t(M);
  for (int i = 0; i < M; i++) cin >> t[i];
  sort(t.begin(), t.end());
  
  vector<int> d(M-1);
  for (int i = 0; i < M-1; i++) {
    d[i] = t[i+1] - t[i];
  }
  sort(d.begin(), d.end(), greater<int>());

  int ans = 0;
  for (int i = N-1; i < M-1; i++) {
    ans += d[i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 1792
from collections import Counter
n=int(input())
a=list(map(int,input().split()))

cnt=Counter(a)
#print(cnt)
cand=[]
for k,v in cnt.items():
    if 2<=v<4:
        cand.append([k,2])
    elif 4<=v:
        cand.append([k,2])
        cand.append([k,2])
cand=sorted(cand,reverse=True)
print(cand[0][0]*cand[1][0] if len(cand)>=2 else 0)


Measured memory_bytes: 18600
#include<iostream>
using namespace std;
int selectionSort(int p[],int n){
    int sw=0;
    int min=0;
    for(int i=0;i<n-1;++i){
        min=i;
        for(int j=i+1;j<n;++j){
            if(p[j]<p[min])
               min=j;
        }
        if(min!=i){int t=p[i];p[i]=p[min];p[min]=t;sw++;}
    }
    return sw;
}
int main(){
    int n;
    cin>>n;
    int *p=new int[n];
    for(int i=0;i<n;++i)cin>>p[i];
    
    int m=selectionSort(p,n);
    
    for(int i=0;i<n-1;++i)cout<<p[i]<<' ';
    cout<<p[n-1]<<endl;
    cout<<m<<endl;
    return 0;
    
}


Measured memory_bytes: 3100
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define INF 1000000000
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N,M;
	cin>>N>>M;
	VI cnt(N,0);
	//map<int,int>city;
	vector<pair<int,int> > id;
	vector<pair<int,pair<int,int> > > py;
	REP(i,M){
		int x,y;
		cin>>x>>y;
		id.push_back(make_pair(x,0));
		py.push_back(make_pair(y,make_pair(x,i)));
	}
	SORT(py);
	REP(i,M){
		//city[py[i].second.second]++;
		id[py[i].second.second].second=cnt[py[i].second.first]+1;
		cnt[py[i].second.first]++;
	}
	REP(i,M){
		printf("%06d%06d\n",id[i].first,id[i].second);
	}
	
	return 0;
}

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

int main(){
  int N;
  int A,B,ans = 0,cnt,tmp;

  cin >> N >> A >> B;
  for(int i = 1; i <= N; i++){
    cnt = 0;
    tmp = i;

    for(int j = 0; j < 5; j++){
      cnt += tmp%10;
      tmp /= 10;
    }

    //cout << cnt << endl;
    if(A <= cnt and cnt <= B) ans += i;
  }

  cout << ans << endl;
  return 0;



}

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

int main(){
  int n;
  cin >> n;
  vector<int> Ps(n);
  
  for(int i = 0; i < n; i++){
    cin >> Ps.at(i);
  }  
  
  int ans = 0;
  for(int i = 1; i< n-1;i++){
      if((Ps.at(i-1) < Ps.at(i) && Ps.at(i) < Ps.at(i+1) )||
         (Ps.at(i+1) < Ps.at(i) && Ps.at(i) < Ps.at(i-1) )){
        ans++;
      }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
  string a;
  int cnt,cnt2;
  cin>>a;
  if(a.size()<3)cout<<"Rabbit"<<endl;
  else{
    while(1){
      cnt=0,cnt2=0;
      int i,size=a.size();
      for(i=0;i<size-2;i++){
        string b;
        b+=a[i];
        b+=a[i+1];
        b+=a[i+2];
        if(b=="mew"){
          for(int j=0;j<3;j++)a.erase(a.begin()+i);
          cnt=1;
          if(a[i]=='m')cnt2=1;
          break;
        }
      }
      if(cnt==0||cnt2==1){
        cout<<"Rabbit"<<endl;
        break;
      }else if(a.size()==0){
        cout<<"Cat"<<endl;
        break;
      }else if(cnt==1&&(i==0||i==size-3)){
          cout<<"Rabbit"<<endl;
          break;
      }
    }
  }
  return 0;
}

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

// 最大公約数
ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m % n);
}
// 最小公倍数
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main() {
    ll A, B;
    cin >> A >> B;
    ll l = lcm(A, B);
    cout << l << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int32_t main(){
	int n,m,t;
	cin>>n>>m>>t;
	n = max(n,m);
	int ans = t/n;
	ans += !!(t%n);
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
typedef vector<int> VI;
#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<pair<double, double>> answers;

    double a, b, c, d, e, f;
    while (cin >> a >> b >> c >> d >> e >> f) {
        pair<double, double> ans;
        ans.first = (e * c - b * f) / (a * e - b * d) + 0.0;
        ans.second = (a * f - d * c) / (a * e - b * d) + 0.0;
        answers.push_back(ans);
    }

    for (auto ans : answers) {
        cout.setf(ios::fixed);
        cout.precision(3);
        cout << ans.first << " " << ans.second << endl;
    }
    
    return 0;
}

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

int main() {
    int a,b;
    char s[2];
    scanf("%d %s %d",&a,s,&b);
    if(s[0]=='+') printf("%d\n", a+b);
    else printf("%d\n", a-b);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    ll ans=0;
    for(int a=1;a<n;a++){
        int bs=(n-1)/a;
        ans+=bs;
    }
    cout << ans;
    return 0;
}

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

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


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 10000000;
    for(int num = -100; num <= 100; num++) {
        int sums = 0;
        rep(i, n) sums += abs(a[i] - num)*abs(a[i] - num);
//cout << "sums: " << sums << " num: " << num << endl;
        ans = min(ans, sums);
    }

    cout << ans << endl;
}


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

int main( int argc, char *argv[] ){
   int length, height;

   if( scanf( "%d %d", &length, &height ) != 2 ){
      exit( 1 );
   }

   printf( "%d %d\n", length * height, 2 * ( length + height ) );
   return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

struct Point {
	sint x, y;
};

double distance(Point const& a, Point const& b) {
	return sqrt(double((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)));
}

void run() {
	auto const N = read<sint>();
	vector<Point> towns;
	for (sint i = 0; i < N; ++i) {
		sint x = read<sint>();
		sint y = read<sint>();
		towns.push_back({x, y});
	}
	double sum = 0.0;
	for (sint i = 0; i < N; ++i) {
		for (sint j = 0; j < N; ++j) {
			if (i == j) {
				continue;
			}
			sum += distance(towns[i], towns[j]);
		}
	}
	writeln(sum / N);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define log(x) cout << (#x) << " is " << (x) << endl


const ll MOD = 1000000007;

int main(int argc, char const *argv[])
{
    int x,y;
    cin>>x>>y;
    ll dp[x][y];
    string s;
    for(int i=0;i<x;i++){
      cin>>s;
      for(int j=0;j<y;j++){
        dp[i][j] = ((char)s[j] == '.') ? 1 : 0;
        if(dp[i][j] == 1 and (i>0 || j>0)){
          ll ways_from_top = i > 0 ? dp[i-1][j] : 0LL;
          ll ways_from_left = j > 0 ? dp[i][j-1] : 0LL;
          dp[i][j] = (ways_from_left + ways_from_top)%MOD;
        }
        // cout<<dp[i][j]<<" ";
      }
      // cout<<endl;
    }
    cout<<dp[x-1][y-1];
    return 0;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll n, K;
    cin >> n >> K;

    vector<ll> P(n);
    rep(i, n) cin >> P[i];
    vector<ll> C(n);
    rep(i, n) cin >> C[i];
    
    rep(i, n) P[i]--;

    ll res = -1e18;
    rep(start, n) {
        int cycleNum = 0;
        ll cycleSum = 0;
        int v = start;
        rep (i, K) {
            v = P[v];
            cycleNum++;
            cycleSum += C[v];
            if (v == start) {
                break;
            }
        }

        if (v != start || cycleSum <= 0) {
            //　ループしない
            ll val = 0;
            v = start;            
            rep (i, cycleNum) {
                v = P[v];
                val += C[v];
                res = max(res, val);
            }
            continue;
        }

        ll nLoop = K / cycleNum - 1;
        ll val = nLoop * cycleSum;
        ll step = nLoop * cycleNum;
        v = start;
        while (step < K) {
            v = P[v];
            val += C[v];
            res = max(res, val);
            step++;
        }
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
    int K;
    cin >> K;
    vector<int> A{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << A[K-1] << endl;

    return 0;
}


Measured memory_bytes: 256
# N = int(input("1以上100以下の数字を入れてください:"))
N = int(input())
if N % 2 ==0:
    print(N // 2) #N // 2にすると小数点以下が切り捨て（整数部分だけ表示される）→つまりint（整数）
else:
    print(N // 2 +1) #elseのインデントはifと揃える
"""
N % 2は割ったときの余りを見る
"""

Measured memory_bytes: 2940
def make_set(x, disjoint):
    disjoint[x] = x

def find_set(x, disjoint):
    if x not in disjoint.keys():
        make_set(x, disjoint)
    if x != disjoint[x]:
        disjoint[x] = find_set(disjoint[x], disjoint)
    return disjoint[x]

def link(x, y, disjoint):
    disjoint[y] = x

def unite(x, y, disjoint):
    link(find_set(x, disjoint), find_set(y, disjoint), disjoint)

def same(x, y, disjoint):
    if find_set(x, disjoint) == find_set(y, disjoint):
        return 1
    return 0

n, q = list(map(int, input().split()))
com_list = list()
x_list = list()
y_list = list()

for _ in range(q):
    com, x, y = list(map(int, input().split()))
    com_list.append(com)
    x_list.append(x)
    y_list.append(y)

disjoint = dict()

for i in range(q):
    com = com_list[i]
    x = x_list[i]
    y = y_list[i]

    if com == 0:
        unite(x, y, disjoint)
    else:
        print(same(x, y, disjoint))

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

int main(){
    int A[9];
    bool B[9];

    for(int i = 0; i < 9; i++){
        cin >> A[i];
        B[i] = false;
    }
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int c;
        cin >> c;
        for(int i = 0; i < 9; i++){
            if(c == A[i]){
                B[i] = true;
            }
        }
    }
    if( B[0] == true && B[1] == true && B[2] == true ) cout << "Yes" << endl;
    else if( B[3] == true && B[4] == true && B[5] == true ) cout << "Yes" << endl;
    else if( B[6] == true && B[7] == true && B[8] == true ) cout << "Yes" << endl;
    else if( B[2] == true && B[4] == true && B[6] == true ) cout << "Yes" << endl;
    else if( B[0] == true && B[4] == true && B[8] == true ) cout << "Yes" << endl;
    else if( B[0] == true && B[3] == true && B[6] == true ) cout << "Yes" << endl;
    else if( B[1] == true && B[4] == true && B[7] == true ) cout << "Yes" << endl;
    else if( B[2] == true && B[5] == true && B[8] == true ) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"


void solve()
{
  int n;cin>>n;
  int c=0;
  int flag=0;
  for(int i=1;i<=n;i++)
  {
      int a;int b;cin>>a>>b;
      if(a==b)
      {
          c++;
          if(c==3)
          flag=1;
      }
      else
      c=0;
  }
  if(flag==0)
  cout<<"No"<<endl;
  else
  cout<<"Yes"<<endl;
}
int32_t main() 
{

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

Measured memory_bytes: 3608
def upper_bound(arr, v)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m] <= v then l = m
    else r = m
    end
  end
  r
end
 
EPS = 1e-9

n, m, l = gets.split.map(&:to_i)
p, t, v = n.times.map{ gets.split.map(&:to_f) }.transpose
time_set = n.times.map{ [0] * (m + 1) }
prob_set = n.times.map{ [0] * (m + 1) }
prob_sum = n.times.map{ [0] * (m + 1) }

factorial = (1..m).each_with_object([1]) { |i, arr| arr << arr[-1] * i }
n.times do |i|
  s = l / v[i]
  (m + 1).times do |j|
    time_set[i][j] = s + t[i] * j
    prob_set[i][j] = (p[i] / 100.0) ** j * (1 - p[i] / 100.0) ** (m - j) * factorial[m] / factorial[m - j] / factorial[j]
    prob_sum[i][j+1] = prob_sum[i][j] + prob_set[i][j]
  end
end

n.times do |i|
  ret = 0
  (m + 1).times do |j|
    prob = prob_set[i][j]
    n.times do |k|
      next if i == k
      idx = upper_bound(time_set[k], time_set[i][j] + EPS)
      if idx == m + 1
        prob = 0
        break
      end
      prob *= 1 - prob_sum[k][idx]
    end
    ret += prob
  end
  puts '%.8f' % ret
end

Measured memory_bytes: 9268
N, W = map(int, input().split())

value = [[0 for i in range(W + 1)] for j in range(N + 1)]
for i in range(1, N + 1):
    w, v = map(int, input().split())

    for j in range(W + 1):
        if j - w >= 0:
            value[i][j] = max(value[i-1][j-w] + v, value[i-1][j])
        else:
            value[i][j] = value[i-1][j]

print(value[N][W])

Measured memory_bytes: 171400
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;

int main(){
    //std::stack<int> stack;
    string s;
    cin >> s;
    int n = s.size();
    vector<int> cnt(2019);
    int ten = 1;
    for(int i = 0; i < 2019; i++){
        cnt[i] = 0;
    }
    cnt[s[n-1] - '0'] ++;
    cnt[0] ++;
    int tmp = s[n-1] - '0';
    for(int i = 1; i < n; i++){
        ten *= 10;
        ten %= 2019;
        cnt[(tmp + ten * (s[n-i-1] - '0')) % 2019] ++;
        tmp = (tmp + ten * (s[n-i-1] - '0')) % 2019;
    }
    long ans = 0;
    for(int i = 0; i < 2019; i++){
        ans += cnt[i] * (cnt[i]-1) / 2;
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 3720
N = int(input())
h_list = [int(elem) for elem in input().split()]


num_waterings = 0

while sum(h_list) > 0:
    left = 0
    for right, h in enumerate(h_list):
        if h != 0:
            continue
        else:  # liquidate
            for i in range(left, right):
                h_list[i] -= 1
            if left < right:
                num_waterings += 1
            left = right + 1
            
    if left < N:
        for i in range(left, N):
            h_list[i] -= 1
        num_waterings += 1
    # print(num_waterings)
    # print(h_list)

# print(h_list)
print(num_waterings)


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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n+1];
    int dp[n+1];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    memset(dp,0,sizeof dp);
    dp[0]=0;
        for(int i=1;i<n;i++){
                for(int j=1;j<=k;j++){
                        if(j==1)dp[i]=abs(arr[i-j]-arr[i])+dp[i-j];
                    if(j<=i)dp[i]=min(abs(arr[i-j]-arr[i])+dp[i-j],dp[i]);
                }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int t,x;
  cin >> t >> x;
  cout << (double)t / x << endl;
}

Measured memory_bytes: 256
from itertools import accumulate
n = int(input())
a = list(map(int,input().split()))
acc = [0]+list(accumulate(a))
dp = [[10**18 for i in range(n)] for j in range(n)]
for w in range(n):
  for i in range(n-w):
    j = i+w
    if w == 0:
      dp[i][j] = 0
    elif w == 1:
      dp[i][j] = a[i]+a[j]
    else:
      for k in range(i,j):
        dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+acc[j+1]-acc[i])
print(dp[0][-1])

Measured memory_bytes: 43116
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		sc.close();

		Arrays.parallelSort(l);

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

		if (l[n - 1] < sum) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A <= C && C <= B)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

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

    long n;
    cin >> n;
//    scanf("%li", &n);
    long a, b;
    long sum;
    long min_sum = 100000;
    for (long i = 1; i <= n / 2; i++) {
        sum = 0;
        a = i;
        b = n - a;
        while (a > 0) {
            sum += a % 10;
            a /= 10;
        }
        while (b > 0) {
            sum += b % 10;
            b /= 10;
        }
        min_sum = min(min_sum, sum);
    }

    cout << min_sum << '\n';

    return 0;
}


Measured memory_bytes: 256
lst1 = input().split()
lst2 = input().split()
key = int(lst1[0])
lst = []
for i in range(102):
    lst.append(i)
for i in lst2:
    lst.remove(int(i))
for i in range(len(lst)):
    if lst[i] > key:
        break
if lst[i] - key < key - lst[i-1]:
    print(lst[i])
else:
    print(lst[i-1])

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
constexpr uint64_t L1 = 1ull;
constexpr ull bit(int n){ return 1ull << n;}

constexpr ll INF       = 1000000000;/* 1e+9a */

void solve(istream& cin) {
    int N;
    while(cin >> N){
        vector<vector<pair<int, int>>> abc(N);
        for (int i = 0; i < N - 1; ++i) {
            ll ta, tb, tc;
            cin >> ta >> tb >> tc;
            ta--;
            tb--;
            abc[ta].push_back({tb, tc});
            abc[tb].push_back({ta, tc});
        }// i
        int Q, K;
        cin >> Q >> K;
        K--;
        vector<ll> distance(N, 0);
        stack<pair<int, int>> st;
        for (auto &&vv : abc[K]) {
            st.push({K, vv.first});
            distance[vv.first] = distance[K] + vv.second;
        } // vv
        while(!st.empty()){
            int point = st.top().second;
            int prev = st.top().first;
            st.pop();
            for (auto &&vv : abc[point]) {
                if(vv.first == prev){ continue; }
                st.push({point, vv.first});
                distance[vv.first] = distance[point] + vv.second;
            } // vv
        }
//        for (auto &&d : distance) {
//            cout << "d:: " << d << endl;
//        } // d
    
        for (int i = 0; i < Q; ++i) {
            int x, y;
            cin >> x  >> y;
            x--; y--;
            cout << distance[x] + distance[y] << endl;
        }// i
    
    }
}

int main(int argc, char *argv[]) {
    string FileName("D"), Modifier("_MEPH");
    string ExecutionName = FileName + Modifier;
    string sub(argv[0]);
    // pass消去
    if(sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size()-ExecutionName.size(), ExecutionName.size());

	// 数値計算もの用
    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        solve(cin);
    }
    else {    
	    cerr << sub << endl;
        string inFile = "D_sample.txt";
        auto fs = fstream(inFile, fstream::in);
        solve(fs);
    }
}


Measured memory_bytes: 9204
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] num = new int[w];
		for(int i = 0; i < w; i++) {
			num[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) -1;
			int b = Integer.parseInt(ab[1]) -1;
			// swap
			int tmp = num[a];
			num[a] = num[b];
			num[b] = tmp; 
		}
		for(int i = 0; i < w; i++) {
			System.out.println(num[i]);
		}
	}
}

Measured memory_bytes: 26200
// E - Gluttony
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	long long n, k;
	cin >> n >> k;
	vector<long long> a(n), f(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> f[i];

	sort(a.begin(), a.end());
	sort(f.begin(), f.end(), greater<long long>());

	long long l = 0, r = a.back() * f.front() + 1;
	while (l < r) {
		long long m = (l + r) / 2;
		long long c = 0;
		for (int i = 0; i < n; i++)
			if (a[i] * f[i] > m) {
				long long t = a[i] * f[i] - m;
				c += t / f[i] + (t % f[i] ? 1 : 0);
			}
		if (c > k) l = m + 1;
		else r = m;
	}

	cout << l << endl;

	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
std::vector<P> tree[100010];
struct edge{int to,cost;};

ll i,j;
ll a,b,c;
ll ima=0,ans=0;
ll d[100005];
ll n,m;
 
int main(){
	cin>>a>>b;
	cout<<100<<" "<<100<<endl;
	a--;
	b--;
	//a=siro b=kuro
	for(i=1;i<=4900;i++){
		if(i%7==0 && b>0){
			cout<<"#";
			b--;
		}else{
			cout<<".";
		}
		if(i%100==0){
			cout<<endl;
		}
	}
	for(i=1;i<=100;i++){
		cout<<".";
	}
	cout<<endl;
	for(i=1;i<=100;i++){
		cout<<"#";
	}
	cout<<endl;
	for(i=1;i<=4900;i++){
		if(i%7==0 && a>0){
			cout<<".";
			a--;
		}else{
			cout<<"#";
		}
		if(i%100==0){
			cout<<endl;
		}
	}
	
		
	return 0;
}

Measured memory_bytes: 4992
import sys

def solve():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    if A > B: print(0)
    elif N == 1:
        if B != A: print(0)
        else: print(1)
    else:
        rem = N - 2
        minS = A + B + rem * A
        maxS = A + B + rem * B
        print(maxS - minS + 1)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
#define rep1(i,n) for(int i = 1 ; i <= n ; ++i)
using namespace std;
typedef long long ll;
const ll INFLL = 1e+15;
int n;
ll wmax;
int v[110];
ll w[110];
ll dp[110][100010];
int main()
{
  cin >> n >> wmax;
  rep(i,n) cin >> w[i] >> v[i];
  
  rep(i,n+1){
    rep(j,100010){
      dp[i][j] = INFLL;
    }
  }
  dp[0][0] = 0;

  rep(i,n){
    rep(j,100010){
      if(j-v[i] < 0) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = min( dp[i][j] , dp[i][j-v[i]] + w[i] );
    }
  }

  int res = 0;
  rep(j,100010){
    if(dp[n][j] <= wmax) res = j;
  }
  cout << res << "\n";
  return 0;
}


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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (k >= s.size()) {
    cout << s << endl;
    return 0;
  }
  rep(i, k) printf("%c", s[i]);
  cout << "..." << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long R, G, B, N;
  cin >> R >> G >> B >> N;
  long result = 0;
  long r = 0;
  while (r * R <= N) {
    long g = 0;
    long tmp = N - r * R;
    while (g * G <= tmp) {
      long tmp2 = tmp - g * G;
      if (tmp2 % B == 0) result++;
      g++;
    }
    r++;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B, C, D float64
	fmt.Scan(&A, &B, &C, &D)

	fmt.Println(calcTime(A, B, C, D))
}

func calcTime(a, b, c, d float64) int {
	max := math.Min(b, d)
	min := math.Max(a, c)

	return int(math.Max(0, max-min))
}


Measured memory_bytes: 512
/*
 *  AUTHOR : _crtlC_crtlV
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(array)  memset(array, 0, sizeof(array))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define sss(array) sort(array, array + n)
#define vvv(vect) sort(vect.begin(),vect.end())

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	char c;
  	cin >> c;
  	if(c == 'z')
      	cout  << 'a'  << "\n";
 	else
      	cout << (char)(c + 1) << "\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N;
    cin >> N;
    VLL A(N);
    ll mini=INF;
    ll sum=0;
    rep(i,N){
        cin >> A[i];
    }
    sort(all(A));
    reverse(all(A));
    ll ans=0;
    ans+=A[0];
    if(N%2!=0){
        ll itr=N-1;
        ll ni=itr/2-1;
        ll count=1;
        for(int i=1; i<ni+1; i++){
            ans+=A[i]*2;
            count++;
        }
        ans+=A[count];
        cout << ans << endl;
    }
    else{
        ll itr=N-1;
        ll ni=itr/2;
        for(int i=1; i<ni+1; i++){
            ans+=A[i]*2;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4760
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;

char map[55][55];
bool vis[55][55];
int H, W;
struct node
{
	int x, y;
	int step;
	node(int _x, int _y, int _s):x(_x),y(_y),step(_s){}
	node(){}
};
int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
int bfs()
{
	if (map[1][1] == '#' || map[H][W] == '#')return -1;
	queue<node>Q;
	Q.push(node(1, 1, 0));
	vis[1][1] = 1;
	while (!Q.empty())
	{
		node u = Q.front();Q.pop();
		int x = u.x, y = u.y, step = u.step;
		
		if (x == H&&y == W)return step;
		int tmpx, tmpy;
		for (int i = 0;i < 4;i++)
		{
			tmpx = x + dir[i][0];
			tmpy = y + dir[i][1];
			if (tmpx <= 0 || tmpx > H || tmpy <= 0 || tmpy > W)continue;
			if (vis[tmpx][tmpy])continue;
			if (map[tmpx][tmpy] == '#')continue;
			Q.push(node(tmpx, tmpy, step + 1));
			vis[tmpx][tmpy] = 1;
		}
	}
	return -1;
}

int main()
{
	
	scanf("%d %d", &H, &W);
	int all = H*W;
	int black = 0;
	for (int i = 1;i <= H;i++)
	{
		scanf("%s", map[i] + 1);
	}
	for (int i = 1;i <= H;i++)
		for (int j = 1;j <= W;j++)
			if (map[i][j] == '#')
				black++;
	int dis=bfs();
	if (dis == -1)
		puts("-1");
	else
	{
		printf("%d\n", all - black - dis-1);
	}
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n==0:
    print(x)
    exit()


for i in range(100):
    num = x-i
    if num not in p:
        print(num)
        exit()
    num = x+i
    if num not in p:
        print(num)
        exit()

Measured memory_bytes: 9188
import java.util.*;
import java.math.*;
class Main {
    //
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println((n+1)/2);
        
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    
    cin>>s;
    
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
    {
        cout<<"3\n";
    }
    else if((s[0]=='R'&&s[1]=='R') || (s[1]=='R'&&s[2]=='R'))
    {
        cout<<"2\n";
    }
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
    {
        cout<<"1\n";
    }
    else cout<<"0\n";
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
using namespace std;

int main(){
	int n, cnt = 0;
	string find, sub;
	char s[101];
	scanf("%d", &n);
	cin >> find;
	for (int i = 0; i < n; i++){
	start:
		if (i >= n)break;
		scanf("%s", s);
		int len = strlen(s);
		for (int j = 0; j < len; j++){
			for (int l = 1; l < len; l++){
				sub = s[j];
				for (int p = j+l; p < len; p += l){
					sub += s[p];
					if (sub == find) { cnt++; i++; goto start; }
				}
			}
		}
 	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 3292
A[1000][1000],I[1000],u[999];i,j;d;F=2;main(N){for(scanf("%d",&N);i<N;++i)for(j=0;~j+N;)scanf("%d",A[j++]+i);for(;F&2;i=N)for(++d,F=1;i--;u[i]<d&&j&&u[F&=2,--j]<d&A[I[j]][j]==i+1&&++I[u[i]=u[j]=d,++I[i],F=2,j])j=A[I[i]][i];printf("%d",F*d-1);}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int answer = a-2*b;
        if (answer >= 0) {
            System.out.println(answer);
        } else {
            System.out.println(0);
        } 

    }
}

Measured memory_bytes: 21844
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let x: i64 = read();

    let mut ans = x / 11 * 2;
    let tmp = x % 11;
    
    ans += if tmp > 6 {
        2
    } else if tmp > 0 {
        1
    } else {
        0
    };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main() {
  int N;
  double x[10];
  string u[10];
  double sum = 0.0;

  cin >> N;
  for (int i = 0; i < N; i++) cin >> x[i] >> u[i];
  for (int i = 0; i < N; i++) {
    sum += u[i] == "JPY" ? x[i] : x[i] * 380000.0;
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())

r = sum([1 for x in s if x == 'R'])
g = sum([1 for x in s if x == 'G'])
b = sum([1 for x in s if x == 'B'])
ans = r * g * b

for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        if j < k <= n - 1:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1

print(ans)


Measured memory_bytes: 68644
#include <stdio.h>

main(){
  int n;
  int a,b;
  int inpa,inpb;
  int i;
  while(1){
    scanf("%d",&n);
    a = 0;
    b = 0;
    if(n==0){
      break;
    }
    for(i = 0; i < n; i++){
      scanf("%d %d", &inpa, &inpb);
      if(inpa > inpb){
        a += inpa + inpb;
      }
      else if(inpb > inpa){
        b += inpa + inpb;
      }
      else{
        a += inpa;
        b += inpb;
      }
    }
    printf("%d %d\n",a,b);
  }
}



Measured memory_bytes: 2040
N,M = map(int,input().split())
 
A = [ list(map(int,input().split())) for _ in range(N) ]
A.sort()
ans = 0
while M > 0:
  if M >= A[0][1]:
    ans += A[0][0] * A[0][1]
    M -= A[0][1]
    del A[0]
  else:
    ans += A[0][0] * M
    M = 0
print(ans)

Measured memory_bytes: 27760
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a<=k)puts("Yay!");
  else puts(":(");

  return 0;
}


Measured memory_bytes: 256