akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    string n;
    cin >> n;
    if (n[0] == '9' || n[1] == '9') {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
string S,T;
cin>>S>>T;

ll ans=0;

for(ll i=0;i<S.size();i++){
if(S[i]==T[i]){
ans++;
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int n;
int id[17],m[17],w[17];

double dp[1<<16][16];
int dp_last[1<<16][16];

double dfs(int S,int v,int we){
	if(dp[S][v] != 1e300) return dp[S][v];
	if(S == (1 << n) - 1) return dp[S][v] = 0.0;

	double ret = 1e300;
	int last = -1;
	FOR(i,n){
		if(!(S & (1 << i))){
			double val = dfs(S | (1 << i),i,we + w[i]);
			int len = abs(m[v] - m[i]);
			val += len / (2000.0 / (70 + we * 20));
			if(ret > val){
				ret = val;
				last = i;
			}
		}
	}

	dp_last[S][v] = last;
	return dp[S][v] = ret;
}

int main(){
	cin>>n; FOR(i,n) cin>>id[i]>>m[i]>>w[i];
	
	FOR(i,1<<16) FOR(j,16){
		dp[i][j] = 1e300;
	}

	dfs(0,n,0);

	int last = dp_last[0][n];
	int S = (1<<last);
	vector<int> ans;
	ans.push_back(last);
	while(S != (1<<n) - 1){
		last = dp_last[S][last];
		S |= (1 << last);
		ans.push_back(last);
	}

	FOR(i,n){
		printf("%d%c",id[ans[i]],i==n-1?'\n':' ');
	}

	return 0;
}

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

pair<double,double> p[104];
int cnt[104];

int main(){
    int n; cin>>n;
    for(int i=1;i<=n;++i){
        cin>>p[i].first>>p[i].second;
        // p[i].first=rand()%1000000;
        // p[i].second=rand()%1000000;
    }

    int point_at_round=8000000;
    double PI=acos(-1);
    double all_deg=2*PI;
    double delta=all_deg/point_at_round;

    for(int i=0;i<point_at_round;++i){
        double x=cos(delta*i)*1e11,y=sin(delta*i)*1e11;
        double md=1e25; int mdi=-1;
        for(int i=1;i<=n;++i){
#define sq(x) ((x)*(x))
            double nd=sq(p[i].first-x)+sq(p[i].second-y);
            if(nd<md){
                md=nd;
                mdi=i;
            }
        }
        ++cnt[mdi];
    }

    for(int i=1;i<=n;++i)cout<<fixed<<setprecision(9)<<(double)cnt[i]/point_at_round<<'\n';
}


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

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

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

#define MAX 100005
#define INF 1001001001

void out(vector<int> a) {
  int n = a.size();
  rep(i,n) {
    cout << a[i];
    if (i==n-1) cout << endl;
    else cout << " ";
  }
}
int main(int, char**)
{
  int n;
  cin >> n;
  vector<int> a(n);
  iota(a.begin(), a.end(), 1);
  do {
    out(a);
  } while (next_permutation(a.begin(), a.end()));

  return 0;
}



Measured memory_bytes: 3156
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
   int n,a,b,cnt1=0,cnt2=0,cnt3=0; cin>>n>>a>>b;
   rep(i,0,n)
   {
     int x; cin>>x;
     cnt1+=(x<=a);
     cnt2+=(x>a and x<=b);
     cnt3+=(x>b);
   }
   cout<<min(cnt1,min(cnt2,cnt3));
}
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n,q;
    cin >> n >> q;
    vector<vector<int>> tree(n, vector<int>(0));
    vector<ll> X(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        tree[a-1].push_back(b-1);
        tree[b-1].push_back(a-1);
    }
    rep(i,q){
        int p;
        ll x;
        cin >> p >> x;
        X[p - 1] += x;
    }
    queue<int> qu;
    vector<int> memo(n);
    qu.push(0);
    memo[0] = 1;
    while(!qu.empty()){
        int ci = qu.front();
        qu.pop();
        for(int r: tree[ci]){
            if(memo[r] == 0){
                qu.push(r);
                memo[r] = 1;
                X[r] += X[ci];
            }
        }
    }
    rep(i,n){
        cout << X[i] << " ";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 17140
#include <bits/stdc++.h>
using namespace std;
const int N = 105, MOD = 1e9 + 7;
int sum[N][4000], dp[N][4000];
int main() {
	int n, k, res = 0;
	scanf("%d%d", &n, &k);
	dp[n + 1][0] = 1;
	for (int i = n; i >= 1; -- i) {
		for (int cnt = 0; cnt <= res; ++ cnt) {
			for (int x = 0; x <= k; ++ x) {
				if (x > i) {
					(dp[i][cnt] += dp[i + 1][cnt]) %= MOD;
					(sum[i][cnt] += (sum[i + 1][cnt] + 1LL * dp[i + 1][cnt] * (x + cnt) % MOD) % MOD) %= MOD;
				}
				else {
					int cc = cnt + (x + cnt) / i;
					(dp[i][cc] += dp[i + 1][cnt]) %= MOD;
					(sum[i][cc] += (sum[i + 1][cnt] + 1LL * dp[i + 1][cnt] * ((x + cnt) % i) % MOD) % MOD) %= MOD;
				}
			}
		}
		res += (res + i) / i;
	}
	int ans = 0;
	for (int i = 0; i <= res; ++ i) (ans += sum[1][i]) %= MOD;
	printf("%d\n", ans);
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD_Q 1e9 + 7
#define MOD_A 998244353

 #define int long long


int MIN = I64_MAX;

void solve()
{

  int N;
  cin>>N; 
  string S1,S2;
  int Nf = N/2;

  for (int i = 0; i < Nf; i++)
  {
    char st;
    cin>>st;
    S1.push_back(st);
  }

  for (int i = Nf; i < N; i++)
  {
    char st;
    cin>>st;
    S2.push_back(st);
  }

  if(S1 == S2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  
  return;  
}
 
int32_t main(int32_t argc, const char *argv[])
{
 
  solve();
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  if ((A + B) > (C + D) ){
    cout << "Left" << endl;
  }
  else if((A + B) < (C + D)){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl; 
  }
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=5000;
const int MAXM=200;

int n,m;
int d[MAXN-1];
int x[MAXN][MAXM];

int stck[MAXM][MAXN],nstck[MAXM];

ll sval[4*MAXN];
ll slazy[4*MAXN];
void smod(int x,int l,int r,int L,int R,ll BY) {
	if(L<=l&&r<=R) {
		sval[x]+=BY;
		slazy[x]+=BY;
	} else {
		int m=l+(r-l)/2;
		if(L<=m) smod(2*x+1,l,m,L,R,BY);
		if(m+1<=R) smod(2*x+2,m+1,r,L,R,BY);
		sval[x]=slazy[x]+max(sval[2*x+1],sval[2*x+2]);
	}
	//printf("smod(%d..%d,%d..%d,%lld) -> %lld\n",l,r,L,R,BY,sval[x]);
}

ll lft[MAXN]; int mark[MAXN],curmark; int q[MAXN],nq;
void smod(int pos,ll by) { if(mark[pos]!=curmark) mark[pos]=curmark,lft[pos]=0,q[nq++]=pos; lft[pos]+=by; }
void spush() { REP(i,nq) smod(0,0,n-1,0,q[i],lft[q[i]]); ++curmark; nq=0; }

void run() {
	scanf("%d%d",&n,&m);
	REP(i,n-1) scanf("%d",&d[i]);
	REP(i,n) REP(j,m) scanf("%d",&x[i][j]);
	//n=MAXN,m=MAXM; REP(i,n-1) d[i]=rand(); REP(i,n) REP(j,m) x[i][j]=rand();

	ll ret=0;
	REP(k,m) nstck[k]=0;
	memset(sval,0,sizeof(sval)); memset(slazy,0,sizeof(slazy));
	memset(lft,0,sizeof(lft)); memset(mark,-1,sizeof(mark)); curmark=0; nq=0;
	REP(i,n) {
		REP(k,m) {
			int was=0;
			while(nstck[k]>0) {
				int j=stck[k][nstck[k]-1];
				if(x[j][k]>x[i][k]) {
					smod(j,-(x[i][k]-was));
					break;
				} else {
					smod(j,-(x[j][k]-was));
					was=x[j][k];
					--nstck[k];
				}
			}
			stck[k][nstck[k]++]=i;
		}
		ll only=0; REP(k,m) only+=x[i][k]; smod(i,+only);
		spush();
		ll cur=sval[0];
		if(cur>ret) ret=cur;
		if(i!=n-1) smod(i,-d[i]);
	}
	printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}


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



int main(){
    int N;
    int A = 1000000;
    cin >> N;
    vector<int> vec(N,0);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    for(int i=0;i<100;i++){
        int B = 0;
        for(int j=0;j<N;j++){
            B += (vec.at(j)-i)*(vec.at(j)-i);
        }
        if(B<A){
            A = B;
        }
    }
    cout << A << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main()
{
	int nLen;
	cin >> nLen;
	char szS[100];
	char szT[100];
	char szX[200];
	memset(szS, NULL, sizeof(szS));
	memset(szT, NULL, sizeof(szT));
	memset(szX, NULL, sizeof(szX));
	cin >> szS;
	cin >> szT;

	for (int i = 0; i < nLen; i++)
	{
		szX[i*2] = szS[i];
		szX[i*2+1] = szT[i];
	}
	cout << szX;
	return 0;
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define MOD 998244353LL
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}

bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n){
    	cin >> a[i];
    }
    sort(a, a+n);
    int sum = 0;
    rep(i, 0, n-1){
    	sum += a[i];
    }
    if(sum > a[n-1]){
    	cout << "Yes" << endl;
    }
    else
    	cout << "No" << endl;
}

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

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

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

constexpr ll mod = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    vector<ll> t(n);
    for (int i=0; i<n; i++) {
        cin >> t.at(i);
    }
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    if (a.at(0) != t.at(n-1)) {
        cout << 0 << "\n";
        return;
    }
    vector<ll> mnt(n);
    mnt.at(0) = (t.at(0) > a.at(0)) ? 0 : 1;
    mnt.at(n-1) = (a.at(n-1) > t.at(n-1)) ? 0 : 1;
    for (int i=1; i<n-1; i++) {
        bool isSameT = (t.at(i) == t.at(i-1));
        bool isSameA = (a.at(i) == a.at(i+1));
        if (isSameT && isSameA) {
            mnt.at(i) = min(t.at(i), a.at(i));
        } else if (isSameT) {
            if (a.at(i) > t.at(i)) mnt.at(i) = 0;
            else mnt.at(i) = 1;
        } else if (isSameA) {
            if (t.at(i) > a.at(i)) mnt.at(i) = 0;
            else mnt.at(i) = 1;
        } else {
            if (t.at(i) != a.at(i)) mnt.at(i) = 0;
            else mnt.at(i) = 1;
        }
    }
    ll ans = 1;
    for (int i=0; i<n; i++) {
        ans *= mnt.at(i);
        ans %= mod;
    }
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	cin >> S;
	bool flg = true;
	for(int i = 0; i < S.length(); i++){
		if((i%2 && S[i] == 'R') || (i%2-1 && S[i] == 'L')){
			flg = false;
			break;
		}
	}
	cout << (flg?"Yes":"No") << endl;
}

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

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

const ll MOD = 1e9 + 7;

vector<ll> as, bs;
ll na, nb;
ll N, K;

ll calProd(vector<ll>& cs){
	ll res = cs[0];
	for(int i=1; i<cs.size(); i++){
		res *= cs[i];
		res %= MOD;
	}
	return (res + MOD) % MOD;
}

ll solve(){
	sort(as.begin(), as.end());
	sort(bs.begin(), bs.end());
	reverse(as.begin(), as.end());
	na = as.size(); nb = bs.size();
	vector<ll> cs;
	if(K == N){
		for(int a : as) cs.push_back(a);
		for(int b : bs) cs.push_back(b);
		return calProd(cs);
	}

	int i = 0, j = 0;
	while(cs.size() < (K/2)*2){
		int lc = cs.size();
		if(i + 1 < na && j + 1 < nb){
			if(as[i] * as[i+1] > bs[j] * bs[j+1]){
				cs.push_back(as[i]); cs.push_back(as[i+1]);
				i+=2;
			} else {
				cs.push_back(bs[j]); cs.push_back(bs[j+1]);
				j+=2;
			}
		}else if(i + 1 < na){
			cs.push_back(as[i]); cs.push_back(as[i+1]);
			i+=2;
		}else if(j + 1 < nb){
			cs.push_back(bs[j]); cs.push_back(bs[j+1]);
			j+=2;
		}
		if(cs.size() == lc) break;
	}

	if(K % 2 && i<na){
		cs.push_back(as[i]);
	}

	if(cs.size() == K) return calProd(cs);

	reverse(bs.begin(), bs.end());
	cs.clear();
	i = 0, j = 0;
	while(cs.size() < K){
		while(cs.size() < K && j < nb){
			cs.push_back(bs[j]);
			j++;
		}
		while(cs.size() < K && i < na){
			cs.push_back(cs[i]);
			i++;
		}

	}

	return calProd(cs);

}

int main(){
	scanf("%lld%lld", &N, &K);
	for(int i=0; i<N; i++){
		int a;
		scanf("%d", &a);
		if(a < 0) bs.push_back(a);
		else as.push_back(a);
	}

	cout<<solve()<<endl;
    return 0;
}






Measured memory_bytes: 8020
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int a, b; cin >> a >> b;
  int ans = 0;
  FOR(i, a, b + 1) {
    string s = to_string(i);
    ans += s[0] == s[4] && s[1] == s[3];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n, dp[110][4][4][4], ans = 0;

int main() {
	cin >> n;
	if (n == 3) {
		cout << 61 << endl;
		return 0;
	}
	REP(i, 4)REP(j, 4)REP(k, 4) dp[3][i][j][k] = 1;
	dp[3][1][2][3] = 0;
	dp[3][1][3][2] = 0;
	dp[3][2][1][3] = 0;
	FOR(no, 3, n) {
		REP(i, 4) {
			REP(j, 4) {
				REP(k, 4) {
					if (j == 1 and k == 3) {
						REP(ne, 4) {
							if (ne != 2) dp[no + 1][1][3][ne] += dp[no][i][j][k];
						}
					}
					else if (j == 2 and k == 1) {
						REP(ne, 4) {
							if (ne != 3) dp[no + 1][2][1][ne] += dp[no][i][j][k];
						}
					}
					else if (j == 1 and k == 2) {
						REP(ne, 4) {
							if (ne != 3) dp[no + 1][1][2][ne] += dp[no][i][j][k];
						}
					}
					else if (i == 1 and j == 2) {
						REP(ne, 4) {
							if (ne != 3) dp[no + 1][2][k][ne] += dp[no][i][j][k];
						}
					}
					else if (i == 1 and k == 2 and j != 2) {
						REP(ne, 4) {
							if (ne != 3) dp[no + 1][j][2][ne] += dp[no][i][j][k];
						}
					}
					else {
						REP(ne, 4) {
							dp[no + 1][j][k][ne] += dp[no][i][j][k];
						}
					}
					REP(ii, 4)REP(jj, 4)REP(kk, 4) dp[no + 1][ii][jj][kk] %= MOD;
				}
			}
		}
	}
	REP(i, 4)REP(j, 4)REP(k, 4) ans += dp[n][i][j][k];
	cout << ans % MOD << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a;
    cin>>a;
    int n;
    n=a.size();
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i+=2){
        cout<<a[i];
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
	int m, f, r;
	char student[300];
	int count = 0;
	while (true)
	{
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1)
		{
			break;
		}
		int total = m + f;
		if (m == -1 || f == -1 || total < 30)
		{
			student[count] = 'F';
		}
		else if (total >= 80)
		{
			student[count] = 'A';
		}
		else if (total >= 65)
		{
			student[count] = 'B';
		}
		else if (total >= 50)
		{
			student[count] = 'C';
		}
		else if (total >= 30)
		{
			student[count] = 'D';
			if (r >= 50)
			{
				student[count] = 'C';
			}
		}

		count++;
	}

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

	return 0;
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0; i < 3; i++){
            a[i] = sc.nextInt();
        }
        
        Arrays.sort(a);
        
        for(int i = 0; i < a.length; i++){
            System.out.print(a[i]);
            if (i != a.length -1){
                System.out.print(" ");
            }else{
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 26240
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
        int ans = 0;
        int r,g,b,n; cin >> r >> g >> b >> n;
        for(int i=0;i <= 3005;i++){
            for(int j=0;j <= 3005; j++){
                if(i*r + j*g <= n && ((n - i*r - j*g) % b) == 0) ans++;
            }
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <bits/stdc++.h>
#include <cstdlib>
#include <math.h> 
using namespace std;
#define ll long long int
int main()
{
	int n;
	ll ans;
	cin>>n;
	ll a[n],b[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	if(n%2)
	{
		ans=b[n/2]-a[n/2]+1;
	}
	else
	{
		ans=b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6724
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,ko;
    ll x,y,w,z;
    char hoge,fuga;
    cin>>n;
    b=n;
    while(b>0){
        sum+=b%10;
        b/=10;
    }
    if(n%sum) No;
    else Yes;

    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		int ans = 0;

		for(int i = 0; i < n; i++){
			h[i] = sc.nextInt();
			if(h[i] >= k){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

int main(int argc, char const *argv[]) {
  string a, s, c, ans;
  cin >> a >> s >> c;
  ans.push_back('A');
  ans.push_back(s[0]);
  ans.push_back('C');
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    Vi a(n);
    rp(i,n) cin >> a.at(i);
    int ans=100000;
    rp(i,n){
        int ctr=0;
        while(a[i]%2==0){
            a[i]/=2;
            ctr++;
        }
        chmin(ans,ctr);
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

const long long MAX_N = 25e6 + 150, inf = 1e9 + 7;
long long n, A1, A2, A3, B1, B2, B3;
long long dp[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n  >> A1 >> A2 >> A3 >> B1 >> B2 >> B3;
	dp[0] = 0;
	for (long long i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		if (A1 <= i)
			dp[i] = max(dp[i], dp[i - A1] + B1 - A1);
		if (A2 <= i)
			dp[i] = max(dp[i], dp[i - A2] + B2 - A2);
		if (A3 <= i)
			dp[i] = max(dp[i], dp[i - A3] + B3 - A3);
	}

	n += dp[n];

	memset(dp, 0, sizeof dp);
	for (long long i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		if (B1 <= i)
			dp[i] = max(dp[i], dp[i - B1] + A1 - B1);
		if (B2 <= i)
			dp[i] = max(dp[i], dp[i - B2] + A2 - B2);
		if (B3 <= i)
			dp[i] = max(dp[i], dp[i - B3] + A3 - B3);
	}

	cout << n + dp[n] << "\n";
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,a,b; cin>>n>>a>>b;
    if((b-a)%2==0) cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

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

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int q; cin >> q;

    REP(_, q) {
        string x, y; cin >> x >> y;

        vector<vi> dp(x.size() + 1, vi(y.size() + 1, 0));

        REP(i, x.size()) REP(j, y.size()) {
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + int(x[i] == y[j]));
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j+1]);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i+1][j]);
        }

        print(dp[x.size()][y.size()]);
    }

}


Measured memory_bytes: 6820
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=100005*4,INF=1e9;
namespace flows{
	const int M=N*(2+2)*2;
	struct Edge{
		int x,y,cap,nxt;
		Edge(){}
		Edge(int _x,int _y,int _cap,int _nxt){
			x=_x,y=_y,cap=_cap,nxt=_nxt;
		}
	}e[M];
	int cnt,n,S,T;
	int fst[N],dis[N],cur[N];
	void clear(int _n,int _S,int _T){
		n=_n,S=_S,T=_T,cnt=1;
		clr(fst);
	}
	void Add(int x,int y,int cap){
		e[++cnt]=Edge(x,y,cap,fst[x]),fst[x]=cnt;
		e[++cnt]=Edge(y,x,0,fst[y]),fst[y]=cnt;
	}
	int bfs(){
		static int q[N];
		int head=0,tail=0;
		memset(dis,-1,sizeof dis);
		dis[S]=0;
		q[++tail]=S;
		while (head<tail){
			int x=q[++head];
			for (int i=fst[x];i;i=e[i].nxt){
				int y=e[i].y;
				if (!~dis[y]&&e[i].cap){
					dis[y]=dis[x]+1;
					q[++tail]=y;
				}
			}
		}
//		outarr(dis,1,n);
		return dis[T]!=-1;
	}
	int dfs(int x,int Lim){
		if (x==T||!Lim)
			return Lim;
		int now=Lim;
		for (int &i=cur[x];i;i=e[i].nxt){
			int y=e[i].y;
			if (e[i].cap&&dis[x]+1==dis[y]){
				int d=dfs(y,min(now,e[i].cap));
				e[i].cap-=d,e[i^1].cap+=d;
				now-=d;
				if (!now)
					break;
			}
		}
		return Lim-now;
	}
	int Dinic(){
		int flow=0;
		while (bfs()){
			For(i,1,n)
				cur[i]=fst[i];
			flow+=dfs(S,INF);
//			outval(flow);
		}
		return flow;
	}
}
int n;
vector <int> s[N],e[N];
int q[N],mat[N],fa[N],vis[N];
int main(){
	n=read();
	int S=(n-1)*2+1,T=S+1;
	flows::clear(T,S,T);
	For(i,1,n-1){
		flows::Add(S,i,1);
		flows::Add(i+n-1,T,1);
		int k=read();
		while (k--){
			int j=read();
			s[i].pb(j);
			e[j].pb(i);
			if (j!=n){
				flows::Add(j,i+n-1,1);
			}
		}
	}
	if (flows::Dinic()<n-1)
		return puts("-1"),0;
	For(i,2,flows::cnt){
		int x=flows::e[i].x,y=flows::e[i].y;
		if (!flows::e[i].cap&&1<=x&&x<=n-1&&n<=y&&y<=n*2-2){
			mat[y-(n-1)]=x;
		}
	}
	int head=0,tail=0;
	q[++tail]=n;
	while (head<tail){
		int x=q[++head];
		for (auto y : e[x]){
			if (vis[y])
				continue;
			vis[y]=1;
			fa[y]=x;
			q[++tail]=mat[y];
		}
	}
	if (tail<n)
		return puts("-1"),0;
	For(i,1,n-1)
		printf("%d %d\n",fa[i],mat[i]);
	return 0;
}

Measured memory_bytes: 52344
#include <stdio.h>

#define MAX 100000

typedef struct node_t {
	int depth;
	int parent;
	int left;
	int right;
} node;

node u[MAX];

int d(int);

int main(void)
{
	int i, j, n, id, k, c1, c2;
	
	scanf("%d",&n);
	
	for (id=0; id<n; id++) {
		u[id].depth = u[id].parent = u[id].right = -1;
	}
	
	for (i=0; i<n; i++) {
		scanf("%d %d", &id, &k);
		if(k==0) {
			u[id].left = -1;
		} else {
			for (j=0; j<k; j++) {
				if(j==0) {
					scanf("%d", &c1);
					u[id].left = c1;
					u[c1].parent = id;
				} else {
					scanf("%d", &c2);
					u[c2].parent = id;
					u[c1].right = c2;
					c1 = c2;
				}
			}
		}
	}
	
	for (id=0; id<n; id++) {
		printf("node %d: parent = %d, depth = %d, ", id, u[id].parent, d(id));
		if(u[id].parent == -1) {
			printf("root, [");
		} else if(u[id].left == -1) {
			printf("leaf, [");
		} else {
			printf("internal node, [");
		}
		c1 = u[id].left;
		if(c1 != -1) {
			while (1) {
				c2 = u[c1].right;
				if (c2 == -1) {
					printf("%d",c1);
					break;
				} else {
					printf("%d, ",c1);
					c1 = c2;
				}
			}
		}
		printf("]\n");
	}
	
	return 0;
}

int d(int id)
{
	if(u[id].depth!=-1) {
		return u[id].depth;
	}
	if(u[id].parent == -1) {
		u[id].depth = 0;
		return 0;
	}
	u[id].depth = d(u[id].parent) + 1;
	return u[id].depth;
}

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

int main(){
  int n; cin >> n;
  int a[100000]={}, b[100000]={};
  for(int i=0; i<n; i++){
    int k; cin >> k;
    if(i%2==0) a[k-1]++;
    else b[k-1]++;
  }
  int amax=-1,bmax=-1;
  int amaxi,bmaxi;
  for(int i=0; i<100000; i++){
    if(amax<a[i]){
      amax=a[i];
      amaxi=i;
    }
    if(bmax<b[i]){
      bmax=b[i];
      bmaxi=i;
    }
  }
  if(amaxi!=bmaxi){
    cout << n-amax-bmax << endl;
  }else{
    a[amaxi]=0; b[bmaxi]=0;
    int amax2=-1,bmax2=-1;
    int amaxi2,bmaxi2;
    for(int i=0; i<100000; i++){
      if(amax2<a[i]){
        amax2=a[i];
        amaxi2=i;
      }
      if(bmax2<b[i]){
        bmax2=b[i];
        bmaxi2=i;
      }
    }
    cout << n-max(amax+bmax2,amax2+bmax) << endl;
  }
}

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

using namespace std;

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

  int h, w;
  cin >> h >> w;
  string stripe(w+2, '#');
  string s;
  cout << stripe << endl;
  for (int i = 0; i < h; ++i) {
    cin >> s;
    cout << '#' << s << '#' << endl;
  }
  cout << stripe << endl;

  return 0;
}



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

int main() {
  string A, B;
  cin >> A >> B;
  if (A.size() != B.size()) {
    cout << (A.size() > B.size() ? "GREATER" : "LESS") << endl;
    return 0;
  }
  cout << (A > B ? "GREATER" : A < B ? "LESS" : "EQUAL") << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 

const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;

int H, W;
ll dp[1005][1005];
char grid[1005][1005];

int main(){ FAST
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

    cin >> H >> W;
    F0R(i,H) F0R(j,W) cin >> grid[i][j];
    dp[0][0] = 1;
    FOR(j,1,W){
        if(grid[0][j] == '.'){
            dp[0][j] = dp[0][j-1];
        }
        else{
            dp[0][j] = 0;
        }
    }
    FOR(i,1,H){
        if (grid[i][0] == '.'){
            dp[i][0] = dp[i-1][0];
        }
        else{
            dp[i][0] = 0;
        }
    }
    FOR(i,1,H){
        FOR(j,1,W){
            if (grid[i][j] == '#') continue;
            if (grid[i][j-1] == '.') dp[i][j] = (dp[i][j-1] + dp[i][j]) % INF;
            if (grid[i-1][j] == '.') dp[i][j] = (dp[i-1][j] + dp[i][j]) % INF;
        }
    }
    finish(dp[H-1][W-1]);













	return 0;
}


Measured memory_bytes: 9088
n,m = map(int,input().split())

t = n * m
if m > 1 and n == 1:
  print(m - 2)
elif n > 1 and m == 1:
  print(n - 2)
elif n == 1 and m == 1:
  print(1)
else:  
  print(t - (n * 2 + m * 2 -4))


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

#define MAX 1000005
int dp[MAX];

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < MAX; i++) {
        dp[i] = 0;
    }
    for (int x : A) {
        if (dp[x] > 2)
            continue;
        for (int j = x; j < MAX; j += x)
            dp[j]++;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (dp[A[i]] == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8276
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
int a[100010] = {};
signed main() {
	int n, s;
	cin >> n;
	s = n + 1;
	int m = comb(n, 2) - n / 2;
	if (n % 2 == 0) {
		loop(i, 1, s) {
			a[i] = s - i;
		}
		cout << m << endl;
		loop(i, 1, s) {
			loop(j, 1, s) {
				if (j != i && j != a[i]&&i<j) {
					cout << i << ' ' << j << endl;
				}
			}
		}
	}
	else {
		loop(i, 1, s) {
			a[i] = n - i;
		}
		cout << m << endl;
		
		loop(i, 1, s) {
			loop(j, 1, s) {
				if (j != i && j != a[i]&&i<j) {
					cout << i << ' ' << j << endl;
				}
			}
		}
	}
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n, a[200009], b[200009], c[200009];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    b[0] = a[0];
    c[n-1] = a[n-1];
    for(int i=1;i<n;i++){
        b[i] = max(b[i-1], a[i]);
    }
    for(int i=n-2;i>=0;i--){
        c[i] = max(c[i+1], a[i]);
    }
    cout << c[1] << endl;
    for(int i=1;i<n-1;i++){
        cout << max(b[i-1], c[i+1]) << endl;
    }
    cout << b[n-2] << endl;
}

Measured memory_bytes: 3968
#include <stdio.h>

#define MAX 1000000
#define MAX_INDEX 100

int InsertionSort(int [],int,int);
int ShellSort(int [],int);

int main(){
  int A[MAX];
  int i,n;
  int cnt;
  
  scanf("%d",&n);

  for (i = 0;i < n;i++)
    scanf("%d",&A[i]);

  cnt = ShellSort(A,n);

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

int InsertionSort(int A[],int n,int g){
  int i,j,v,cnt = 0;
  
  for (i = g;i < n;i++){
    v = A[i];
    j = i - g;
    
    while (j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
  
    A[j + g] = v;
}

  return cnt;
}
  
int ShellSort(int A[],int n){
  int i,cnt = 0,m,h = 1;
  int G[MAX_INDEX];
  
  for (i = 0;i < MAX_INDEX;i++){
    if (h > n)
      break;
    
    G[i] = h;
    h = 3*h + 1;
  }
  
  m = i;

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

  for (i = 0;i < m;i++){
    if (i)
      printf(" ");

    printf("%d",G[m-1 - i]);
  }

  printf("\n");
  
  for (i = 0;i < m;i++)
    cnt += InsertionSort(A, n, G[m-1 - i]);

    return cnt;
}



Measured memory_bytes: 5632
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    if (S.find("AC") != string::npos) {
        yes;
    } else no;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  mat a(n,vec(n));
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      cin >> a[i][j];
    }
  }
  vec dp(1<<n);
  for(ll i=0;i<(1<<n);i++) {
    for(ll j=0;j<n;j++) {
      for(ll k=j+1;k<n;k++) {
        if((i>>j)&(i>>k)&1) {
          dp[i]+=a[j][k];
        }
      }
    }
    for(ll j=i;j>0;j=(j-1)&i) {
      dp[i]=max(dp[i],dp[j]+dp[i^j]);
    }
  }
  cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{   
    int k, n;
    cin >> k >> n;
    int as[1000000] = {0};

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

    int ans = -1;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, as[i] - as[i - 1]);
    }

    cout << k - ans << endl;

    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

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

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll A,B,C,D;cin >> A >> B >> C >> D;
  A--;
  ll sum = B-A;
  ll LCM = C/gcd(C,D) * D;
  sum -= B/C - A/C;
  sum -= B/D - A/D;
  sum += B/LCM - A/LCM;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    int x = n*(n-1)/2;
    int y = m*(m-1)/2;
    cout << x+y << endl;
}

Measured memory_bytes: 892
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define INF (1<<29)
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;

int main(){
	int W;
	for( int n = 1; cin >> W; n++ ){
		if( W == 0 ) break;
		int N;
		cin >> N;
		vi v(N), w(N);
		for( int i = 0; i < N; i++ ){
			scanf("%d,%d", &v[i], &w[i]);
		}
		// DP
		vector<vector<pii> > dp(N+1, vector<pii>(W+1,mp(0,0)));
		for( int i = 1; i <= N; i++ ){
			for( int j = 1; j <= W; j++ ){
				pii upperLeft = dp[i-1][j-w[i-1]], upper = dp[i-1][j];
				if( j-w[i-1] < 0 ){
					dp[i][j] = upper;
				}else{
					if( upper.first == upperLeft.first+v[i-1] ){
						dp[i][j] = mp(upper.first, min(upper.second, upperLeft.second+w[i-1]));
					}else if( upper.first < upperLeft.first+v[i-1] ){
						dp[i][j] = mp(upperLeft.first+v[i-1], upperLeft.second+w[i-1]);
					}else{
						dp[i][j] = upper;
					}
				}
			}
		}
		cout << "Case " << n << ":" << endl;
		cout << dp[N][W].first << endl;
		cout << dp[N][W].second << endl;
	}
}

Measured memory_bytes: 9012