akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  string S;
  cin >> N >> S;
  vector<int> data(N);
  int count = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i) == '#')count++;
    data.at(i) = count;
  }
  int ans = 100000000, a;
  for(int i = 0; i < N; i++){
    a = data.at(i) + (N - i - 1 - (data.at(N - 1) - data.at(i)));
    ans = min(ans, a);
  }
  ans = min(ans, N - data.at(N - 1));
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;


int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> ns(n), ms(m);
  for (int i = 0; i < n; ++i) {
    cin >> ns[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> ms[i];
  }

  int res;

  for (int i = x + 1; i < y; ++i) {
    res = 0;
    for (int j = 0; j < n; ++j) {
      if (ns[j] >= i) continue;
      ++res;
    }
    if (ns.size() != res) continue;
    for (int j = 0; j < m; ++j) {
      if (ms[j] < i) continue;
      ++res;
    }
    if (ns.size() + ms.size() != res) continue;
    cout << "No War" << endl;
    return 0;
  }

  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int64_t dfs(const vector<vector<int64_t>>& links, const vector<int64_t>& a, int64_t current, int64_t parent) {
  if (links[current].size() == 1 && parent >= 0) {
    return a[current];
  }

  vector<int64_t> tmp;
  int64_t s = 0;
  for (auto v : links[current]) {
    if (v == parent) {
      continue;
    }
    tmp.push_back(dfs(links, a, v, current));
    if (tmp.back() < 0) {
      return -1;
    }
    s += tmp.back();
  }
  
  int64_t m = a[current];
  int64_t k = s - m;
  if (k < 0 || k > m || 2 * k > s) {
    return -1;
  }
  
  auto ret = m - k; // = 2 * m - s
  sort(tmp.begin(), tmp.end());
  while (!tmp.empty()) {
    auto x = tmp.back();
    s -= x;
    tmp.pop_back();
    if (x >= s) {
      if (s >= k) {
        return ret;
      } else {
        return -1;
      }
    }
    if (k < x) {
      return ret;
    }
    k -= x;
  }
  
  assert(false);
  return -1;
}

main() {
  int64_t n;
  cin >> n;
  
  vector<int64_t> a(n);
  for (auto&& aa : a) {
    cin >> aa;
  }
  
  vector<vector<int64_t>> links(n);
  for (auto _ : irange(0L, n - 1)) {
    int64_t x, y;
    cin >> x >> y;
    --x;
    --y;
    links[x].push_back(y);
    links[y].push_back(x);
  }
  
  auto ret = dfs(links, a, 0, -1);
  cerr << ret << endl;
  if (ret < 0 || (ret != 0 && links[0].size() > 1)) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }  
}

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

