akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N;
    cin >> N;
    vector<string> v(N);
    rep(i, N) cin >> v[i];
    set<string> s;
    for (ll i = 0; i < N; i++){
        s.insert(v[i]);
    }

    cout << s.size() << endl;
}


Measured memory_bytes: 25072
def main():
    weekday_name = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
    s = input()
    for i in range(7):
        if weekday_name[i] == s:
            print(7 - i)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A, B;
  cin >> A >> B;
  if(B == 1) {
    cout << 0 << endl;
  }
  else {
    cout << A - B << endl;
  }
}

Measured memory_bytes: 3596
def main
  loop do
    start_min = 540
    end_max = 1260
    pc_num,student_num = gets.chomp.split(' ').map(&:to_i)
    break if (pc_num|student_num) == 0

    pc_log_list = Array.new(pc_num+1).map{Array.new(end_max-start_min+1, 0)}

    log_num = gets.chomp.to_i
    log_num.times do
      time,pc,student,action = gets.chomp.split(' ').map(&:to_i)
      time -= start_min
      case action
      when 1
        pc_log_list[pc][time] = student
      when 0
        (time-1).downto(0) do |i|
          break if pc_log_list[pc][i] == student
          pc_log_list[pc][i] = student
        end
      end
    end

    question_num = gets.chomp.to_i
    question_num.times do
      start_time,end_time,student = gets.chomp.split(' ').map(&:to_i)
      start_time -= start_min
      end_time -= start_min

      total = 0
      (start_time..end_time-1).each do |time|
        (1..pc_num).each do |pc|
          if pc_log_list[pc][time] == student
            total += 1
            break
          end
        end
      end
      puts total
    end
  end
end

main

