akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int h, n, sum = 0;
	cin >> h >> n;
	rep (i, n) {
	  int a;
	  cin >> a;
	  sum += a;
	}
	cout << (sum >= h ? "Yes" : "No") << endl;

	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll n,M,L;
    cin>>n>>M>>L;
    ll d[301][301]={};
    for(int i=0;i<=300;i++){
        for(int j=0;j<=300;j++){
            if(i!=j) d[i][j]=1e18;
        }
    }
    for(int i=0;i<M;i++){
        int A,B,C;
        cin>>A>>B>>C;
        d[A][B]=d[B][A]=C;
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    ll e[301][301]={};
    for(int i=0;i<=300;i++){
        for(int j=0;j<=300;j++){
            if(i!=j) e[i][j]=1e18;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i!=j&&d[i][j]<=L) e[i][j]=1;
        }
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
            }
        }
    }
    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        int s,t;
        cin>>s>>t;
        if(e[s][t]==1e18) cout<<-1<<endl;
        else cout<<e[s][t]-1<<endl;
    }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;

int PS[200001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, ans=0x7fffffff;
	string s;
	cin>>N>>s;
	for(int i=0;i<N;i++) PS[i+1]=(s[i]=='#')+PS[i];
	for(int i=0;i<=N;i++) {
		ans=min(ans,PS[i]+(N-i)-PS[N]+PS[i]);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 1300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

void solve1() {
    string s; cin >> s;
    ll ans = 0;
    for(int i = 0; i < (1 << (int)s.size() - 1); i++) {
        string ss;
        for(int j = 0; j < (int)s.size(); j++) {
            ss.push_back(s[j]);
            for(int k = 0; k < (int)s.size() - 1; k++) {
                if(i & (1 << k)) {
                    if(j == k) {
                        ss.push_back('+');
                    }
                }
            }
        }

        string plus;
        for(int j = 0; j < (int)ss.size(); j++) {
            if(ss[j] != '+') {
                plus.push_back(ss[j]);
            } else {
                ans += atoll(plus.c_str());
                plus = "";
            }
        }
        ans += atoll(plus.c_str());
    }
    cout << ans << endl;
}

int main()
{
    solve1();
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] a = {0,100001};
        boolean flag = true;
        while(m>0){
            int l = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());
            if(r < a[0] || a[1] < l){
                System.out.println(0);
                flag = false;
                break;
            }
            if(a[0] < l){
                a[0] = l;
            }
            if(r < a[1]){
                a[1] = r;
            }
            m--;
        }
        sc.close();
        if(flag){
            System.out.println(a[1]-a[0]+1);
        }
    }
}


