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

using namespace std;

typedef long long ll;

#define MAX 1000001    //nCrのnの最大値+1

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

void COMinit(ll mod) {
    fac[0] = 1, finv[0] = 1;
    fac[1] = 1, inv[1] = 1, finv[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) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

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

int main() {
    ll n, k, mod = 1e9+7;    cin >> n >> k;
    ll *a = new ll[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    sort(a, a+n);
    COMinit(mod);

    ll ans = 0;
    for (int i = 0; i < n-k+1; i++) {
        ans -= a[i] * COM(n-i-1, k-1, mod) % mod;
        ans %= mod;
    }
    for (ll i = k-1; i <= n-1; i++) {
        ans += a[i] * COM(i, k-1, mod) % mod;
        ans %= mod;
    }

    ans = (mod + ans) % mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 27840
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	cout << string(dx, 'R') << string(dy, 'U');
	cout << string(dx, 'L') << string(dy, 'D');

	cout << 'D' << string(dx + 1, 'R') << string(dy + 1, 'U') << 'L';
	cout << 'U' << string(dx + 1, 'L') << string(dy + 1, 'D') << 'R';

	return 0;
}


Measured memory_bytes: 256
#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(){
    long double a, b, h;
    cin >> a >> b >> h;

    cout << (a+b)*h/2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
public static void main(String[] args) {
	InputStream inputStream = System.in;
	OutputStream outputStream = System.out;
	FastInput in = new FastInput(inputStream);
	PrintWriter out = new PrintWriter(outputStream);
	ABC179A solver = new ABC179A();
	solver.solve(1, in, out);
	out.close();
}

static class ABC179A {

	public void solve(int testNum, FastInput in, PrintWriter out) {
		String s = in.next();
		int n = s.length();
		
		if(s.charAt(n-1) == 's') {
			out.println(s+"es");
		}
		else {
			out.println(s+"s");
		}
		
	}

}

static class FastInput{
	private final BufferedReader in;
	private String[] buff;
	private int index = 0;
	
	public FastInput(InputStream is) {
		in = new BufferedReader(new InputStreamReader(is));
	}
	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	String next() {
		while (buff == null || index >= buff.length) {
			buff = nextLine().split(" ");
			index = 0;
		}
		return buff[index++];
	}
	int nextInt() {
		return Integer.parseInt(next());
	}
	
	long nextLong() {
		return Long.parseLong(next());
	}
	
	Double nextDouble() {
		return Double.parseDouble(next());
	}
	
	BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
	
	BigDecimal nextBigDecimal() {
		return new BigDecimal(next());
	}
	
	public int[] nextIntArray(final int n) {
		final int[] res = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextInt();
		}
		return res;
	}
	
	public long[] nextLongArray(final int n) {
		final long[] res= new long [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextLong();
		}
		return res;
	}
	
	public double[] nextDoubleArray(final int n ) {
		final double[] res = new double [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextDouble();
		}
		return res;
	}
	
	
	public int[][] nextInt2DArray(final int n , final int m){
		int [][]res = new int [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextInt();
			}
		}
		return res;
	}
	public long[][] nextLong2DArray(final int n , final int m){
		long [][]res = new long [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextLong();
			}
		}
		return res;
	}
	
	public char[][] nextChar2DArray(final int n){
		char [][]res = new char [n][];
		
		for(int i = 0 ; i < n ;i++) {
			String s = next();
			res[i] = s.toCharArray();
		}
		
		return res;
	}
}
}




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

int n, m, d;