Measured memory_bytes: 13752
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cstring>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < (n); i++)

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

    int A[n], B[n];
    repi(i, n, 0)
    {
        cin >> A[i] >> B[i];
    }
    int dp[n+1][h+1];
    memset(dp,127,sizeof dp);
    // vector<vector<int>> dp(n+1,vector<int>(h+1,INF));
    dp[0][0] = 0;
    repi(i, n, 0)
    {
        repi(j, h + 1, 0)
        {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);//i番目を使った時と使わなかったときのjダメージの最小
            dp[i + 1][min(j+A[i],h)] = min(dp[i + 1][min(j+A[i],h)], dp[i + 1][j] + B[i]);//i番目を使った時と使わなかったときのj+Aiダメージの最小
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 39296
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	a, b := ReadString(), ReadString()
	c, _ := strconv.Atoi(a + b)
	for i := 1; i*i <= c; i++ {
		if i*i == c {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

typedef long long LL;

using namespace std;

int main(){
	LL n;
	cin >> n;
	map<string,int> mp;
	for(LL i=0;i<n;i++){
		string s;
		cin >> s;
		mp[s]++;
	}
	
	LL cnt=0;
	for(auto p:mp){
		cnt++;
	}
	
	cout << cnt << endl;
	return 0;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;

    // 処理
    int ans  = 0;
    int a[n] = {};
    for (int i = 1; i <= n; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) {
                cnt++;
            }
        }
        if (cnt == 8) ans++;
    }

    // 出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

/*#define d 1*/
#define out (1000000000+7)

int main()
{
        int i;
        int input=0;
        unsigned long long power=1;

        scanf("%d", &input);

        for(i=1;i<=input;i++)
        {
                power=(unsigned long long)(power*i);
                power=power%out;
#ifdef d
                printf("%llu\n", power);
#endif
        }

        printf("%llu\n", power);

        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+100;
struct Segment_Tree{
    ll min_val[maxn*4];
    ll lzy[maxn*4];
    void up(int x){
        min_val[x] = min(min_val[x<<1],min_val[x<<1|1]);
    }
    void down(int x){
        min_val[x<<1] += lzy[x];
        min_val[x<<1|1] += lzy[x];
        lzy[x<<1] += lzy[x];
        lzy[x<<1|1] += lzy[x];
        lzy[x] = 0;
    }
    void update(int x,int l,int r,int L,int R,ll val){
        if (l > R || L > r)return;
        if (L <= l && r <= R){
            min_val[x] += val;
            lzy[x] += val;
            return;
        }
        int mid = l + r >> 1;
        down(x);
        update(x<<1,l,mid,L,R,val);
        update(x<<1|1,mid+1,r,L,R,val);
        up(x);
    }
    ll query_min(int x,int l,int r,int L,int R){
        if (l > R || L > r)return LLONG_MAX;
        if (L <= l && r <= R)return min_val[x];
        int mid = l + r >> 1;
        down(x);
        return min(query_min(x<<1,l,mid,L,R),query_min(x<<1|1,mid+1,r,L,R));
    }
}segtree;
vector<pair<int,ll> > a[maxn];
int n,m;
ll dp[maxn][2];
int main(){
    scanf("%d%d",&n,&m);
    ll sum = 0;
    for (int i=0;i<m;i++){
        int l,r,a;
        scanf("%d%d%d",&l,&r,&a);
        sum += a;
        ::a[r].push_back({l,a});
    }
    for (int i=1;i<=n;i++){
        for (pair<int,ll> ai : a[i]){
            segtree.update(1,0,n,0,ai.first-1,ai.second);
        }
        dp[i][1] = min(dp[i-1][1],dp[i-1][0]);
        dp[i][0] = segtree.query_min(1,0,n,0,i-1);
        segtree.update(1,0,n,i,i,dp[i][1]);
    }
    cout<< sum - min(dp[n][0],dp[n][1]);
    return 0;
}


Measured memory_bytes: 24960
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

char s[100002];
char t[100001];
int d[100002][26];
int main(void){
	int n=nextstr(s+1);
	int m=nextstr(t);
	for(int i=n; i>0; i--){
		for(int c=0; c<26; c++){
			d[i][c]=d[i+1][c];
		}
		int c=s[i]-'a';
		d[i][c]=i;
	}
	for(int c=0; c<26; c++){
		d[0][c]=d[1][c];
	}
	int ans=0;
	int now=0;
	for(int i=0; i<m; i++){
		int c=t[i]-'a';
		now++;
		if(d[now][c]!=0){
			now=d[now][c];
		}else if(d[0][c]!=0){
			now=d[0][c];
			ans++;
		}else{
			puts("-1");
			return 0;
		}
	}
	printf("%ld\n", (long)ans*n+now);
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(N);
  vector<int>B(N);
  vector<int>C(N);
  vector<long long>D(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)cin>>B[i];
  for(int i=0;i<N;i++)cin>>C[i];
  sort(A.begin(),A.end());
  sort(C.begin(),C.end());
  long long ans=0;
  for(int i=0;i<N;i++){
    ans+=(N-(A.end()-lower_bound(A.begin(),A.end(),B[i])))*(C.end()-upper_bound(C.begin(),C.end(),B[i]));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5052
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};

/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[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! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        xu: [[String; 2]; n],
    }

    let answer: f64 = xu
        .iter()
        .map(|xu| {
            if &xu[1] == &"BTC" {
                xu[0].parse::<f64>().unwrap() * 380000.0
            } else {
                xu[0].parse::<u64>().unwrap() as f64
            }
        })
        .sum();

    println!("{}", answer);
}


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

using namespace std;

int main() {
  long long n, m, x;
  cin >> n >> m >> x;
  long long a[n], b[m];
  for(long long i = 0; i < n; i++) cin >> a[i];
  for(long long i = 0; i < m; i++) cin >> b[i];

  long long ans = 0, sum = 0, i = 0, j = 0;
  while(i < n && sum + a[i] <= x) {
    sum += a[i];
    i++;
  }
  ans = i;

  while(j < m) {
    sum += b[j];
    j++;
    while(sum > x && i > 0) {
      i--;
      sum -= a[i];
    }
    if(sum <= x && i + j > ans) ans = i + j;
  }

  cout << ans << endl;
}


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

b = [0] * (N + 1)
half = N // 2
b[half + 1:] = A[half:]
for i in range(half, 1, -1):
    s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2
    if s != A[i - 1]:
        b[i] = 1
s = sum(b)
if s % 2 != A[0]:
    b[1] = 1
    s += 1
print(s)
print(*[i for i in range(1, N + 1) if b[i] == 1])

Measured memory_bytes: 13108
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;

    static string s;
    static int K;
    static void input()
    {
        cin = new Scanner();
        s = cin.next();
        K = cin.nextInt();
    }
    static void solve()
    {
        input();
        HashSet<string> hs = new HashSet<string>();
        int count = 0;
        for(int i = 0; i < 26; i++)
        {
            char c = Convert.ToChar('a' + i);
            for (int j = 0; j < s.Length; j++)
            {
                if(s[j] == c)
                {
                    for(int k = 1; k <= Min(s.Length - j, K); k++)
                    {
                        if (hs.Add(s.Substring(j, k)))
                            count++;
                    }
                }
            }
            if (count >= K)
                break;
        }
        WriteLine(hs.ToArray().OrderBy(x => x).Skip(K - 1).First().ToString());
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13920
def main():
    A,B,M=map(int, input().split())
    AS=list(map(int, input().split()))
    BS=list(map(int, input().split()))
    XYC=[tuple(map(int, input().split()))for _ in range(M)]
    ans=min(AS)+min(BS)
    for x,y,c in XYC:
        ans=min(ans, AS[x-1]+BS[y-1]-c)
    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 29028
def dfs(nums, length, min_lim):
# numsは数列の本体、lengthは数字の何個目まで決めたか、min_limは次の数字の最小値
    ans = 0
    if length == n:
    # 数列が完成したので、得点を計算します
        score_ret = 0
        for a, b, c, d in req:
            # nums[0]を捨てたので、nums[b-1]...としなくて済みます
            if nums[b] - nums[a] == c:  
                score_ret += d
        return score_ret  # この数列の得点を返します
    else:
        # まだ数列が完成していません
        for nu in range(min_lim, m + 1):
        # 次の数字の下限はmin_limで、上限はmです
            new_nums = nums + [nu]  # 長さ1のリスト[nu]を連結します
            # lengthは1増えて、次の下限は今付け加えた数字nuです
            score = dfs(new_nums, length + 1, nu)
            ans = max(ans, score) # 最大の得点を更新します

    # すべてが終わったので、答えを返します
    return ans


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

# 問題文のa,b,c,dのリストreqです。[[a1,b1,c1,d1],[a2,b2,c2,d2],[a3,b3,c3,d3]]のようになります。
req = [list(map(int, input().split())) for _ in range(q)]

# 最終的に答えが返ってくるようにします。処理はすべてdfsメソッドでやってもらいます。
# 数列の番号と添字を一致させたいので、長さ1のリストを最初の状態にしておきます。
# サンプル1の数列は[-1, 1, 3, 4]になります。
ans = dfs([-1], 0, 1)
print(ans)

Measured memory_bytes: 9132
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli h,w,k;
vst a;
lli sx,sy;
lli mind = 10000000000;

lli near(lli x,lli y){
    return min({x,y,h-x-1,w-y-1});
}

vll par;
vll rnk;
void init(lli n){
    par = vll(n);
    rnk = vll(n);
    for(lli i = 0;i < n;i++) par[i] = i;
}
lli find(lli x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}
void unite(lli x,lli y){
    x = find(x);y = find(y);
    if(x == y) return;
    if(rnk[x] < rnk[y]) par[x] = y;
    else {
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}
bool same(lli x,lli y){
    return find(x) == find(y);
}


bool isin(lli i,lli j){
    return i >= 0 && j >= 0 && i < h && j < w && a[i][j] != '#';
}

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

int main(){
    cin >> h >> w >> k;
    a = vst(h);
    init(h*w);
    for(lli i = 0;i < h;i++) cin >> a[i];
    for(lli i = 0;i < h;i++){
        for(lli j = 0;j < w;j++){
            if(a[i][j] == 'S'){
                sx = i;
                sy = j;
            }
            if(a[i][j] != '#'){
                for(lli k = 0;k < 4;k++){
                    lli x = i+dx[k];
                    lli y = j+dy[k];
                    if(isin(x,y)){
                        unite(i*w+j,x*w+y);
                    }
                }
            }
        }
    }
    for(lli i = 0;i < h;i++){
        for(lli j = 0;j < w;j++){
            if(same(i*w+j,sx*w+sy) && abs(i-sx) + abs(j-sy) <= k){
                mind = min(mind,near(i,j));
            }
        }
    }
    if(mind == 0) cout << 1 << endl;
    else cout << mind/k+(mind%k?1:0)+1 << endl;
    return 0;
}

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

using namespace std;

#define pii pair<int, int>
#define fi first
#define se second
#define REP(i, a, n) for (register int i = a, _n = n; i <= _n; ++i)
#define DREP(i, a, n) for (register int i = a, _n = n; i >= _n; --i)
#define FOR(i, a, n) for (register int i = a, _n = n; i < _n; ++i)
#define EREP(i, a) for (register int i = first[a]; i; i = edge[i].nxt)
#define debug(x) cout << #x << " = " << x << endl

char IO;
inline int rd () {
	int res = 0;
	while ((IO = getchar()) && (IO < '0' || IO > '9'));
	while (IO >= '0' && IO <= '9') 
		res = (res << 1) + (res << 3) + (IO ^ 48), IO = getchar();
	return res;
}

int n, d;
int main () {
	cin >> n >> d;
	cout << (n - 1) / (2 * d + 1) + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    if s[5]=='1':
        print('TBD')
        exit()
    else:
        if s[6]=='4' or s[6]=='3' or s[6]=='2' or s[6]=='1':
            print('Heisei')
        else:
            print('TBD')


if __name__ == '__main__':
    main()

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

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

int func(int n){

}

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(a%2 == 0){
            int count = 0;
            while(true){
                if(a%2 == 0){
                    a /= 2;
                    count++;
                }else{
                    break;
                }
            }
            sum += count;
        }
    }
    cout << sum;
    return 0;
}

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

int main() {
  string n;
  int a=0;
  cin>>n;
  for (size_t i = 1; i < 4; i++) {
    if (n[i]==n[i-1]) {
      a+=1;
    }
    else if (n[i]!=n[i-1] && a!=2) {
      a=0;
    }
  }
    if (a>=2) {
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  if(n==m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
  
}

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

int main(void){
   int N,M;
   cin >> N >> M;
   int count=0;
   int sum=0;
   vector<int> A(N);
   for (int i=0;i<N;i++) {
       cin >> A[i];
       sum+=A[i];
   }
   
   for (int i=0;i<N;i++) {
       if (A[i]>= (sum+4*M-1)/(4*M)){
           count++;
       }
   }
   
   if(count<M) {
       cout << "No" << endl;
   }
   else {
       cout << "Yes" << endl;
   }
   
}




Measured memory_bytes: 3612
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

struct DisjointSet {
	vector<int> par;

	DisjointSet(int N) : par(N, -1) {}

	bool isSame(int a, int b) {
		return root(a) == root(b);
	}

	int root(int a) {
		if (par[a] < 0) return a;
		par[a] = root(par[a]);
		return par[a];
	}

	int size(int a) {
		return -par[root(a)];
	}

	void unite(int a, int b) {
		if (!isSame(a, b)) {
			a = root(a);
			b = root(b);
			if (size(a) < size(b)) swap(a, b);
			par[a] += par[b];
			par[b] = a;
		}
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i];
		--A[i];
		--B[i];
	}
	vector<long> ans(M);
	ans[M - 1] = (long)N * (N - 1) / 2;
	DisjointSet ds(N);
	for (int i = M - 1; i > 0; --i) {
		ans[i - 1] = ans[i];
		if (!ds.isSame(A[i], B[i])) {
			ans[i - 1] -= (long)ds.size(A[i]) * ds.size(B[i]);
			ds.unite(A[i], B[i]);
		}
	}
	for (long& i : ans) cout << i << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const ll INF = (1LL << 60);
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/
/******** User-defined Function *******/
int f(int n){
    if(n==0) return 1;
    return f(n)*f(n-1);
}
/**************************************/
/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<pair<double,double>> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;
    sort(all(p));

    int div = 1;
    rep1(i,n) div *= i;
    
    double sum = 0;
    do{
        rep1(i,n-1){
            int dx = p[i].first - p[i-1].first;
            int dy = p[i].second - p[i-1].second;
            sum += sqrt(dx*dx + dy*dy);
        }
    }while(next_permutation(all(p)));

    Dcout(sum/div);
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3788
#include <iostream>

using namespace std;

int check(int num,char c){
  if(c == '1')return num%5;
  if(c == '7' || c == '9')return num%4;
  else return num%3;
}

int main(){
  int n,i,j;
  string s;
  char b[10][5];
  char c = 'a';
  b[1][0]='.';
  b[1][1]=',';
  b[1][2]='!';
  b[1][3]='?';
  b[1][4]=' ';
  for(i=2;i<10;i++){
    for(j=0;j<3;j++){
      b[i][j]=c;
      c++;
    }
    if(i==7 || i==9){
      b[i][3]=c;
      c++;
    }
  }
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s;
    j=0;
    while(j<s.size()){
      c = s[j];
      if(c=='0'){
        j++;
        continue;
      }
      int num=0;
      j++;
      while(s[j]==c){
        num++;
        j++;
      }
      num = check(num,c);
      cout << b[c-'0'][num];
    }
    cout << endl;
  }
  return 0;
}



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

int main(){
	int a;
	string res = "No\n";
	cin>>a;
	if(a>81){
	cout<<res;
	return 0;
	}
	
	for(int i = 9; i>=1; i--){
		if(a%i==0){
			if((a/i)>=1 && (a/i)<=9){
				res = "Yes\n";
				break;
				} 
	}
	}
	cout<<res;
	return 0;	
}

Measured memory_bytes: 256
n=input()
s=input()
ans=0
for i in range(1000):
 i=str(i).zfill(3)
 a=s.find(i[0])
 if a!=-1:
  b=s.find(i[1],a+1)
  if b!=-1:
   if s.find(i[2],b+1)!=-1:ans+=1
print(ans)

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

int vis[801][801];

int H,W,K;
bool in(int x,int y){
	return x>=0&&x<H&&y>=0&&y<W;
}
string g[800];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>H>>W>>K;
	int sx,sy;
	for(int i=0;i<H;i++)
		cin>>g[i];
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(g[i][j]=='S')
				sx=i,sy=j;
	queue<int> q;
	q.emplace(sx);
	q.emplace(sy);
	memset(vis,-1,sizeof vis);
	vis[sx][sy]=0;
	while(!q.empty()){
		int x=q.front();q.pop();
		int y=q.front();q.pop();
		if(vis[x][y]==K)	continue;
		for(int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(in(nx,ny)&&vis[nx][ny]==-1&&g[nx][ny]=='.')
				vis[nx][ny]=vis[x][y]+1,q.emplace(nx),q.emplace(ny);
		}
	}
	int ans = 1e9;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(vis[i][j]!=-1)
				ans=min({ans,i,H-1-i,j,W-1-j});
	cout<<1+(ans+K-1)/K<<endl;
}



Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define REP(i, a, b) for(long long i=a; i<=b; ++i)
#define REPN(i, a, b) for(long long i=a; i<=b; --i)
#define rep(i, a, b) for(long long i=a; i<b; ++i)
#define rep0(i,b) for(long long i=0; i<b; ++i)
#define REP0(i,b) for(long long i=0; i<=b; ++i)
#include<cmath>
#include <iomanip>
using namespace std;


typedef long long ll;

int MODE = 1e9+7;

ll dp[22][(1<<21)];
int arr[21][21];

int helper(int currentMan, int mask, int n)
{


    if(currentMan == n)
    {
        return 1;
    }
    if(dp[currentMan][mask] != -1)
    {

        return dp[currentMan][mask];
    }

    int total = 0;

    for(int i=0; i<n; ++i)
    {
         //cout<<arr[currentMan][i]<<"\t"<< (mask>>i & 1)<<endl;
        if(arr[currentMan][i] == 1 && ( (mask>>i) & 1 == 1))
        {
            int tempMask = mask ^ (1<<i);

            total += helper(currentMan + 1, tempMask, n);
            total %= MODE;
        }
    }


    return dp[currentMan][mask] = total;


}


int main()
{

    int n;
    cin>>n;
    memset(dp, -1, sizeof(dp));
    rep0(i, n)
    {
        rep0(j, n)
        {
            cin>>arr[i][j];
        }
    }






    int mask = (1<<n) - 1;

    cout<<helper(0, mask, n)<<endl;



    return 0;

}


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

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();

        static long mod = 1000000007;
        static long[] factorial = new long[100001];
        static long[] invFactorial = new long[100001];

        private static void calcFanctorial(long N)
        {
            factorial[0] = 1;
            for(int i=1; i< N+1; i++)
            {
                factorial[i] = factorial[i - 1] * i;
                factorial[i] %= mod;
            }
            invFactorial[N] = inv(factorial[N]);
            for (int i = (int)N; i > 0; i--)
            {
                invFactorial[i - 1] = invFactorial[i] * i % mod;
            }

        }

        static void Main(string[] args)
        {


            var AA = ReadLongArr();
            var N = AA[0];
            var K = AA[1];

            calcFanctorial(N);
            var ll = ReadLongArr();
            Array.Sort(ll);

            long res = 0;
            for(int i=0; i< N; i++)
            {
                res += ll[N - 1 - i] * nCm(N - 1 - i, K - 1);
                res %= mod;
                res -= ll[i] * nCm(N - 1 - i, K - 1);
                res %= mod;
            }
            res = (res % mod + mod) % mod;
            Console.WriteLine(res);


        }

        private static long nCm(long n, long m)
        {
            if (n < m) return 0;

             return (factorial[n] * invFactorial[m] % mod) * invFactorial[n-m] % mod;
        }

        public static long pow(long a, long b, long mod)
        {
            a %= mod;

            if (b <= 0) return 1;
            var t = pow(a, b / 2, mod);
            if ((b & 1) == 0) return t * t % mod;
            return t * t % mod * a % mod;
        }

        public static long pow(long a, long b) => pow(a, b, mod);
        public static long inv(long a) => pow(a, mod - 2);


        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


Measured memory_bytes: 30812
parentalString = list(input())
childString = list(input())
numOfDiffs = []

for i in range(0,(len(parentalString) - len(childString))+1):
  count = 0
  for k in range(0,len(childString)):
    if childString[k] != parentalString[i+k]:
      count = count + 1
  numOfDiffs.append(count)

print(min(numOfDiffs))

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl; 
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N,A,B;
  cin>>N>>A>>B;
  int ans=0;
  for(int i=1;i<=N;i++){
    int c=0,t=i;
    for(int j=0;j<5;j++){
      c+=t%10;
      t/=10;
    }
    if(c>=A&&c<=B){
      ans+=i;
    }
  }
  printf("%d",ans);
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.Math.*;

class Main{

    static long[][] dp = new long[101][100001];
    static int maxVal = 1000000001;

    public static void main(String[] args){
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();

        for(int i = 1; i<= N; i++){
            dp[i][0] = 0;
            for(int j = 1; j <= 100000; j++){
                dp[i][j] = maxVal;
            }
        }

        int w = sc.nextInt();
        int v = sc.nextInt();
    
        for(int j = 0; j <= 100000; j++){
            if(v >= j) dp[1][j] = w;
        }        

        for(int i = 2; i <= N; i++){
            w = sc.nextInt();
            v = sc.nextInt();
            for(int j = 1; j <= 100000; j++){
                //slucaj da ne uzememo i-ti po redu
                dp[i][j] = dp[i-1][j];
                //ako zelimo uzeti i-ti po redu                
                int temp = w;
                if(j - v > 0) temp += dp[i-1][j-v];
                dp[i][j] = Math.min(dp[i][j], temp);

            }    
        }            

        int res = 0;
        for(int j = 1; j <= 100000; j++){
            //System.out.print(dp[N][j] + " ");            
            if(dp[N][j] <= W) res = j;
            else break;
        }
        
        System.out.println(res);
    }
}





















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

int main ()
{
	int w, h, x, y, r;
	std::cin >> w >> h >> x >> y >> r;

	bool a = (0 <= x - r) && (x + r <= w);
	bool b = (0 <= y - r) && (y + r <= h);
	if (a && b)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
}

Measured memory_bytes: 3096
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

x = ni()

ans = 0
res = 100
while res < x:
    res += res // 100
    ans += 1

print(ans)

Measured memory_bytes: 9248
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

//constexpr int inf = TEN(9)+5;
//constexpr ll linf = 3*TEN(18);

signed main()
{
    int D,T,S;cin>>D>>T>>S;
    if (T*S >= D) cout << "Yes\n";
    else cout << "No\n";
}


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

using namespace std;

int calc(long long v) {
  int k = 1;
  while (v >= 10) {
    v /= 10;
    k++;
  }
  return k;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n; cin >> n;
  int ans = 1e9;
  for (long long i = 1; i * i <= 1e10; i++) {
    if (n % i == 0) {
      long long v = n / i;
      ans = min(ans, max(calc(i), calc(v)));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/**********************************************
#code by --> @ { shadat </> sk40 [ o_o  ^_^ ] } }
**********************************************/
#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
#define tezz ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define doub long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define stp setprecision(20)


int main() {
  int n;cin >>n;
  if(n==1){
    cout << "Yes" << endl;
    return 0;
  }
  vector<int> v(n);
  for(int i=0;i<n;++i) cin >> v[i];
  for(int i=n-1;i>0;--i)if(v[i]<v[i-1])--v[i-1];
  bool valid = true;
  for(int i=0;i<n-1;++i){
    if(v[i]>v[i+1]){
      valid = false;
      break;
    }
  }
  if(valid){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")



int main() {
    ll n, k;
    ll ans = 0;
    cin >> n >> k;

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n){
        ll front = 0, back = 0;
        rep(j,i){
            if(a[j] < a[i]) front ++;
        }
        for(int j=i; j<n; j++){
            if(a[j] < a[i]) back ++;
        }
        ans += ((k * (k-1) / 2) % MOD) * (front + back) + back * k;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  string ans = "NG";
  for(int i=a; i<=b; i++){
    if(i%k == 0){
      ans = "OK";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
using System;

namespace aoj
{
    class Program
    {
        static void Main()
        {
            var size = int.Parse(Console.ReadLine());
            var arr = new string[size];
            for (var i = 0; i < size; i++)
            {
                arr[i] = Console.ReadLine();
                var _ = arr[i].Split(' ');
                var num = new int[3];
                for (var j = 0; j < 3; j++)
                {
                    num[j] = int.Parse(_[j]);
                }
                if (num[0]*num[0] + num[1]*num[1] == num[2]*num[2] ||
                    num[1]*num[1] + num[2]*num[2] == num[0]*num[0] ||
                    num[2]*num[2] + num[0]*num[0] == num[1]*num[1])
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, x;
  cin >> n >> x;

  vector<ll> l(n);
  rep(i, n) {
    cin >> l[i];
  }

  vector<ll> y(n + 1);
  REP(i, n + 1) {
    y[i] = y[i - 1] + l[i - 1];
  }

  cout << distance(y.begin(), upper_bound(all(y), x)) << endl;

  return 0;
}


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

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

    int n;
    cin >> n;
    long long a[n], ans = 0;

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

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            for (int k = j + 1; k < n; k++)
                if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k] && a[i] + a[j] > a[k])
                    ans++;
    cout << ans << '\n';
}

Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt(),r = obj.nextInt();
        System.out.println((r+100*Math.max(0,10-n)));
    }
}


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

int euclid(int a, int b){
  while(1){
  if(a > b){
    int k = a;
    a = b;
    b = k;
  }
  if(!a) break;
  b %= a;
}
  return b;
}

int main(void){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  ll gcd = (c*d)/euclid(c,d);
  ll count = b / c + b / d - b / gcd;
  ll hiku = (a-1)/c + (a-1)/d - (a-1)/gcd;
  cout << b - a + 1 - (count - hiku) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
    char C[2][3];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 3; j++){
            std::cin >> C[i][j];
        }
    }
    for(int i = 0; i < 3; i++){
        if(C[0][i] != C[1][2 - i]){
            std::cout << "NO" << std::endl;
            return 0;
        }
    }
    std::cout << "YES" << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int K, S, ans = 0;

  cin >> K >> S;

  for(int i = 0;i <= K;i++){
    for(int j = 0;j <= K;j++){
      if(0 <= S - i - j && S - i - j <= K) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	if(n==1) {
		cout<<1<<endl;
		return 0;
	}
	vector<ll> num(1001,0);
	FOR(i,2,n+1) {
		ll buf=i;
		for(ll j=2; j*j<=i; j++) {
			while(buf%j==0) {
				buf/=j;
				num[j]++;
			}
		}
		if(buf!=1) num[buf]++;
	}
	ll ret=1;
	REP(i,1001) {
		ret*=num[i]+1;
		ret%=MOD;
	}
	cout<<ret<<endl;
}


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

bool f(vector<int> nums, int sum, int i,vector<char> op)
{
  if (i > 3)
  {
    if(sum == 7)
    {
      cout << nums.at(0) << op.at(1) << nums.at(1) << op.at(2)
        << nums.at(2) << op.at(3) << nums.at(3) << "=7" << endl; 
      return true;
    }
    else
    {
      return false;
    }
  }
  op.at(i) = '+';
  if (f(nums, sum + nums.at(i), i + 1, op))
  {
    return true;
  }
  op.at(i) = '-';
  if ( i > 0 && f(nums, sum - nums.at(i), i + 1, op))
  {
    return true;
  }
  return false;
}


int main() {
  string S;
  
  cin >> S;
  vector<int> nums(4);
  vector<char> op(5);
  rep(i, 4)
  {
    nums.at(i) = S.at(i) - '0';
  }
  f(nums,0,0,op);
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll S;
    cin >> S;
    ll x1,y1,x2,y2,x3,y3;
    x1 = 0, y1 = 0;
    if(S == 1e18){
        x2 = 1e9;
        y2 = 0;
        x3 = 0;
        y3 = 1e9;
    }else{
        x2 = 1e9;
        y2 = 1;
        x3 = 1e9 - (S % (ll)1e9);
        y3 = (S + x3) / (ll)1e9;
    }
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    
}

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

int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  
  int xa=min(K,A);
  K-=xa;
  int xb=min(K,B);
  K-=xb;
  
  int count=xa-K;
  
  cout<<count<<endl;
    

}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
const LL INF=1e18;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    LL s=1;
    vector<LL> a(n);
    bool z=0;
    REP(i,n) {
        cin >> a[i];
        if ( a[i]==0 ) {
            z=1;
        }
    }
    if ( z ) {
        cout  << 0 << '\n';
        return 0;
    }
    sort(ALL(a));
    REP(i,n) {
        if ( log(s)+log(a[i])>log(INF) ) {
            cout << -1 << '\n';
            return 0;
        } 
        s*=a[i];
    }
    if ( s<=INF ) 
    cout << s << '\n';
    else 
    cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 3996
#include <cstdio>

int main(){
	int a1count = 0, a2count = 0, a4count = 0;

	int N,x;
	scanf("%d", &N);

	while(N != 0){
		scanf("%d", &x);
		if(x % 4 == 0)
			a4count++;
		else if(x % 2 == 0)
			a2count++;
		else
			a1count++;

		N--;
	}

	if(a2count > 0 && a1count <= a4count)
		printf("Yes\n");
	else if(a2count == 0 && a1count <= a4count + 1)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 256