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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    vector<string> s(N);
    vector<ll> t(N);
    rep(i, N){
        cin >> s.at(i) >> t.at(i);
    }
    string X; cin >> X;
    ll ans = 0;
    rep2(i, find(s.begin(), s.end(), X) - s.begin() + 1, N){
        ans += t.at(i);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a + b + 1 >= c) cout << b + c << endl;
	else cout << b + a + b + 1 << endl;
}

Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int x, t;
  cin >> x >> t;
  cout << max(x-t, 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int keta(ll num)
{
    int ans = 0;
    while (num)
    {
        num /= 10;
        ans++;
    }
    return ans;
}
int main()
{
    ll n;
    cin >> n;
    ll ans = keta(n);
    ll cur;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i != 0)
            continue;
        ll j = n / i;
        cur = max(keta(i), keta(j));
        if (cur < ans)
        {
            ans = cur;
        }
    }
    cout << ans << endl;
    return 0;
}


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

ll n, x, m, ans, id[100100], sum[1001001];

ll f(ll n, ll x){
	ll re = 0;
	for(ll i=1;i<=n;i++){
		re += x;
		x = (x * x) % m;
	}
	return re;
}

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

	for(ll i=1;i<=n;i++){
		if(id[x]){
			ll left = n - i + 1;
			ll sz = i - id[x];

			ll s = 0;
			for(ll j=id[x];j<i;j++) s += sum[j];

			ans += (left / sz) * s;
			ans += f(left % sz, x);
			break;
		}

		ans += x;
		id[x] = i;
		sum[i] = x;
		x = x * x % m;
	}

	cout << ans;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define deb(a) cout<<#a<<" "<<a<<endl
#define WW 100000
#define INF 1000000000000000000 //1e18
#define EPS 0.000000001 //1e-9
//get<a>(t) gives ath element of tuple named t, numbering starts from 0
//max({_,......,_}) can give maximum of any number of elements. Similarly min also.
//don't forget to initialise freq arrays
//reverse(all(v)) would reverse a vector  
//pow(10.0, 2.0) can give exactly 100.0, slightly greater, or slightly less. 
//Therefore use(int)(pow(10.0,zz)+EPS)
int dp[3002][3002];
int32_t main()
{
    IOS;
    string s,t; cin>>s>>t;
    int n=s.length(),m=t.length();
    //string ans[2][m+1]={};
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                {dp[i][j]=dp[i-1][j-1]+1;/* ans[1][j]=ans[0][j-1]; ans[1][j]+=(s[i-1]);*/}
            else
             { 
                if(dp[i-1][j]>dp[i][j-1])
                dp[i][j]=dp[i-1][j]/*,ans[1][j]=ans[0][j]*/; else dp[i][j]=dp[i][j-1]/*,ans[1][j]=ans[1][j-1]*/;
             }
        }
        //for(int j=1;j<=m;j++)
          //  ans[0][j]=ans[1][j],ans[1][j]="";
    }
    int idx=dp[n][m];
    string ans="";
    int i=n,j=m;
    while(i>0 and j>0)
    {
        if(s[i-1]==t[j-1])
            ans.pb(s[i-1]),i--,j--;
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else j--;
    }
    reverse(all(ans));
    cout<<ans;
    return 0;
}

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

