akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

long long extgcd(long long a, long long b, long long &x, long long &y) {
    long long g = a;
    if(b != 0){
        g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1;
        y = 0;
    }
    return g;
}

long long mod_inverse(long long a, long long m)
{
    long long x, y;
    extgcd(a, m, x, y);
    return (x % m + m) % m;
}

class FactorialCalculation
{
private:
    const int mod;
    vector<long long> factorial;
    vector<long long> invFactorial;
public:
    FactorialCalculation(int n, int mod) : mod(mod)
    {
        factorial.resize(n+1, 1);
        invFactorial.resize(n+1, 1);
        for(int i=1; i<=n; ++i){
            factorial[i] = factorial[i-1] * i % mod;
            invFactorial[i] = mod_inverse(factorial[i], mod);
        }
    }
    long long getFactorial(int n){
        return factorial[n];
    }
    long long getInvFactorial(int n){
        return invFactorial[n];
    }
    long long getPermutation(int n, int r){
        if(n < r)
            return 0;
        return factorial[n] * invFactorial[n-r] % mod;
    }
    long long getCombination(int n, int r){
        if(n < r)
            return 0;
        return getPermutation(n, r) * invFactorial[r] % mod;
    }
    long long getHomogeneous(int n, int r){
        return getCombination(n+r-1, r);
    }
};

const int MOD = 1000000007;

int main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    FactorialCalculation fc(n, MOD);

    vector<long long> dp(n+1, 0);
    dp[n] = 1;
    for(int i=a; i<=b; ++i){
        for(int j=1; j<=n; ++j){
            long long tmp = 1;
            int x = 0;
            for(int f=1; f<=d; ++f){
                x += i;
                if(j < x)
                    break;

                tmp *= fc.getCombination(j-x+i, i);
                tmp %= MOD;

                if(f >= c){
                    long long add = dp[j] * tmp;
                    add %= MOD;
                    add *= fc.getInvFactorial(f);
                    add %= MOD;
                    dp[j-x] += add;
                    dp[j-x] %= MOD;
                }
            }
        }
    }
    cout << dp[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define pp(a, b) pair <a, b>
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define itr iterator
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
 
 
using namespace __gnu_pbds;
using namespace std;
 
template <class T> T printr(T p){ cout << p << '\n'; return 0; }
template <class T> T printe(T p){ cout << p << '\n'; exit(0); }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
 
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif
 
ll power(ll x, ll y, ll p){ 
   ll res = 1;
   x = x % p;  
   while (y > 0) {
      if (y & 1) 
         res = (res * x) % p; 
      y = y >> 1;
      x = (x * x) % p; 
   }
   return res;
}
 
const ll INF = (ll)(8e18);
const ll MOD = 1e9 + 7;
 
const int maxn = 200010;

ll a[maxn], s[maxn];
map <ll , ll> mp;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int n, k; cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    if(k == 1){
        cout << 0 << '\n';
        return 0;
    }
    for(int i = 1; i <= n; i++){
        s[i] = s[i - 1] + a[i];
        s[i] %= k;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i > k){
            mp[(s[i - k] - ((i - k) % k) + k) % k] -= 1;
        }
        ans += mp[(s[i] - (i % k) + k) % k];
        if(s[i] == i) ans += 1;
        mp[(s[i] - (i % k) + k) % k] += 1;
    }
    cout << ans << '\n';
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 15872
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const long long INF=4223372036854775807ll;
const int SIZE=200005;
const double EPS=1e-6;

long long dp[SIZE][5],a[SIZE];

