akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define mk make_pair
#define endl '\n'

const ll M=1e9+7;

ll pow(ll val, ll exp, ll MOD)
{
    ll x=1,y=val; 
    while(exp > 0)
    {
        if(exp%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD; 
        exp /= 2;
    }
    return x;
}

int main()
{
    IOS;
    int n;
    cin>>n;
    vector<pair<ll,ll>> a(n);
    map<pair<ll,ll>,int> mp;
    int groupa=0,groupb=0,groupboth=0;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i].first>>a[i].second;
        if(a[i].first==0 && a[i].second!=0)
        {
            groupa++;
        }
        else if(a[i].first!=0 && a[i].second==0)
        {
            groupb++;
        }
        else if(a[i].first==0 && a[i].second==0)
        {
            groupboth++;
        }
        else
        {
            ll x,y;
            x=a[i].first;y=a[i].second;
            int sign=(x/abs(x))*(y/abs(y));
            ll temp=__gcd(abs(x),abs(y));
            x=abs(x)/temp;
            y=abs(y)/temp;
            mp[mk(sign*x,y)]++;
        }
    }

    ll ans=1;
    for (auto &&i : mp)
    {
        int sign=i.first.first/abs(i.first.first);
        int v1,v2;
        v1=i.second;
        i.second=0;
        v2=mp[mk(-1*sign*i.first.second,abs(i.first.first))];
        mp[mk(-1*sign*i.first.second,abs(i.first.first))]=0;
        ll temp=pow(2,v1,M)+pow(2,v2,M)-1;
        ans*=(temp%M);
        ans%=M;
    }
    ans*=(pow(2,groupa,M)+pow(2,groupb,M)-1)%M;
    ans%=M;
    ans+=groupboth;
    ans%=M;
    ans+=M-1;
    ans%=M;
    cout<<ans;
}

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

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

    bool flag1=true, flag2=true;
    for(int i=0; i<S.length(); i++){
        if(i%2 == 0){
            if(S[i] == 'L'){
                flag1 = false;
                break;
            }
        }else{
            if(S[i] == 'R'){
                flag2 = false;
                break;
            }
        }
    }

    if(flag1 && flag2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,t;
	int x,y;
	while(cin>>s>>t,s.size()!=1){
		x=0;y=0;
		for(int i=0;i<4;i++)
		for(int j=0;j<4;j++){
			if(s[i]==t[j]){
				if(i==j)
					x++;
				else y++;
			}
		}
		cout<<x<<' '<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 912
/*
    ASEEN AAN 
            PINDAN AALE JATT!!!
                                */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1000000007;   
lli INF=1e17;
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,q,z,x,y,k,m;
const double pi1=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
//lli tot=0;
vector<lli> pf(string s) {
    int n = (int)s.length();
    vector<lli> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//map<ll,lli> dp;
//set<lli> s[100005];
lli dp[100005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    lli a[n+1];
    for(int i=1;i<=n;i++)
    cin>>a[i];
    mem1(dp,1e17);
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
        if(i>2)
        dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n];
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <limits>
#include <cstdlib>
#include <regex>
using namespace std;

double inf = numeric_limits<double>::infinity();

#define REP(i,n) for(int i=0;i<n;i++)
using LL = long long int;
LL GCD(LL a,LL b){ if(a<b) return GCD(b,a); else if(a%b==0) return b; else return GCD(b,a%b); }
LL LCM(LL a,LL b){ return (a/GCD(a,b))*b; }


int main() {
    int n;
    cin >> n;
    int a, b;
    int maxa = 0;
    int maxb = 0;
    REP(i,n) {
        cin >> a >> b;
        if (a > maxa) {
            maxa = a;
            maxb = b;
        }
    }
    cout << maxa + maxb << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2);

int main()
{
  int N;cin>>N;
  vector<ll> B(N,0);
  for (int i=1;i<=N-1;i++)
    cin>>B[i];
  
  vector<ll> A(N+1,0);
  A[1]=B[1];
  for (int i=1;i<=N-1;i++)
  {
    if (A[i]>B[i]) A[i]=B[i];
    A[i+1]=B[i]; 
  }
  
  ll ans=0;
  for (int i=1;i<=N;i++)
  {
    //cout<<"A["<<i<<"]="<<A[i]<<endl; 
    ans += A[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n,m,xc,yc;
	 int x[1000]={0},y[1000]={0};
	 cin>>n>>m>>xc>>yc;
	 for(int i=0;i<n;i++)
	 cin>>x[i];
	 for(int i=0;i<m;i++)
	 cin>>y[i];
	 int flag=0;
	 for(int i=xc+1;i<=yc;i++)
	 {  flag=0;
	 	for(int j=0;j<n;j++)
	     {
	     	if(i>x[j])continue;
	     	else 
			 {flag=1;
			 	break;
			 }
		 }
		 if(flag)continue;
	 for(int j=0;j<m;j++)
	 {
	 	if(i<=y[j])continue;
	     	else 
			 {flag=1;
			 	break;
			 }
	 }
	 if(flag==0)break;
	 }
	 if(flag==0)
	 {
	 	cout<<"No War"<<endl;
	 }
	 else
	 {
	 	 cout<<"War"<<endl;
	 }
 } 

Measured memory_bytes: 256
import heapq
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
hq = []
for z in p:
  heapq.heappush(hq, [-z, 1])
for z in q:
  heapq.heappush(hq, [-z, 2])
for z in r:
  heapq.heappush(hq, [-z, 3])
red = 0
green = 0
less = 0
ans = 0
while red + green + less < x + y:
  v, f = heapq.heappop(hq)
  if f == 1 and red < x:
    ans -= v
    red += 1
  elif f == 2 and green < y:
    ans -= v
    green += 1
  elif f == 3:
    ans -= v
    less += 1
print(ans)

Measured memory_bytes: 55488
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
 
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
 
 
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=8&&b<=8){
		cout<<"Yay!"<<endl;
	}else{
		cout<<":(";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef pair<int,lld> pil;
typedef pair<lld,int> pli;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
const lld mod = 1e9 + 7;
lld arr[222222];
int main(void){
	int n;
	scanf("%d",&n);
	lld tot = 0;
	for(int e=0;e<n;e++){
		scanf("%lld",&arr[e]);
		tot = (tot+arr[e])%mod;
	}
	lld ans = 0;
	for(int e=0;e<n;e++){
		tot = (tot-arr[e]+mod)%mod;
		ans = (ans + arr[e]*tot)%mod;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 5372
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};


int main(void){
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    map<int, int> all;
    for(int i = 0; i < N; i++) all[A[i]]++;
    vector<int> xs;
    for(auto p: all){
        xs.push_back(p.second);
    }
    sort(xs.begin(), xs.end());
    int s = xs.size();
    int ans = 0;
    for(int i = 0; i < s - K; i++){
        ans += xs[i];
    }
    cout << ans <<  endl;
    
}


Measured memory_bytes: 11516
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define ll long long

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

using namespace std;

ll n, m, k;
const ll N = 222222;
const ll mod = 998244353;
//---------------------------------------------------------------------------------------------------
ll f[N];
void init()
{
	f[0] = 1;
	reps(i, 1, N) f[i] = (f[i - 1] * i) % mod;
}
//---------------------------------------------------------------------------------------------------
ll inv(ll x)
{
	ll res = 1;
	ll k = mod - 2;
	ll y = x;
	while (k)
	{
		if (k & 1)
			res = (res * y) % mod;
		y = (y * y) % mod;
		k /= 2;
	}
	return res;
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k)
{
	ll a = f[n];	 // = n!
	ll b = f[n - k]; // = (n-k)!
	ll c = f[k];	 // = k!

	ll bc = (b * c) % mod;

	return (a * inv(bc)) % mod;
}

void solve()
{
	init();

	ll ren[N] = {0};
	ren[0] = 1;
	ren[1] = m;
	reps(i, 2, n + 1)
	{
		ren[i] = (ren[i - 1] * (m - 1)) % mod;
	}

	ll result = 0;
	rep(i, k + 1)
	{
		ll ans = (ren[n - i] * C(n - 1, i)) % mod;
		//cout << "cha " << i << " " << ren[n - i] << " " << C(n - 1, i) << endl;

		result = (result + ans) % mod;
	}

	cout << result << endl;
}

void input()
{
	cin >> n >> m >> k;
}

int main()
{
	input();
	solve();
}


Measured memory_bytes: 6688
# Initializing variables
monsterHP, attackDamage = map(int, input().split())
attack = 1

# Calculating the number of attacks serval needs to make to win.
while monsterHP > attackDamage :
    monsterHP -= attackDamage
    attack += 1
print(attack)

# Check out my Youtube channel! https://www.youtube.com/channel/UCMOKVyAbTZOpKikTrX5dy_A


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }


    vector<int> cost(n, -1);
    cost[0] = 0;
    queue<int> que;
    que.push(0);

    while (!que.empty()) {
        int cur = que.front(); que.pop();
        for (auto v : g[cur]) {
            if (cost[v] != -1) continue;
            cost[v] = cost[cur] + 1;
            que.push(v);
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < n; ++i) {
        for (auto v : g[i]) {
            if (cost[v] < cost[i]) {
                cout << v + 1 << endl;
                break;
            }
        }
    }
}



Measured memory_bytes: 10152
(let* ((h (read))
       (w (read))
       (instr (make-array h :element-type 'string
                            :adjustable t
                            :fill-pointer 0))
       (mp (make-array '(50 50) :element-type 'integer
                                :initial-element -1))
       (white 0)
       (que '((0 0))))
  (dotimes (i h)
    (setf (aref instr i) (read-line))
    (dotimes (j w)
      (if (equal #\. (char (aref instr i) j)) (setf white (1+ white)))))
  (setf (aref mp 0 0) 0)
  (loop for x from 0 upto 2
        when (> (length que) 0) do (let ((a (car (car que)))
                                         (b (elt (car que) 1)))
                                     ;(format t "~A~A~%" a b)
                                     (if (> a 0) (if (and (not (equal (char (aref instr (- a 1)) b) #\#)) (equal (aref mp (- a 1) b) -1))
                                                     (progn (setf (aref mp (- a 1) b) (1+ (aref mp a b)))
                                                            (setf que (append que (list (list (- a 1) b)))))))
                                     (if (> b 0) (if (and (not (equal (char (aref instr a) (- b 1)) #\#)) (equal (aref mp a (- b 1)) -1))
                                                     (progn (setf (aref mp a (- b 1)) (1+ (aref mp a b)))
                                                            (setf que (append que (list (list a (- b 1))))))))
                                     (if (< a (- h 1)) (if (and (not (equal (char (aref instr (+ a 1)) b) #\#)) (equal (aref mp (+ a 1) b) -1))
                                                     (progn (setf (aref mp (+ a 1) b) (1+ (aref mp a b)))
                                                            (setf que (append que (list (list (+ a 1) b)))))))
                                     (if (< b (- w 1)) (if (and (not (equal (char (aref instr a) (+ b 1)) #\#)) (equal (aref mp a (+ b 1)) -1))
                                                     (progn (setf (aref mp a (+ b 1)) (1+ (aref mp a b)))
                                                            (setf que (append que (list (list a (+ b 1)))))))))
                                   (setf que (cdr que))
                                   (setf x 0))
  (format t "~A~%" (if (not (equal -1 (aref mp (- h 1) (- w 1)))) (- white (1+ (aref mp (- h 1) (- w 1)))) -1)))


Measured memory_bytes: 27748
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		String s = sc.next();

		sc.close();

		if (a >= 3200) {
			out.println(s);
		} else {
			out.println("red");
		}

	}

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


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ

    Scanner sc = new Scanner(System.in);
    char a = sc.next().charAt(0);
    char b = sc.next().charAt(0);
    char c = sc.next().charAt(0);

    System.out.println(String.valueOf(a) + String.valueOf(b) + String.valueOf(c));
  }
}


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

const int NOTV = 0;
const int VIST = 1;
const int NMAX = 100;
const int VMAX = 2000;
const int NILL = -1;
const int INFTY = 1 << 21;
int n;
int a[NMAX][NMAX];  //??£??\??????
int v[NMAX];  //????°???¨?????¨?????????
int d[NMAX];  //????°???¨?????¨??????????????????
int vis[NMAX];
//priority_queue <greater<int>> pq;

int prim() {
	for (int i = 0; i < n; i++) {
		vis[i] = NOTV;
		d[i] = INFTY;
		v[i] = -1;
	}
	d[0] = 0;
	int u = 0;
	while (1) {
		int mincost = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (vis[i] == NOTV and mincost > d[i]) {
				mincost = d[i];
				u = i;
			}
		}
		if (u == -1) break;
		vis[u] = VIST;
		for (int ver = 0; ver < n; ver++) {
			if (vis[ver] == NOTV and a[u][ver] != INFTY) {
				if (a[u][ver] < d[ver]) {
					d[ver] = a[u][ver];
					v[ver] = u;
					vis[ver] = NOTV;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] != -1) ans += a[i][v[i]];
	}
	return ans;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int e;
			cin >> e;
			a[i][j] = e;
			if (a[i][j] == -1) {
				a[i][j] = INFTY;
			}
		}
	}
	
	cout << prim() << endl;
	return 0;
}

Measured memory_bytes: 3100
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

int main() {
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> a(X), b(Y), c(Z);
    for (ll& ai : a) cin >> ai;
    for (ll& bi : b) cin >> bi;
    for (ll& ci : c) cin >> ci;
    priority_queue<ll> pq;
    for (ll& ai : a) {
        for (ll& bi : b) pq.push(ai + bi);
    }
    priority_queue<ll> pq2;
    for (int i = 0; i < K; i++) if (!pq.empty()) {
        ll sum = pq.top(); pq.pop();
        for (ll& ci : c) pq2.push(sum + ci);
    }
    for (int i = 0; i < K; i++) {
        ll sum = pq2.top(); pq2.pop();
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 43112
#include <iostream>
#include <unordered_map>

using namespace std;

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

    unordered_map<int, int> m;

    for (int i = 1; i < N; ++i) {
        int Ai;
        cin >> Ai;
        m[Ai] += 1;
    }

    for (int i = 1; i <= N; ++i) {
        cout << m[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 11472
#include <algorithm>
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
  int a, b;
  cin >> a >> b;
  
  int x = a;
  int loop = b;
  if (b < a) {
    x = b;
    loop = a;
  }
  for (int i = 0; i < loop; ++i) {
    cout << (char)('0' + x);
  }
  cout << endl;
  return 0;
}

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

int main() {
  string s;
  cin>>s;
  string kotae;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0')kotae.push_back('0');
    else if(s[i]=='1')kotae.push_back('1');
    else if(s[i]=='B'){
      if(kotae.size()!=0){
        kotae.erase(kotae.size()-1,1);
      }
    }
  }
  cout<<kotae<<endl;
  return 0;
}

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

int main()
{
	int A,B,K;
	cin >> A >> B >> K;
	
	for(int i=0;i<K;i++)
	{
		if(i%2==0)
		{
			if(A%2==1)A--;
			B+=(A/2);
			A/=2;
		}
		if(i%2==1)
		{
			if(B%2==1)B--;
			A+=(B/2);
			B/=2;
		}
	}
	cout << A << " " << B << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,d,x;
    cin >> n >> d >> x;
    intl a[n];
    cin(i,a);
    intl cnt = x;
    rep(i,n){
        cnt += (d-1)/a[i] + 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict
input = sys.stdin.readline
    
icase=0
if icase==0:
    n,m=map(int,input().split())
    a=[0]*m
    b=[0]*m
    for i in range(m):
        ai,bi=map(int,input().split())
        a[i]=ai-1
        b[i]=bi-1

pair=[i for i in range(n)]

def root(x):
    if x==pair[x]:
        return x
    else:
        tmp=root(pair[x])
        pair[x]=tmp
        return tmp

def unite(x,y):
    x=root(x)
    y=root(y)
    if x==y:
        return
    elif x>y:
        pair[x]=y
    else:
        pair[y]=x

def q087():
    cc=[]
    c1=[1]*n
    c2=defaultdict(int)
    c2[1]=n
    c=n    
    for i in range(m-1):
        rta=root(a[m-i-1])
        rtb=root(b[m-i-1])
        if c1[rta]>=n or c1[rtb]>=n:
            cc.append(0)
            continue
        if rta<rtb:
            d2=c1[rta]
            d3=c1[rtb]
            c1[rta]+=c1[rtb]
            c1[rtb]=0
            d1=c1[rta]
#            pair[rtb]=rta
            unite(a[m-i-1],b[m-i-1])
        elif rta>rtb:
            d2=c1[rta]
            d3=c1[rtb]
            c1[rtb]+=c1[rta]
            c1[rta]=0
            d1=c1[rtb]
#            pair[rta]=rtb
            unite(a[m-i-1],b[m-i-1])
        else:
            cc.append(c)
            continue

        c2[d1]+=1    
        if c2[d2]>0:
            c2[d2]-=1
        if c2[d3]>0:
            c2[d3]-=1
        q=[]
        for c2k,c2v in c2.items():
            if c2v==0:
                q.append(c2k)
        while q:
            del c2[q.pop()]            
        c3=[]
        for c2k,c2v in c2.items():
            c3.append((c2k,c2k*c2v))

        c=0
        for i,c3i in enumerate(c3):
            c+=c3i[1]*(c3i[1]-c3i[0])//2
            for j,c3j in enumerate(c3[0:i]):
                c+=c3i[1]*c3j[1]
        cc.append(c)

    for i in range(m-2,-1,-1):
        print(cc[i])
    print(n*(n-1)//2)
#-------------------------------
q087()
#-------------------------------



Measured memory_bytes: 91012
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int sum,max,n;
  sum =0;
  max = 0;
  for(int i=0;i<N;i++){
    cin >> n;
    sum +=n;
    if(max<n){
      max = n;
    }
  }
  if(sum-max>max){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll k,t;cin>>k>>t;
    vector<ll> a(t);
    priority_queue<ll> que;
    rep(i,t){
        ll a;cin>>a;
        que.push(a);
    }
    ll tmp=0;//前日食ったものの種類の個数
    while(que.size()){
        ll a=que.top();que.pop();
        a--;
        if(tmp!=0)que.push(tmp);
        tmp=a;
    }
    cout<<tmp<<endl;
}

Measured memory_bytes: 256
#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)

N=gets.to_i

nodes=Array.new(N){Array.new}

(N-1).times do
  u,v,w=gets.split.map(&:to_i)
  nodes[u-1] << [v-1,w]
  nodes[v-1] << [u-1,w]
end

colors=Array.new(N)
colors[0]=0
stack=[[0,-1]] # index parent

while stack.size!=0
  nod,par=stack.pop
  nodes[nod].each do |c,w|
    next if par==c
    if w%2!=0
      colors[c]=1-colors[nod]
    else
      colors[c]=colors[nod]
    end
    stack << [c,nod]
  end
end
puts colors

Measured memory_bytes: 27516
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
ll a[200000];

bool solve(int m) {
    vector<P> v;
    for (int i = 1; i < n; i++) {
        if (a[i-1] < a[i]) continue;
        if (m == 1) return false;
        bool flag = false;
        for (int j = (int)v.size()-1; j >= 0; j--) {
            if (v[j].first > a[i]) {
                v.pop_back();
            } else if (v[j].first == a[i]) {
                v[j].second++;
                int pos = j;
                while (v[pos].second == m+1) {
                    if (v[pos].first == 1) return false;
                    if (pos == 0 || v[pos-1].first+1 != v[pos].first) {
                        int t = v[pos].first;
                        v.pop_back();
                        v.push_back(P(t-1, 2));
                        break;
                    } else {
                        v.pop_back();
                        pos--;
                        v[pos].second++;
                    }
                }
                flag = true;
                break;
            } else {
                v.push_back(P(a[i], 2));
                flag = true;
                break;
            }
        }
        if (!flag) v.push_back(P(a[i], 2));
    }
    return true;
}

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    int st = 0, en = n, mid;
    while (en-st > 1) {
        mid = (st + en) / 2;
        if (solve(mid)) en = mid;
        else st = mid;
    }
    cout << en << endl;
}



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

int main(void) {
    int H, W, N;
    cin >> H >> W >> N;

    int ans, div;
    div = max(H, W);
    ans = N / div;
    if(N%div!=0) ans++;

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int n,x,y,ans;

int gcd(int x,int y){
	if(x>y)swap(x,y);
	if(!x)return y;
	return gcd(y%x,x);
}

int main(){
	scanf("%d%d",&n,&x);
	scanf("%d",&y);ans=abs(y-x);
	for(int i=2;i<=n;++i)scanf("%d",&y),ans=gcd(ans,abs(y-x));
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
    int n;
    cin >> n;
    long long count = 0;
    for(int a = 1; a <= n-1; a++){
        count += (n-1)/ a;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3576
s = input()
k = int(input())

s_sorted = sorted(s)
array = set()

n = len(s)
for i in range(n):
  for j in range(n):
    if s_sorted[i] == s[j]:
      for l in range(k):
        if l+j >= n:
          break
        
        array.add(s[j:l+j+1])
      
  if len(array) >= k:
    break
    
array = sorted(array)
print(array[k-1])

Measured memory_bytes: 39920
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,max=0,min=10000000000;
	cin>>i;
	int a[i];
	for (int j=1;j<=i;j++)
	{
		cin>>a[j];
		if (a[j]>max)
		{
			max=a[j];
		}
		else
		{
			max=max;
		}
		if (a[j]<min)
		{
			min=a[j];
		}
	}
	i=max-min;
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
import itertools

n, m, R = map(int, input().split())
r = list(map(int, input().split()))

dis = [[float("inf") for i in range(n)] for j in range(n)]
for i in range(n):
    dis[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    dis[a-1][b-1] = c
    dis[b-1][a-1] = c

def warshall_floyd(dis):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j])
    return dis

data = warshall_floyd(dis)
ans = float("inf")
for i in itertools.permutations(r, R):
    num = 0
    for j in range(R - 1):
        num += data[i[j] - 1][i[j + 1] - 1]
    ans = min(ans, num)
print(ans)

Measured memory_bytes: 71644
A = list(map(int,input().split()))
n = int(input())
base = {}
for i in range(4):
    tmp = 2**(i)
    base.update({i:A[i]/tmp})
dict = sorted(base.items(), key=lambda x: x[1])
m = n*4
ans = 0
for x in dict:
    y = 2**(x[0])
    kosuu = m // y
    m -= y*kosuu
    ans += kosuu*A[x[0]]
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   long long int k,n,x,d1,d2;
   vector<long long int> v,v1,v2;
   priority_queue<long long int> pq;
   cin>>k>>n;
   for(int i=0;i<n;i++)
   {
      cin>>x;
      v.push_back(x);
   }
   for(long long int i=1;i<=n;i++)
   {
      d1=v[n-1]-v[i-1];
      d2=k-v[n-1]+v[i-1];
      if(i==1)
         v1.push_back(d1);
      else if(i==n)
         v1.push_back(d2);
      else
         v1.push_back(d1+d2);
      d1=v[i-1];
      if(i!=n)
      d2=k-v[i];
      else
      d2=0;
      v1.push_back(d1+d2);
   }
   sort(v1.begin(),v1.end());
   cout<<v1[0];
   return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    string s[H];
    for (int i = 0; i < H; i++)
    {
        cin >> s[i];
    }
    
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {

            if (s[i][j] == '#')
            {
                if ((j + 1 < W && s[i][j + 1] == '#')
                    || (j > 0 && s[i][j - 1] == '#')
                    || (i + 1 < H && s[i + 1][j] == '#')
                    || (i > 0 && s[i - 1][j] == '#'))
                {
                    continue;
                }
                cout << "No" << endl;
                return 0;
            }
        }
        
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  if((B-A)%2 == 1){
    cout << "Borys" << endl;
  }
  else{
    cout << "Alice" << endl;
  }
}

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


int main()
{
	long long n,k,a,b,arr[100006];
	cin>>n>>k;
	long long g = 0;
	long long m = -1;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		g = __gcd(g,arr[i]);
		m = max(m,arr[i]);
	}
	if(k>m || (k%g!=0)){
		cout<<"IMPOSSIBLE";
	}
	else
		cout<<"POSSIBLE";
	return 0;
}

Measured memory_bytes: 4288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;

//C
int main() {
	ll N;
	scanf("%lld", &N);

	ll result = INF;

	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ll move = (i - 1) + (N / i - 1);
			result = min(result, move);
		}
	}

	printf("%lld\n", result);
}


//B
/*
int main() {
	ll N;
	scanf("%lld", &N);

	bool result = false;

	for (ll i = 1; i <= 9; i++) {
		if (N % i == 0 && N / i <= 9) {
			result = true;
			break;
		}
	}

	if (result == true) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}
*/

//A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	ll result = 0;

	if (A <= 9 && B <= 9) {
		result = A * B;
	}
	else {
		result = -1;
	}

	printf("%lld\n", result);
}
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int n,a[2<<18],B[1<<18],s,c,m,A,i,j,L;main(){for(cin>>n;cin>>a[A++];);for(;i<29;s|=c<<i++){m=1<<i+1;for(c=j=0;j<n;j++)B[j]=a[j+n]%m;sort(B,B+n);for(j=0;j<n;c^=(a[j++]&m/2?n-L:L)&1)A=a[j]%(m/2),L=lower_bound(B,B+n,m-A)-lower_bound(B,B+n,m/2-A);}cout<<s;}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll x;
/******* define variable end *******/
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
int solve() {
	cin >> x;
	ll k = 0;
	ll count = 0;
	while(true){
		count++;
		k += x;
		if(k % 360 == 0){
			break;
		}
	}
	cout << count << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3572
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [a,b]=nrin(2)
  out(b>=a?a:a-1)
}
main();

Measured memory_bytes: 7372
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h> 
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INF 1e18L+5
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef vector<int> vi;
typedef pair<int,int>ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<long long > vl;
template<typename T>
void show(vector<T> v){
    bool ok=true;
for(auto it:v){

    
   cout<<it<<" ";
    //cout<<it;
}
cout<<"\n";
}
const int N=101;
int A[N],B[N];
 int main() { ios_base::sync_with_stdio(false); cin.tie(0);
 int a,b,n;cin>>n;ll compt=0;
 for(int c=1;c<n;++c){
     int cal=n-c;
    // compt+=3;
    //cout<<(sqrt(cal)+1)<<"\n";
     for(int i=1;i*i<=cal;i++){
         
         if(cal%i==0){
             int a=i,b=cal/i;
             //cout<<a<<" "<<b<<" "<<" "<<c<<"\n";
             if(a==b)compt++;
             else compt+=2;
             //compt+=(i==(cal/i))?3:2;
         }
     }
 }
 cout<<compt;
 
return 0;
}

Measured memory_bytes: 3632
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	ll K;
	cin>>K;
	vll v(100010);
	rep(i,n){
		int a,b;
		cin>>a>>b;
		v[a] += b;
	}
	rep(i,100010){
		K -= v[i];
		if(K<=0){
			cout<<i<<endl;
			return;
		}
	}
}


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

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int N,M;
  cin>>N>>M;
  vector<int>K(N);
  int a=0;
  int likedata[N][30]={};
  for(int i=0;i<=N-1;i++){
  
    cin>>K[i];
    for(int k=0;k<=K[i]-1;k++){
    
      cin>>a;
      likedata[i][a-1]=1;
    }
  }
  int ans=0;
  bool flag=0;
  for(int i=0;i<=29;i++){
  
    flag=0;
    for(int k=0;k<=N-1;k++){
    
      if(likedata[k][i]==0){
        flag=1;
        break;
      }
    }
    if(flag==0)ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 3580
def main():
    x, k, d = map(int, input().split())
    x = abs(x)
    count = x // d
    if count > k:
        ans = x - (k*d)
    else:
        # if k % 2 == count % 2:
        if (k - count) % 2 == 0:
            ans = x - (count*d)
        else:
            ans = x - (count+1) * d
    print(abs(ans))
    
if __name__ == '__main__':
    main()



Measured memory_bytes: 9112
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int h, w;
    cin >> h >> w;
    vector<string> M(h);
    for (int i = 0; i < h; ++i) {
        cin >> M[i];
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (M[i][j] == '.') {
                int cnt = 0;
                for (int a = -1; a < 2; ++a) {
                    for (int b = -1; b < 2; ++b) {
                        int x = i + a, y = j + b;
                        if (x >= 0 && x < h && y >= 0 && y < w && !(x == i && y == j)) {
                            if (M[x][y] == '#') {
                                ++cnt;
                            }
                        }
                    }
                }
                M[i][j] = (char)('0' + cnt);
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        cout << M[i] << '\n';
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int w, h, x, y, r;
  fscanf(stdin, "%d %d %d %d %d", &w, &h, &x, &y, &r);

  int left = x - r, right = x + r;
  int top = y + r, bottom = y - r;
  if (0 <= left && right <= w && 0 <= bottom && top <= h) {
    fprintf(stdout, "Yes");
  }
  else {
    fprintf(stdout, "No");
  }
  fprintf(stdout, "\n");
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n),a(n);
  REP(i,n) cin >> t[i] >> a[i];

  ll T = 1, A = 1;
  REP(i,n) {
    ll div = max((T+t[i]-1)/t[i], (A+a[i]-1)/a[i]);
    T = t[i]*div; A = a[i]*div;
  }
  cout << T + A << endl;
}

Measured memory_bytes: 256
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
void fx(vector<int> &a,int n, int m){

}

// -----------------------------------------------------------------------


// -----------------------------------------------------------------------



void q1(){
	int a,b;
	cin>>a>>b;
	if(a==1 || b==1){
		if(a==1 && b==1)
		cout<<"Draw";
		else if(a==1)
		cout<<"Alice";
		else
		cout<<"Bob";
	}
	else if(a==b)
	cout<<"Draw";
	else if(a>b)
	cout<<"Alice";
	else
	cout<<"Bob";
	
}
// -----------------------------------------------------------------------


void q2(){
	int n,m;
	cin>>n>>m;
	bool fg=false;
	int arr[n][n],brr[m][m];
	for(int i=0;i<n;++i){
		string s;
		cin>>s;
		for(int j=0;j<n;++j)
		if(s[j]=='.')
		arr[i][j]=0;
		else
		arr[i][j]=1;
	}
	for(int i=0;i<m;++i){
		string s;
		cin>>s;
		for(int j=0;j<m;++j)
		if(s[j]=='.')
		brr[i][j]=0;
		else
		brr[i][j]=1;
	}
	for(int i=0;i<=n-m;++i){
		for(int j=0;j<=n-m;++j){
			bool tp=true;
			for(int ii=0;ii<m;++ii)
			for(int jj=0;jj<m;++jj)
			if(arr[i+ii][j+jj]!=brr[ii][jj])
			tp=false;
			fg|=tp;
		}
	}
	if(fg)
	cout<<"Yes";
	else
	cout<<"No";
	return ;
}

// -----------------------------------------------------------------------

void q3(){
	
}


// -----------------------------------------------------------------------

void q4(){
	
}

// -----------------------------------------------------------------------


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q2();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        for(int i=1;;i++){
                int x;
                scanf("%d",&x);
                if(x){
                        printf("Case %d: %d\n",i,x);
                }else{
                        break;
                }
        }
        return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int,int> mii;
typedef unordered_map<int,int> umii;
typedef queue<int> qi;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	//int q; cin >> q;
	//while (q--) {
		
	//}
	ll a, b; cin >> a >> b;
	if (b >= a) cout << "unsafe\n";
	else cout << "safe\n";
	
	return 0;
}


Measured memory_bytes: 3652
n = int(input())
p = [0 for i in range(n)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            N = x**2+y**2+z**2+x*y+y*z+z*x-1
            if N < n:
                p[N] += 1
for i in range(n):
    print(p[i])

Measured memory_bytes: 69444
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=200010;
char S[maxn],T[maxn];
int N,M,pos[26],nxt[maxn][26];
int main(){
	//freopen("in","r",stdin);
	scanf("%s",S+1);
	scanf("%s",T+1);
	N=strlen(S+1);
	M=strlen(T+1);
	for(int i=N;i>=1;i--){
		pos[S[i]-'a']=i;
		for(int j=0;j<26;j++)
			nxt[i][j]=pos[j];
	}
	int now=1,ans=0;
	for(int i=1;i<=M;i++){
		if(nxt[now][T[i]-'a']){
			now=nxt[now][T[i]-'a']+1;
			if(now==N+1)
				ans++,now=1;
		}
		else{
			if(now==1)
				return printf("-1\n"),0;
			now=1,ans++,i--;
		}
	}
	cout<<1LL*ans*N+now-1<<endl;
	return 0;
}



Measured memory_bytes: 12672
n,t = map(int,input().split())

ct = []
for i in range(n):
    a = [int(j) for j in input().split()]
    if a[1]<=t:
        ct.append(a)
    
ct.sort()
if len(ct) > 0:
    print(ct[0][0])
else:
    print("TLE")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 700;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o') ans += 100;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next(); //例：Main
    String array[] = new String[str.length()];
    String before = str.substring(0, 1);
    String here = "";
    boolean isGood = true;
    for (int i = 1; i < array.length; i++) {
      here = str.substring(i, i + 1);
      if(here.equals(before)){
        isGood = false;
        break;
      }
      before = str.substring(i, i + 1);
    }
    if(isGood){
      System.out.println("Good");   
    }else{
      System.out.println("Bad");   
    }
  }
}


Measured memory_bytes: 23892
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main()
{
  int n;
  int s[1000];
  
  while ( cin >> n && n != 0 )
    {
      double a = 0, m = 0;
      
      for ( int i = 0; i < n; i++ )
        {
          cin >> s[i];
          m += s[i];
        }
      
      m /= n;

      for ( int i = 0; i < n; i++ )
        {
          a += (s[i] - m) * (s[i] - m);
        }
      
      cout << fixed << setprecision(6) << sqrt( a / n ) << endl;
    }
    
  return 0;
}

Measured memory_bytes: 1236