int main()
{
    long long N, M;
    cin >> N >> M;

    vector<long long> A(N + 1, -2e5);
    for (long long i = 1; i <= N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    vector<long long> sum(N + 1, 0);
    for (long long i = 1; i <= N; i++)
    {
        sum[i] = sum[i - 1] + A[i];
    }

    long long l = 0;
    long long r = 2e5 + 1;
    long long c;

    while (r - l > 1)
    {
        c = (l + r) / 2;
        long long count = 0;
        for (long long i = 1; i <= N; i++)
        {
            long long ll = 0;
            long long rr = N;
            long long cc;
            if (A[i] + A.back() < c)
            {
                continue;
            }
            while (rr - ll > 1)
            {
                cc = (ll + rr) / 2;
                if (A[i] + A[cc] >= c)
                {
                    rr = cc;
                }
                else
                {
                    ll = cc;
                }
            }
            count += N - rr + 1;
        }
        if (count >= M)
        {
            l = c;
        }
        else
        {
            r = c;
        }
    }
    long long ans = 0;
    long long count = 0;
    for (long long i = 1; i <= N; i++)
    {
        long long ll = 0;
        long long rr = N;
        long long cc;
        if (A[i] + A.back() < l)
        {
            continue;
        }
        while (rr - ll > 1)
        {
            cc = (ll + rr) / 2;
            if (A[i] + A[cc] >= l)
            {
                rr = cc;
            }
            else
            {
                ll = cc;
            }
        }
        count += (N - rr + 1);
        ans += (sum[N] - sum[rr - 1]) + (N - rr + 1) * A[i];
    }
    if (count > M)
    {
        ans -= (count - M) * l;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <map>
#include <string>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int

constexpr auto mod = 1000000007;
using namespace std;
int main() {

long long int h,w;
  cin>>h>>w;
 if(h!=1&&w!=1) {if((h*w)%2==0){
    cout<<h*w/2;
  }
  else{
    cout<<(h*w+1)/2;
  }
  }
  else{
    cout<<1;
  }
}

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

using namespace std;

int n, m;
vector<int> G[200005];
bool used[200005];
bool canArrive = false;

void DFS(int nod, int depth) {
    used[nod] = true;

    if (depth == 2) {
        if (nod == n) {
            canArrive = true;
        }

        return;
    }

    for (auto it = G[nod].begin(); it != G[nod].end(); ++it) {
        if (!used[*it]) {
            DFS(*it, depth + 1);
        }
    }
}

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

    cin >> n >> m;

    int a, b;
    for (int i = 1; i <= m; ++i) {
        cin >> a >> b;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    DFS(1, 0);

    cout << ((canArrive) ? "POSSIBLE" : "IMPOSSIBLE");

    return 0;
}


Measured memory_bytes: 12144
#include<stdio.h>

int main(void){
    
    int count = 0;
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    for(int i=a;i<=b;i++){
        if(c%i == 0)count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2100
import math

a, b, x = map(int, input().split(" "))

cap = a ** 2 * b

if x == cap / 2:
    s = 45
elif x < cap / 2:
    t = 2 * x / (a * b ** 2)
    s = 90 - math.degrees(math.atan(t))
else:
    q = cap - x
    t = 2 * q / (a ** 3)
    s = math.degrees(math.atan(t))
    
print(float(s))

Measured memory_bytes: 3064
import collections
from collections import Counter

n = int(input())
ls = [input() for i in range(n)]    
c = Counter(ls).most_common()

count = c[0][1]
ans = []

for i in range(len(c)):
    if c[i][1] == count:
        ans.append(c[i][0])
    else:
        break   
ans = sorted(ans)
for i in ans:
    print(i)

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

int main() {
  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;
  int64_t a_c = (A-1)/C, a_d = (A-1)/D;
  int64_t b_c = B/C, b_d = B/D;
  int64_t gcd, c = C, d = D;
  while (true) {
    if (d % c == 0) {
      gcd = c;
      break;
    }
    d %= c;
    swap(c, d);
  }
  int64_t lcm = C*D/gcd;
  int64_t a_cd = (A-1)/lcm, b_cd = B/lcm;
  cout  << (B-A+1) - (b_c-a_c) - (b_d-a_d) + (b_cd-a_cd) << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S = list(map(str, input().split()))

ans = 0
for i in range(3):
    for j in range(3):
        for k in range(3):
            if i==j or j==k or k==i: continue
            a=S[i]
            b=S[j]+S[k]
            ans=max(ans,int(a)+int(b))
print(ans)


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

int main(){
	int n, k, a, p;
	scanf("%d%d", &n, &k);
	int k2 = k;
	k--;
	for(int i=1;i<=n;i++){
		scanf("%d", &a);
	}
	int ans = 1e9;
	for(int i=1;i<=n-k2+1;i++){
		int l = i, r = i+k2-1;
		int le = i-1, ri = n-r;
		ans = min(ans, (le+k-1)/k + (ri+k-1)/k + 1);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    string s, t;
    cin >> s >> t;
    vector<vector<int> > vecs(26,vector<int>(0));

    for(int i=0; i<(int) s.size(); i++){
        vecs[s[i]-'a'].push_back(i);
    }

    long long ans=0;
    long long tmp=0;
    for(int i=0; i<(int) t.size(); i++){
        int x=t[i]-'a';
        auto it =lower_bound(vecs[x].begin(), vecs[x].end(), tmp);
        if(it==vecs[x].end()){
            ans++;
            it=lower_bound(vecs[x].begin(), vecs[x].end(), 0);
            if(it==vecs[x].end()){
                cout << -1 << endl;
                return 0;
            }
        }
        tmp=(*it)+1;
    }
    cout << ans*s.size()+tmp << endl;
}

Measured memory_bytes: 1216
import math
n, k = map(int, input().split())
P = list(map(int, input().split()))
 
maxsum = 0
maxindex = 0
p_sum = 0
for i in range(k):
    p_sum += P[i]
maxsum = p_sum
maxindex = 0
for i in range(1, n - k + 1):
    p_sum = p_sum - P[i - 1] + P[i + k - 1]
    if p_sum > maxsum:
        maxsum = p_sum
        maxindex = i
result = 0
for i in range(maxindex, maxindex + k):
    result += (1 + P[i]) * P[i] / 2 / P[i]
print(result)

Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
ll gcd(ll a, ll b) { return (b > 0) ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a*b/gcd(a, b); }

using ipair = pair<ll, ll>;

int main()
{
  ll N, K;
  vector<ipair> v;
  cin >> N >> K;
  if((N-1)*(N-2)/2 < K){
    cout << "-1" << "\n";
  }
  else{
    REP(i, 1, N) v.push_back({i, N});
    ll max = (N-1)*(N-2)/2-K;
    ll ci=1, cj=2;
    rep(i, max){
      v.push_back({ci, cj});
      ++cj;
      if(cj == N){
        ++ci;
        cj = ci + 1;
      }
    }
    cout << v.size() << "\n";
    for(auto a: v){
      cout << a.first << " " << a.second << "\n";
    }
  }
}


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

int main(){
  int i,j,count=0,ans=0;
  string a;
    cin >> a;
  if(stoi(a.substr(5,1)) < 1 && stoi(a.substr(6,1))<5 ){
    cout << "Heisei";
  }else{
    cout << "TBD";
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		len = new int[n];
		
		for(int i = 0; i < n; i++) {
			len[i] = sc.nextInt();
		}
		
		group = new int[n];
		
		System.out.println(solve(0));
	}
	static int n;
	static int a, b, c;
	static int len[];
	static int group[];

	static int solve(int depth) {
		if(depth == n) {
			int cost = 0;
			int array[] = new int[4];
			for(int i = 0; i < n; i++) {
//				System.out.print(group[i]+" ");
				if(group[i] != 0 && array[group[i]] != 0) {
					cost += 10;
				}
				
				array[group[i]] += len[i];
			}
//			System.out.println();
			if(array[1] == 0 || array[2] == 0 || array[3] == 0) {
				return Integer.MAX_VALUE;
			}
			
//			for(int i = 1; i <= 3; i++) {
//				System.out.print(array[i]+" ");
//			}
//			System.out.println();
			
			cost += Math.abs(a - array[1]);
			cost += Math.abs(b - array[2]);
			cost += Math.abs(c - array[3]);
//			System.out.println(cost);
			return cost;
		}
		
		int result = Integer.MAX_VALUE;
		for(int i = 0; i < 4; i++) {
			group[depth] = i;
			result = Math.min(result, solve(depth + 1));
		}
		
		return result;
	}
}


Measured memory_bytes: 30172
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
//#define INF 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
#define int long long
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef ll Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}
signed main(){
	ll N,M,s,t;
	cin>>N>>M>>s>>t;
	Graph Ge,Gs;
	for(int i=0;i<N;i++){
		Edges E;
		Ge.pb(E);
		Gs.pb(E);
	}
	for(int i=0;i<M;i++){
		ll u,v,a,b;
		cin>>u>>v>>a>>b;
		u--;
		v--;
		Ge[u].pb(Edge(u,v,a));
		Ge[v].pb(Edge(v,u,a));
		Gs[u].pb(Edge(u,v,b));
		Gs[v].pb(Edge(v,u,b));
	}
	vector<Weight> De,Ds;
	vector<int> Pe,Ps;
	shortestPath(Ge,s-1,De,Pe);
	shortestPath(Gs,t-1,Ds,Ps);
	vll ans;
	ll maxi=0;
	for(int i=N-1;i>=0;i--){
		maxi=max(1000000000000000LL-De[i]-Ds[i],maxi);
		ans.pb(maxi);
	}
	reverse(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 24740
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string Input;
            Input = Console.ReadLine();

            int K = int.Parse(Input.Split(' ')[0]);
            int X = int.Parse(Input.Split(' ')[1]);
            int sum = K * 500;

            if(X <= sum)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>

int main() {
  int x,x1,x2,x3;
  
  scanf("%d", &x);
  
  x1 = x / 500;
  x2 = x % 500;
  x3 = x2 / 5;
  
  printf("%d", x1*1000 + x3*5);
  
  return 0; 
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())

nums = []
for comb in product(['0', '7', '5', '3'], repeat=9):
    candidate = str(int(''.join(comb)))
    if all((x in candidate) for x in ['7', '5', '3']) \
       and '0' not in candidate:
        nums.append(int(candidate))
nums.sort()

ans = 0
for n in nums:
    if n <= N:
        ans += 1
    else:
        break
print(ans)


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

int main(){
	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
	int a,b;
	cin>>a>>b;
	int ans = -1 ;
	for(int i = 1 ; i < 10000 ; i++){
		if( ((i * 8/100) == a ) &&  ((i * 10/100) == b )){
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M, count = 0;
  cin >> N >> M;
  
  vector<int> H(N);
  vector<int> h(N);
  vector<int> A(M);
  vector<int> B(M);
  
  for(int i = 0; i < N; i++){
    cin >> H[i];
    h[i] = H[i];
  }
  for(int i = 0; i < M; i++){
    cin >> A[i] >> B[i];
  }
  
  for(int i = 0; i < M; i++){
    if(H[A[i]-1] < H[B[i]-1]){
      h[A[i]-1] = 0;
    }
    else if(H[B[i]-1] < H[A[i]-1]){
      h[B[i]-1] = 0;
    }
    else{
      h[A[i]-1] = 0;
      h[B[i]-1] = 0;
    }
  }
  
  for(int i = 0; i < N; i++){
    if(h[i] != 0) count++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 4808
#include<iostream>
#include <math.h>
using namespace std;

int main() {
    int n,a[100];
    int min = 1000000001, max = 0;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > max) { max = a[i]; }
        if (a[i] < min) { min = a[i]; }
    }
    cout << (max - min) << endl;
    

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7
plus = []
zero = []
minus = []
ans = 1

for k in range(N):
  if A[k] > 0:
    plus.append(A[k])
  elif A[k] < 0:
    minus.append(-1 * A[k])
  else:
    zero.append(A[k])
plus.sort(reverse = True)
minus.sort(reverse = True)
lp = len(plus)
lm = len(minus)
lz = len(zero)

if lz + K > N:
  print(0)
  exit()
elif lp == 0: 
  if K % 2 == 1:
    if lz > 0:
      print(0)
      exit()
    else:
      for k in range(K):
        ans = ans * (-1) * minus[- k - 1] % mod  
      print(ans)
      exit()
  else:
    for k in range(K):
      ans = ans * (-1) * minus[k] % mod
    print(ans)
    exit()
elif lm == 0:
  for k in range(K):
    ans = ans * plus[k] % mod
  print(ans)
  exit()

p = 0
m = 0
for k in range(K):
  if plus[p] >= minus[m]:
    p += 1
    if p == lp:
      m = K - p  
      break
  else:
    m += 1
    if m == lm:
      p = K - m
      break

def main(mp, mm, plus, minus):
  mod = 10 ** 9 + 7
  ans = 1
  for k in range(mp):
    ans = ans * plus[k] % mod
  for k in range(mm):
    ans = ans * (-1) * minus[k] % mod
  print(ans)
  exit()

if m % 2 == 0:
  main(p, m, plus, minus)
else:
  if p == lp:
    if m != lm:
      main(p - 1, m + 1, plus, minus)
    else:
      if lz > 0:
        print(0)
        exit()
      else:
        main(p, m, plus, minus)
  elif m == lm:
    main(p + 1, m - 1, plus, minus)
  elif p == 0:
    main(p + 1, m - 1, plus, minus)
  else:
    if plus[p] * plus[p - 1] > minus[m - 1] * minus[m]:
      main(p + 1, m - 1, plus, minus)
    else:
      main(p - 1, m + 1, plus, minus)

Measured memory_bytes: 31868
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<vector<int> > data(3, vector<int>(3));
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> data.at(i).at(j);
        }
    }
    bool ans = true;
    for (int i=0; i<=data.at(0).at(0); i++) {
        int a_1 = i;
        int b_1 = data.at(0).at(0) - i;
        int b_2 = data.at(0).at(1) - a_1;
        int b_3 = data.at(0).at(2) - a_1;
        int a_2 = data.at(1).at(0) - b_1;
        int a_3 = data.at(2).at(0) - b_1;
        if (data.at(1).at(2) != a_2 + b_3) {
            ans = false;
            break;
        } 
        if (data.at(1).at(1) != a_2 + b_2) {
            ans = false;
            break;
        }
        if (data.at(2).at(1) != a_3 + b_2) {
            ans = false;
            break;
        }
        if (data.at(2).at(2) != a_3 + b_3) {
            ans = false;
            break;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split(' ').map(n => parseInt(n, 10));
    x = input[0];
    y = input[1];
    z = input[2];
    cal = (x - z) / (y + z);
    console.log(Math.floor(cal));
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
ll a,b;
cin >> a >> b;
for(int i=1;i<=b;i++){
    if(a*i%b==0){
    cout << a*i<<endl;break;
}
}

}
 


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

#define REP(w, n) for(int w=0;w<int(n);++w)

int main() {
    int n; cin >> n;
    int a[n]; REP(i, n) cin >> a[i];
    int b[n]; REP(i, n) cin >> b[i];
    int c[n - 1]; REP(i, n - 1) cin >> c[i];

    int res = 0;
    int prv = -30;
    REP(i, n) {
        int t = a[i] - 1;
        res += b[t];
        if (prv + 1 == t) res += c[t - 1];
        prv = t;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)x
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e3 + 5;

int R, C;
int dp[N][N];
char grid[N][N];

int add(int x, int y) {
    return ((x % MOD) + (y % MOD)) % MOD;
}

bool inside(int r, int c) {
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

int f(int r, int c) {
    if(grid[r][c] == '#') return 0;
    if(!inside(r, c)) return 0;
    if(r == R && c == C) return 1;
    int &sol = dp[r][c];
    if(sol != -1) return sol;
    return sol = add(f(r + 1, c), f(r, c + 1));
}

void solve() {
    cin >> R >> C;
    for(int i = 1; i <= R; i++) {
        for(int j = 1; j <= C; j++) {
            cin >> grid[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1, 1) % MOD << "\n";
}

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

    solve();
    
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T, class C> void chmax(T &a, C b) { a > b ?: a = b; }
template <class T, class C> void chmin(T &a, C b) { a < b ?: a = b; }

int main() {

  int a, b;
  cin >> a >> b;
  if (b >= a) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }

  return 0;
}


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int n; cin >> n;
    vector<P> RL(n);
    rep(i,n) {
        int x,l;
        cin >> x >> l;
        RL[i] = P(x+l, x-l);
    }

    sort(RL.begin(), RL.end());
    int ans = 0;

    int gx = -1e9-1;
    rep(i, n){
        if(gx <= RL[i].second) {
            ans++;
            gx = RL[i].first;
        }
    }


    cout << ans << "\n";
    return 0;
}


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

char a[310][310];
int dp[310][310],qq[310][310],n;
void ini(int k){
    int i,j;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            qq[i][j]=qq[i-1][j-1];
            if(a[i][k]==a[j][k+1]) qq[i][j]++;
        }
    }
    return ;
}
int main(){
    int m,k,i,j;
    scanf("%d%d",&n,&m);
    for(k=1;k<=n;k++){
        scanf("%s",a[k]+1);
    }
    int ans=0,c;
    for(k=1;k<m;k++){//cmp k k+1 column
        memset(dp,0,sizeof(0));
        ini(k);
        for(i=1;i<=n;i++){
            for(j=1;j<=n;j++){
                c=qq[i][j];
                dp[i][j]=std::min(dp[i-1][j],dp[i][j-1])+c;
            }
        }
        ans+=dp[n][n];
    }
    printf("%d",ans);
}
    

Measured memory_bytes: 1024
n,k = map(int,input().split())
result = 0
for b in range(k+1,n+1):
  roop = n //b
  roop_ok = (b-1) - (k-1)
  amari = n % b
  amari_ok = amari - k + 1
  if roop_ok >= 0 :
    result += roop * roop_ok
    if amari_ok > 0 :
      result += amari_ok
      
if k == 0:
  print(n**2)
else:
  print(result)
  
    
  
  

Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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; }

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

	vll h(N);
	rep(i, N) cin >> h[i];

	vll dp(N, INF);
	dp[0] = 0;

	repl(i, 1, N)
	{
		dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));

		if (i >= 2)
		{
			dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}

	cout << dp[N - 1] << endl;

	return 0;
}

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

int main() {
int k;
cin >> k;
string s;
cin >> s;
if(s.size() <= k){
    cout << s << endl;
}
else{
    cout << s.erase(k) << "..."  <<endl;
}

return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define test int t;cin>>t; while(t--)
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
vi b_v;void bin(unsigned int n) { if (n > 1) bin(n>>1); b_v.pb(n & 1); }
int isPowerof2(int x) { return (x && !(x & x-1)); }

int maxx(int a,int b,int c){
    return max(a,max(b,c));
}

int32_t main(){
    boost;osit;
    int n;
    cin>>n;
    int a[n][3];
    rep(i,0,n){
        rep(j,0,3){
            cin>>a[i][j];
        }
    }
    int dp[n][3];
    dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
    rep(i,1,n){
        rep(j,0,3){
            dp[i][j]=max(dp[i-1][(j+1)%3]+a[i][j],dp[i-1][(j+2)%3]+a[i][j]);
        }
    }
    cout<<maxx(dp[n-1][0],dp[n-1][1],dp[n-1][2]);
    return 0;
}

Measured memory_bytes: 4992
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

#[allow(unused_macros)]
macro_rules ! max {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr $ (, ) * ) => {{std :: cmp :: max ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cmp :: max ($ a , max ! ($ ($ rest ) ,+ ) ) } } ; }
#[allow(unused_macros)]
macro_rules ! chmax {($ base : expr , $ ($ cmps : expr ) ,+ $ (, ) * ) => {{let cmp_max = max ! ($ ($ cmps ) ,+ ) ; if $ base < cmp_max {$ base = cmp_max ; true } else {false } } } ; }

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut dp = vec![vec![std::i64::MIN; 2]; n];
    dp[0][1] = 0;
    for i in 0..n - 1 {
        if dp[i][0] != std::i64::MIN {
            chmax!(dp[i + 1][1], dp[i][0] - a[i]);
            chmax!(dp[i + 1][0], dp[i][0] + a[i]);
        }
        if dp[i][1] != std::i64::MIN {
            chmax!(dp[i + 1][0], dp[i][1] - a[i]);
            chmax!(dp[i + 1][1], dp[i][1] + a[i]);
        }
    }

    let ret = (dp[n - 1][0] - a[n - 1]).max(dp[n - 1][1] + a[n - 1]);
    println!("{}", ret);
}


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

int main() {
	int  a, b, c;
	cin >> a;
	b = a / 10;
	c = a % 10;
	if (b == 9 || c == 9)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

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

namespace app1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');
            int N = int.Parse(NK[0]);
            int K = int.Parse(NK[1]);
            int result = 0;
            List<int> KList = new List<int>();

            for (int i = 0; i < N; i++)
            {
                KList.Add(i);
                if(KList.Count == K)
                {
                    result++;
                    KList.RemoveAt(0);
                }
            }

            Console.WriteLine($"{result}");
        }
    }
}


Measured memory_bytes: 11220
N = int(input())

factor = [0 for _ in range(N + 1)]

for i in range(2, N + 1):
    n = i
    for j in range(2, i + 1):
        while n % j == 0:
            factor[j] += 1
            n //= j


def num(m):
    return len(list(filter(lambda x: x >= m - 1, factor)))

ans = num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){
  string S;
  cin >> S;
  
  string a,b,c;
  int a1,b1,c1;
  a = S.substr(0,4);
  a1 = stoi(a);
  b = S.substr(5,2);
  b1 = stoi(b);
  c = S.substr(8,2);
  c1 = stoi(c);

  if(a1 <= 2019){
      if(b1 <= 04){
          if(c1 <= 30){
              cout << "Heisei" << endl;
          }else{
              cout << "TBD" << endl;
          }
      }else{
          cout << "TBD" << endl;
      }
  }else{
      cout << "TBD" << endl;
  }

}


Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    var F = BooleanArray(N + 1)
    for (i in 2 .. N)
        for (j in i + i .. N step i) F[j] = true
    var ans = 1L
    fun f(n: Int): Long {
        var ret = 1L
        var j = n
        while (j <= N) {
            ret += N / j
            j *= n
        }
//System.err.println("$n $ret")
        return ret
    }
    for (i in 2 .. N)
        if (!F[i]) ans = ans * f(i) % 1000000007L
    println(ans)
}

fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }


Measured memory_bytes: 33732
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			int X = sc.nextInt();
			int t = sc.nextInt();
			if(X-t>0){
				System.out.println(X-t);
			}else{
				System.out.println(0);
			}
    }
}