int main(){
	/*main function start*/
	int l;
	scanf("%d",&l);
	for(int i=0;i<l;i++){
		scanf("%lld",a+i);
	}
	for(int i=0;i<=l;i++){
		dp[i][0]=dp[i][1]=dp[i][2]=dp[i][3]=dp[i][4]=INF;
	}
	dp[0][0]=0;
	for(int i=1;i<=l;i++){
		if(a[i-1]==0){
			long long p=dp[i-1][0];
			dp[i][0]=p;
			p=min(p,dp[i-1][1]);
			dp[i][1]=p+2;
			p=min(p,dp[i-1][2]);
			dp[i][2]=p+1;
			p=min(p,dp[i-1][3]);
			dp[i][3]=p+2;
			p=min(p,dp[i-1][4]);
			dp[i][4]=p;
		}
		else if(a[i-1]%2==0){
			long long p=dp[i-1][0];
			dp[i][0]=p+a[i-1];
			p=min(p,dp[i-1][1]);
			dp[i][1]=p;
			p=min(p,dp[i-1][2]);
			dp[i][2]=p+1;
			p=min(p,dp[i-1][3]);
			dp[i][3]=p;
			p=min(p,dp[i-1][4]);
			dp[i][4]=p+a[i-1];
		}
		else{
			long long p=dp[i-1][0];
			dp[i][0]=p+a[i-1];
			p=min(p,dp[i-1][1]);
			dp[i][1]=p+1;
			p=min(p,dp[i-1][2]);
			dp[i][2]=p;
			p=min(p,dp[i-1][3]);
			dp[i][3]=p+1;
			p=min(p,dp[i-1][4]);
			dp[i][4]=p+a[i-1];
		}
	}
	long long ans=min(min(min(dp[l][0],dp[l][1]),min(dp[l][2],dp[l][3])),dp[l][4]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>

int main() {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    auto left = a + b;
    auto right = c + d;
    if (left > right) {
        std::cout << "Left";
    } else if (left < right) {
        std::cout << "Right";
    } else {
        std::cout << "Balanced";
    }
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    cout << (1000-n%1000) % 1000 << endl;
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  vector<pair<int, int>> data_array;

  for (int i = 0;; i++) {
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) break;

    data_array.emplace_back(x, y);
  }

  for (auto &&i : data_array) {
    if (i.first > i.second) {
      swap(i.first, i.second);
    }
    cout << i.first << " " << i.second << endl;
  }

  return 0;
}



Measured memory_bytes: 3044
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    vec A(N), B(N);
    Rep (i, N) {
        cin >> A[i] >> B[i];
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    ll m, M;
    if (N % 2 == 1) {
        m = A[N/2];
        M = B[N/2];
    } else {
        m = A[N/2]+A[N/2-1];
        M = B[N/2]+B[N/2-1];
    }

    cout << M-m+1 << "\n";
}

Measured memory_bytes: 6340
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	vector<vector<int> > G(N);
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			if (A[i] > A[j]) {
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	vector<int> va, vb;
	vector<int> col(N, -1);
	bool ok = true;
	for (int i = 0; i < N && ok; ++i) {
		if (col[i] != -1) continue;
		queue<int> que;
		que.push(i);
		col[i] = 0;
		int ca = 0, cb = 0;
		while (!que.empty()) {
			int u = que.front(); que.pop();
			if (col[u] == 0) ++ca;
			else ++cb;
			for (int j : G[u]) {
				if (col[j] == -1) {
					col[j] = col[u] ^ 1;
					que.push(j);
				}
				else if (col[j] == col[u]) {
					ok = false;
					break;
				}
			}
		}
		va.push_back(ca);
		vb.push_back(cb);
	}
	if (!ok) {
		cout << 0 << endl;
	}
	else {
		vector<int> dp(N + 1, 0);
		dp[0] = 1;
		for (int i = 0; i < va.size(); ++i) {
			vector<int> ndp(N + 1, 0);
			for (int j = 0; j <= N; ++j) {
				if (j >= va[i]) ndp[j] += dp[j - va[i]];
				if (j >= vb[i]) ndp[j] += dp[j - vb[i]];
				if (ndp[j] >= mod) ndp[j] -= mod;
			}
			dp = ndp;
		}
		int ans = 0;
		for (int i = N - M; i <= M; ++i) {
			ans += dp[i];
			if (ans >= mod) ans -= mod;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 5952
#include <stdio.h>

int main(void)
{
    int S, h, m, s;
    
    scanf("%d", &S);
    
    s = S % 60;
    m = (S - s) / 60 % 60;
    h = (S - s) / 60 / 60;
    
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m,k;
char str[200010];
string s;
int a[200010],b[200010];
int tac;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	scanf("%s",&str);
	s=str;
	tac=0;
	for (int i=0;i<n;i++)
	{
		if (tac==m) break;
		if (s[i]=='x') continue;
		a[tac++]=i,i+=k;
	}
	tac=m-1;
	for (int i=n-1;i>=0;i--)
	{
		if (tac<0) break;
		if (s[i]=='x') continue;
		b[tac--]=i,i-=k;
	}
	for (int i=0;i<m;i++) if (a[i]==b[i]) printf("%d\n",a[i]+1);
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<(n);++i)
#define itn int
#define ocut cout
#define ouct cout
#define outc cout

int main(){
    int n;
    cin >> n;
    int p[n];
    int w=n+1,q=0;
    re(i,n){
        cin >> p[i];
        if(p[i]<w){
            w=p[i];
            q=q+1;
        }
    }
    cout << q;
}



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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;
const int N = 30;


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

    ll sum = 0;
    string n;
    cin>>n;

    for(auto it:n)
        sum += (it - '0');

    if(sum%9 == 0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3740
# AOJ 0108 Operation of Frequency of Appearance
# Python3 2018.6.18 bal4u

f = [0]*105
a = [[0 for j in range(15)] for i in range(2)]
while True:
	n = int(input())
	if n == 0: break
	a[0] = list(map(int, input().split()))
	a[1] = [0]*n
	cnt = k1 = 0
	while True:
		for i in range(n): f[a[k1][i]] += 1
		k2 = 1-k1
		for i in range(n): a[k2][i] = f[a[k1][i]]
		for i in range(n): f[a[k1][i]] = 0
		if a[0] == a[1]: break
		k1 = k2
		cnt += 1
	print(cnt)
	print(*a[0])


Measured memory_bytes: 5604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
          int N = int.Parse(Console.ReadLine());
          string[] s = Console.ReadLine().Split(' ');
          int ans = 0;
          for (int i = 0; i <N; i++)
          {
              if(s[i] == "Y"){
                  ans++;
                  break;
              }
          }
          Console.WriteLine(ans ==0?"Three":"Four");
        }
    }
}


Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main(){
	int n;
	cin >> n;
	int yakusucnt=0, cnt=0;
	for (int i = 1; i <= n; i++) {
		yakusucnt = 0;
		if (i % 2 == 1) {
			for(int j=1 ;j <= n; j++){
				if (i%j == 0) {
					yakusucnt++;
				}
			}
			//cout << yakusucnt << endl;
			if (yakusucnt == 8) cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
#ifdef XS
const int w = 10,h = 10;
#else
const int w = 100,h = 100;
#endif
char ans[200][200];
void inp(){
	int a,b;scanf("%d%d", &a,&b);
	char ca = '.',cb = '#';
	int i;
	// xian gao b yong a 
	for(i =0 ; b > 1 && i< h;i++){
		if( i % 2 == 0 ){
			for(int j = 0; j < w;j++){
				if(b == 1 || j % 2)ans[i][j] = ca;
				else {
					ans[i][j] = cb;
					b --;
				}
			}
		}
		else for(int j =0 ;j<w;j++)ans[i][j] = ca;
	}

	for(int j = 0;j<w;j++)ans[i][j] = ca;
	i++;
	a --;
	// ...........

	// ############
	for(int j = 0;j<w;j++)ans[i][j] = cb;
	i++;
	b --;

	assert( b == 0);
	int f = 0;
	for(;a > 0 &&  i < h;i++, f ++){
		if( f % 2  == 0){
			for(int j =0 ;j<w;j++){
				if( a == 0||j % 2 == 1){
					ans[i][j] = cb;
				}
				else {
					ans[i][j] = ca;
					a--;
				}
			}
		}
		else {
			for(int  j= 0;j<w;j++)ans[i][j] = cb;
		}
	}
	assert(a == 0&& b == 0);
	printf("%d %d\n", i,w);
	for(int k =0 ;k<i;k++){
		for(int j =0 ;j<w;j++){
			putchar(ans[k][j]);
		}
		putchar('\n');
	}
}
//D.cc by xsthunder at Sun Mar 25 20:22:27 2018


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	char s[100],p[100];
	int c = 0;
	int d = 0;
	while(1){
		char a;
		scanf("%c",&a);
		if(a=='\n') break;
		s[c] = a;
		c++;
	}
	while(1){
		char a;
		scanf("%c",&a);
		if(a=='\n') break;
		p[d] = a;
		d++;
	}
	if(c<d){ cout << "No" << endl; return 0;}
	else{
		for(int i=0;i<c;i++){
			int b = 0;
			for(int j=0;j<d;j++){
				int t = (j+i)%c;
				if(p[j]==s[t]) b++;
				else break;
			}
			if(b==d){ cout << "Yes" << endl; return 0;}
		}
	}
	cout << "No" << endl;
}

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

#define ll long long
const int maxn=1e5+10;

int main()
{
    ll n,k,ans=0;
    cin>>n>>k;
    if(k==0){cout<<n*n;return 0;}
    //if(k==1){cout<<n*n-n;return 0;}
    for(int i=k+1;i<=n;i++)
    {
        if(n%i)
        {
            ll t=n/i;
            ans+=t*(i-k);
            if(n%i>=k)if(k)ans+=n%i-k+1;
            else ans+=n%i;
        }
        else
        {
            ll t=n/i;
            ans+=t*(i-k);
        }
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int main() {

	int x;
	cin >> x;
	if (x < 600) {
		cout << 8 << endl;
	}
	else if (x < 800) {
		cout << 7 << endl;
	}
	else if (x < 1000) {
		cout << 6 << endl;
	}
	else if (x < 1200) {
		cout << 5 << endl;
	}
	else if (x < 1400) {
		cout << 4 << endl;
	}
	else if (x < 1600) {
		cout << 3 << endl;
	}
	else if (x < 1800) {
		cout << 2 << endl;
	}
	else if (x < 2000) {
		cout << 1 << endl;
	}

	return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

void solve(){
	ll n,k;
	cin>>n>>k;
	if(n%k==0)
		cout<<0<<endl;
	else{
		ll aux = n/k*k+k;
		cout<<min(n,(ll)abs(n-aux))<<endl;
	}
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3596
from collections import deque

h,w = map(int,input().split())
field = [ list(input()) for _ in range(h) ]

visited = [ [0]*w for _ in range(h) ]
q = deque()

for j in range(h):
    for i in range(w):
        a = field[j][i]
        if a=="#":
            q.append([j,i,0])
            visited[j][i] = 1
        else:
            pass

m = 0
while q:
    y,x,d = q.popleft()
    for j,i in ([1,0],[0,-1],[-1,0],[0,1]):
        ny = y + j
        nx = x + i
        if ny==-1 or nx==-1 or ny==h or nx==w:
            pass
        elif visited[ny][nx]==0:
            visited[ny][nx] = 1
            q.append([ny,nx,d+1])
            m = max(m,d+1)   
print(m)

Measured memory_bytes: 169180
from collections import deque
S=input()
Q=int(input())
query=[list(map(str,input().split())) for _ in range(Q)]

ans=deque(S)
reverse=False
for i,q in enumerate(query):
  if len(q)==1:
    reverse=not reverse
  else:
    _,f,c=q
    if (f=='2') ^ reverse:
      ans.append(c)
    else:
      ans.appendleft(c)
if reverse:
  print(*reversed(ans),sep='')
else:
  print(*ans,sep='')

Measured memory_bytes: 48368
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod= 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e17;
const int inf = 2e9+100;
const int nmax = 2e5+10;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;


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

    int n,m;
    cin>>n>>m;
    vector<int>v(n+1);
    int pen = 0, solv = 0;
    while(m--){
        int p;
        cin>>p;
        string s;
        cin>>s;
        if(s[0]=='A') {
            if(v[p]!=-1) pen+=v[p], v[p] = -1, solv++;
        }
        else {
            if(v[p]!=-1) v[p]++;
        }
    }
    cout<<solv<<" "<<pen<<endl;
}


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

int main() {
  long N,K;
  cin >> N >> K;
  vector<long> h(N);
  for (int i=0;i<N;i++) {
    cin >> h.at(i);
  }
  
  sort(h.begin(), h.end());

  long gap=1000000000;
  for (int i=0;i<N-K+1;i++) {
    if (gap > h.at(i+K-1)-h.at(i)) {
      gap = h.at(i+K-1)-h.at(i);
    }
  }
  cout << gap << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll d = a - b;
  if (k % 2 == 1) d = -d;
  cout << d << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N, M;
  cin >> N >> M;
  vector<int> S(N), T(M);
  for (int i = 0; i < N; i++) cin >> S.at(i);
  for (int i = 0; i < M; i++) cin >> T.at(i);

  vector<vector<int>> dp(N + 10, vector<int>(M + 10, 0));
  dp.at(0).at(0) = 1;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 0; j <= M; j++)
    {
      dp.at(i + 1).at(j) += dp.at(i).at(j);
      dp.at(i + 1).at(j) %= MOD;

      dp.at(i).at(j + 1) += dp.at(i).at(j);
      dp.at(i).at(j + 1) %= MOD;
      
      dp.at(i + 1).at(j + 1) += MOD - dp.at(i).at(j);
      dp.at(i + 1).at(j + 1) %= MOD;

      if (i < N && j < M && S.at(i) == T.at(j))
      {
        dp.at(i + 1).at(j + 1) += dp.at(i).at(j);
        dp.at(i + 1).at(j + 1) %= MOD;
      }
    }
  }
  
  int ans = dp.at(N).at(M);
  cout << ans << endl;
}

Measured memory_bytes: 31872
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll a;
	cin >> a;
	cout << (a + a*a + a*a*a) << endl;
	return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        
        int n = 3;
        
        int v[] = new int[n];
        
        for (int i = 0; i < n; i++)
        {
            v[i] = scan.nextInt();
        }
        
        Arrays.sort(v);
        
        for (int i = 0; i < n-1; i++)
        {
            System.out.print(v[i] + " ");
        }
        System.out.println(v[n-1]);
    }
}



Measured memory_bytes: 26300
class BinaryIndexedTree:
    def __init__(self, size=10**7):
        self.size = size
        self.data = [0]*(size+1)

    def add(self, index, x):
        while index <= self.size:
            self.data[index] += x
            index += index & -index

    def prefix_sum(self, index):
        res = 0
        while index >= 1:
            res += self.data[index]
            index -= index & -index
        return res
    
    def interval_sum(self, left, right):
        return self.prefix_sum(right) - self.prefix_sum(left-1)

    def __getitem__(self, index):
        return self.sum(index) - self.sum(index-1)

    # def __setitem__(self, index, x):
    #     before = self.__getitem__(index)
    #     self.add(index, -before)
    #     self.add(index, x)

def main():
    from sys import stdin
    input = lambda: stdin.readline()
    LMIIS = lambda: list(map(int,input().split()))


    N,Q = LMIIS()
    # 1-indexedにするためリストの先頭に0を追加
    C = [0] + LMIIS()

    # クエリを保存するリストのリスト, r -> (l,クエリの順番)のリスト
    queries = []
    for i in range(N+1):
        queries.append([])

    # クエリを保存
    for i in range(Q):
        l,r = map(int,input().split())
        queries[r].append((l,i))

    # 玉の種類 -> 良い玉の場所
    good_ball_places = [0] * (N+1)

    # 場所 -> 良い玉が存在するなら1,しないなら0
    good_ball_exists = BinaryIndexedTree(N)

    #　玉の更新済み範囲
    k = 0
    # クエリの回答
    out = [0] * Q
    for r,query in enumerate(queries):
        for l,order in query:
            for i in range(k+1,r+1):
                # 位置iの玉の色
                color = C[i]
                # 色colorの良い玉の前の位置
                before = good_ball_places[color]
                # 色colorが既出なら、前の位置での存在を消去
                if 0 < before:
                    good_ball_exists.add(before,-1)
                # 色colorの良い玉の位置はi
                good_ball_places[color] = i
                # 位置iに良い玉が存在
                good_ball_exists.add(i,1)
            # 良い玉を更新した範囲
            k = r
            # [l,r]に存在する良い玉の数の合計
            out[order] = good_ball_exists.interval_sum(l,r)
    print('\n'.join(map(str,out)))


        








    
main()

Measured memory_bytes: 237512
use proconio::input;

fn main() {
    input!{
        n: i32,
        mut k: i32,
        mut p: [i32; n],
    }
    p.sort();
    let mut sum = 0;
    let mut index = 0;

    while k > 0 {
        sum += p[index as usize];
        index += 1;
        k -= 1;
    }

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


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

int N, K;
vector<int> graph[100000];
long long ans = 1;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1; finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void dfs(int cur, int parent) {
  int size = graph[cur].size();
  if (parent != -1) {
    --size;
  }
  if (size == 0 ) {
    return;
  }
  int x;
  if (parent == -1) {
    x = K - 1;
  } else {
    x = K - 2;
  }
  ans = (ans * fac[x]) % MOD;
  ans = (ans * finv[x-size]) % MOD;
  if (x - size < 0) {
    ans = 0;
    return;
  }
  for (int to: graph[cur]) {
    if (to != parent) {
      dfs(to, cur);
    }
  }
}
int main() {
  cin>>N>>K;
  COMinit();
  for (int i=0; i<N-1; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  ans = K;
  dfs(0, -1);
  cout<<ans<<endl;
}

Measured memory_bytes: 21120
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
 
typedef long long ll;

typedef long double ld;
 
using namespace std;
 
const ll maxn = 310;
const ll mod = 998244353;

ll n, m, k, t;

ll D[maxn][maxn][2 * maxn];

vector <ll> A;

vector <ll> S;

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    string s;
    cin >> s;
    cin >> k;
    n = s.length();
    k = min(k, n);
    k *= 2;
    ll cur = 0;
    for (q = 0; q < s.length(); q++) {
        if (s[q] == '0') {
            A.pb(cur);
            cur = 0;
        }
        else {
            cur++;
        }
    }
    A.pb(cur);
    reverse(all(A));
    S.resize(A.size() + 1);
    // cout << "A:" << endl;
    // for (q = 0; q < A.size(); q++) {
    //     cout << A[q] << " ";
    // }
    // cout << endl;
    S[0] = 0;
    for (q = 0; q < A.size(); q++) {
        S[q + 1] = A[q] + S[q];
    }
    D[0][0][0] = 1;
    // cout << "FALL" << endl;
    for (q = 0; q < A.size(); q++) {
        for (e = 0; e <= k; e++) {
            for (ll x = 0; x <= S[q + 1]; x++) {
                for (w = -A[q]; w <= S[q]; w++) {
                    // cout << "W " << w << " " <<  w + x << " " << D[q][x + w][e - abs(w)] << endl;
                    if (x + w < maxn && x + w >= 0 && e - abs(w) >= 0) {
                        D[q + 1][x][e] += D[q][x + w][e - abs(w)];
                        D[q + 1][x][e] %= mod;
                    }
                }
                // cout << q << " " << x << " " << e << " D " << D[q + 1][x][e] << endl << endl;
            }
            // cout << endl;
        }
        // cout << endl;
    }
    ll ans = 0;
    for (q = 0; q <= k; q++) {
        // cout << 
        ans += D[A.size()][0][q];
        ans %= mod;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 111188
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
cnt = 0

for i in 1..(n-1)
  for j in 0..(i-1)
    if a[i] < a[j]
      cnt += 1
    end
  end
end

a.sort!{|a,b| b <=> a}
tmp = 0
for i in 1..(n-1)
  for j in 0..(i-1)
    if a[i] < a[j]
      tmp += 1
    end
  end
end

puts (cnt*k + tmp*((k*(k-1))/2)) % (10**9 + 7)

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

int main() {
  ll x;
  cin >> x;

  ll num = (x + 10) / 11;
  ll ans = num * 2;
  if (num * 11 - 5 >= x) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int a[1000001],n,b[1000001],m,x;
int main()
{
  	cin>>n>>m;
  	for(int i=1;i<=m;i++)
    {
      cin>>x;
      b[x]=1;
    }
  a[0]=1;
  	for(int i=1;i<=n;i++)
    {
      if(b[i-1]==0)a[i]+=a[i-1];
      if(b[i-2]==0)a[i]+=a[i-2];
      a[i]=a[i]%1000000007;
    }
  cout<<a[n];
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll ans,cnt,h[100001];
int n,ext=-1;
vector<int> pos[200];
string s,t;
bool f[200];
int main()
{
	cin>>s>>t;
	n=s.size();
	for (int i=0;i<s.size();++i) pos[s[i]].push_back(i+1),f[s[i]]=true;
	for (int i=0;i<t.size();++i)
		if (f[t[i]]==false)
		{
			cout<<"-1";
			return 0;
		}
	for (int i=0;i<t.size();++i)
		if (pos[t[i]][pos[t[i]].size()-1]<=ext) ++cnt,ext=pos[t[i]][0];
		else ext=*std::upper_bound(pos[t[i]].begin(),pos[t[i]].end(),ext);
	ans=cnt*n+ext;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  REP(i,1,n + 1){
    if((i % 15 != 0) && i % 3 != 0 && i % 5 != 0)ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];

int b[N];
char s[N];
char t[N];
ll f[N];
int used[15];
int cmp1(ll a,ll b)
{
    return b<a;
}

multiset<int> ss;
map<int,int>mp;
int main()
{
    int n;
    cin>>n;

    ll money=1000;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++){
        if(a[i+1]>a[i]){
            ll x=money%a[i];
            money=money/a[i]*a[i+1];
            money+=x;
        }
    }
    cout<<money<<endl;


}


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

struct R {
  int id;
  char name[15];
  int point;
};

bool comp(const R& a, const R& b) {
  int s = strcmp(a.name, b.name);
  if (s == 0) {
    if (a.point > b.point) return true;
  } else if (s < 0) return true;

  return false;
}

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

  R rs[110];
  for (int i = 0; i < N; ++i) {
    rs[i].id = i + 1;
    cin >> rs[i].name;
    cin >> rs[i].point;
  }

  sort(rs, rs + N, comp);

  for (int i = 0; i < N; ++i) {
    cout << rs[i].id << endl;
  }
  
  return 0;
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b*2==a+c){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}
   
 
      
 
  
   
  
	
	  
	  
	  
	  
	  
	  
     
  
  
  
  
  

  

 
  


 

    
  


Measured memory_bytes: 256
#include <algorithm>
        #include <cmath>
        #include <ctime>
        #include <deque>
        #include <fstream>
        #include <iomanip>
        #include <iostream>
        #include <map>
        #include <queue>
        #include <set>
        #include <sstream>
        #include <string>
        #include <vector>
        #include <climits>
        #define sync                                                                   \
                ios_base::sync_with_stdio(0);                                                \
                cin.tie(0);                                                                  \
                cout.tie(0)
        #define ss second
        #define ff first
        #define ll long long
        #define mp make_pair
        #define endl "\n"
        #define pb push_back
        #define ld long double
        #define M_PI 3.14159265358979323846
        #define puss vector
        #define ull unsigned long long
        #define FOR(i,a,b) for(int i = (a); i < (b); ++i)
        #define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
        #define die {cout<<-1; return 0;}
        double EPS = 0.00001;
        const ll INF = 1000000007;
        using namespace std;


        int main() {
                sync;
                int n;
                cin>>n;
                vector<int> a(n);
                int mx=0, mxi;
                vector<pair<int,int> > ans;
                FOR(i, 0, n) cin>>a[i];
                FOR(i, 0, n) if (abs(a[i])>=abs(mx)) mx=a[i], mxi=i;
                if (mx>0){
                    ans.pb(mp(mxi, n-1));
                    ans.pb(mp(mxi, n-1));
                    mxi=n-1;
                    for (int i=0;i<n-1;i++){
                            //mx*=2;
                            ans.pb(mp(mxi, mxi));
                            //a[i+1]+=mx;
                            ans.pb(mp(mxi, i+1));

                    }
                }
                else{
                    ans.pb(mp(mxi, 0));
                    ans.pb(mp(mxi, 0));
                    mxi=0;
                    RFOR(i, n , 1){
                            //mx*=2;
                            ans.pb(mp(mxi, mxi));
                            //a[i-1]+=mx;
                            ans.pb(mp(mxi, i-1));

                    }
                }
                cout<<ans.size()<<endl;
                FOR(i, 0, ans.size()){
                    cout<<ans[i].ff+1<<' '<<ans[i].ss+1<<endl;
                }
        }


Measured memory_bytes: 256
import numpy as np
INF = 10 ** 12

N, W = map(int, input().split())
w = []
v = []
for _ in range(N):
    w_i, v_i = map(int, input().split())
    w.append(w_i)
    v.append(v_i)

w = np.array(w, dtype=np.int64)
v = np.array(v, dtype=np.int64)
sumv = np.sum(v)

# 価値vの時の重さの最小値
dp = np.zeros((N + 1, sumv + 1), dtype=np.int64)
dp[0][1:] = INF

for i in range(N):
    dp[i+1][:v[i]] = dp[i][:v[i]]
    dp[i+1][v[i]:] = np.minimum(dp[i][v[i]:], dp[i][:-v[i]] + w[i])

ans = 0
for v, w in enumerate(dp[N]):
    if w <= W:
        ans = max(v, ans)

print(ans)

Measured memory_bytes: 92832
a=input()
k=int(input())
a=list(a)
#print(a)
d=0
for i in range(0,len(a)):
    if a[i]!='1':
        break
    d+=1
if a[0]=='1':
    if k<=d:
        print("1")
    else:
        for i in range(0,len(a)):
            if a[i]!='1':
                print(a[i])
                break
else:
    print(a[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
const int N = 5 * 100000 + 100;

const int oo = 1e9;

string s;
ll L , R;
int pre[N];
ll len[N], f[N][26];

void kmp() {
	int idx = 0;
	for (int i = 1; i < s.size(); ++i) {
		while (idx > 0 && s[i] != s[idx])idx = pre[idx - 1];
		if (s[i] == s[idx])++idx;
		pre[i] = idx;
	}
}
ll calc(int c , ll rem) {
	if (rem <= s.size()){
		ll res = 0;
		for (int i = 0; i < rem; ++i)
			if (c == s[i] - 'a')res++;
		return res;
	}
	int id = 2;
	while (rem >= len[id - 2] + len[id - 1]) {
		f[id][c] = f[id - 2][c] + f[id - 1][c];
		len[id] = len[id - 2] + len[id - 1];
		id++;
	}

	if (len[id - 1] == rem)return f[id - 1][c];
	return f[id - 1][c] + calc(c, rem - len[id - 1]);
}
int main() {
	cin >> s;
	cin >> L >> R;
	kmp();
	len[1] = s.size() / 2;
	len[0] = s.size() / 2 - pre[s.size() / 2 - 1];
	for (int i = 0; i < len[0]; ++i)
		f[0][s[i] - 'a']++;
	for (int i = 0; i < len[1]; ++i)
		f[1][s[i] - 'a']++;
	for (int i = 0; i < 26; ++i) {
		if (i)printf(" ");
		printf("%lld", calc(i, R) - calc(i, L - 1));
	}
	puts("");
	return 0;
}

Measured memory_bytes: 4740
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()

if N % 2:
    print(N//2)
else:
    print((N-1)//2)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
  int h,w;
  int i,j;
  char s[51][51];
  scanf("%d%d",&h,&w);
  for(i=0;i<h;i++){
    scanf("%s",s[i]);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s[i][j]=='.') continue;
      if(0<=i-1){
        if(s[i-1][j]=='#') continue;
      }
      if(0<=j-1){
        if(s[i][j-1]=='#') continue;
      }
      if(j+1<=w-1){
        if(s[i][j+1]=='#') continue;
      }
      if(i+1<=h-1){ 
        if(s[i+1][j]=='#') continue;
      }
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

unsigned long long x,y,ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>x>>y;
    for(unsigned long long i=x;i<=y;i*=2){
        ans++;
    }
    cout<<ans<<newl;
}


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

int main(){
    int a, b, c;
    while(cin >> a >> b >> c){
	if(a == -1 && b == -1 && c == -1)return 0;
	int t = 2 * 3600 - a * 3600 - b * 60 - c;
	printf("%02d:%02d:%02d\n", t/3600, (t%3600)/60, t%60);
	t *= 3;
	printf("%02d:%02d:%02d\n", t/3600, (t%3600)/60, t%60);
    }
    return 0;
    
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back


struct Compare {
  using pti2 = pair<pair<int,int>,int>;
  constexpr bool operator()(pti2 const &a, pti2 const &b)const noexcept{
    return a.first.first!=b.first.first? a.first.first>b.first.first : a.first.second > b.first.second;
  }
};

class Dijkstra {
public:
  struct edge{
    int to; int dist; int cost;
  };
  vector<vector<edge> > G;
  vector<int> d,c;
  int V;
  using pti = pair<int,int>;
  using pti2 = pair<pair<int,int>,int>;
  Dijkstra(int node_size){
    V = node_size;
    G.resize(V),d.resize(V,numeric_limits<int>::max()),c.resize(V,numeric_limits<int>::max());
  }
  void add_edge(int u,int v,int dist,int cost){
    G[u].pb((edge){v,dist,cost}),G[v].pb((edge){u,dist,cost});
  }

  int solve(int s){
    priority_queue<pti2,vector<pti2>,Compare> que;
    d[s] = 0;
    c[s] = 0;
    que.push(pti2(pti(0,0),s));
    while(!que.empty()){
      pti2 p = que.top();
      que.pop();
      int v = p.second;
      for(auto& w : G[v]){
        if(d[w.to]>d[v]+w.dist){
          d[w.to] = d[v]+w.dist;
          c[w.to] = w.cost;
          que.push(pti2(pti(d[w.to],c[w.to]),w.to));
        } else if(d[w.to]==d[v]+w.dist){
          if (c[w.to]>w.cost){
            c[w.to] = w.cost;
            que.push(pti2(pti(d[w.to],c[w.to]),w.to));
          }
        }
      }
    }
    int tot=0;
    rep(i,V)tot+=c[i];
    return tot;
  }

};

int main(){

  while(1){
    int n,m;
    cin >> n >> m;
    if(n==0)break;
    vector<int> u(m),v(m),d(m),c(m);
    Dijkstra g(n);
    rep(i,m){
      int u,v,d,c;
      cin >> u >> v >> d >> c;
      u--;v--;
      g.add_edge(u,v,d,c);
    }
    cout << g.solve(0) << endl;
  }

  return 0;
}



Measured memory_bytes: 4456
#include <iostream>

int main()
{
	unsigned n, x;
	while (std::cin >> n >> x, n) {
		unsigned count{};
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j < i; j++) {
				for (int k = 1; k < j; k++) {
					if (i+j+k == x) {
						count++;
						break;
					}
				}
			}
		}
		std::cout << count << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/*
 public class abc079c {

 }

 */
public class Main {
  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    String abcd = in.read();

    int[] a = new int[4];

    a[0] = abcd.charAt(0) - '0';
    a[1] = abcd.charAt(1) - '0';
    a[2] = abcd.charAt(2) - '0';
    a[3] = abcd.charAt(3) - '0';

    for (int i = 0; i < 8; i++) {
      int[] b = a.clone();
      for (int j = 0; j < 3; j++) {
        if ((i & (1 << j)) == 0) {
          b[3 - j] = -b[3 - j];
        }
      }

      if (sum(b) == 7) {
        StringBuilder ans = new StringBuilder();
        for (int j = 0; j < b.length; j++) {
          if (b[j] < 0) {
            ans.append('-');
          } else {
            if (j > 0) {
              ans.append('+');
            }
          }
          ans.append(Math.abs(b[j]));
        }
        ans.append("=7");
        System.out.println(ans.toString());
        break;
      }
    }

    // end here
  }

  int sum(int[] b) {
    int s = 0;
    for (int i = 0; i < b.length; i++) {
      s += b[i];
    }

    return s;
  }

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

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}


Measured memory_bytes: 20820