int main(){
    cin >> n >> m >> d;
    double ans = ((d == 0) ? 1.0 : 2.0) * (n-d) / n * (m-1) / n;
    cout << fixed << setprecision(10) << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int dp[100010];
std::vector<int> graph[100010];

int rec(int v){
    if(dp[v] != 0){
        return dp[v];
    }
    int res = 0;
    for(int sub_v: graph[v]){
        res = std::max(res, rec(sub_v)+1);
    }
    return dp[v] = res;
}


int main(){
    int n, m;
    std::cin >> n >> m;
    for(int i = 0; i < m; i++){
        int x, y;
        std::cin >> x >> y;
        graph[--x].push_back(--y);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans = std::max(ans, rec(i));
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	ll cnt = 0, cntz = 0, ans = 0, mini = 1e18;
	rep(i,N) {
		cin >> A[i];
		if(A[i] < 0) cnt++;
		if(A[i] == 0) cntz++;
		chmin(mini, abs(A[i]));
		ans += abs(A[i]);
	}
	if(cnt % 2 == 1 && cntz == 0) ans -= mini*2;
	cout << ans << endl;



  return 0;
}


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

int main()
{
	char s[10];
	for(int i = 0; i < 10; i++)
	{
		s[i] = 0;
	}
	gets(s);
	for(int i = 0; i < 10 && s[i] != 0; i += 2)
	{
		if(s[i] != 'h' || s[i + 1] != 'i')
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[200000]={0};
    int tmp;
    for(int i(1);i<n;i++){
        cin>>tmp;
        a[tmp-1]++;
    }
    for(int i(0);i<n;i++){
        cout<<a[i]<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n;
ll a[maxn], dp[maxn];
vector<int> graph[maxn];

void dfs(int u, int prev)
{
	if (prev != -1 && graph[u].size() == 1)
	{
		dp[u] = a[u];
		//cerr << '@' << u << ' ' << dp[u] << endl;
		return;
	}
	for (int i : graph[u])
		if (i != prev)
			dfs(i, u);

	ll sum = 0;
	for (int i : graph[u])
		if (i != prev)
			sum += dp[i];
	ll count = sum - a[u];
	ll checker = a[u] - count, mx = a[u] - count;
	for (int i : graph[u])
		if (i != prev)
			checker += dp[i], mx = max(mx, dp[i]);
	if (a[u] - count < 0)
	{
		cout << "NO" << endl;
		exit(0);
	}
	if ((checker & 1) || mx > checker / 2)
	{
		cout << "NO" << endl;
		exit(0);
	}
	dp[u] = a[u] - count;
	//cerr << '@' << u << ' ' << dp[u] << endl;
}

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

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i < n; i++)
	{
		int u, v;
		cin >> u >> v;
		graph[--u].pb(--v);
		graph[v].pb(u);
	}
	int root = -1;
	for (int i = 0; i < n; i++)
		if (graph[i].size() > 1)
		{
			root = i;
			break;
		}

	if (root == -1)
	{
		cout << (a[0] == a[1] ? "YES" : "NO") << endl;
		return 0;
	}
	//cerr << "### " << root << endl;
	dfs(root, -1);
	ll checker = 0, mx = -1;
	for (int i : graph[root])
		checker += dp[i], mx = max(mx, dp[i]);
	if ((checker & 1) || mx > checker / 2)
	{
		cout << "NO" << endl;
		return 0;
	}
	cout << (dp[root] ? "NO" : "YES") << endl;
}



Measured memory_bytes: 13952
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<deque>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
using namespace std;
int vis[200005],s[200005];
int main()
{
     int n,k;
     scanf("%d%d",&n,&k);
     int m=0;
     for(int i=0;i<n;i++)
     {
          int a;
          scanf("%d",&a);
          if(!vis[a])
          {
               vis[a]=m+1;
               s[++m]++;
          }
          else
          {
               s[vis[a]]++;
          }
     }
     if(m<=k)
     {
          printf("0\n");
          return 0;
     }
     else
     {
          sort(s+1,s+1+m);
          int a=m-k;
          int sum=0;
          for(int i=1;i<=a;i++)
               sum+=s[i];
          printf("%d\n",sum);
     }
}


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

using namespace std;
#define ll         long long
#define f(n)       for(int i = 0; i < n; i++)
#define pb         push_back
#define mp         make_pair
#define vi         vector<int>
#define w(t)       while(t--)
#define all(v)     v.begin(),v.end()

int main()
{
    int n, m, sum = 0, summ = 0;
    cin >> n >> m;
    for(int i = 1; i < n; i++){
        sum = sum + i;
    }

    for(int i = 1; i < m; i++){
        summ += i;
    }

    cout << sum + summ << endl;

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod (1000000007)
#define REP(i,n) for(ll i=0;i<(n);i++)
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    vector<ll>lcm(1000010,0);
    ll n,ans=0;cin>>n;
    ll a[n];REP(i,n)cin>>a[i],(ans+=power(a[i],mod-2))%=mod;
    REP(i,n){
        ll tmp=a[i];
        for(int j=2;j*j<=tmp;j++){
            if(tmp==1)break;
            if(tmp%j==0){
                ll cnt=0;
                while(tmp%j==0)tmp/=j,cnt++;
                while(lcm[j]<cnt)(ans*=j)%=mod,lcm[j]++;
            }
        }
        while(tmp>1&&!lcm[tmp])(ans*=tmp)%=mod,lcm[tmp]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

vector<int> sieve(int n) {
	vector<int> res;
	vector<bool> is_prime(n + 1, true);
	
	is_prime[0] = is_prime[1] = false;
	
	for (ll i = 2; i * i <= n; i++) if (is_prime[i]) {
		res.push_back(i);
		for (ll j = 1; i * j <= n; j++) is_prime[i * j] = false;
	}
	
	REP(i, n + 1) if (is_prime[i]) res.push_back(i);
	sort(res.begin(), res.end());
	return res;
}

int main() {
	int N;
	cin >> N;
	
	map<int, int> mm;
	vector<int> prime = sieve(N);
	
	FOR(i, 2, N + 1) {
		int cur = i;
		REP(j, prime.size()) {
			while (cur % prime[j] == 0) { mm[prime[j]]++; cur /= prime[j]; }
		}
	}
	
	ll dp[100] = {};
	dp[1] = 1;
	
	REP(i, prime.size()) {
		for (int j = 99; j >= 1; j--) {
			for (int k = mm.find(prime[i])->se; k >= 1; k--) {
				int next = j * (k + 1);
				if (next >= 100) continue;
				dp[next] += dp[j];
			}
		}
	}
	
	cout << dp[75] << endl;
	
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
    l,r=map(int,input().split())
    a.append(l)
    b.append(r)
a=max(a)
b=min(b)
if(a>b):
    print(0)
else:
    print(b-a+1)

Measured memory_bytes: 10996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int k,s;
	ll ans=0;
	
	cin>>k>>s;
	for(int x=0;x<k+1;x++)
	{
		for(int y=0;y<k+1;y++)
		{
			int z = s-(x+y);
			if(z<k+1 && z>-1)
				ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,a,b;
  cin >>n;
  vector <pair<ll,ll>> p;
  for(ll i=0;i<n;i++){
    cin >> a>>b;
    p.push_back(make_pair(b,a));
  }
  sort(p.begin(),p.end());
  ll t=0;
  for(ll i=0;i<n;i++){
     t+=p[i].second;
     if(t>p[i].first){
      cout <<"No"<<endl;
       return 0;
     }
  }
  cout <<"Yes"<<endl;
  }


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    vector<int> divisors;
    for (int i = 1; i * i <= sum; i++) {
        if (sum % i == 0) {
            divisors.push_back(i);
            if (i != sum / i) divisors.push_back(sum / i);
        }
    }

    int res = 0;
    vector<int> r(N);
    for (int d : divisors) {
        for (int i = 0; i < N; i++) {
            r[i] = A[i] % d;
        }
        sort(r.begin(), r.end());

        vector<int> L(N + 1), R(N + 1);
        L[0] = 0; R[N] = 0;
        for (int i = 0; i < N; i++) {
            L[i + 1] = r[i] + L[i];
        }
        for (int i = N - 1; i >= 0; i--) {
            R[i] = (d - r[i]) + R[i + 1];
        }
        for (int i = 0; i <= N; i++) {
            if (L[i] == R[i] && L[i] <= K) {
                res = max(res, d);
                break;
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
PY=sorted([list(map(int,input().split()))+[_] for _ in range(m)],key=lambda x:x[1])

A,B={},[]
for p,y,num in PY:
    if p not in A:
        A[p]=1
        B.append([p,A[p],num])
    else:
        A[p] +=1
        B.append([p,A[p],num])

for a,b,c in sorted(B,key=lambda x:x[2]):
    print(str(a).zfill(6)+str(b).zfill(6))

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

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

using namespace std;

#define MAX_N 100100
#define MAX_Q 100100

class FenwickTree {
private:
  int n;
  vector<int> bit;
public:
  FenwickTree(int n) : n(n) {
    bit.clear();
    bit.resize(n+2,0);
  }
  void add(int a,int w) {
    ++a;
    for(int x=a;x<=n;x+=x&-x){
      bit[x] += w;
      assert(bit[x]>=0);
    }
  }
  int sum(int a) {
    ++a;
    if( a <= 0 ) return 0;
    int ret = 0;
    for(int x=a;x>0;x-=x&-x) ret += bit[x];
    return ret;
  }
  int sum(int a,int b) {
    return sum(b) - sum(a-1);
  }
};

#define IN 0
#define OUT 1

struct Event {
  int ep, type, index;
  bool operator < ( const Event &e ) const {
    if( ep != e.ep ) return ep < e.ep;
    return type > e.type; // OUT ???????????????
  }
};

int n, x[MAX_N], Q, l[MAX_Q], r[MAX_Q], e[MAX_Q], answer[MAX_Q];

void compute() {
  vector<Event> events;
  rep(i,Q) {
    events.push_back((Event){l[i],IN,i});
    events.push_back((Event){r[i]+1,OUT,i});
  }
  sort(events.begin(),events.end());
  map<int,int> mp;
  {
    vector<int> vec;
    rep(i,n) vec.push_back(x[i]);
    rep(i,Q) {
      int a = x[l[i]], b = x[r[i]];
      if( a > b ) swap(a,b);
      vec.push_back(a-e[i]-1);
      vec.push_back(b+e[i]+1);
    }
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()),vec.end());
    rep(i,(int)vec.size()) mp[vec[i]] = i;
  }

  int m = (int)mp.size();
  int sweep = 0;
  FenwickTree fenwick = FenwickTree(m+2);
  rep(i,(int)events.size()) {
    while( sweep < events[i].ep ) {
      fenwick.add(mp[x[sweep]],+1);
      ++sweep;
    }
    int a = x[l[events[i].index]], b = x[r[events[i].index]];
    if( a > b ) swap(a,b);
    if( events[i].type == IN ) {
      answer[events[i].index] -= fenwick.sum(mp[a-e[events[i].index]-1]);
      answer[events[i].index] -= fenwick.sum(mp[b+e[events[i].index]+1],m-1);
    } else {
      answer[events[i].index] += fenwick.sum(mp[a-e[events[i].index]-1]);
      answer[events[i].index] += fenwick.sum(mp[b+e[events[i].index]+1],m-1);
    }
  }
  rep(i,Q) printf("%d\n",answer[i]);
  //(-3,0) (0,1) (1,2) (3,3) (4,4) (5,5) (7,6) (8,7) (10,8) (12,9) (13,10)
}

int main() {
  scanf("%d",&n);
  rep(i,n) scanf("%d",&x[i]);
  scanf("%d",&Q);
  rep(i,Q) {
    scanf("%d %d %d",&l[i],&r[i],&e[i]);
    --l[i], --r[i];
  }
  compute();
  return 0;
}

Measured memory_bytes: 21224
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{ int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL) T[l].p=v;
    if(r!=NIL) T[r].p=v;
  }

  for(i=0;i<n;i++)
    if(T[i].p==NIL)
      root=i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int x = scan.nextInt()-1;
		int y = scan.nextInt()-1;

		int[] dist = new int[n - 1];

		for (int i = 0; i < n-1; i++) {
			for (int j = i+1; j < n; j++) {
				int a = j-i;
				int b = Math.min(Math.abs(x-i)+1+Math.abs(y-j) , Math.abs(y-i)+1+Math.abs(x-j));
				dist[Math.min(a, b)-1]++;
			}
		}
		
		for(int i = 0; i < n-1; i++) {
			System.out.println(dist[i]);
		}
	}

}

Measured memory_bytes: 23764
#include <iostream>
// #include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <algorithm>
// #include <cmath>
// #include <math.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; ++i) cin >> d[i];
    set<int> values;
    for(int i=0; i<N; ++i){
        values.insert(d[i]);
    }
    cout << values.size() << endl;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int h(int x, int y){
	return x * x + 2 * x * y + x + 1;
}

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

	int n, d, x;
	cin >> n >> d >> x;
	int ans = 0;
	forn(i, n){
		int a;
		cin >> a;
		for(int j = 1; j <= d; j += a)ans++;
		
	}
	cout << ans + x << '\n';
	return 0;
}



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

int main(void){
    int x;
    cin >> x;
    int ans = 1;
    for(int i=1; i<=x; i++){
        for(int j=2; j<i; j++){
            int b = j*j;
            while(b <= i){
                if(b == i){
                    ans = i;
                    break;
                }
                b *= j;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    string s;
    cin >> s;
    rep(i,s.size())cout << "x";
    cout << endl;
}


Measured memory_bytes: 256
#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;
    cin >> n;
    vector <int> in(n+1,1);

    int nn;
    rep(i,n-1){
        nn=i+2;
        rep(j,n-1){
            while(nn%(j+2)==0){
                nn/=j+2;
                ++in[j+2];
            }
        }
    }

    ll ans=1;
    rep(i,n+1){
        ans*=in[i];
        ans=ans%1000000007;
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>

#define N 100

int calculate(int a,int b,char op);

int main(void)
{
	int a,b,count=0,ans[N];
	char op;
	
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		
		if(op=='?'){
			break;
		}
		
		ans[count]=calculate(a,b,op);;
		count++;
	}
	
	for(int i=0;i<count;i++){
		printf("%d\n",ans[i]);
	}
	
	return 0;
}

int calculate(int a,int b,char op)
{
	switch(op){
		case '+':
			return a+b;
			break;
		case '-':
			return a-b;
			break;
		case '*':
			return a*b;
			break;
		case '/':
			return a/b;
			break;
		default:
			printf("無効な演算子です\n");
			break;
	}
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

const int MAX_N = 105;
const int MAX_V = 100005;

ll dp[MAX_N][MAX_V];

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vi w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  rep(i, MAX_N) rep(j, MAX_V) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i, n) rep(j, MAX_V) {
    if (j - v[i] >= 0) chmin(dp[i+1][j], dp[i][j-v[i]] + w[i]);
    chmin(dp[i+1][j], dp[i][j]);
  }
  ll ans = 0;
  rep(j, MAX_V) if (dp[n][j] <= k) ans = j;
  cout << ans << endl;
}

Measured memory_bytes: 85624
N, Y = map(int,input().split())#調べる要素が少ないものからループしないと実行時間が間に合わない。
counter = 0
if counter==0:
    for i in range(Y//10000+1):
        if counter==0:   
            for j in range((Y-10000*i)//5000+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)

Measured memory_bytes: 3064
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

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

const int MAXN = 1003;
int n, m;
int p[MAXN];
vector<int> key[MAXN];
int memo[MAXN][1 << 12];

int solve(int idx, int mask) {
//    cout << idx << ' ' << mask << '\n';
    if (mask + 1 == (1 << n))
        return 0;
    if (idx == m)
        return (int)1e9;
    int &ret = memo[idx][mask];
    if (~ret)
        return ret;
    ret = solve(idx + 1, mask);
    int newMask = mask;
    for (int x : key[idx]) {
        newMask |= (1 << x);
    }
    ret = min(ret, solve(idx + 1, newMask) + p[idx]);
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
        int b;
        cin >> b;
        key[i].resize(b);
        for (int &x : key[i]) {
            cin >> x;
            --x;
        }
    }

    memset(memo, -1, sizeof memo);
    int ans = solve(0, 0);
    if (ans >= (int)1e9) {
        cout << -1 << '\n';
    } else {
        cout << ans << '\n';
    }

    return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100050;
ll a[maxn],b[maxn],c[maxn],v[maxn];
bool cmp(ll a, ll b)
{
    return a > b;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    for(ll i=0; i<n; i++)
    {
        scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);

    }
    ll ans = 0x3f3f3f3f*-1;
    for(int mark = 0;mark<8;mark++)
    {
        int a1 = (mark&1)?1:-1;
        int b1 = (mark&2)?1:-1;
        int c1 = (mark&4)?1:-1;
        for(ll i=0;i<n;i++)
            v[i] = a1*a[i] + b1*b[i] + c1*c[i];
        sort(v,v+n,cmp);
        ll cnt = 0;
        for(ll i=0;i<m;i++)
            cnt+=v[i];
        ans = max(ans,cnt);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var M = int.Parse(inputs[1]);
        var mat = new int[N, M];
        for (int i = 0; i < N; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            for (int j = 1; j < inputs.Length; j++)
            {
                var m = int.Parse(inputs[j]) - 1;
                mat[i, m] = 1;
            }
        }

        int count = 0;
        for (int m = 0; m < M; m++)
        {
            int sum = 0;
            for (int n = 0; n < N; n++)
            {
                sum += mat[n, m];
            }
            if (sum == N)
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}



Measured memory_bytes: 13140
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                {
                    let mut out = Vec::<u8>::new();
                    solve($input,&mut out);
                    let out_str =str::from_utf8(&out).unwrap();
                    assert_eq!(&out_str, &$output);
                }
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
#[allow(unused_mut)]
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr,str) => {
        $iter.next().unwrap()
    };

    ($iter:expr, $t:tt) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    let mut out = std::io::stdout();

    solve(&stdin!(), &mut out);
}

#[allow(unused_mut)]
fn solve<W: std::io::Write>(src: &str, out: &mut W) {
    #[allow(unused_macros)]
    macro_rules! out {
        ($fmt:expr) => {{
            let _ = out.write_fmt(format_args!($fmt));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            let _ = out.write_fmt(format_args!($fmt, $($args)*));
        }};
    }
    #[allow(unused_macros)]
    macro_rules! outln {
        ($fmt:expr) => {{
            out!(concat!($fmt,"
"));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            out!(concat!($fmt, "
"), $($args)*);
        }};
    }

    input! {
        source = src,
        n:usize,
        a:[usize;n],
    }
    let mut m = 0;
    let mut s = 0;
    for &ai in a.iter() {
        if ai < m {
            s += m - ai;
        }
        m = max(m, ai);
    }
    out!("{}", s);
}
test! {}


Measured memory_bytes: 5744
from copy import deepcopy
N, M = map(int, input().split())

graph = [[float('infinity')] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c
ans = 0
# 頂点g -> eまでの最短経路コストと、その経路を記録する

for i in range(N):
    for j in range(N):
        if i == j:
            graph[i][j] = 0

original = deepcopy(graph)

def warshall_floyd(graph, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

warshall_floyd(graph, N)

ans = 0
for i in range(N):
    for j in range(i):
        if original[i][j] != float('infinity') and graph[i][j] != original[i][j]:
            ans += 1
print(ans)

Measured memory_bytes: 47192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax=200010;
//ll a[Nmax];
//int* P = new int[N];

int main() {
	int N;
	cin >> N;
	
	int a,c,flag=0,cnt=0;
	for(int i=2;i < 55555;i++){
		flag=0;
		for(int j=2;j < i;j++){
			if(i%j == 0) break;
			if(j==i-1)
				if(i%5==1){
					cout << i << endl;
					cnt++;
				}
		}
		if(cnt==N) break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){fastio
    string s,t;cin>>s>>t;
    rep(i,0,s.size()-1){
        cout<<s[i];
        if(i==s.size()-1&&s.size()!=t.size())break;
        cout<<t[i];
    }
    
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,k;
    cin >> n >> m >> k;
    vector<bool> a((n+1)*(m+1));

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= m; j++) {
            int tmp=i*(m-j)+(n-i)*j;
            a[tmp]=true;
        }
    }
    if(a[k]) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int w, a, b;
int main() {
  cin>>w>>a>>b;
  if (a + w < b) {
  	cout<<b-a-w<<endl;
  } else if (b + w < a) {
  	cout<<a - b - w<<endl;
  } else {
  	cout<<0<<endl;
  }
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = []
for i in range(H):
  S = input()
  f = 0
  for j in range(W):
    if S[j] == "#":
      f = 1
      break
  if f == 1:
    A.append(S)
H = len(A)
ANS = ["" for i in range(H)]
for j in range(W):
  f = 0
  for i in range(H):
    if A[i][j] == "#":
      f = 1
      break
  if f == 1:
    for i in range(H):
      ANS[i] += A[i][j]
for i in range(H):
  print(ANS[i])

Measured memory_bytes: 68304
main = getLine >>= putStrLn . unwords . filter isWord . splitBy isPunc
 where isWord s = elem (length s) [3..6]; isPunc c = elem c " .,"

splitBy p xs
 | null xs = []
 | p (head xs) = splitBy p (tail xs)
 | otherwise = (takeWhile (not.p) xs : splitBy p (dropWhile (not.p) xs))

Measured memory_bytes: 4012
#include<bits/stdc++.h>
//#include<boost\lexical_cast.hpp> 

#define ll long long
#define ld long double
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int> 
#define vvi vector< vi >
#define vl vector<ll>
#define vpi vector<pi> 
#define vpl vector<pl>

#define PB emplace_back
#define MP make_pair
#define SZ(x) (ll)x.size()
#define SS second
#define FF first


#define DEB(x) cout << #x << "=" << x << endl
#define DEB2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define DEB3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define DEB4(x, y, z, k) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," <<#k << "=" << k<< endl
#define DEBC(a) for(auto x:a) cout<<x<<" ";
#define DEBP(name,a) cout<<name<<endl;for(auto x:a){ cout<<x.first<<"\t"<<x.second<<endl;}

#define INF 0x7fffffff
#define LINF 2000000000000000007
#define endl "\n"
#define MOD 1000000007
#define MAX 100010

#define FILL(a,x) memset(x,a,sizeof x)
#define ALL(x) x.begin(),x.end()
#define REP(i,a,n) for(ll i=a;i<n;++i)
#define REPR(i,n,b) for(ll i=n;i>=b;i--)
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

using namespace std;
//using boost::lexical_cast;
//using boost::bad_lexical_cast;
int main(){
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int test=1;
    //cin>>test;
    while(test--){
       ll n, m;
       cin>>n>>m;
       ll sm=0, tmp;
       REP(i,0,m){
        cin>>tmp;
        sm+=tmp;
       }
       if(sm>=n){
            cout<<"Yes\n";
       }
       else{
            cout<<"No\n";
       }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <array>

using namespace std;

int succ[200002][26];
int dp[200002];
int pre[200002];

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

  const int n = s.size();
  reverse(s.begin(), s.end());
  s = '^' + s;
  for (int i = 0; i < 26; i++) {
    succ[n][i] = -1;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      if (s[i + 1] == j + 'a') {
        succ[i][j] = i + 1;
      } else {
        succ[i][j] = succ[i + 1][j];
      }
    }
  }

  for (int i = 0; i < 200002; i++) {
    dp[i] = 1e9;
    pre[i] = -1;
  }
  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      int k = succ[i][j];
      if (k != -1) {
        if (dp[k] > dp[i] + 1) {
          dp[k] = dp[i] + 1;
          pre[k] = i;
        } else if (dp[k] == dp[i] + 1) {
          if (s[pre[k]] > s[i]) {
            pre[k] = i;
          }
        }
      }
    }
  }

  int mn = 1e9;
  for (int i = 0; i <= n; i++) {
    bool all = true;
    for (int j = 0; j < 26; j++) {
      if (succ[i][j] == -1) all = false;
    }
    if (!all) {
      mn = min(mn, dp[i]);
    }
  }

  string ans = "~";
  for (int i = 0; i <= n; i++) {
    bool all = true;
    for (int j = 0; j < 26; j++) {
      if (succ[i][j] == -1) all = false;
    }
    if (all) continue;
    if (dp[i] != mn) continue;
    string cand;
    for (int j = 0; j < 26; j++) {
      if (succ[i][j] == -1) {
        cand += j + 'a';
        break;
      }
    }
    for (int j = i; j != 0; j = pre[j]) {
      cand += s[j];
    }
    ans = min(ans, cand);
  }

  cout << ans << endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d,w;
string s[100],t;
//vll a,b;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	cin>>n>>m;
	for(ll i=0;i<n;i++) cin>>s[i];

	for(ll i=0;i<n;i++) {
		for(ll j=0;j<m;j++) {
			ll pick = true;
			if(s[i][j]=='#') {
				pick = false;
				if(i && s[i-1][j]=='#') pick = true;
				if(i+1<n && s[i+1][j]=='#') pick = true;
				if(j && s[i][j-1]=='#') pick = true;
				if(j+1<m && s[i][j+1]=='#') pick = true; 
			}
			if(pick == false) {
				cout<<"No\n";
				return;
			}
		}
	}
	cout<<"Yes\n";
	return;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	for(ll i=1;i<=T;i++) {
		MAIN(i);
	}
	return 0;
}



Measured memory_bytes: 3628
package main

import "fmt"

func divs(n int) []int {
	r := make([]int, 0)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			r = append(r, i)
			if i*i != n {
				r = append(r, n/i)
			}
		}
	}
	return r
}
func cols(n int) int {
	cnt := 0
	for n > 0 {
		cnt++
		n /= 10
	}
	return cnt
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var N int
	fmt.Scan(&N)
	ds := divs(N)
	ans := int(1e10) + 1
	for _, v := range ds {
		ans = min(ans, max(cols(v), cols(N/v)))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define line cout<<endl;
#define space cout<<" ";
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI 3.141592653589793238
typedef long long int ll;

using namespace std;

const int N = 1e9+7;

vector<ll> wt(100005);
vector<ll> val(100005);

ll dp[105][100005];

ll knapsackone(ll n,ll w)
{
    if(n==0||w==0)
        return 0;

    if(dp[n][w]!=-1)
        return dp[n][w];

    if(wt[n-1]<=w)
    {
        return  dp[n][w] = max(val[n-1]+knapsackone(n-1,w-wt[n-1]),knapsackone(n-1,w));
    }
    else
        return dp[n][w] = knapsackone(n-1,w);
}


void solve()
{
    memset(dp,-1,sizeof(dp));
    ll n,w;
    cin>>n;
    cin>>w;

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

    ll ans = knapsackone(n,w);
    cout<<ans;
}


int main()
{
   ll t;
   t = 1;
  // cin>>t;

   while(t--)
   {
       solve();
       cout<<endl;
   }




}
















Measured memory_bytes: 86780
N = int(input())
S = input()

strs = ["%d" % i for i in range(10)]
strs += ["%02d" % i for i in range(100)]

flags = set()
for d in S:
    tmp = set()
    for i in strs:
        if i in flags:
            tmp.add(i + d)
    tmp.add(d)
    flags |= tmp

print(sum([len(f) == 3 for f in flags]))

Measured memory_bytes: 41564
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
const ll MOD = 998244353ll;

int n,m;
int a[52525], b[52525], c[52525];
gp_hash_table<int, int> M[125252];
int dp[252521];
bool ppcnt[16];

int eq(int a, int b,int v){
  auto it = M[a].find(b);
  return it!=M[a].end() && it->second==v;
}
int neq(int a,int b,int v){
  auto it = M[a].find(b);
  return it!=M[a].end() && it->second!=v;
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d%d%d",a+i,b+i,c+i),a[i]--,b[i]--;
  REP(i,16)ppcnt[i] = __builtin_popcount(i)%2==0;
  REP(i,m)M[a[i]][b[i]] = c[i];
  REP(j,16){
    if(!ppcnt[j])continue;
    bool ok = true;
    REP(i,4)if(neq(i>>1, i&1, j>>i&1))ok = false;
    if(ok)dp[j>>3&1] += 1;
  }
  REP(i,n-2)REP(r2,2)if(dp[i*2+r2]){
    int ci = i+1;
    REP(ld,2){
      int ru = r2 ^ ld;
      if(neq(ci-1,ci+1,ld))continue;
      if(neq(ci+1,ci-1,ru))continue;
      REP(to,8){
        int nj = to*2+r2;
        if(!ppcnt[nj])continue;
        if(neq(ci+1,ci+0,nj>>1&1))continue;
        if(neq(ci+0,ci+1,nj>>2&1))continue;
        if(neq(ci+1,ci+1,nj>>3&1))continue;
        dp[(i+1)*2+(nj>>3)] += dp[i*2+r2];
        if(dp[(i+1)*2+(nj>>3)]>=MOD)dp[(i+1)*2+(nj>>3)]-=MOD;
      }
    }
  }
  ll ans = dp[(n-2)*2] + dp[(n-2)*2+1];
  if(ans>=MOD)ans-=MOD;
  ll fr = n<=3 ? 0ll : ((ll)n*n - 7ll*2 - 5ll*(n-4))/2;
  REP(i,m){
    int x = a[i], y = b[i], z = c[i];
    if(abs(x-y)<=2)continue;
    if(neq(y,x,z))ans = 0;
    else if(!eq(y,x,z) || x<y)fr--;
  }
  ll aa = 2ll;
  while(fr){
    if(fr&1)ans = ans * aa % MOD;
    aa = aa * aa % MOD;
    fr >>= 1;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 28800
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

template<typename T, typename U>
T gcd(T u, U v) {
	if (u == 0)return v;
	if (v == 0)return u;
	T r;
	while (v) {
		r = u % v;
		u = v;
		v = r;
	}
	return u;
}

template<typename T, typename U>
long long lcm(T u, U v) {
	long long res = (long long)u / gcd(u, v);
	res *= v;
	return res;
}

int main() {
	IOS;
	ll a, b;
	cin >> a >> b;
	put(lcm(a, b));
	return 0;
}


Measured memory_bytes: 256
N,A,B = map(int,input().split())
L = []
for i in range(1,N+1) :
    c = 0
    C = list(str(i))
    for j in range(len(C)) :
        c += int(C[j])
    if A <= c <= B :
        L.append(i)
print(sum(L))



Measured memory_bytes: 3292
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double ans = 0;
        for (int i = 0 ; i < n ; i++) {
            double x = sc.nextDouble();
            String w = sc.next();
            if (w.equals("JPY")) {
                ans += x;
            } else {
                ans += 380000 * x;
            }
        }

        System.out.println(ans);

    }

}


Measured memory_bytes: 23252