Measured memory_bytes: 21844
program ABC_094_A_CatsandDogs
   implicit none
   integer A, B, X
   read(*, *) A, B, X
   if(B >= X - A .and. X - A >=0) then
      write(*, *) 'YES'
   else 
      write(*, *) 'NO'
   end if
end program ABC_094_A_CatsandDogs

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

using namespace std;

#define int long long

main() {
    //freopen("input.txt", "r", stdin):
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0, cnt = 1;
    cin >> n;
    vector < string > a;
    for (int i = 1; i <= n; ++i) {
        string s;
        cin >> s;
        vector < char > tmp;
        for (auto c : s) tmp.push_back(c);
        sort(tmp.begin(), tmp.end());
        string s1 = "";
        for (auto c : tmp) s1 += c;
        a.push_back(s1);
    }
    sort(a.begin(), a.end());
    for (int i = 1; i < n; ++i) {
        if (a[i] == a[i - 1]) cnt++;
        else {
            ans += (cnt * (cnt - 1) / 2);
            cnt = 1;
        }
    }
    ans += (cnt * (cnt - 1) / 2);
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 8820
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 
#define MODB  998244353

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n, l; cin >> n >> l;
	vector<string> s(n);
	cin >> s;
	sort(s.begin(), s.end());
	REP(i, s.size()) cout << s[i];
	cout << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int N=1e6+5;
const long long INF = 1e6;
const int mod=998244353;
int n,s,dp[3005][3005];
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>s;
    dp[0][0]=1;
    vector<int> v(n+5,0);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=s;j++)
        {
            dp[i][j]+=(2*dp[i-1][j])%mod;
            if(j>=v[i])
            {
                dp[i][j]+=dp[i-1][j-v[i]];
                dp[i][j]=dp[i][j]%mod;
            }
        }
    }
    cout<<dp[n][s];



}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int main() {
    int n;
    cin >> n;
    LL ans = 1;
    LL odd = 1;
    forn(i, n) {
        int x;
        cin >> x;
        ans *= 3;
        if (x % 2 == 0) {
            odd *= 2;
        }
    }
    ans -= odd;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
	while b!=0:
		a,b=b,a%b
	return a

def lcm(a,b):
	return a*b//gcd(a,b)

a,b,c,d = map(int,input().split())
a-=1
ac = a//c
ad = a//d
bc = b//c
bd = b//d
cd = lcm(c,d)

if cd <= b:
	print((b-a)-((bc+bd)-(ac+ad))+(b//cd-a//cd))
else:
	print((b-a)-((bc+bd)-(ac+ad)))

Measured memory_bytes: 38384
#include <stdio.h>

int main() {
	static int kk[5];
	int n, i, j, k;
	long long ans;

	scanf("%d", &n);
	while (n--) {
		static char s[11];
		char c;

		scanf("%s", s);
		c = s[0];
		if (c == 'M')
			kk[0]++;
		else if (c == 'A')
			kk[1]++;
		else if (c == 'R')
			kk[2]++;
		else if (c == 'C')
			kk[3]++;
		else if (c == 'H')
			kk[4]++;
	}
	ans = 0;
	for (i = 0; i < 5; i++)
		for (j = i + 1; j < 5; j++)
			for (k = j + 1; k < 5; k++)
				ans += (long long) kk[i] * kk[j] * kk[k];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
N,Q = map(int,input().split())
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
tree = [[] for _ in range(N)]

for i in range(N-1):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    tree[y].append(x)
    tree[x].append(y)
ans = [0]*N
for i in range(Q):
    x,y = map(int,input().split())
    ans[x-1] += y


def dfs(cur,par):
    for chl in tree[cur]:
        if chl == par: #これで木の流れの逆行を防ぐ
            continue
        ans[chl] += ans[cur]
        dfs(chl,cur)

dfs(0,-1)
print(*ans)

Measured memory_bytes: 230940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

//#include <set>
//#include <unordered_map>
//#include <stack>

using namespace std;

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

#define max_n 100

int N;
int A[100000];

int main() {

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


	long long ans = 1;
	int Color[3] = { 0 };
	rep(i, N) {
		int c = 0;
		int co = 0;
		rep(j, 3) { if (Color[j] == A[i]) { c++; co = j; } }
		ans *= c;
		Color[co] ++;
		ans = ans % 1000000007;
	}
	

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        boolean ans = solve(N, K);

        System.out.println(ans ? "YES" : "NO");
    }

    private static boolean solve(int N, int K) {
        return  K*2-1 <= N;
    }
}


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

namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var end = GetInput_long()[0];
            long sum = 0;
            for(long i = 0; i <= end; i++)
            {
                if (i % 3 == 0 || i % 5 == 0)
                {

                }
                else
                {
                    sum += i;
                }
            }
            Console.WriteLine(sum);
        }
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        #endregion
    }
}