int main(void) {
  string S, T;
  cin >> S >> T;
  int cnt=0;
  
  for(int i=0; i<3; i++){
    if(S[i]==T[i])
      cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	long long k, i;
	vector<long long> a;
	
	cin>>k;
	a.resize(k);
	for (long long& x: a)
		cin>>x;
	
	long long nl = 2, nh = 2;
	for (i = k - 1; i >= 0; --i)
	{
		nl += (a[i] - nl % a[i]) % a[i];
		nh += (a[i] - nh % a[i] - 1) % a[i];
		
		if (nl > nh)
		{
			cout<<"-1\n";
			return 0;
		}
	}
	
	cout<<nl<<' '<<nh<<'\n';
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 1010
#define inf 1e16
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int x[MN],y[MN],r[MN];
int sx,sy,tx,ty,n,s,t;
double dis[MN];
bool vis[MN];
inline double dist(int ax,int ay,int bx,int by){
	return (double) sqrt(1ll*(ax-bx)*(ax-bx)+1ll*(ay-by)*(ay-by));
}
int main()
{
	sx=in();sy=in();tx=in();ty=in();
	n=in();s=n+1,t=n+2;
	x[n+1]=sx;y[n+1]=sy;x[n+2]=tx;y[n+2]=ty;
	for (int i=1;i<=n;++i) x[i]=in(),y[i]=in(),r[i]=in();n+=2;
	for (int i=1;i<=n;++i) dis[i]=inf;dis[s]=0;
	while (1){
		int v=0;
		for (int j=1;j<=n;++j) if (!vis[j]&&((!v)||dis[j]<dis[v])) v=j;
		if (!v) break;vis[v]=1;
		for (int j=1;j<=n;++j) dis[j]=min(dis[j],dis[v]+max(0.0,dist(x[v],y[v],x[j],y[j])-r[v]-r[j]));
	}
	printf("%.10lf",dis[t]);return 0;
}

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

string toBinary(long long x, int n)
{
    string s;
    while (x != 0)
    {
        int r = abs(x % n);
        s += to_string(r);
        x -= r;
        x /= n;
    }
    reverse(s.begin(), s.end());

    return s;
}

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

    long long ans = 0LL;
    for (int i = 0; i < 1 << (S.size() - 1); i++)
    {
        string b = toBinary((long long)i, 2);
        while (b.size() < S.size() - 1)
        {
            b = "0" + b;
        }

        int loop_num = 1;
        int index = 0;
        for (int j = 0; j < b.size(); j++)
        {
            if (b[j] == '0')
            {
                loop_num++;
            }
            else
            {
                string tmp = "";
                for (int k = 0; k < loop_num; k++)
                {
                    tmp += S[index];
                    index++;
                }
                // cout << b << ": " << tmp << endl;
                ans += stoll(tmp);
                loop_num = 1;
            }
        }
        string tmp_last = "";
        for (int k = 0; k < loop_num; k++)
        {
            tmp_last += S[index];
            index++;
        }
        ans += stoll(tmp_last);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m,k,tmp=0;
	while(cin>>n>>m>>k){
		tmp=0;
		vector<vector<ll>>  arr(n+1,vector<ll>(m));
		for(int i=0;i<m;i++){
			cin>>arr[0][i];
		}
		ll ans=0;
		for(int i=0;i<n;i++){
			tmp=0;
			for(int j=0;j<m;j++){
				cin>>arr[i+1][j];
				tmp+=arr[0][j]*arr[i+1][j];
			}
			if(tmp+k>0)
				ans++;
		} 
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
signed main(){
    int N;
  	cin>>N;
    double D=2*N*3.1415;
    cout<<D<<endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007

ll h,w;
char a[1010][1010];
ll b[1010][1010];
vector< pair<ll,ll> > p,q;



bool check(char a[1010][1010]){
  bool flag=true;
  rep(i,h)rep(j,w)if(a[i][j]=='.')flag=false;
  return flag;
}

ll res=0;
ll counter=0;

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

void dfs(ll x,ll y){
  rep(i,4){
    ll nx=x+dx[i],ny=y+dy[i];
    if(0<=nx&&nx<h&&0<=ny&&ny<w&&a[nx][ny]=='.'){
      a[nx][ny]='#';
      b[nx][ny]=counter;
      pair<ll,ll>qa=make_pair(nx,ny);
      q.push_back(qa);
      res++;
    }
  }
}

int main(){
  cin >> h >> w;
  ll dot=0;

  rep(i,h)rep(j,w){
    cin >> a[i][j];
    if(a[i][j]=='.'){
      b[i][j]=0;
      dot++;
    }else{
      pair<ll,ll> pa=make_pair(i,j);
      p.push_back(pa);
    }
  }


  while(res!=dot){
    counter++;
    for(auto it=p.begin();it!=p.end();it++){
      dfs(it->first,it->second);
    }
    p=q;
    q.erase(ALL(q));
    /*
    rep(i,h)rep(j,w){
      if(a[i][j]=='#'&&b[i][j]==counter-1)dfs(i,j);
    }*/
  }
  cout << counter << endl;
}


Measured memory_bytes: 33892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;

int main() {
    string S;
    cin >> S;
    bool yflag = true;
    for(int i = 0; i < S.length(); ++i) {
        if(!(i % 2) && S[i] == 'L') {
            yflag = false;
            break;
        }
        if(i % 2 && S[i] == 'R') {
            yflag = false;
            break;
        }
    }
    cout << (yflag ? "Yes" : "No") << endl;
    return 0;
}


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

P, Y = [], []
for _ in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)

result = [1] * M
citys = [[] for _ in range(N)]

for i, n in enumerate(P):
    citys[n-1].append([Y[i], i])

for c in citys:
    
    c.sort()
    for i, k in enumerate(c):
        result[k[1]] += i



for x, y in zip(P, result):
    x, y = str(x), str(y)
    print('0'*(6-len(x))+x+'0'*(6-len(y))+y)


Measured memory_bytes: 37444
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n; ll ar[21][21]; ll dp[22][(1ll<<21)+1];
ll maxval(ll i,ll mask){
	if(i==n) return 1;
	if(dp[i][mask]!=-1) return dp[i][mask];
	ll j,an=0;
	for(j=0;j<n;j++){
		if(ar[i][j]==1&&((1ll<<j)&mask)==0){
			an=(an+maxval(i+1,((1ll<<j)|mask))%mod)%mod;
		}
	}
	return dp[i][mask]=an%mod;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin>>ar[i][j];
		}
	}	
	memset(dp,-1,sizeof(dp));
	ll an=maxval(0,0);
	cout<<an;
	return 0;	
}

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

typedef pair<int, int> P;

int R, C;
int sy, sx;
int gy, gx;
vector<vector<char>> c;
vector<vector<int>> v;

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
int bfs(int sy, int sx) {
    queue<P> que;
    que.push(P(sy, sx));
    v[sy][sx] = 0;
    while (!que.empty()) {
        P p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int y = p.first + dy[i], x = p.second + dx[i];
            if (0 <= y && y < R && 0 <= x && x < C && c[y][x] != '#' &&
                v[y][x] > v[p.first][p.second] + 1) {
                que.push(P(y, x));
                v[y][x] = v[p.first][p.second] + 1;
            }
        }
    }
    return v[R - 1][C - 1];
}

int main() {
    cin >> R >> C;
    c.assign(R, vector<char>(C));
    int cost = R * C;
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            cin >> c[i][j];
            if (c[i][j] == '#') cost--;
        }
    }
    v.assign(R, vector<int>(C, 1e9));
    cost = cost - bfs(0, 0) - 1;
    cout << (cost >= 0 ? cost : -1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(), v.end()
using namespace std;

int n;
string ans[] = { "pon" , "pon" , "hon" , "bon" , "hon" , "hon" , "pon" , "hon" , "pon" , "hon" };

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    cout << ans[ n%10 ];

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main(){
    fast();

/* you get what you work for not what you wish for */

    inps(a, b);
    if(a>=1&&b>=1&&a<=9&&b<=9){
        cout << a*b << endl;
    }
    else{
        cout << -1 << endl;
    }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e1 + 5);

int a[MAX_N];

ll ans;

ll calc() {
  ll tmp = 0;

  for (int i = 0; i < 5; ++i) {
    tmp += a[i];
    if (i == 4) break;
    while (tmp % 10 != 0) {
      tmp += 1;
    }
  }

  return tmp;
}

int main(void) {
  // Here your code !

  for (int i = 0; i < 5; ++i) {
    scanf("%d", &(a[i]));
  }

  ans = INF;

  do {
    ans = min(ans, calc());
  } while (next_permutation(a, a + 5));

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string W, str;
    cin >> W;
    int cnt = 0;
    
    while(1){
        cin >> str;
        if(str == "END_OF_TEXT")    break;
        for(int i = 0; i < str.length(); i++){
            if('A' <= str[i] && str[i] <= 'Z')  str[i] += 32;
        }
        if(str == W)    cnt++;
    }
    
    cout << cnt << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

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

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  char a; cin >> a;
  char result = a>='A'&&a<='Z' ? 'A' : 'a';
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main() {
	//A
	/*char a[1001];
	int i;
	for (i = 0; i < 1001; i++) {
		a[i] = '0';
	}
	cin >> a;
	int n, s, w, e;
	n = 0;
	s = 0;
	w = 0;
	e = 0;
	for (i = 0; i < 1001; i++) {
		if (a[i] == 'N') {
			n = 1;

		}
		else if (a[i] == 'S') {
			s = 1;
		}
		else if (a[i] == 'W') {
			w = 1;
		}
		else if (a[i] == 'E') {
			e = 1;
		}
	}
	if ((n == s) && (w == e)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;*/

	//B
	int n;
	int a[100000];
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	long long int c;
	c = 0;
	int flag;
	flag = 0;
	for (i = 0; i < n; i++) {
		if (a[i] == 0) {
			flag = 0;
		}
		else {
			if (flag == 0) {
				if (a[i] % 2 == 0) {
					c = c + a[i] / 2;
				}
				else {
					flag = 1;
					c = c + (a[i] - 1) / 2;

				}
			}
			else {
				if (a[i] % 2 == 0) {
					c = c + a[i] / 2;
				}
				else {
					flag = 0;
					c = c + (a[i] + 1) / 2; 
				}
			}
		}
	}
	cout << c;
	return 0;

	//C

	/*int n;
	cin >> n;
	int a[100000],b[100000],c;
	int i,j;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = 0;
	}
	for (i = 0; i < n-1; i++) {
		for (j = 0; j < n - 1 - i; j++) {
			if (a[j] > a[j + 1]) {
				c = a[j];
				a[j] = a[j + 1];
				a[j + 1] = c;
				c = b[j];
				b[j] = (b[j + 1] + 1) % 2;
				b[j + 1] = (c + 1) % 2;
			}
		}
	}
	c = 0;
	for (i = 0; i < n; i++) {
		if (b[i] == 1) {
			c++;
		}
	}
	cout << c / 2;
	return 0;*/
}


Measured memory_bytes: 640
use proconio::input;

fn main() {
    input!{
        k: usize
    }
    let mut acc: usize = 0;
    println!("{}", 
        if let Some(ans) = (1..1_000_002).find(|_| {
            acc = (10*acc + 7) % k;
            acc == 0
        }) { ans as isize } else { -1 }
    );


}


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

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

void solve(long long A, long long B, long long C){
    if(A==B&&A!=C || B==C && B != A || A==C && A!=B)cout<<YES<<endl;else cout<<NO<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

typedef double ld;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int main(){ _

	int N,M;
	cin >> N >> M;

	vector<vector<char>> A(N, vector<char>(N));
	vector<vector<char>> B(M, vector<char>(M));
	
	for(auto &x : A)
		for(auto &y : x)
			cin >> y;

	for(auto &x : B)
		for(auto &y : x)
			cin >> y;

	bool ans = 0;
	for(int i = 0; i < N - M + 1; i++){
		for(int j = 0; j < N - M + 1; j++){
			bool ok = 1;
			for(int k = 0; k < M; k++){
				for(int l = 0; l < M; l++){
					ok &= (A[i+k][j+l] == B[k][l]);
				}
			}
			ans |= ok;
		}
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3620
import bisect



n, q = map(int, input().split())

Q = [[] for _ in range(n)]


for _ in range(q):

    command, *list_num = input().split()

    t = int(list_num[0])

    if   command == "0":
        # insert(t, x)
        x = int(list_num[1])
        bisect.insort(Q[t], x)
    elif command == "1":
        # getMax(t)
        if Q[t]:
            print(Q[t][-1])
    elif command == "2":
        # deleteMax(t)
        if Q[t]:
            del Q[t][-1]
    else:
        raise


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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
//int t = 1; int ti;


const int N = 3e3 + 5;
double dp[N][N];
double p[N];
int n;

void solve(){
    cin>>n;

    fori(i, 1, n)
    cin>>p[i];

    dp[1][1] = p[1];
    dp[1][0] = 1-p[1];


    fori(i, 2, n){
        fori(j, 0, i){
            dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*(p[i]);
        }
    }
    
    double ans = 0;

    fori(i, 0, n){
        if(i > (n-i))
        ans += dp[n][i];
    }

    cout<<ans;
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cout<<fixed<<setprecision(10);
    solve();
}

Measured memory_bytes: 69120
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long x = saori.saorihayami();
		long y = saori.saorihayami();
		long ans = 0;
		long count = 1;
		long n = x;
		while(n <= y){
			n = count*x;
			if(n <= y){
				ans++;
			}
			count *= 2;
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32380
def main():
    MOD = 1000000007
    N, M = map(int, input().split())
    a = [int(input()) for _ in range(M)]
    table = [1]*(N+1)
    for broken in a:
        table[broken] = 0
    table[1] = table[0] * table[1]
    if N > 1:
        for n in range(2, N+1):
            table[n] = ((table[n-2] + table[n-1]) * table[n]) % MOD
    print(table[-1])
main()

Measured memory_bytes: 7848
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)
#define min(p,q)((p)<(q)?(p):(q))
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll a[1010];
int main(){
	ll n;
	while(scanf("%lld",&n),n){
		rep(i,0,n)scanf("%lld",a+i);
		sortup(a,n);
		ll m=1000000;
		rep(i,0,n-1)m=min(m,a[i+1]-a[i]);
		printf("%lld\n",m);
	}
}


Measured memory_bytes: 2044
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define f first
#define s second
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define fast 
#define f first
#define s second
#define endl "\n"
#define pie 3.1415926535
   
int main(){
    int n;
    cin >> n;
    double r = (2*pie*n);
    cout << r<<endl;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int M1,D1;
  cin >> M1 >> D1;
  int M2,D2;
  cin >> M2 >> D2;
  if(M1 != M2) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll dp[3001][3001] = {};
ll pas[3001][3001] = {};
ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
int main() {
	ll n; ll m; cin >> n >> m;
	rep(i, 3001) {
		dp[i][0] = 1;
		Rep(j, 1, i) {
			dp[i][j] = (dp[i - 1][j - 1] + ((ll)(j+1))*dp[i - 1][j]%m) % m;
		}
		dp[i][i] = 1;
	}
	rep(i, 3001) {
		rep(j, 3001) {
			if (i == 0 || j == 0)pas[i][j] = 1;
			else pas[i][j] = (pas[i - 1][j] + pas[i][j - 1]) % m;
		}
	}
	ll sum = 0;
	for (ll i = 0; i <= n; i++) {
		ll csum = mod_pow((ll)2, n - i, (m-(ll)1));
		csum = mod_pow((ll)2, csum, m);
		csum = csum * pas[n - i][i] % m;
		ll nex = 0;
		for (ll j = 0; j <= i; j++) {
			ll ccsum = mod_pow((ll)2, (n - i)*j, m);
			ccsum = ccsum * dp[i][j] % m;
			nex = (nex + ccsum) % m;
		}
		csum = csum * nex%m;
		if ((int)i % 2==0) {
			sum = (sum + csum) % m;
		}
		else {
			sum = (sum - csum + m) % m;
		}
	}
	cout << sum << endl;
	return 0;
}

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

int main(){
    int N, mid;
    cin >>N;
    vector<int> a(N), b(N), c(N);
    long long ans=0, topCount, botCount;

    for(int i=0; i<N; i++)
	cin >> a[i];
    for(int i=0; i<N; i++)
	cin >> b[i];
    for(int i=0; i<N; i++)
	cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    for(int i=0; i<N; i++){
	mid = b[i];
	topCount = lower_bound(a.begin(), a.end(), mid) - a.begin();
	botCount = c.end() - upper_bound(c.begin(), c.end(), mid);
	ans += topCount*botCount;
    }
    cout << ans << endl;
}




Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define print(x) cout << to_string(x) << '\n'
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 1e9+7;
 
string to_string(char &c) {string x(1, c); return x;}
string to_string(const char s[]) {return (string)s;}
string to_string(string &s) {return s;}
string to_string(vb &v) {string res; for (const bool &x : v) res += to_string(x) + ' '; return res;}
template <class C> string to_string(C &v) {string res; for (auto &x : v) res += to_string(x) + ' '; return res;}
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    REP(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n,m,v,p;
    cin >> n >> m >> v >> p;
    vi a(n);
    cin >> a;
    sort(a.begin(), a.end());
 
    vi pref = a;
    REP(i, 1, n) pref[i] += pref[i-1];
 
    v -= p-1;
 
    int k = -1;
    for (int b=n; b>=1; b/=2) {
        while (k+b<n-p) {
            int chk = k+b;
            int ev = v - (chk+1);
            ev = max(0LL, ev);
            if (m >= a[n-p]-a[chk]) {
                int sm = pref[n-p] - pref[chk];
                if (sm + m*ev <= (m+a[chk])*(n-p-chk)) break;
            }
            k += b;
        }
    }
    ++k;
 
    int res = 0;
    REP(i, 0, n) if (a[i] >= a[k]) ++res;
    print(res);
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
print(len(set(A)))


Measured memory_bytes: 6604
#include <iostream>
#include <string>

using namespace std;
int main(){
	int n;
	cin >> n;

	long double sum = 0;

	long double btoy = 380000;

	for (int i = 0; i < n; i++) {
		long double x;
		string u;

		cin >> x;
		cin >> u;

		sum += (u == "BTC") ? (x * btoy) : (x);
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  double sum = 0;
  rep(i,N) {
    sum += (double)1 / (double)A[i];
  }
  double ans = (double)1/sum;
  cout << setprecision(30) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n, m;
ll a[1 << 14], b[1 << 14];
int main() {
	while (cin >> n >> m, n) {
		rep(i, n) {
			a[i] = b[i] = 0;
		}
		rep(i, m) {
			ll s; cin >> s; int k; cin >> k;
			rep(j, k) {
				int c; cin >> c; c--;
				a[c] += s;
				if (k == 1) {
					b[c] += s;
				}
			}
		}
		ll ma = 0; int id;
		ll mi = INF; int chk;
		rep(i, n) {
			if (ma < a[i]) {
				ma = a[i]; id = i;
			}
			if (mi > b[i]) {
				mi = b[i]; chk = i;
			}
		}
		ll out = 0;
		if (id != chk) {
			out = ma - mi + 1;
		}
		else {
			ll ma2 = 0,mi2 = INF;
			rep(i, n) {
				if (i != id) {
					ma2 = max(ma2, a[i]);
				}
				if (i != chk) {
					mi2 = min(mi2, b[i]);
				}
			}
			out = max(ma2 - mi+1, ma - mi2+1);
		}
		cout << out << endl;
	}
	return 0;
}



Measured memory_bytes: 3272
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
 
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    StringTokenizer stk = new StringTokenizer(in.readLine());
    String s = stk.nextToken();  
    String abc = "ABC";
    int cnt = 0;
    for(int i=0; i+3<=n; i++){
      if(s.substring(i,i+3).equals(abc))
        cnt++;
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 21076
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int c = scan.nextInt();
        int k = scan.nextInt();
        int[] t = new int[n];
        for(int i = 0; i < n; i++) t[i] = scan.nextInt();
        Arrays.sort(t);
        int count = 1;
        int cval = t[0] + k;
        int out = 1;
        for(int i = 1; i < n; i++){
            if(cval >= t[i] && count + 1 <= c){
                count++;
            }else{
                out++;
                count = 1;
                cval = t[i] + k;
            }
        }
        System.out.println(out);
        scan.close();
    }

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


Measured memory_bytes: 59616
def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr=={}:
        arr[n] = 1

    return arr


a, b = map(int, input().split()) 
a_fac = factorization(a)
b_fac = factorization(b)
lcm = {}
for prime,cnt in a_fac.items():
    if prime in b_fac and prime != 1:
        lcm[prime] = min(cnt, b_fac[prime])

print(len(lcm)+1)

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

// macro
using ll = long long;

// code starts
int main()
{
  int n;
  cin >> n;
  while(n != 0)
  {
    vector<int> s(n);
    for(int i=0;i<n;i++) cin >> s[i];
    sort(s.begin(), s.end());
    int sum = 0;
    for(int i=1;i<n-1;i++) sum += s[i];
    cout << sum/(n-2) << endl;
    cin >> n;
  }
}



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

int Ws[300010];
int Hs[300010];
int hw[300010][2];
int main()
{
    int H, W, M, h, w;
    cin >> H >> W >> M;
    for (int i = 0; i < M; i++) {
        cin >> h;
        h = h -1;
        Hs[h] += 1;
        cin >> w;
        w = w-1;
        Ws[w] += 1;
        hw[i][0] = h;
        hw[i][1] = w;
    }

    int h_max=-1;
    int w_max=-1;
    int num_h_max=0, num_w_max=0;
    vector<int> arg_h_max, arg_w_max;
    for (int i = 0; i < H; i++)
    {
        if (h_max < Hs[i]) {
            h_max = Hs[i];
            num_h_max = 1;
        }
        else if (h_max == Hs[i]) {
            num_h_max += 1;
        }
    }
    for (int i = 0; i < W; i++)
    {
        if (w_max < Ws[i]) {
            w_max = Ws[i];
            num_w_max = 1;
        }
        else if (w_max == Ws[i]) {
            num_w_max += 1;
        }
    }
    
    int result = h_max + w_max;
    int count = 0;
    for (int k = 0; k < M; k++)
    {
        if ((Hs[hw[k][0]] == h_max) && (Ws[hw[k][1]] == w_max)) {
            count ++;
        }
    }
    if (count == num_h_max * num_w_max) result -= 1; 

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 8320
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,m,i,j,cc=0;
    cin>>n>>m;
    ll ara[n];ll bra[n];
    for(i=0;i<n;i++){cin>>ara[i],bra[i]=abs(m-ara[i]);}
    if(n==1)cout<<bra[0]<<endl;
    else{
        cc=bra[0];
        for(i=1;i<n;i++){
            cc=__gcd(cc,bra[i]);
        }
        cout<<cc<<endl;
    }
return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cstring>
#define INF 500050
using namespace std;
int arr[INF],brr[INF];
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	for(int i=1; i<=a; i++) {
		arr[i]=b;
	}
	for(int i=1; i<=c; i++) {
		int q;
		cin >> q;
		brr[q]++;
	}
	
	for(int i=1; i<=a; i++) {
		arr[i] = arr[i] - c + brr[i];
		if(arr[i] >= 1) cout<<"Yes"<<endl;
		else cout<<"No" <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    string s;
    cin>>n>>k>>s;
    string t="AC";
    int cnt[n+2]={0};
    int b[n+2]={0};
    for(int i=0;i+1<n;i++){
        if(s.substr(i,2)==t){
            cnt[i+1]=1;
        }
    }
    b[0]=cnt[0];
    for(int i=1;i<n;i++)b[i]=b[i-1]+cnt[i];
    for(int i=0;i<k;i++){
        int l,r;
        cin>>l>>r;
        r--;
        if(l!=0)cout<<b[r]-b[l-1]<<endl;
        else cout<<b[r]<<endl;
    }
}


Measured memory_bytes: 4492
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
#define INF (long long)102000000000000
typedef long long ll;
typedef unsigned long long ull;
class solution{
public:
	void solve(){
		ll n;
		cin>>n;
		ll a,b;
		cin>>a>>b;
		ll dif = abs(a-b);
		if(dif&1){
			ll ans = min(min(a,b)-1,n-max(a,b));
			ans += (dif-1)/2+1;
			cout<<ans;
		}
		else{
			cout<<dif/2;
		}
	}

};
	  
int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

if N % 2 == 1:
    if A.count(0) != 1:
        print(0)
        quit()

c = {}
for e in A:
    if e == 0:
        continue
    if e in c.keys():
        c[e] += 1
    else:
        c[e] = 1
if all([x == 2 for x in c.values()]):
    print(2**(N//2)%(10**9+7))
else:
    print(0)


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

void solve(long long N, std::vector<long long> A) {
    ll ans = 0;
    map<ll, ll> arraymap;
    map<ll, bool> ansmap;

    sort(A.begin(), A.end());
    rep(i, N) {
        arraymap[A[i]]++;
        ansmap[A[i]] = true;
    }

    for (ll i = 0; i < N; i++) {
        if (arraymap[A[i]] >= 2) {
            ansmap[A[i]] = false;
        }

        for (ll j = A[i] * 2; j <= *(A.end() - 1); j += A[i]) {
            ansmap[j] = false;
        }
    }
    rep(i, N) {
        if (ansmap[A[i]]) {
            ans++;
        }
    }

    cout << ans << endl;
}

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


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

int main(void){
    int n,k,h;
    cin >> n >> k;
    int ans=0;
    for(int i=0;i<n;i++){
        cin >> h;
        if(h>=k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int w, h, n, ox = 0, oy = 0;
    cin >> w >> h >> n;

    for (int i = 0; i < n; ++i) {
        int x, y, a;
        cin >> x >> y >> a;

        if (a == 1) ox = max(ox, x);
        if (a == 2) w = min(w, x);
        if (a == 3) oy = max(oy, y);
        if (a == 4) h = min(h, y);
    }
    cout << ((w > ox) && (h > oy) ? (w - ox) * (h - oy) : 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,a[100000];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  ll ans=a[0]-1,t=2;
  for(int i=1;i<n;i++){
    if(a[i]==t)t++;
    if(a[i]>t)ans+=(a[i]-1)/t;
  }
  cout<<ans<<endl;
  return 0;
}

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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

#define INF_INT 1001001001
#define DEV 1000000007

// Edu DP -A
int main() {
    int n, m;
    cin >> n >> m;

    vector<bool> ban(n + 1);
    int banidx;
    rep(i, 0, m) {
        cin >> banidx;
        ban[banidx] = true;
    }

    // vector<int> cost(n + 1, 0);
    vector<ll> cost(n + 1, 0);
    cost[0] = 1;
    if (!ban[1]) cost[1] = 1;

    repe(i, 2, n) {
        if (ban[i]) { continue; }
        cost[i] += cost[i - 1] + cost[i - 2];
        cost[i] %= DEV;
    }

    // for (int c : cost) { cout << c << " "; }
    // cout << cost[n - 1] << endl;
    printf("%lld\n", cost[n]);

    return 0;
}



Measured memory_bytes: 1024