akhauriyash/Code-Regression huggingface dataset:
s = input()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])

if A + B + C + D == 7:
    print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
    exit()
if A - B + C + D == 7:
    print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
    exit()
if A + B - C + D == 7:
    print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
    exit()
if A - B - C + D == 7:
    print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
    exit()
if A + B + C - D == 7:
    print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
    exit()
if A - B + C - D == 7:
    print(str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
    exit()
if A + B - C - D == 7:
    print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
    exit()
if A - B - C - D == 7:
    print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
    exit()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;
int n, k, a[26]; string S;
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> S; a[S[0] - 'A']++;
	}
	sort(a, a + 26, greater<int>()); int cnt = 0;
	while (true) {
		bool OK = true;
		for (int i = 0; i < k; i++) {
			a[i]--; if (a[i] < 0)OK = false;
		}
		if (OK == false)break;
		cnt++;
		sort(a, a + 26, greater<int>());
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#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 = 2e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, c[maxn], par[maxn], sz[maxn];
ll x, y, w[maxn], fact[maxn], invFact[maxn];
map<int, int> colorCount[maxn];
vector<pair<ll, int> > colors[maxn];
set<pair<ll, int> > picker;

ll powmod(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	ll tmp = powmod(a, b / 2);
	tmp = tmp * tmp % mod;
	if (b & 1) {
		tmp = tmp * a % mod;
	}
	return tmp;
}

int find(int u) {
	return (par[u] == u ? u : par[u] = find(par[u]));
}

void merge(int u, int v) {
	u = find(u);
	v = find(v);
	if (u == v) {
		return;
	}
	if (colorCount[u].size() < colorCount[v].size()) {
		swap(u, v);
	}
	for (pair<int, int> i : colorCount[v]) {
		colorCount[u][i.ff] += i.ss;
	}
	sz[u] += sz[v];
	par[v] = u;
}

void handle(int a, int b) {
	if (a == b) {
		return;
	}

	if (c[a] == c[b]) {
		if (w[a] + w[b] <= x) {
			merge(a, b);
		}
	}
	else {
		if (w[a] + w[b] <= y) {
			merge(a, b);
		}
	}
}

void handleAll(int x) {
	for (int i = 0; i < n; i++) {
		handle(x, i);
	}
}

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

	for (int i = 0; i < maxn; i++) {
		par[i] = i;
		sz[i] = 1;
		fact[i] = (i ? fact[i - 1] * i % mod : 1);
		invFact[i] = powmod(fact[i], mod - 2);
	}

	cin >> n >> x >> y;
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> w[i];
		colors[c[i]].pb(mp(w[i], i));
		colorCount[i][c[i]] = 1;
	}

	for (int i = 0; i < maxn; i++) {
		sort(all(colors[i]));

		if (!colors[i].empty()) {
			picker.insert(colors[i][0]);
			for (int j = 1; j < colors[i].size(); j++) {
				handle(colors[i][0].ss, colors[i][j].ss);
			}
		}
	}

	if (picker.size() > 1) {
		auto it = picker.begin();
		handleAll(it->ss);
		it++;
		handleAll(it->ss);
	}

	ll ans = 1;
	for (int i = 0; i < n; i++) {
		if (par[i] == i) {
			ans = ans * fact[sz[i]] % mod;
			for (pair<int, int> extra : colorCount[i]) {
				ans = ans * invFact[extra.ss] % mod;
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 54592
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int a, b, x;
	cin >> x >> a >> b;
	string s;
	if (b <= a) s = "delicious";
	else if ((x + a) < b) s = "dangerous";
	else if (a < b && b <= a + x)s = "safe";
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef pair<int,int> P;
const int INF = 1e9;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char> > grid(H,vector<char>(W));
    vector<vector<int> > dist(H,vector<int>(W,INF));
    queue<P> que;
    rep(i,H){
        rep(j,W){
            cin >> grid[i][j];
            if(grid[i][j] == '#'){
            que.push(make_pair(i,j));
            dist[i][j] = 0;
            }
        }
    }
    int res = 0;
    while(!que.empty()){
        P p = que.front();
        que.pop();
        res = dist[p.first][p.second];
        rep(i,4){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(nx < 0 || ny < 0 || nx >= W || ny >= H)continue;
            if(dist[ny][nx] != INF || grid[ny][nx] != '.')continue;
            que.push(make_pair(ny,nx));
            dist[ny][nx] = dist[p.first][p.second]+1;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    ll sa = 0, sb = 0, cnt = 0;
    rep(i, 0, n) {
        if (a[i] < b[i]) cnt += (b[i] - a[i] + 1) / 2;
        sa += a[i];
        sb += b[i];
    }
    if (sb - sa >= cnt) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int H,W;
	cin>>H>>W;
	vector<string> vec(H);
	for(int i=0; i<H; i++){
		cin>>vec.at(i);
	}
	
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if((vec.at(i)).at(j)=='#'){
				cout<<'#';
			}
			else{
				int A=0; //以降上から時計回り
				if(i>0&&(vec.at(i-1)).at(j)=='#'){
					A++;
				}
				
				if(i>0&&(j<W-1)&&(vec.at(i-1)).at(j+1)=='#'){
					A++;
				}
				
				if(j<W-1&&(vec.at(i)).at(j+1)=='#'){
					A++;
				}
				
				if(j<W-1&&(i<H-1)&&(vec.at(i+1)).at(j+1)=='#'){
					A++;
				}
				
				if(i<H-1&&(vec.at(i+1)).at(j)=='#'){
					A++;
				}
				
				if(i<H-1&&(j>0)&&(vec.at(i+1)).at(j-1)=='#'){
					A++;
				}
				
				if(j>0&&(vec.at(i)).at(j-1)=='#'){
					A++;
				}
				
				if(j>0&&(i>0)&&(vec.at(i-1)).at(j-1)=='#'){
					A++;
				}
				
				cout<<A;
				
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

dst = list()
for i in range(n):
    dst.append(int(0))
src = 0
for i in range(n):
    src += a1[i]
    dst[i] = src
    for j in range(i,n):
        dst[i] += a2[j]
dst.append(src)
print(max(dst))


Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
int n, k, a;
long long e, x, b, i, c[200001];
int main() {
	scanf("%d%d", &n, &k);
	for (i = 1; i <= n; i++) {
		scanf("%d", &a);
		b = (a + b - 1) % k;
		c[i] = b * (k + n) + i;
	}
	std::sort(c, c + n + 1);
	for (i = 1; i <= n; i++) {
		while (c[i] - c[x] >= k)x++;
		e += i - x;
	}
	printf("%lld\n", e);
}

Measured memory_bytes: 1664
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>

#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------


int main(void)
{
	int a, b;

	cin >> a >> b;

	for (int i = 0; i <= 1500; i++)
	{
		if (floor(i * 0.08) == a && floor(i * 0.10) == b)
		{
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;
}

Measured memory_bytes: 256
Dice = Struct.new(:top, :south, :east, :west, :north, :bottom) do
  def self.init(labels)
    labels = labels.dup.freeze
    raise ArgumentError, "length of labels should be 6" unless labels.count == 6

    new(*labels)
  end

  def rotate(direction)
    case direction
    when ?N then rotate_northward
    when ?S then rotate_southward
    when ?E then rotate_eastward
    when ?W then rotate_westward
    when ?R then rotate_right
    when ?L then rotate_left
    else raise ArgumentError, "direction should be N, S, E, W, L or R, but #{direction} was given."
    end
  end

  def labels
    [top, south, east, west, north, bottom]
  end

  def rotate_westward
    a,b,c,d,e,f = labels
    self.class.init([c,b,f,a,e,d])
  end

  def rotate_eastward
    c,b,f,a,e,d = labels
    self.class.init([a,b,c,d,e,f])
  end

  def rotate_southward
    a,b,c,d,e,f = labels
    self.class.init([e,a,c,d,f,b])
  end

  def rotate_northward
    e,a,c,d,f,b = labels
    self.class.init([a,b,c,d,e,f])
  end

  def rotate_left
    a,b,c,d,e,f = labels
    self.class.init([a,d,b,e,c,f])
  end

  def rotate_right
    a,d,b,e,c,f = labels
    self.class.init([a,b,c,d,e,f])
  end

  def [](index)
    raise ArgumentError, "index should be in 1 to 6" unless (1..6).include?(index)

    labels[index-1]
  end

  def all_state
    ('WNWNWN'.chars.flat_map{|c|[c,*[?R]*4]}).reduce([self]){|dices, inst|
      dices + [dices[-1].rotate(inst)]
    }
  end
end

labels = gets.split.map(&:to_i)
dice = Dice.init(labels)
gets.to_i.times{
  top, south = gets.split.map(&:to_i)
  p dice.all_state.find{|d|
    d.top == top && d.south == south
  }.east
}


Measured memory_bytes: 9068
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [a[i]-b[i] for i in range(n)]
c.sort()
chsum = 0
ans = 0
if sum(c)<0:
  print(-1)
  exit()
for i in range(n):
  if c[i] < 0:
    chsum -= c[i]
    c[i] = 0
    ans += 1
for i in range(n-1,-1,-1):
  if chsum > 0:
    chsum -= c[i]
    c[i] -= (min(chsum,c[i]))
    ans += 1
print(ans)
    

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

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

    int n,m;
    cin >> n >> m;

    vector<pair<int,int>> v;
    vector<int> broken;

    rep(i,m) {
        int a,b;
        cin >> a >> b;

        v.push_back(make_pair(b,a));
    }
    sort(v.begin(),v.end());

    int cnt = 1;
    broken.push_back(v[0].first - 1);
    for(int i = 1; i < v.size(); i++){
        if(broken.back() < v[i].first && broken.back() >= v[i].second);
        else {
            broken.push_back(v[i].first - 1);
            cnt++;
        }
    }
    cout << cnt << endl; 
}

Measured memory_bytes: 1400
//
// Created by わたなべかずき on 2019/09/21.
//

#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    REP(i, 1, H+1){
        REP(j, 1, W+1){
            if(i <= B && j <= A) {
                cout << 1;
            } else if (i > B && j > A) {
                cout << 1;
            } else {
                cout << 0;
            }
        }
        cout << endl;

    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int debu(string a)
{
	cout<<a<<endl;
}
int debu()
{
	cout<<"ok"<<endl;
}
int debu(int a)
{
	cout<<a<<endl;
}




int main()
{
	int n;
	cin>>n;
	rep(i,n)
	{
		int k,p;
		cin>>k>>p;
		if(k%p==0)
		{
			cout<<p<<endl;
		}
		else
		{
			cout<<k%p<<endl;
		}
	}
}

Measured memory_bytes: 1160
import numpy as np

S = input()
mod = int(10**9 + 7)
dp = np.zeros(13, dtype=int)
dp[0] = 1

M = np.zeros((13, 13), dtype=int)
for i in range(13):
    for d in range(10):
        M[i][(i * 10 + d) % 13] += 1

for s in S:
    ndp = np.zeros(13, dtype=int)
    if s == '?':
        ndp = np.dot(dp, M)
    else:
        d = int(s)
        for j in range(13):
            ndp[(j * 10 + d) % 13] += dp[j]
    dp = ndp % mod

print(dp[5])

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int a,b,c,d;

int main(){
	cin.sync_with_stdio(false);
  cin>>a>>b>>c>>d;
  cout<<max(0,min(b,d)-max(a,c))<<endl;
	return 0;
}


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

int main()
{
	int b,c,sum=0;
    string a;
    for(int i=0;i<3;i++)
        cin>>a[i];
    
    for(int i=0;i<3;i++)
    {
        if(a[i]=='1')
            a[i]='9';
        else
            a[i]='1';
    }
    for(int i=0;i<3;i++)
        cout<<a[i];
	
	
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin >> N;
  long long m = N * 2;
  for (long long i = 1; i * i <= N; i++){
    if (N % i == 0){
      m = min(m, (long long) max(to_string(i).size(), to_string(N / i).size()));
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define vll vector<long long> 
#define pll pair<ll,ll>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define F first
#define S second
#define pb(i) push_back(i)
#define mp(x,y) make_pair(x,y)
#define all(v)  (v).begin(),(v).end()
#define sz 1001
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
 
int main(){
	FIO;ll n,m,mod = 1e9+7;cin>>n>>m;
	ll dp[n][m];
	char ch[n][m];
	f(i,0,n) cin>>ch[i];
	if(ch[0][0] == '.') dp[0][0]=1;
	f(i,1,n){
		if(ch[i][0]=='.') dp[i][0] = dp[i-1][0];
		else dp[i][0] = 0;
	}
	f(j,1,m){
		if(ch[0][j]=='.') dp[0][j] = dp[0][j-1];
		else dp[0][j] = 0;
	}
	f(i,1,n){
		f(j,1,m){
			if(ch[i][j]=='.'){
				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
			}
			else dp[i][j] = 0;
		}
	}
	cout<<dp[n-1][m-1]<<"\n";
}

Measured memory_bytes: 12300
#include <bits/stdc++.h>
using namespace std;
int dp[100100];
int ds(int n) {
	if(n < 6) {return n;}
	if(dp[n] != -1) return dp[n];
	int ma = ds(n-1)+1;
	for(int k=6;k<=n;k*=6) {
		ma = min(ma,ds(n-k)+1);
	}
	for(int k=9;k<=n;k*=9) {
		ma = min(ma,ds(n-k)+1);
	}
	return dp[n] = ma;
}
int main() {
	memset(dp,-1,sizeof(dp));
	int n;
	scanf("%d ",&n);
	printf("%d\n",ds(n));
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MM 1000000007
using namespace std;

int main()
{
	int n;
	cin>>n;
	int arr[n],fake[n];
	fake[n-1]=0;
	for (int i=0;i<n;i++)cin>>arr[i];
	
	int ans=0;
	for (int i=n-2;i>=0;i--)
	{
		if (arr[i]>=arr[i+1])
			fake[i]=fake[i+1]+1;
		else
			fake[i]=0;
		
		ans=max(ans,fake[i]);
	}
	
	cout<<ans;
	
	
}


Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <map>

using namespace std;
std::vector<long long> replacing(int n, int a[], int q, int b[], int c[]) {
  map<int, long long>  counter;
  long long sum = 0;
  for(int i=0;i<n;i++) {
    sum += a[i];
    counter[a[i]] += 1;
  }
  vector<long long> ans;
  for(int i=0; i<q; i++) {
    if(counter.find(b[i]) == counter.end()) {
      ans.push_back(sum);
      continue;
    }
    auto b_num = counter[b[i]];
    sum -= b_num * b[i];
    sum += b_num * c[i];
    ans.push_back(sum);
    counter[c[i]] += b_num;
    counter[b[i]] = 0;
  }

  return ans;
}

int main() {
  int n, q;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  cin >> q;
  int b[q];
  int c[q];
  for(int i=0;i<q;i++) {
    cin >> b[i];
    cin >> c[i];
  }
  vector<long long> v = replacing(n, a, q, b, c);
  for(long long i=0;i<q;i++) {
    cout << v[i] << endl;
  }

}

Measured memory_bytes: 10348
#include <stdio.h>

int gcd(int a, int b)
{
  int x, y;
  x = a;
  y = b;
  int tmp;
  if (x < y)
  {
    tmp = x;
    x = y;
    y = tmp;
  }
  
  int r;
  r = x % y;
  while (r != 0)
  {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

int main(void)
{
  int k;
  scanf("%d", &k);
  
  int sum = 0;
  int a = 1, b, c;
  while (a <= k)
  {
    b = 1;
    while (b <= k)
    {
      c = 1;
      while (c <= k)
      {
        sum += gcd(gcd(a, b), c);
        c++;
      }
      b++;
    }
    a++;
  }
  printf("%d", sum);
  return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
int n,q,S[10000+10]={},T,ans=0;
signed main(){
  cin >> n;
  rep(i,n) cin >> S[i];
  cin >> q;
  rep(i,q){
    cin >> T;
    S[n]=T;//番兵
    int j=0;
    while(S[j]!=T) j++;
    if(j==n);
    else ans++;
  }
  cout << ans << endl;

  return 0;
}



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

using namespace std;

#define ff first
#define ss second
#define pb push_back

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

const int oo = 1e9;
const int N = 1e6 + 5;

vector<ll> ja;
vector<ll> di;

int main(){
	ll a, b;
	scanf("%lld %lld", &a, &b);
	ll g = __gcd(a, b);
	int ans = 0;
	for(ll i = 1; i * i <= g; i++){
		if(g % i == 0){
			di.pb(i);
			if(g/i != i){
				di.pb(g/i);
			}
		}
	}
	sort(di.begin(), di.end());
	for(ll i : di){
		bool ok = true;
		for(ll j : ja){
			if(j != 1 && i % j == 0){
				ok = false;
				break;
			}
		}
		if(ok){
			ja.pb(i);
		}
	}
	printf("%d\n", ja.size());
	return 0;
}


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

int main() {
	ll n;
	cin>>n;
	
	ll ans=10101010101010;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			ans=min(ans,i+n/i-2);
		}
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

y(len(set(list(input())))==2)


Measured memory_bytes: 5332
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int n,i,cnt=0,ans=0;
    cin>>n;
    for(i=2;i<sqrt(n);i++) {
        if((n%i)==0) {
            cnt=0;
            while(((n%i)==0)) {
                cnt++;
                n=n/i;
            }
            int j=0;
            while((j*(j+1))/2 <= cnt)
            {
                j++;
            }
            ans+=(j-1);
        }
    }
    if(n>1)
        ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3696
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int f(int x){
    if(x<10)return x;
    return f(x/10)+x%10;
}
int main(){
    int N;
    R(N);
    puts(N%f(N)?"No":"Yes");
    return 0;
}


Measured memory_bytes: 256
#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() {
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	vector<int> B(N);
	rep(i,N) B[i] = 0;
	ll ans = 1;
	rep(i,N) {
		if(N % 2 == 0 && A[i] % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
		else if (N % 2 == 1 && A[i] % 2 == 1) {
			cout << 0 << endl;
			return 0;
		}
		B[A[i]]++;
	}
	int b = N % 2 ? 2 : 1;
	for(int i=b; i<N; i+=2) {
		if(B[i] > 2 || B[i] == 1) {
			cout << 0 << endl;
			return 0;
		}
		if(B[i] == 2) {
			ans = (ans * 2) % MOD;
		}
	}
	
	cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
bool path[105][105];

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

    ll sum;
    if(n % 2 == 0){
        sum = n + 1;
    }else{
        sum = n;
    }

    rep(i, 1, n + 1){
        rep(j, 1, n + 1){
            if(i == j) continue;
            if(i + j == sum) continue;
            path[i][j] = true;
            path[j][i] = true;
        }
    }

    ll count = 0;
    rep(i, 1, n + 1){
        rep(j, 1, n + 1){
            if(path[i][j]){
                count++;
                path[j][i] = false;
            }
        }
    }

    cout << count << endl;
    rep(i, 1, n + 1){
        rep(j, 1, n + 1){
            if(path[i][j]){
                cout << i << " " << j << endl;
            }
        }
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int a, b;
  cin >> a >> b;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
S = list(input())
N = len(S) + 1
l = [0 for i in range(N)]
r = [0 for i in range(N)]
for i in range(N-1):
  if S[i] == '<':
    l[i+1] = l[i] + 1
  if S[N-i-2] == '>':
    r[N-i-2] = r[N-i-1] + 1
print(sum([max(l[i], r[i]) for i in range(N)]))


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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef set<int> si;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a);
#define nl '\n'
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) (sizeof(a) / sizeof(a[0]))
#define INF 1000000007
#define mp(a, b) make_pair(a, b)
#define FILL(a, v, b) memset(a,v,(b) * sizeof(a[0]))

template<typename T>
void print_array(T* arr, int num) {
	FOR(i, 0, num) cout << arr[i] << ' ';
	cout << nl;
}

template<typename T> 
void print_vector(vector<T> vec) {
	FOR(i,0,vec.size()) cout << vec[i] << ' ';
	cout << nl;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("test.txt", "r", stdin);
	string s;
	getline(cin,s);
	s[5] = ' ';
	s[13] = ' ';
	cout << s;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <set>

using namespace std;

int main(){

  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
  }

  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  set<pair<int, long long>> s;
  s.insert(make_pair(0, 0));
  for(int i = 0; i < N; i++){
    pair<int, long long> tempP = make_pair(h[i], a[i]);
    
    auto itr = s.lower_bound(tempP);
    itr--;

    tempP.second += itr->second;
    itr++;
    while(itr != s.end()){
      if(itr->second <= tempP.second){
	itr = s.erase(itr);
      }
      else{
	break;
      }
    }

    s.insert(tempP);
  }

  auto itr = s.end();
  itr--;
  
  cout << itr->second << endl;
    
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> S(n,0);
    for( auto&& x: S){
        cin >> x;
    }

    int q;
    cin >> q;
    vector<int> T(q,0);
    for( auto&& x: T){
        cin >> x;
    }

    int C = 0;
    for(int i=0; i<q; ++i){
        for(int j=0; j<n; ++j){
            if(T[i] == S[j]){
                ++C;
                break;
            }
        }
    }

    cout << C << endl;

}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef OJ
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define sz(x) ((int)x.size())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const char en = '\n';
const int MOD = 0;
const int MAXN = 0;
const int INF = 1e9;

int solve() {
    int x; cin >> x;
    cout << ((x >= 30)  ? "Yes" : "No") << en;
    return 0;
} 

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int ntest = 1;
    //cin >> ntest;
    int t = 1;
    fori(test, ntest) {
        //cout << "Case #" << t << ": ";
        solve();
        t++;
    }

    return 0;
}


Measured memory_bytes: 3612
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
N = int(input())
e = []
for i in range(N):
    e.append(int(input()))

if A[0] in e and A[1] in e and A[2] in e or \
    B[0] in e and B[1] in e and B[2] in e or \
    C[0] in e and C[1] in e and C[2] in e or \
    A[0] in e and B[1] in e and C[2] in e or \
    C[0] in e and B[1] in e and A[2] in e or \
    A[0] in e and B[0] in e and C[0] in e or \
    A[1] in e and B[1] in e and C[1] in e or \
    A[2] in e and B[2] in e and C[2] in e:
    print("Yes")
else:
    print("No")

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

static class CodeJam
{
    class Card
    {
        public readonly int B;
        public readonly int C;
        public Card(int[] args)
        {
            B = args[0];
            C = args[1];
        }
    }
    
    static long Solve(int N, int M, int[] A, Card[] cards)
    {
        Array.Sort(A);
        Array.Sort(cards, (x, y) => y.C.CompareTo(x.C));
        long sum = 0;
        int i = 0;
        int j = 0;
        int k = 0;
        while (i < N)
        {
            if (j < M && cards[j].C > A[i])
            {
                sum += cards[j].C;
                if (++k == cards[j].B)
                {
                    ++j;
                    k = 0;
                }
            }
            else
            {
                sum += A[i];
            }
            ++i;
        }
        return sum;
    }

    static void Main(string[] args)
    {
        int[] V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = V1[0], M = V1[1];
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var cards = new Card[M];
        for (int i = 0; i < M; ++i)
        {
            cards[i] = new Card(Array.ConvertAll(Console.ReadLine().Split(), int.Parse));
        }
        Console.WriteLine(Solve(N, M, A, cards));
    }
}


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

int main() {
  int H,W;
  cin >> H >> W;
  string S[50];
  for(int i=0;i<H;i++){
    cin >> S[i]; 
  }
  
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  for(int i=0;i<H;i++){
    for(int k=0;k<W;k++){
      if(S[i][k]=='#') continue;
      
      int count = 0;
      for(int d = 0; d < 8; d++){
        const int ni = i + dy[d];
        const int nk = k + dx[d];
        
        if (ni < 0 or H <= ni) continue;
        if (nk < 0 or W <= nk) continue;
       	if(S[ni][nk]=='#') count++;
      }
      S[i][k] = (char)(count+'0');
    }
  }
  for(int i=0;i<H;i++){
    cout << S[i] << endl; 
  }
}

Measured memory_bytes: 256
s = input()
t = input()
n = len(s)
m = len(t)

ans = []
for i in range(n-m+1):
  cnt = 0
  for j in range(m):
    if s[i+j] != t[j]:
      cnt += 1
  ans.append(cnt)
  
print(min(ans))

Measured memory_bytes: 8980
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
  	std::vector<int> h;
    for (int i = 0; i < n; ++i) {
      int tmp;
      cin >> tmp;
      h.push_back(tmp);
    }
    std::sort(h.begin(), h.end());
    int min = h.at(n-1);
    for (int i = 0; i < n - (k - 1); ++i) {
      int tmp = h.at(i + k - 1) - h.at(i);
      if (min > tmp) min = tmp;
    }
    // 出力
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 892
import math

N = int(input())


def hoge(n):
    if n == 2:
        return True
    for x in range(2, int(math.sqrt(n) + 2)):
        if n % x == 0:
            return False
    return True


while True:
    if hoge(N):
        print(N)
        exit()
    N += 1


Measured memory_bytes: 2940
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
   ll a=0,b=0,c=0,d=0;
   cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes";
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
ll mpow(ll x, ll n){ //x^n(mod M) ????pow(x,n)?????????????mod??
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
int main (){
  ll i,x,f=0;
  cin>>x;
  ll a,b,ab,apb;
  for(a=1;f==0;a++){
    for(b=a-1;b>=1-a;b--){
      ab=a*b;
      apb = a+b;
      //cout<<a<<","<<b<<","<<apb*((apb*apb-2*ab)*(apb*apb-2*ab)-ab*(2*ab+apb*apb+3))<<endl;
      if(apb*((apb*apb-2*ab)*(apb*apb-2*ab)-ab*(apb*apb-ab))==x){
        f=1;
        break;
      }
    }
    if(f==1)
    break;
  }
  //a--;b++;
  cout<<a<<endl<<-1*b<<endl;
  
 
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

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


/* BIEN CUC BO BEGIN*/
	int a, b, c;
/* BIEN CUC BO END*/

void solve(){
	cin >> a;
	if (a == 1 || a == 2){
		cout << 4;
		return;
	}
	while (a != 4){
		++b;
		if (a%2) a = 3*a + 1;
		else a/=2;
	}
	cout << b + 4;
}	

int main(){ FIO;
	solve();
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

int main () {
  int n, k;
  cin >> n >> k;
  ll num[n + 1];
  for (int i = 0; i <= n; i++) {
    num[i] = 0;  
  }
  pair<int, int> td[n];
  for (int i = 0; i < n; i++) {
    ll t, d;
    cin >> t >> d;
    td[i] = make_pair(d, t);
  }
  sort(td, td + n);
  priority_queue<pair<int, int> >  nokori;
  priority_queue<pair<int, int>, vector<pair<int, int> > , greater<pair<int, int> > > ans;
  ll kind = 0;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    int j = n - 1 - i;
    if (ans.size() == k) {
      break;  
    }
    if (num[td[j].second] == 0) {
      ans.push(
        make_pair(td[j].first, td[j].second)
      );  
      num[td[j].second]++;
      kind++;
      sum += td[j].first;
    }    
    else {
      nokori.push(
        make_pair(td[j].first, td[j].second)
      );  
    }
  }
  while (ans.size() < k) {
    ans.push(nokori.top());
    sum += nokori.top().first;
    num[nokori.top().second]++;
    nokori.pop();
  }
  ll now = kind * kind + sum;
  while (!nokori.empty()) {
    ll t = nokori.top().second;
    ll d = nokori.top().first;
    ll nt = ans.top().second;
    ll nd = ans.top().first;
    if (nd > d) {
      break;  
    } 
    if (nd < d) {
      ll sub = (kind - 1) * (kind - 1) + sum + d - nd;
      if (sub > now) {
        now = sub;
        kind--;
        sum = sum + d - nd;
        ans.pop();
      }    
    }
    nokori.pop();
  }
  cout << now << endl;
}

Measured memory_bytes: 3316
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()

print(n * 800 - n // 15 * 200)


Measured memory_bytes: 2940
import java.util.*;
import java.math.BigInteger;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    while (true) {
      c -= b;
      if (c <= 0) {
        System.out.println("Yes");
        break;
      }
      a -= d;
      if (a <= 0) {
        System.out.println("No");
        break;
      }
    }
  }
}


Measured memory_bytes: 35336
import sys
import math
L,R = map(int, input().split())
#L,R = 2020,2040
#L,R = 4,5
#L,R = 2019,4037

ans = 2019
for i in range (L,R+1):
    for j in range (i+1, R+1):
        ans = min(ans, (i*j) % 2019)
        if ans == 0:
            print(0)
            sys.exit(0)
print(ans)

# l_mod = L % 2019
# l_div = L // 2019
# r_mod = R % 2019
# r_div = R // 2019

# if r_div - l_div >= 1:
#     ans = 0
# else:
#     if l_mod == 0:
#         ans = 0
#     else:
#         ans = (l_mod * (l_mod + 1)) % 2019
# print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
string int2string(int x){
        stringstream ss;
        ss << x;
        string tmp;
        ss >> tmp;
        return tmp;
    }
int string2int(string s){
    stringstream ss;
    ss << s;
    int x;
    ss >> x;
    return x;
}
long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long bigpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    ll r= a/gcd(a,b)*b;
    return r;
}
//***********************CODE*****************
void dfs(vector<vector<int> >&g,vector<vector<char> >&ans,int p,int i,vector<bool>&vis)
{
	ans[p][i]='Y';
	for(int j=0;j<g[i].size();j++)
	{
		if(!vis[g[i][j]])
		{
			vis[g[i][j]]=1;
			dfs(g,ans,p,g[i][j],vis);
			vis[g[i][j]]=0;
		}
	}
}
int main(){
    
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);

	int a,b,c;
	cin>>a>>b>>c;
	int k;
	cin>>k;
	while(b<=a)
	{
		if(k==0)break;
		b*=2;
		k--;
		
	}
	while(c<=b)
	{
		if(k==0)break;
		c*=2;
		k--;
	}
	if(c>b && b>a)cout<<"Yes";
	else cout<<"No";
    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 200000
#define mod1 1000000007
#define mod2 1000000009
#define mod3 998244353
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
void Google(ll tt){
    cout<<"Case #"<<tt<<": ";
}

int main()
{
    IO
	clock_t begin = clock();
    ll n,m;
    cin>>n>>m;
    ll dp[n+1][m+1];
    char ch[n+1][m+1];
    for(ll i=0;i<=n;i++)
    {
    	for(ll j=0;j<=m;j++)
    		dp[i][j] = 0;
    }
    for(ll i=1;i<=n;i++)
    {
    	for(ll j=1;j<=m;j++)
    	{
    		cin>>ch[i][j];
    	}
    }
    dp[1][1] = 1;
    for(ll i=1;i<=n;i++)
    {
    	for(ll j=1;j<=m;j++)
    	{
    		if(i==1 && j==1)
    			continue;
    		dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod1;
    		if(ch[i][j]=='#')
    			dp[i][j] = 0;
    	}
    }
    cout<<dp[n][m]<<endl;
    // cout<<double(clock() - begin)/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 12424
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;


int main(void) {

  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];

  vector<int> c(8,0);
  int cnt = 0;
  for(int i=0; i<n; i++){

    if( a[i] < 400 ) c[0]++;
    else if( a[i] < 800 ) c[1]++;
    else if( a[i] < 1200 ) c[2]++;
    else if( a[i] < 1600 ) c[3]++;
    else if( a[i] < 2000 ) c[4]++;
    else if( a[i] < 2400 ) c[5]++;
    else if( a[i] < 2800 ) c[6]++;
    else if( a[i] < 3200 ) c[7]++;
    else cnt++;

  }
  int ans = 0;
  for(int i=0; i<8; i++){
    if( c[i] != 0 ) ans++;
  }
  int mx = ans + cnt;
  int mn = ans;
  if( mn == 0 ) mn = 1;
  cout << mn << " " << mx << endl;

  return 0;
}


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


int main() {
	int H1, H2, M1, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	int ans = (H2 - H1) * 60 + M2 - M1 - K;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;

const int N = 1e6 + 5;

int nxt[N][26], cnt[N][26], cur = 0;

void insert (string s) {
  vector < int > c (26, 0);
  int idx = 0;
  for (auto i : s) c[i - 'a']++;
  for (int j = 0; j < 26; j++) cnt[idx][j] += (c[j] > 0);
  for (auto i : s) {
    c[i - 'a']--;
    if (!nxt[idx][i - 'a']) {
      nxt[idx][i - 'a'] = ++cur;
    }
    idx = nxt[idx][i - 'a'];
    for (int j = 0; j < 26; j++) cnt[idx][j] += (c[j] > 0);
  }
}

int solve (string s) {
  int n = s.length(), idx = 0;
  for (int i = 0; i < n - 1; i++) {
    idx = nxt[idx][s[i] - 'a'];
  }

  return cnt[idx][s[n - 1] - 'a'] - 1;
}

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

  int n;
  cin >> n;
  vector < string > s (n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    reverse (s[i].begin(), s[i].end());
    insert (s[i]);
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += solve (s[i]);
  }

  cout << ans << '\n';
}


Measured memory_bytes: 207436
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		while (n-- > 0) {
			System.out
					.println(scanner.nextLine().replace("Hoshino", "Hoshina"));
		}
	}
}

Measured memory_bytes: 17268
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct UnionFind{
  Int n;
  vector<Int> r,p;
  UnionFind(){}
  UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
  Int size(Int x){
    return r[find(x)];
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  UnionFind uf(n);
  for(Int i=0;i<m;i++){
    Int x,y,z;
    cin>>x>>y>>z;
    x--;y--;
    z%=2;
    
    uf.unite(x,y);
  }

  Int ans=0;
  for(Int i=0;i<n;i++)
    ans+=uf.find(i)==i;

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int H, W; cin >> H >> W;
  constexpr int INF = 1e9;
  vector<vector<int>> g(H * W, vector<int>(H * W, INF));
  rep(i, H * W) g[i][i] = 0;
  vector<string> G(H);
  rep(i, H) cin >> G[i];
  rep(i, H) rep(j, W) {
    if (i + 1 < H and G[i][j] == '.' and G[i + 1][j] == '.') {
      g[i * W + j][i * W + j + W] = 1;
      g[i * W + j + W][i * W + j] = 1;
    }
    if (j + 1 < W and G[i][j] == '.' and G[i][j + 1] == '.') {
      g[i * W + j][i * W + j + 1] = 1;
      g[i * W + j + 1][i * W + j] = 1;
    }
  }
  rep(k, H*W) rep(i, H*W) rep(j, H*W) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  int ans = 0;
  rep(i, H*W) rep(j, H*W) if (g[i][j] != INF) ans = max(ans, g[i][j]);
  cout << ans << endl;
}

Measured memory_bytes: 896
#23:50
n = int(input())
a = list(map(int,input().split()))
ans = 0
while True:
  now = 0
  cnt = [0 for _ in range(n)]
  for i in range(n):
    #(a[i] - (n-1) - 1) // n + 1
    tmp = a[i]//n
    cnt[i] += tmp
    now += tmp
    a[i] -= tmp * n
  for i in range(n):
    a[i] += now - cnt[i]
  ans += now
  if now == 0:
    print(ans)
    break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];

    vector<int> b(n + 1);
    rep(i, 0, n) b[a[i]] ++;

    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    

    int K = 0,i = 0;
    while(K != k + 1){
        if(b[i]) K++;
        if(!b[i]) break;
        i++;
    }
    if(b[k] == 0) cout << 0 << endl;
    // rep(i, 0, n) cout << b[i] << endl;
    // cout << i-1 << endl;
    // cout << b[i-1] << endl;
    else{
        int ans = 0;
        i --;
        while(b[i] != 0){
            ans += b[i];
            i++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1792