Measured memory_bytes: 27536
def main():
    n, m = map(int, input().split())
    ab = [sorted(list(map(int, input().split()))) for _ in [0] * m]
    l = [0] * (n - 1)
    for i in range(m):
        a, b = ab[i]
        if a != 1:
            l[a-2]+=1
        l[b - 2] += 1
    l=[i%2 for i in l]
    if sum(l) > 0:
        print("NO")
    else:
        print("YES")
main()

Measured memory_bytes: 27936
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;

int n,a[100000],x1,x2;

signed main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=n-1;i>=1;i--){
		if(a[i]==a[i-1]){
			if(x1!=0&&x2==0) x2=a[i];
			if(x1==0) x1=a[i];
			i--;
		}
	}
	int s=x1*x2;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n), y(n);
    vector<int> xary, yary; 

    rep(i, n) {
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }

    sort(xary.begin(), xary.end());
    sort(yary.begin(), yary.end());

    ll ans = 1LL * (xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);

    for(int xi = 0; xi < n; xi++) {
        for(int xj = xi + 1; xj < n; xj++) {
            for(int yi = 0; yi < n; yi++) {
                for(int yj = yi + 1; yj < n; yj++) {

                    int num = 0;
                    ll lx = xary[xi];
                    ll rx = xary[xj];
                    ll by = yary[yi];
                    ll uy = yary[yj];

                    rep(i, n) {
                        if(lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy) {
                            num++;
                        }
                    }

                    if(num >= k) {
                        ans = min(ans, 1LL * (rx - lx) * (uy - by));
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=(1<<31)-1;
const double pi=acos(-1);

class RMQ{
	private:
	vi rmq;
	bool two_judge(int x){
		if(x==1) return 0;
		if(x==0) return 1;
		return two_judge(x/2);
	}
	public:
	int N;
	RMQ(int x){
		N=1;
		while(N<x) N*=2;
		rmq=vi(2*N-1,inf);
	}
	void update(int x,int y){
		x+=N-1;
		rmq[x]=y;
		while(x>0){
			x=(x-1)/2;
			rmq[x]=min(rmq[x*2+1],rmq[x*2+2]);
		}
	}
	int find(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return inf;
		if(a<=l&&r<=b) return rmq[k];
		int vl=find(a,b,k*2+1,l,(l+r)/2);
		int vr=find(a,b,k*2+2,(l+r)/2,r);
		return min(vl,vr);
	}
	void open(){
		for(int i=0;i<N;i++){
			if(two_judge(i)) cout<<endl;
			cout<<rmq[i]<<' ';
		}
	}
};

int n,q;

int main(){
	cin>>n>>q;
	RMQ tree(n);
	for(int i=0;i<q;i++){
		int type,one,two;
		cin>>type>>one>>two;
		if(type) cout<<tree.find(one,two+1,0,0,tree.N)<<endl;
		else tree.update(one,two);
	}
}

Measured memory_bytes: 3116