Measured memory_bytes: 47684
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
double len(double x1,double y1,double x2,double y2)
{
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
double solve(double a,double b,double c)
{
	double z;
	z=(a+b+c)/2;
	return sqrt(z*(z-a)*(z-b)*(z-c));
}
int main()
{
	double x[22],y[22];
	double ans=0.0;
	int c=0;
	for(;;c++)
	{
		if(scanf("%lf,%lf",&x[c],&y[c])==-1)break;
	}
	for(int i=1;i<c-1;i++)
	{
		ans+=solve(len(x[0],y[0],x[i],y[i]),len(x[i],y[i],x[i+1],y[i+1]),len(x[i+1],y[i+1],x[0],y[0]));
	}
	printf("%f\n",ans);
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> a(m);
    for (int i = 0; i < m; ++i) {
        cin >> a.at(i);
    }

    int ans = n;
    for (int i = 0; i < m; ++i) {
        ans -= a.at(i);
    }

    if (ans < 0) {
        cout << "-1" << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
	int n,m;
	cin>>n>>m;
	bool ok[100010]={};
	UnionFind uf(100010);
	rep(i,m){
		int x,y,z;
		cin>>x>>y>>z;
		uf.marge(x-1,y-1);
	}
	int ans=0;
	rep(i,n){
		if(!ok[uf.root(i)]){
			ans++;
			ok[uf.root(i)]=true;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define all(v) v.begin(),v.end()
#define pb push_back
using namespace std;

int main(){
	string s;
	cin>>s;
	bool check=false;
	rep(i,s.size()-1){
		if(s.substr(i,2)=="AC"){
			check=true;
			break;
		}
	}
	cout<<((check)?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
# define P 3.141592653
#include <iomanip>

using namespace std;
int main()
{
	int r;
	double s;
	while(cin>>r)
	{
		s=2*P*r;
		printf("%.10lf\n",s);
	}
	return 0;
} 

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

int main(){
  int want, money, c1, c2, meat;
  
  while(cin >> want){
    if(want == 0) break;
    cin >> money >> c1 >> c2 >> meat;
    
    int ans1 = money / c1;
    if(ans1 > meat) ans1 = meat;
    
    int budget = ans1 * c1;
    int ans2 = 0;
    int sale = money - budget;
    int buy_normal = sale / c2;
    ans2 += buy_normal;
    sale -= buy_normal * c2;
    while(1){
      if(ans1 + ans2 >= want) break;
      if(ans1 == 0) break;
      ans1--, budget -= c1; // テ、ツクツ?」ツ?、テ・ツ」ツイテ」ツつ?
      sale += c1; // テ・ツ」ツイテ」ツ?」テ」ツ?ヲティツイツーテ」ツ?」テ」ツ?淌」ツ?甘ゥツ??
      buy_normal = sale / c2;
      ans2 += buy_normal; //テ・ツ慊ーテゥツカツ湘」ツつ津・ツ」ツイテ」ツ?」テ」ツ?ヲテ」ツ?ァテ」ツ?催」ツ?淌」ツ?甘ゥツ?妥」ツ?ァテ」ツ?ァテ」ツ?催」ツつ凝」ツ??」ツ?妥ゥツカツ湘ィツつ嘉」ツつ津ィツイツキテ」ツ??テ・ツ?凝ヲツ閉ーテッツシツ?     
      sale -= buy_normal * c2;     
      budget += ans2 * c2;
    }
    if(ans1 == 0) cout << "NA" << endl;    
    else cout << ans1 << ' ' << ans2 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void)
{
  int i;
  char str[1201];

  gets(str);

  for(i = 0; i <= 1200; i++) {
    if(str[i] >= 65 && str[i] <= 90) {
      str[i] += 32;
    }else if(str[i] >= 97 && str[i] <= 122) {
      str[i] -= 32;
    }
  }

  printf("%s\n", str);

  return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main(void)
{
	int n;
	vector<int> p;
	cin >> n;

	for (int i = 0; i<n; i++){
		int tmp;
		cin >> tmp;
		p.push_back(tmp);
	}

	auto hoge = max_element(p.begin(), p.end());
	int sum = accumulate(p.begin(), p.end(), 0);

	if (sum - *hoge  > *hoge){
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

Measured memory_bytes: 256
a, b = map(int, input().split())
c = 1
if abs(a-b) >= 2:
    print(0)
elif abs(a-b) == 1:
    for i in range(1, a+1):
        c = (c * i) % (10**9+7)
    for i in range(1, b+1):
        c = (c * i) % (10**9+7)
    print(c % ((10**9)+7))
elif abs(a-b) == 0:
    for i in range(1, a+1):
        c = (c * i * i) % ((10**9)+7)
    print((c*2) % ((10**9)+7))


Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> a, b;

    REP(i, n) {
        int ai;
        cin >> ai;
        a.push_back(ai);
    }
    REP(i, n) {
        int bi;
        cin >> bi;
        b.push_back(bi);
    }

    long long d1 = 0;
    long long d2 = 0;
    long long odd = 0;
    REP(i, n) {
        long long diff = a[i] - b[i];
        if (diff >= 0)
            d2 += diff;
        else {
            d1 += -diff;
            odd += -diff % 2;
        }
    }

    long long m = min(d2, (d1 - odd) / 2);
    d1 -= 2 * m;
    d2 -= m;
    
    cout << (d2 == 0 ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){
    int n,h;
    cin >> h >> n;
    rep(i,n){
        int a;
        cin >> a;
        h -= a;
    }
    if(h > 0)cout << "No" << endl;
    else cout << "Yes" << endl;
	
    








	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc153.contest.atcoder.jp/tasks/abc153_b

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASheepAndWolves solver = new ASheepAndWolves();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASheepAndWolves {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int s = in.nextInt();
            int w = in.nextInt();
            out.println(s <= w ? "unsafe" : "safe");
        }

    }
}



Measured memory_bytes: 35868
n = int(input())
an = list(map(int, input().split()))

dict1 = {}
for i in range(n):
  if dict1.get(an[i], -1) == -1:
    dict1[an[i]] = 1
  else:
    dict1[an[i]] += 1
    
for a, b in dict1.items():
  if b != 1:
    print('NO')
    exit()
    
print('YES')


Measured memory_bytes: 32948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
ll dp[2][N];
int main()
{
       ll x,y,a,b,c;
       cin>>x>>y>>a>>b>>c;
       ll p[a];
       ll q[b];
       ll r[c];
       arrin(p,a);
       arrin(q,b);
       arrin(r,c);
       sort(p,p+a);
       sort(q,q+b);
       sort(r,r+c);
       reverse(p,p+a);
       reverse(q,q+b);
       reverse(r,r+c);
       vector<ll> curr;
       ll ans = 0;
       fri(i,0,x){
              curr.pb(p[i]);
              ans += p[i];
       }
       fri(i,0,y){
              curr.pb(q[i]);
              ans += q[i];
       }
       sort(all(curr));
       ll cl = 0;
       ll ii = 0;
       while(ii<curr.size()&&cl<c)
       {
              if(r[cl]<=curr[ii]){break;}
              ans += r[cl];
              ans -= curr[ii];
              cl++;
              ii++;
       }
       cout<<ans<<endl;
}


Measured memory_bytes: 4724
#include<stdio.h>

int main(){
    int a,op,b,x;
    while(op!='?'){
    scanf("%d %c %d",&a,&op,&b);
        if(op=='+'){
            x=a+b;
            printf("%d\n",x);
        }else if(op=='-'){
            x=a-b;
            printf("%d\n",x);
        }else if(op=='*'){
            x=a*b;
            printf("%d\n",x);
        }else if(op=='/'){
            x=a/b;
            printf("%d\n",x);
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	int count = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == T[i]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
h,w,k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0
for n in range(1 << h):
  for m in range(1 << w):
    count = 0
    for i in range(h):
      for j in range(w):
        if n >> i & 1:
          continue
        if m >> j & 1:
          continue
        if c[i][j] == '#':
          count += 1
    if count == k:
      ans += 1
print(ans)

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

const int MAXN = 1e5+5;

int n, q, arr[26][26];
vector<int> qu[4*MAXN];
int ord[MAXN][26];
int ch[4*MAXN][26];
int sz[4*MAXN];
int where[MAXN];
int ans[MAXN];
int ct;
int w[4*MAXN];
int all = 0;

int ins(string g, int x) {
    int at = 0;
    for (int i = 0; i < g.length(); ++i) {
        if (ch[at][g[i]-'a'] == 0) {
            ct++;
            ch[at][g[i]-'a'] = ct;
        }
        at = ch[at][g[i]-'a'];
        // cout << at << endl;
    }

    where[x] = at;
    sz[at]++;
    w[at]++;
}

void dfs1(int v = 0) {
    for (int i = 0; i < 26; ++i)
        if (ch[v][i] != 0) {
            dfs1(ch[v][i]);
            sz[v] += sz[ch[v][i]];
        }
    // cout << v << ' ' << sz[v] << endl;
}

void dfs2(int v) {
    // cout << v << ' ' << arr[0][1] << ' ' << arr[1][0] << endl;
    for (int i = 0; i < qu[v].size(); ++i) {
        // cout << v << ' ' << qu[v][i] << endl;
        int y = qu[v][i];
        for (int j = 0; j < 26; ++j)
            for (int k = j+1; k < 26; ++k)
                ans[y] += arr[ord[y][j]][ord[y][k]];
        ans[y] += all;
    }
    for (int i = 0; i < 26; ++i) {
        if (ch[v][i] == 0)
            continue;
        for (int j = 0; j < 26; ++j) {
            if (j != i && ch[v][j] != 0)
                arr[j][i] += sz[ch[v][j]];
        }
        all += w[v];
        dfs2(ch[v][i]);
        for (int j = 0; j < 26; ++j)
            if (j != i && ch[v][j] != 0)
                arr[j][i] -= sz[ch[v][j]];
        all -= w[v];
    }
    // cout << v << ' ' << arr[0][1] << ' ' << arr[1][0] << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        ins(s, i);
    }
    dfs1();
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int x; cin >> x; x--;
        string g; cin >> g;
        for (int j = 0; j < 26; ++j)
            ord[i][j] = g[j]-'a';
        qu[where[x]].push_back(i);
    }
    dfs2(0);

    for (int i = 0; i < q; ++i)
        printf("%d\n", ans[i]+1);
}

Measured memory_bytes: 82188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    while(true){
        int cnt = 0;
        int a, b;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        for(int i = 1 ; i <= a ; i ++){
            for(int j = 1 ; j <= a ; j ++){
                for(int k = 1 ; k <= a ; k ++){
                    if(i > j && j > k && i + j + k == b) cnt++;
                }
            }
        }
        cout << cnt << "\n";
    }
}


Measured memory_bytes: 3068
n = int(input())
mod = 10**9 + 7

if n == 1:
    print(1)
    exit()
if n == 2:
    print(2)
    exit()

prime = [2]
for i in range(3, n+1):
    j = 0
    flag = True
    while prime[j] * prime[j] <= i:
        if i % prime[j] == 0:
            flag = False
            break
        j += 1
    if flag:
        prime.append(i)

ans = 1
for p in prime:
    num = 1
    i = p
    while i <= n:
        num += n // i
        i *= p
    ans *= num
    ans %= mod

print(ans)

Measured memory_bytes: 65020
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

map<pair<ll, ll>, ll> memo;
ll N, A[212345];

ll dp(ll i, ll n) {
	if (n == 0) return 0;
	if (i < 2 * (n - 1)) return -2123450000000000;
	if (memo.find({ i, n }) != memo.end()) return memo[{i, n}];
	return memo[{i, n}] = max(dp(i - 1, n), dp(i - 2, n - 1) + A[i]);
}

int main() {

	cin >> N;
	rep(i, N) cin >> A[i];

	cout << dp(N - 1, N / 2) << endl;

	return 0;
}


Measured memory_bytes: 33332
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(B) > sum(A):
    print(-1)
    exit(0)

if all(map(lambda x: x[0] >= x[1], zip(A,B))):
    print(0)
    exit(0)

residual = []
required = []
ans_num_changed = 0


for i in range(N):
    if A[i] > B[i]:
        residual.append(A[i]-B[i])
    elif A[i] < B[i]:
        required.append(B[i]-A[i])

tarinai_all = sum(required)
ans_num_changed += len(required)

residual = sorted(residual, reverse=True)

for e,r in enumerate(residual, 1):
    tarinai_all -= r
    ans_num_changed += 1
    if tarinai_all <= 0:
        break
print(ans_num_changed)
    





Measured memory_bytes: 18292
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1000005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
  int sum = 0;
  for(auto c : s){
    sum += c-'0';
  }
  cout<<(sum%9==0?"Yes": "No")<<endl;
  return 0;
}

Measured memory_bytes: 3716
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
signed main() {
	int n;
	while (cin >> n, n) {
		int ans1, ans2;
		for (int i = 1; i * (i + 1) / 2 <= n; i++) {
			if ((n - i * (i + 1) / 2) % i == 0) {
				ans1 = (n - i * (i + 1) / 2) / i + 1;
				ans2 = i;
			}
		}
		cout << ans1 << ' ' << ans2 << endl;
	}
}


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

int main() {
  int N, M, count = 0;
  int i, a = 0, b = 0;
  int n, m;
  
  cin >> N >> M;
  
  for(i = 0; i <= N - 1; i++)
    {
       a += i;
    }

  for(i = 0; i <= M - 1; i++)
    {
       b += i;
    }
    count = a + b;
  
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner s  = new Scanner(System.in);
        int n, i, x;
        long count;
        String str="";
        char arr[];
        n = s.nextInt();
        HashMap<String, Integer> hm = new HashMap<String, Integer>();
        for(i=0; i<n; i++){
            str = s.next();
            arr = str.toCharArray();
            Arrays.sort(arr);
            str  = new String(arr);
            if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1);
        }
        
        count = 0l;
        Iterator itr = hm.entrySet().iterator();
        while(itr.hasNext()){
            Map.Entry me = (Map.Entry)itr.next();
            x = (int)me.getValue();
            count += (((long)x)*((long)(x-1)))/2;
        }
      System.out.println("" + count);
    }
}

Measured memory_bytes: 54252
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
from decimal import Decimal
from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7


w=[]
r=[]
n=int(data())
s=data()
for i in range(n):
    if s[i]=='R':
        r.append(i)
    else:
        w.append(i)
cnt=0
w=w[::-1]
while r and w:
    if r.pop()<w.pop():
        break
    cnt+=1
out(cnt)






Measured memory_bytes: 88576
#include<bits/stdc++.h>
using namespace std;
int n,m,l,r,ans=3000,H[3000];
int main() {
	scanf("%d %d",&l,&r);
	for(int i=l,j=1; i<=r&&j<=5000; i++,j++) {
		H[i%2019]++;
	}
	for(int i=0; i<2019; i++) {
		if(H[i]) {
			H[i]--;
			for(int j=0; j<2019; j++) {
				if(H[j])ans=min(ans,i*j%2019);
			}
			H[i]++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
def exchange(l):
    newlist = [0, 0, 0]
    for i in range(3):
        for j in range(3):
            if i != j:
                newlist[i] += l[j]//2
    return newlist


def containsOdd(l):
    for i in range(3):
        if l[i] % 2 == 1:
            return True
    return False


def isAllEquals(l):
    if l[0] == l[1] == l[2]:
        return True
    return False


def main():
    cookies = [int(x) for x in input().split()]
    ans = 0
    while True:
        if isAllEquals(cookies):
            if cookies[1] % 2 == 1:
                print(0)
                return
            print(-1)
            return 0
        if containsOdd(cookies):
            print(ans)
            return 0
        cookies = exchange(cookies)
        ans += 1


if __name__ == '__main__':
    main()


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

using namespace std;

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

int H,W,N,x,y,d;
char f[20][20],c;
char dir[]={'U','D','L','R'};
char m[]={'^','v','<','>'};
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
bool flg;

bool inField(int y,int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

void shoot(){
  int tx = x, ty = y;
  while(true){
    int nx = tx + dx[d],ny = ty + dy[d];
    if(!inField(ny,nx) || f[ny][nx] == '#') return;
    if(f[ny][nx] == '*'){ f[ny][nx] = '.'; return; }
    tx = nx, ty = ny;
  }
}

void move(){
  int nx = x + dx[d],ny = y + dy[d];
  f[y][x] = m[d];
  if(!inField(ny,nx) || f[ny][nx] == '-' ||
     f[ny][nx] == '#' || f[ny][nx] == '*') return;
  f[y][x] = '.'; f[ny][nx] = m[d];
  y = ny, x = nx;
}

void print(){
 rep(i,H){
   rep(j,W){
     cout << f[i][j];
   }
   cout << endl;
 }
}

void solve(){
  cin >> N;
  rep(i,N){
   
    cin >> c;
    if(c == 'S'){
      rep(j,4){
        if(m[j] == f[y][x]){
          d = j;
          break;
        }
      }
      shoot();
    }else{
      rep(j,4){
        if(dir[j] == c){
          d = j;
          break;
        }
      }
      move();
    }
  }
  print();
}

int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    if(flg) cout << endl; flg = true;
    cin >> H >> W;
    rep(i,H) rep(j,W){
      cin >> f[i][j];
      if(f[i][j] == '<' || f[i][j] == '>' ||
         f[i][j] == '^' || f[i][j] == 'v'){
        y = i; x = j;
      }
    }
    solve();
  }

  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#define N 19
const long long mod=1e9+7;
using namespace std;
int n,m;
int a[N];
long long factorial[(1<<N)],inverse[(1<<N)],dp[N][(1<<N)];

int cmp(int x,int y) { return x>y; }
long long ksm(long long x,long long y)
{
	long long res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}
long long assemble(int x,int y) { return factorial[x]*inverse[y]%mod*inverse[x-y]%mod; }
int getbit(int now)
{
	int res=0;
	while(now) { res+=(now&1); now>>=1; }
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",&a[i]);
	sort(a+1,a+m+1,cmp);
	int maxn=(1<<n);
	factorial[0]=1;
	for(int i=1;i<=maxn;i++) factorial[i]=factorial[i-1]*i%mod;//cout<<factorial[maxn]<<endl;
		//求阶乘
	inverse[maxn]=ksm(factorial[maxn],mod-2);
	// cout<<inverse[maxn]<<endl;
	for(int i=maxn-1;i>=0;i--) inverse[i]=inverse[i+1]*(i+1)%mod;
		// for(int i=1;i<=3;i++) cout<<inverse[i]<<endl;
		//求逆元
	dp[0][0]=1;
	for(int i=1;i<=m;i++)
		for(int j=0;j<(1<<n);j++)
		{
			if(dp[i-1][j]) 
			{
				(dp[i][j]=dp[i-1][j]+dp[i][j])%=mod;
				for(int k=0;k<n;k++)
					if(((1<<k)&j)==0)
					{
						dp[i][j|(1<<k)]+=dp[i-1][j]*factorial[(1<<k)]%mod*assemble(maxn-a[i]-j,(1<<k)-1)%mod;
						dp[i][j|(1<<k)]%=mod;
						// cout<<dp[i][j|(1<<k)]<<endl;
					}
			}
		}
	
	long long ans=0;
	for(int i=0;i<(1<<n);i++)
	{
		// cout<<"***"<<endl;
		// cout<<ans<<endl;
		// cout<<(getbit(i)&1)<<" "<<ans<<endl;
		if((getbit(i)&1)!=0) 
		{
			ans=ans-dp[m][i]*factorial[maxn-i-1]%mod+mod;
			// cout<<dp[m][i]<<" "<<factorial[maxn-i-1]<<endl;
			if(ans>=mod) ans-=mod;
		}
		else ans=ans+dp[m][i]*factorial[maxn-i-1]%mod+mod;
		ans=(ans%mod+mod)%mod;
	}
	ans=ans*(1<<n)%mod;
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 37120
a, b, c, d, e, f = map(int, input().split())

set_ = set()
for i in range(3000):
    for j in range(3000):
        set_.add(c * i + d * j)

ans_noudo = -1
w = -1
s = -1
for i in range(31):
    for j in range(31):
        water = 100 * a * i + 100 * b * j
        if water == 0:
            continue
        if water > f:
            continue
        nokori = f - water
        for suger in range(0, nokori + 1):
            if suger not in set_:
                continue
            if water * e < suger * 100:
                continue
            noudo = 100 * suger / (water + suger)
            if ans_noudo < noudo:
                ans_noudo = noudo
                w = water
                s = suger
print(w + s, s)

Measured memory_bytes: 47452
from collections import deque
n,m = map(int,input().split())
graph = [[]for i in range(n+1)]

for i in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
#dist = [-1]*(n+1)
route = [-1]*(n+1)
route[0] = 0
route[0] = 0
#dist[0] = 0
#dist[1] = 0
d = deque()
d.append(1)
while d:
  v = d.popleft()
  for i in graph[v]:
    if route[i] == -1:
      #dist[i] = dist[v] + 1
      route[i] = v
      d.append(i)
if route.count(-1) == 0:
  print("Yes")
  for i in range(2,len(route)):
    print(route[i])
else:
  print("No")

Measured memory_bytes: 33992
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    set<int> primes;
    bool pairwise = true;
    for(int i = 0; i < n; i++){
        int x = a[i];
        if(x % 2 == 0){
            if(primes.find(2) != primes.end()){
                pairwise = false;
                break;
            }
            else{
                primes.insert(2);
                while(x % 2 == 0)
                    x /= 2;
            }
        }
        if(!pairwise)
            break;
        for(int p = 3; p * p <= x; p += 2){
            if(x % p == 0){
                if(primes.find(p) != primes.end()){
                    pairwise = false;
                    break;
                }
                else{
                    primes.insert(p);
                    while(x % p == 0){
                        x /= p;
                    }
                }
            }
        }
        if(x > 1){
            if(primes.find(x) != primes.end()){
                pairwise = false;
                break;
            }
            else{
                primes.insert(x);
            }
        }
        if(!pairwise)
            break;
    }
    if(pairwise){
        cout << "pairwise coprime\n";
        return;
    }
    int g = a[0];
    for(int i = 1; i < n; i++){
        g = __gcd(g, a[i]);
    }
    if(g == 1){
        cout << "setwise coprime\n";
        return;
    }
    cout << "not coprime\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 7292
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(ll i=a;i<(b);i++)
#define fj(a,b) for(ll j=a;j<(b);j++)
#define fk(a,b) for(ll k=a;k<(b);k++)
//hash base 177013
const int mod=1e9+7;
ll binpow(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1){
			res=((res%mod)*(a%mod))%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b=b>>1;
	}
	return res%mod;
}
const int mxn=1e6+3;
vector<ll> fact(mxn),inv(mxn);
void facto()
{
	fact[0]=fact[1]=1;
	fi(2,mxn)
	{
		fact[i]=(fact[i-1]*i)%mod;
		//assert(fact[i]>=0&&fact[i]<=mod);
	}
	inv[0]=inv[1]=1;
	fi(2,mxn)
	{
		inv[i]=binpow(fact[i],mod-2)%mod;
		//assert(inv[i]>=0&&inv[i]<=mod);
	}	
}

ll ncr(ll a,ll b)
{
	//assert(a-b>=0);
	return (((fact[a]*inv[b])%mod)*inv[a-b]%mod)%mod;
}

int main()
{
	FAST;
	facto();
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		ll n;
		cin>>n;
		ll ans=1,ans2=1,ans3=1;
		fi(0,n)
		{
			ans=(ans*9)%mod;
			ans2=(ans2*8)%mod;
			ans3=(ans3*10)%mod;
		}	
		//cout<<ans2<<'\n';
		cout<<(ans3+ans2-(2*ans)%mod+mod)%mod<<'\n';
		//map<int,int> m;
		//fi(1,n+1)
		//{	
			//ll pos_zero=ncr(n,i);
			//fj(1,n+1)
			//{
				//if(i+j>n) break;
				//ll pos_one=ncr(n-i,j);
				//ll rem=n-i-j;
				//ans=(ans+(((binpow(8,rem)*pos_zero)%mod)*pos_one%mod)%mod)%mod;
			//}
		//}
		//cout<<ans<<'\n';
	}
}



Measured memory_bytes: 18608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pl = pair<ll,ll>;

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

    vector<pl> v(n);
    rep(i,n){
        ll a,b;
        cin >>a >>b;
        v[i] = {b,a};
    }
    sort(all(v));

    ll t = 0;
    rep(i,n){
        ll b = v[i].fi, a = v[i].se;
        if(t+a > b){
            cout << "No" << endl;
            return 0;
        }
        t += a;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define all(i) i.begin(),i.end()
#define fix(i) fixed<<setprecision((i))
#define Max( i , j ) (i)=max((i),(j))
#define Min( i , j ) (i)=min((i),(j))
#define pii pair<int,int>
using namespace std;

const long long maxn = 1e5+100;
const long long INF = 3e18+1191;
const long long mod = 1e9+7;

int h , w ;
char c[100][100];
int cnt[10][100];
int32_t main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	cin >> h >> w;
	for(int i = 1 ; i <= h ; i++)
		for(int j = 1 ; j <= w ; j ++){
			cin >> c[i][j];
		}

	for(int i = 1 ; i <= h ; i++)
		for(int j = 1 ; j <= w; j++){
			if(c[i][j] == '#'){
				int cnt = 0;
				if(i==1 && j == 1){
					if(c[i+1][j] == '#')cnt ++;
					if(c[i][j+1] == '#')cnt ++;
					if(cnt  ==0)
						return cout << "No" << endl,0;
				}
				else if(i == 1 && j > 1){
					if(c[i+1][j] == '#')cnt ++;
					if(c[i][j+1] == '#')cnt ++;
					if(c[i][j-1] == '#') cnt ++;
					if(cnt  ==0) return cout << "No" << endl,0;
				}
				else if( i > 1 && j ==1){
					if(c[i+1][j] == '#')cnt ++;
					if(c[i][j+1] == '#')cnt ++;
					if(c[i-1][j] == '#') cnt ++;
					if(cnt  ==0) return cout << "No" << endl,0;
		
				}
				else if(i > 1 && j > 1){
					if(c[i+1][j] == '#')cnt ++;
					if(c[i][j+1] == '#')cnt ++;
					if(c[i-1][j] == '#') cnt ++;
					if(c[i][j-1] == '#') cnt ++;
					if(cnt  ==0) return cout << "No" << endl,0;
				}////////////////////////////
					if(i==h && j == w){
					if(c[i-1][j] == '#')cnt ++;
					if(c[i][j-1] == '#')cnt ++;
					if(cnt  ==0)
						return cout << "No" << endl,0;
				}
				else if(i == h && j < w){
					if(c[i-1][j] == '#')cnt ++;
					if(c[i][j+1] == '#')cnt ++;
					if(c[i][j-1] == '#') cnt ++;
				if(cnt  ==0) return cout << "No" << endl,0;
				}
				else if( i < h && j ==w){
					if(c[i+1][j] == '#')cnt ++;
					if(c[i][j-1] == '#')cnt ++;
					if(c[i-1][j] == '#') cnt ++;
				if(cnt  ==0) return cout << "No" << endl,0;
		
				}
				else if(i < h && j < w){
					if(c[i+1][j] == '#')cnt ++;
					if(c[i][j+1] == '#')cnt ++;
					if(c[i-1][j] == '#') cnt ++;
					if(c[i][j-1] == '#') cnt ++;
				if(cnt  ==0) return cout << "No" << endl,0;
				}
				
				
			}
		}
	cout << "Yes" << endl;
  
	return 0;
}



Measured memory_bytes: 256
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")
//#pragma GCC optimize("SEX_ON_THE_BEACH")	
//#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:36777216")

#define _CRT_SECURE_NO_WARNINGS
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--+i+--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++-l-++--++--++--++--++--++--++--++--++--++--++--++--++
#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define sqr(a) ((a) * (a))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pin(p) cin >> p.first >> p.second;
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define rev(v) reverse(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define sp system("pause")
//o++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--+v+--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;

//++-e-++--++--++--++--++--++--++--s++--++--++--++--++--++--++--++--++--++--++--++--++--++-p-++--++--++--++--++--++--++--++--++--++--++--++--++--++--++-a-++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//+c+--++--++--++--++--++--++--++--++e--++--++--++--++--++--++--++--++--++--++--++l--++--++--++--++--++--++--++--++--++--++--++--++--+e+--++--++--++--++--++-++--++--++--++--++--++--++--++-o-++--++
const ld EPS = 1e-5;
const ld PI = acos(-1);
int mod = (int)998244353;
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const ll kekmod = 1791791791;
const ll bestmod = 1148822869;
vector<ll> mods = { kekmod,bestmod,mod,MOD9,1000000007 };
vector<ll> hashpows = { 29,31,37,43,47,53,179,229 };
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count() + 228 + 'i' + 'q' + 1337 + 1488);
ll MOD = mods[rnd() % mods.size()];
ll hashpow = hashpows[rand() % hashpows.size()];

signed main()
{
	fastio();
	int r;
	cin >> r;
	cout << r * r;
	sp;
}


Measured memory_bytes: 504
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <climits>

long long int solve(long long int& N, long long int& A, long long int& B)
{
    long long int residual = N % (A + B);
    long long int ans = (N - residual) / (A + B);
    ans *= A;
    if(residual >= A) ans += A;
    else ans += residual;

    return ans;
}

int main()
{
    long long int N, A, B; std::cin >> N >> A >> B;

    long long int ans = solve(N, A, B);

    std::cout << ans << std::endl;
    
    return 0;
}

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

int main(void) {
    int N,M,X;cin>>N>>M>>X;
    int pre = 0;
    int lat = 0;
    for (int i = 1; i <= M; i++) {
        int A;cin>>A;
        if (A < X) pre++;
        else lat++;
    }
    cout << min(pre, lat) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
ll n,k,ans[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    ll res=0;
    for(int i=k;i>=1;i--)
    {
        ans[i]=(ans[i]+qpow(k/i,n))%mod;
        res=(res+ans[i]*i)%mod;
        for(int j=1;j*j<=i;j++)
            if(i%j==0)
            {
                if(j!=i)
                    ans[j]=(ans[j]-ans[i])%mod;
                if(i/j!=j&&i/j!=i)
                    ans[i/j]=(ans[i/j]-ans[i])%mod;
            }
    }
    res=(res+mod)%mod;
    printf("%lld\n",res);
}


Measured memory_bytes: 4564
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    int N,W; cin >> N >> W;
    int v[N],w[N];
    int dp[W+1];
    rep(i,W+1) dp[i]=0;
    rep(i,N) cin >> v[i] >> w[i];
    rep(i,N){
        rng(j,w[i],W+1){
            chmax(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    string S;cin>>S;
    int N=S.size()-1;
    ll ans=0;
    rep(bit,1<<N){
        ll now=S[N]-'0',p=1;
        rep(i,N){
            if(bit&(1<<i)){
                p=1;
                now+=(S[N-1-i]-'0');
            }
            else{
                p*=10;
                now+=(S[N-1-i]-'0')*p;
            }
        }
        ans+=now;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256