akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl

const ll INF=1e15+7;
const ll N = 100003;
vector <ll> nxt[N];
bool did[N];
vector <ll> road;
ll n,a,b;
ll ansf=0,ansn=0;

void fromxton(ll x){
	road.pb(x);
	did[x]=true;
	if(did[n]==true)return;
	FOR(i,0,nxt[x].size()){
		if(did[nxt[x][i]]==false){
			fromxton(nxt[x][i]);
		}
		if(did[n]==true)return;
	}
	did[x]=false;
	road.pop_back();
}

void kazoeruf(ll x){
	if(road.size()%2==1&&x==road[road.size()/2+1])return;
	if(road.size()%2==0&&x==road[road.size()/2])return;
	ansf++;
	did[x]=true;
	FOR(i,0,nxt[x].size()){
		if(did[nxt[x][i]]==false){
			kazoeruf(nxt[x][i]);
		}
	}
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	FILA(did,N,false);
	FOR(i,0,n-1){
		cin>>a>>b;
		nxt[a].pb(b);
		nxt[b].pb(a);
	}
	fromxton(1);
	FILA(did,N,false);
	kazoeruf(1);
	if((n-ansf)<ansf){
		pri("Fennec");
	}else{
		pri("Snuke");
	}

	return 0;
}


Measured memory_bytes: 9844
#include "bits/stdc++.h"
using namespace std;

int main(){
	string a,b,c;
	cin>>a>>b>>c;
	
	int ap=0;
	int bp=0;
	int cp=0;
	
	int flag=0;
	
	while(1){
		if(flag==0){
			if(a.size()==ap){
			cout<<"A"<<endl;
			return 0;
		}
			if(a[ap]=='b'){
				flag=1;
			}else if(a[ap]=='c'){
				flag=2;
			}
			ap++;
		}else if(flag==1){
			if(b.size()==bp){
			cout<<"B"<<endl;
			return 0;
		}
			if(b[bp]=='a'){
				flag=0;
			}else if(b[bp]=='c'){
				flag=2;
			}
			bp++;
		}else if(flag==2){
			if(c.size()==cp){
			cout<<"C"<<endl;
			return 0;
		}
			if(c[cp]=='a'){
				flag=0;
			}else if(c[cp]=='b'){
				flag=1;
			}
			cp++;
		}
		
		
		
		
	}
	
	
	return 0;
}

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

class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Split(' ');
        if (int.Parse(s[0]) <= 8 && int.Parse(s[1]) <= 8)
            Console.WriteLine("Yay!");
        else
            Console.WriteLine(":(");

    }
}

Measured memory_bytes: 13140
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a <= 5 {
		fmt.Println("0")
	} else if a <= 12 {
		fmt.Printf("%v\n", b/2)
	} else {
		fmt.Printf("%v\n", b)
	}
}


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

int main() {
    int N,A,B;
    cin >> N >> A >> B;
    char S[N];
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    int c=1;
    int b=0;
    for(int i=0;i<N;i++){
        if(S[i]=='a'){
            if(c<=A+B){
                c++;
                cout << "Yes"<<endl;
            }
            else{
                cout << "No"<<endl;
            }

        }
        else if(S[i]=='b'){
            b++;
            if(c<=A+B && b<=B){
                c++;
                cout << "Yes"<<endl;
            }
            else{
                cout << "No"<<endl;
            }
        }
        else{
            cout << "No"<<endl;
        }
    }
}

Measured memory_bytes: 768
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx1 = x2 - x1, dy1 = y2 - y1;
	int x3, y3, x4, y4;
	x3 = x2 - dy1;
	y3 = y2 + dx1;
	x4 = x1 - dy1;
	y4 = y1 + dx1;
	cout << x3 << " " << y3  << " " << x4 << " " << y4 << "\n";

	return 0;
}

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

void solve()
{
    int n;
    cin>>n;
    int h[n+5];
    for(int i=0;i<n;i++)
        cin>>h[i];
    int dp[n+5];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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

using namespace std;

void solve() {
	int l,r,d;
	cin>>l>>r>>d;
	int count=0;
	for(int i=l;i<=r;i++) {
		if(i%d==0) count++;
	}
	cout<<count<<endl;
}

int main() {
//	freopen("input.txt","r",stdin);
	int t=1;
	//cin>>t;
	while(t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;


public class Main {

	static Scanner sc;
	static int num;
	static int dp[] = new int[31];
	
	public static void main(String[] args) {
		
		dp[1]=1;
		dp[2]=2;
		dp[3]=4;
		
		for(int i=4; i<=30; i++){
			dp[i]=dp[i-1] + dp[i-2] + dp[i-3];
		}
		
		sc = new Scanner(System.in);
		
		new Main();
	}
	
	Main(){
		
		while (sc.hasNext()) {
			
			num = sc.nextInt();;
			
			if(num==0) break;
			
			System.out.println((dp[num]/3650)+1);
		}	
	}
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    string t; cin >> t;
    rep(i, t.size()) if(t[i]=='?') t[i] = 'D';
    out(t);
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

void solve(){
  int n, k; cin >> n >> k;
  vector<int> v(n);
  for(int i = 0; i < n; i++) cin >> v[i];
  int minv = v[0 + k - 1] - v[0] + abs(v[0]);
  for(int i = 1; i < n - k + 1; i++){
    minv = min(v[i + k - 1] - v[i] + abs(v[i]), minv);
  }
  for(int i = n - 1; i >= k - 1; i--){
    minv = min(v[i] - v[i - k + 1] + abs(v[i]), minv);
  }
  cout << minv << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
# input
a = int(input())
num = list(map(int,input().split(" ")))
# Odd or Even
counter = 0
while True:
    b = list(map(lambda x: x % 2, num))
    if b.count(0) == a:
        num = list(map(lambda x: x/2, num))
        counter += 1
    else:
        print(counter)
        break


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <memory>
#include <array>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using point = complex<double_t>;
void print(const point p){
  cout<<real(p)<<' '<<imag(p)<<'\n';
}
const point rota = polar(1.0, M_PI/3.0);
void koch(const point first, const point last, size_t n){
  if(n==0) print(first);
  else{
    point mid1 = first+(last-first)/3.0;
    point mid3 = first+(last-first)*2.0/3.0;
    point mid2 = mid1+(mid3-mid1)*rota;
    koch(first, mid1, n-1);
    koch(mid1, mid2, n-1);
    koch(mid2, mid3, n-1);
    koch(mid3, last, n-1);
  }
}
int32_t main(){
  size_t n; cin>>n;
  const point first(0, 0), last(100, 0);
  koch(first, last, n);
  print(last);
}


Measured memory_bytes: 3264
/*
 * Problem     : AOJ1167
 * Title       : Pollock's conjecture (ポロック予想)
 * Author      : mizo0203
 * Language    : C++
 * Copyright   : Your copyright free
 * Description : 動的計画法
 */
#include <stdio.h>
#include <algorithm>

using namespace std;

int n;
int dp1[1000000];
int dp2[1000000];

void init() {
  int i, j;
  int tmp, cnt;

  tmp = 1;
  cnt = 1;
  while (tmp < 1000000) {
    //printf("%d\n", tmp);
    dp1[tmp] = 1;
    if (tmp % 2 == 1)
      dp2[tmp] = 1;
    cnt++;
    for (i = 1; i <= cnt; i++) {
      tmp += i;
    }
  }
  /*
   for (i = 500000; i > 0; i--) {
   if (!dp[i])
   continue;
   for (j = 1; i * j < 1000000; j++) {
   if (!dp[i * j] || dp[i * j] > dp[i] * j) {
   dp[i * j] = dp[i] * j;
   }
   }
   }
   */

  for (i = 1; i < 1000000; i++) {
    if (dp1[i] == 1) {
      for (j = i; i + j < 1000000; j++) {
        if (!dp1[i + j] || dp1[i + j] > dp1[i] + dp1[j])
          dp1[i + j] = dp1[i] + dp1[j];
      }
      if (dp2[i] == 1)
        for (j = i; i + j < 1000000; j++) {
          if (!dp2[i + j] || dp2[i + j] > dp2[i] + dp2[j])
            dp2[i + j] = dp2[i] + dp2[j];
        }
    }
  }
/*
  for (i = 1; i < 1000000; i++) {
    printf("%d\n", dp1[i]);
  }
  */
  //printf("%d\n", cnt);

}

bool input() {
  //int i;

  scanf("%d", &n);
  if (!n)
    return false;

  return true;
}

int main() {

  init();
  while (input()) {
    printf("%d %d\n", dp1[n], dp2[n]);
  }
  return 0;
}

Measured memory_bytes: 8444
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  sort(all(a));
  int x = a.back();
  auto lb = lower_bound(all(a), x/2);
  int y = *lb;
  lb--;
  int z = *lb;

  double diffy = y - x/2.0;
  double diffz = x/2.0 - z;
  int ans;
  if (diffy < diffz) {
    ans = y;
  } else {
    ans = z;
  }
  printf("%d %d\n", x, ans);

  return 0;
}


Measured memory_bytes: 640
# C - Linear Approximation

N = int(input())
A = list(int(a) for a in input().split())


A_diff = []
b = 0
for i, a in enumerate(A, 1):
    tmp = a - i
    A_diff.append(tmp)

A_diff.sort()
b = A_diff[N//2]

ans = 0
for a in A_diff:
    ans += abs(a - b)

print(ans)

Measured memory_bytes: 30920
n=gets
an=gets.split(" ")
an=an.map{|n| n.to_i}


#軽くする処理が必要
#0があったら
#1があったら
#でかい数字があったら

if an.delete(0)
  p 0
  exit
end
an.delete(1)

sum=1
for a in an
  sum*=a
  if sum > 1000000000000000000
    p -1
    exit
  end
end
p sum


Measured memory_bytes: 21640
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
ll now,ans=1,K,n,k;
vector<ll> neg,pos,zero;
vector<pair<ll,ll> > li;
int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>k;
  K = k;
  for(int i = 1;i <= n;i++){
    cin>>now;
    if(now > 0){
      pos.push_back(now);
      li.push_back({now,1});
    }
    else if(now < 0){
      neg.push_back(abs(now));
      li.push_back({abs(now),-1});
    }
    else{
      zero.push_back(now);
      li.push_back({now,1});
    }    
  }
  sort(pos.begin(),pos.end());
  sort(neg.begin(),neg.end());
  sort(li.begin(),li.end());
  int sp = pos.size()-1;
  int sn = neg.size()-1;
  if(k&1){
    if(pos.size()){
      ans = pos[sp];
      sp--;
      k--;
    }
  }
  while(k and (sp > 0 or sn > 0)){
    ll a = -inf,b = -inf;
    if(sp >= 1){
      a = pos[sp]*pos[sp-1];
    }
    if(sn >= 1){
      b = neg[sn]*neg[sn-1];
    }
    if(a > b){
      ans = (ans*(a%mod))%mod;
      k -= 2;
      sp -= 2;
    }
    else{
      ans = (ans*(b%mod))%mod;
      k -= 2;
      sn -= 2;
    }
  }
  if(k){
    if(zero.size()){
      ans = 0;
    }
    else{
      ans = 1;
      for(int i = 0;i < K;i++){
	ans = ((ans)*(li[i].first*li[i].second)%mod+mod)%mod;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9268
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int p = sc.nextInt();
        int numOfOdd = 0;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (tmp % 2 == 1) {
                numOfOdd++;
            }
        }

        if (numOfOdd == 0) {
            System.out.println(p == 0 ? (long)Math.pow(2, n): 0);
            return;
        }

        System.out.println((long)Math.pow(2, n - 1));
    }
}

Measured memory_bytes: 21972
object Main extends App {

  // 入力値から座標の配列を生成
  def generateCoordinates: Array[Array[Int]] = {
    var coordinates = scala.collection.mutable.ListBuffer.empty[Array[Int]]
    io.Source.stdin.getLines().zipWithIndex.foreach {
      case (line, index) if index != 0  =>
        val coordinate = line.split(" ").map(_.toInt)
        coordinates += coordinate
      case _ =>
    }
    coordinates.toArray
  }

  def isIntegerDistance(a1: Array[Int], a2: Array[Int]): Boolean = {
    val squareSum = a1.zip(a2).map {
      case (p1, p2) =>
        val diff = math.abs(p1 - p2)
        diff * diff
    }.sum
    val d = math.sqrt(squareSum)
    d == d.toInt
  }

  val coordinates = generateCoordinates
  val lastCoordinateIndex = coordinates.size - 1
  var result: Int = 0

  coordinates.zipWithIndex.foreach {
    case (c, selfIndex) =>
      var targetIndex = selfIndex + 1
      while (targetIndex <= lastCoordinateIndex) {
        val t = coordinates(targetIndex)
        if (isIntegerDistance(c, t)) result += 1
        targetIndex += 1
      }
  }

  println(result)

}


Measured memory_bytes: 25560
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int n,m,h,k;
int s[1001];
int lef[100001];
int righ[100001];
int now[1001];
int num[1001];
vector<P> vec;
int main()
{
	while(1)
	{
		memset(s,0,sizeof(s));
		memset(lef,0,sizeof(lef));
		memset(righ,0,sizeof(righ));
		memset(now,0,sizeof(now));
		memset(num,0,sizeof(num));
		vec.clear();
		cin >> n >> m >> h >> k;
		if(n==0&&m==0&&h==0&&k==0)break;
		for(int i=0;i<n;i++)
		{
			cin >> s[i];
		}
		for(int i=0;i<m;i++)
		{
			int a,b;
			cin >> a >> b;
			vec.pb(P(b,a-1));
		}
		SORT(vec);
		for(int i=0;i<n;i++)
		{
			now[i]=i;
		}
		for(int i=0;i<vec.size();i++)
		{
			lef[i]=now[vec[i].sec];
			righ[i]=now[vec[i].sec+1];
			swap(now[vec[i].sec],now[vec[i].sec+1]);

		}
		for(int i=0;i<n;i++)
		{
			num[now[i]]=i;
		}
		int ans=0;
		int mx;
		for(int i=0;i<k;i++)
		{
			ans+=s[num[i]];
		}
		mx=ans;
		for(int i=0;i<m;i++)
		{
			if(lef[i]<k&&righ[i]>=k)
			{
				ans=min(ans,mx+s[num[righ[i]]]-s[num[lef[i]]]);
			}
			else if(lef[i]>=k&&righ[i]<k)
			{
				ans=min(ans,mx+s[num[lef[i]]]-s[num[righ[i]]]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2904
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n, m;
vector<int> vege;

const int INF = 1 << 29;

int main(void)
{
	//0111111 0000110 1011011 1001111 1100110 1101101 1111101 0100111 1111111 1101111
	int memo[] = {127 - 64, 6, 64 + 16 + 8 + 2 + 1, 64 + 15, 64 + 32 +4 + 2,64+32+8+4+1,127-2, 32+7,127,127-16 };
	int nisin[] = {64, 32, 16, 8, 4, 2, 1};
	while(cin >> n && n != -1)
	{
		int bit = 0;
		for (int i = 0; i < n; i++)
		{
			int a;
			cin >> a;
			int ans = bit ^ memo[a];
			bit = memo[a];
			for (int j = 0; j < 7; j++)
			{
				if(ans >= nisin[j])
				{
					ans -= nisin[j];
					cout << 1;
				}
				else cout << 0;
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
#define PI 3.14159265358979323846
int main()	{
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double omegaA=2*PI*((h*60)+m)/(60*12);
  double omegaB=2*PI*m/60;
  double omdiff=abs(omegaA-omegaB);
  double ans=sqrt(a*a+b*b-2*a*b*cos(omdiff));
  cout<<fixed<<setprecision(9)<<ans<<endl;
}

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

int main() {
    int n;
    cin >> n;
    int S[n + 1];
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }
    int q;
    cin >> q;
    int T[q + 1];
    for (int i = 0; i < q; i++) {
        cin >> T[i];
    }

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

    cout << c << endl;

    return 0;
}



Measured memory_bytes: 3072
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll total_result = a[0];
  for (int i = 1; i < N; i++) {
    total_result ^= a[i];
  }
  if (total_result == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
struct s{
  int num;
  char moji;
  int key;
};
struct s A[100001];
int Partition(int,int);
void Quicksort(int,int);
main(){
  char c1,c2,c3;
  int n;
  int i,a,b=0;
  scanf("%d%c",&n,&c1);
  for(i=0;i<n;i++){
    scanf("%c%c%d%c",&A[i].moji,&c2,&A[i].num,&c3);
    A[i].key=i;
  }
  a = Partition(0,n-1);
  Quicksort(0,n-1);
  for(i=0;i<n;i++){
    if(A[i].key>A[i+1].key && A[i].num==A[i+1].num){
      b=1;
      break;
    }
  }
  if(b==0) printf("Stable\n");
  if(b==1) printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].moji,A[i].num);
  }
  return 0;
}
 
int Partition(int p,int r){
  int i,j;
  struct s x,tmp;
  x.num=A[r].num;
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].num<=x.num){
      i=i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}
 
void Quicksort(int p,int r){
  int q;
  if(p<r){
    q=Partition(p,r);
    Quicksort(p,q-1);
    Quicksort(q+1,r);
  }
}

Measured memory_bytes: 1780
//
//  main.cpp
//  equeue
//
//  Created by Dong Truong on 5/31/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;
#define maxn 1000

int n,k,a[maxn];
vector <int> g,p,q;

void nhap()
{
    cin>>n>>k;
    for (int i=1;i<=n;++i) cin>>a[i];
}
void gan(vector <int> &a,vector <int> &b)
{
    a.clear();
    for (int i=0;i<b.size();++i)
        a.push_back(b[i]);
}
bool cmp(int a,int b)
{
    return a>b;
}
int sum(vector <int> &q)
{
    int s=0;
    for (int i=0;i<q.size();++i)
        s+=q[i];
    return s;
}
void sol()
{
    int kq=-1e9;
    for (int i=0;i<=min(k,n);++i)
    {
        int sl=k-i;
        if (i>0) g.push_back(a[i]);
        gan(p,g);
        for (int j=n+1;j>max(n-sl,i);--j)
        {
            if (j!=n+1) p.push_back(a[j]);
            gan(q,p);
            sort(q.begin(),q.end(),cmp);
            int o=0,sl2=sl-n-1+j;
            while (!q.empty() && q.back()<0 && sl2>o)
            {
                q.pop_back();
                ++o;
            }
            kq=max(kq,sum(q));
        }
    }
    cout<<kq;
}
int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
    //freopen("a.inp","r",stdin);
    nhap();
    sol();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))
idx = L.index(max(L))
sum_L = 0
for i in range(len(L)):
    if i == idx:
        pass
    else:
        sum_L += L[i]

if L[idx] < sum_L:
    print('Yes')
else:
    print('No')
    

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

using namespace std;
void dijkstra(int start, vector<int> &costs,
              unordered_map<int, vector<int>> &edges) {
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      q;
  costs[0] = start;
  q.push(make_pair(0, start));
  while (!q.empty()) {
    auto v = q.top();
    q.pop();
    for (auto &e : edges[v.second]) {
      if (v.first + 1 < costs[e]) {
        costs[e] = v.first + 1;
        q.push(make_pair(costs[e], e));
      }
    }
  }
}

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

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

  int ans = 0;
  for (int i = 0; i < m; ++i) {
    unordered_map<int, vector<int>> edges;
    for (int j = 0; j < m; ++j) {
      if (i == j)
        continue;
      edges[a[j]].emplace_back(b[j]);
      edges[b[j]].emplace_back(a[j]);
    }
    vector<int> costs(n, INT_MAX);
    dijkstra(0, costs, edges);

    for (int j = 0; j < n; ++j) {
      if (costs[j] == INT_MAX) {
        ++ans;
        break;
      }
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<functional>
#include<vector>
using namespace std;

#define ll long long
#define P pair<int,int>

int t[70000];
P p[70000];
int main(){
	int n;
	unsigned int ans=0;

	while(cin>>n,n!=0){
	for(int i=0;i<70000;i++)t[i]=0,p[i].first=0,p[i].second=0;
	for(int i=0;i<n;i++)cin>>t[i];
	for(int i=0;i<n-1;i++){
	int tmp;
	cin>>tmp;
	p[i]=P(tmp,i);//長さでソートして,iとi+1を継ぐパイプ
	}
	sort(&p[0],&p[0]+n,greater<pair<int,int> >());
	int sum=0,cnt=n;
	for(int i=0;i<n;i++)sum+=t[i];
	ans=sum*cnt;
	for(int i=0;i<n-1;i++){
	P tmp=p[i];
	sum+=p[i].first;
	cnt--;
	ans=max(ans,(unsigned int)sum*cnt);
	}
	cout<<ans<<endl;
	}
	return 0;
}

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

int check(int N){
  int x = 0;
  while (N > 0)
  {
    x += N % 10;
    N /= 10;
  }
  return x;
}

int main() {
  int N; cin >> N;
  int num = check(N);
  
  if(num == 1) {
    cout << 10 << endl;
  } else {
    cout << num << endl;
  }
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: i64 = itr.next().unwrap().parse().unwrap();
    let a: i64 = itr.next().unwrap().parse().unwrap();
    let b: i64 = itr.next().unwrap().parse().unwrap();

    if a > b || (n == 1 && a != b) {
        println!("0")
    } else if n == 1 {
        println!("1")
    } else {
        let mx = a + (n - 1) * b;
        let mn = a * (n - 1) + b;
        println!("{}", mx - mn + 1);
    }

    // a ~ b
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string O,E;
    cin >>O>>E;

    rep(i,O.size()){
        cout<<O[i];
        if(i<E.size()){
            cout<<E[i];
        }
    }
    
    cout << endl;


    return 0;
    

}

Measured memory_bytes: 3620
//Papers, Please

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    nvarep(n,a);
    rep(i,0,n){
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                cout<<"DENIED"<<nnn;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int

int main() {
  string s;
  ll ans = 0, w = 0;
  cin >> s;
  for ( int i = 0; i < s.length(); ++i ) {
    if ( s[i] == 'W' ){
      ans += i - w;
      ++w;  
    }  
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 952
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)
#define int long long

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

const int modp=1e+9+7;
int h,w;
char a[1010][1010];
int dp[1010][1010];

signed main() {
	cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
	
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(a[i][j]=='#'){
                dp[i][j]=0;
                continue;
            }
            if(i>0){
                dp[i][j]+=dp[i-1][j];
            }
            if(j>0){
                dp[i][j]+=dp[i][j-1];
            }
            dp[i][j]%=modp;
        }
    }

    cout<<dp[h-1][w-1]<<endl;
	
	return 0;
}


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

const int INF = 1 << 30;
int main(){
  int n;
  string s;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int ans=INF;
  for (int i=1;i < 100;i++){
    int cst=0;
    for (int j=0;j < n;j++){
      cst+=(v[j]-i)*(v[j]-i);
    }
    ans=min(ans,cst);
  }
  cout << ans << endl;
 
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;


int main() {
	const long long int mod = 1000000007;

	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int  n, m, a,b, c, d, k, h, w,left=1,right=0;
	long long int sc, sr, num2, no[1005][1005] = {},res=0,count=0;
	
	string str, t;

	cin >>n>>a>>b>>c>>d >>str;
	a--;
	b--;
	c--;
	d--;
	if (c < d) {
		for (int i = b + 1; i <= d - 2; i++) {
			if (str[i] == '#' && str[i + 1] == '#') {
				cout << "No";
				return 0;
			}
		}
		for (int i = a + 1; i <= c - 2; i++) {
			if (str[i] == '#' && str[i + 1] == '#') {
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
		return 0;
	}
	else {
		for (int i = b + 1; i <= d - 2; i++) {
			if (str[i] == '#' && str[i + 1] == '#') {
				cout << "No";
				return 0;
			}
		}
		for (int i = a + 1; i <= c - 2; i++) {
			if (str[i] == '#' && str[i + 1] == '#') {
				cout << "No";
				return 0;
			}
		}
		for (int i = b; i <= d; i++) {
			if (str[i - 1] == '.' && str[i] == '.' && str[i + 1] == '.') {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 640
L, R = map(int,input().split(' '))

flag = 0
min_ = 2020
for i in range(L,R):
    for j in range(i+1,R+1):
        s = (i*j) % 2019
        if s == 0:
            print('0')
            exit()
        if s < min_:
            min_ = s
print(min_)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c)
			System.out.println("Yes");
		else {
			System.out.println("No");
		}

	}
}

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

using namespace std;

int main()
{
	int m1, m2, d1, d2;

	int ans = 0;

	cin >> m1 >> d1 >> m2 >> d2;


	if (m1 != m2)
		ans = 1;


	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	int n;
	cin >> n;
	vector<ll> a(n);
	ll xo = 0;
	for ( ll &i : a){
		cin >> i;
		xo ^= i;
	}
		
	for ( int i = 0; i < n; i++){
		ll x = a[i] ^ xo;
		cout << x << ' ';
	}
	cout << endl;
	return 0;
}

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

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

    ll K, A, B;
    cin >> K >> A >> B;

    if (B - A <= 2) {
        cout << K + 1 << endl;
        exit(0);
    }
    ll ans = A;
    K -= A - 1;
    ans += (K / 2) * (B - A);
    K %= 2;
    ans += K;

    cout << ans << endl;

    return 0;
}

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

int main() {
  string s; cin >> s;
  set<char> u;
  rep(i,s.size()) {
    u.insert(s[i]);
  }
  rep(i,26) {
    if (u.count(char(97+i)) == 0) {
      cout << (char(97+i)) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 3728
#include<iostream>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;


int main () {
  int r, c, value, sum;
  int i, j;
  cin >> r >> c;
  int sheet[r+1][c+1];

  // input
  rep(i,r) {
    rep(j,c) {
      cin >> value;
      sheet[i][j] = value;
    }
  }

  // process1
  rep(i,r) {
    sum = 0;
    rep(j,c) { 
      sum += sheet[i][j];
    }
    sheet[i][c] = sum;
  }

  // process2
  rep(j,c+1) {
    sum = 0;
    rep(i,r) { 
      sum += sheet[i][j];
    }
    sheet[r][j] = sum;
  }

  // output
  rep(i,r+1) {
    rep(j,c+1) {
      cout << sheet[i][j];
      if (j < c) cout << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve(){
    int n;
    cin >> n;
    vector<float> v(n);
    for(int i = 0 ; i < n ; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 1 ; i < n ; i++){
        v[i] = ( v[i] + v[i - 1])/2;
    }
    cout << v.back() << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3792
#include<iostream>

using namespace std;

int main() {

	int n, k,h;

	cin >> n >> k;

	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> h;

		if (h >= k) sum++;


	}
	cout << sum << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define repi(i,n) for(int i=0; i<(n); i++)

int main() {
  int n, c1=0, c2=0, c3=0, c4=0;
  string s;
  cin >> n;
  
  repi(i,n) {
    cin >> s;
    if(s=="AC") c1++;
    else if(s=="WA") c2++;
    else if(s=="TLE") c3++;
    else if(s=="RE") c4++;
  }

  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", c1, c2, c3, c4);
  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int X; cin >> X;
    ATYN(X >= 30)

    return 0;
}

Measured memory_bytes: 3652
#import<cstdio>

int N, d[8 << 15], p[8 << 15], x, i;

main(){
    scanf("%d", &N);
    for(; i < N; d[x] = ++i)
        scanf("%d", &x);
    x = N;
    for(; --i; p[i] += p[i + 1])
        if(p[i + 1]){
            if((d[i] < d[i + 1]) ^ (d[i + 1] < d[x]) ^ (d[x] < d[i])){
                ++p[i];
                x = i + 1;
            }
        }else
            if(d[i] < d[i + 1])--x;
            else++p[i];
    printf("%d", p[1]);
}


Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
 int a,b;
 while(scanf("%d %d",&a,&b)!=EOF)
 {
   if(a==0&&b==0)break;
   else if(a>b)printf("%d %d\n",b,a);
   else printf("%d %d\n",a,b);
 }

 return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main(){
    ll H, W;
    cin >> H >> W;

   ll ans = H * W;
    ll s[3];
    for(int i=0; i<2; i++) {
        for(ll h = 1; h < H; h++) {
            //s[i], s[2]を縦に割る
            s[0] = h * W;
            s[1] = (H - h) * (W / 2);
            s[2] = H * W - (s[0] + s[1]);
            sort(s, s+3);
            ans = min(ans, s[2] - s[0]);

            //s[1], s[2]を横に割る
            s[0] = h * W;
            s[1] = ((H - h)/2) * W;
            s[2] = H * W - (s[0] + s[1]);
            sort(s, s + 3);
            ans = min(ans, s[2] - s[0]);
        }
        swap(H, W);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    vector<ll>vc;
    vc.push_back(a);
    vc.push_back(b);
    vc.push_back(c);
    sort(vc.begin(),vc.end());
    ll sum=0;
    for(int i=0;i<2;i++)
    {
        sum+=vc[i];
    }
    cout<<sum<<endl;
    return 0;
}



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

int main(){
        double w,h,x,y,z;
        cin >> w;
        cin >> h;
        cin >> x;
        cin >> y;
        z=w*h/2;
        printf("%.6f",z);
        cout<< " ";
    if (w/2==x && h/2==y){
            cout<<1<<endl;
        }else{
            cout<<0<<endl;
        }
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
//#define debug1 cout<<"?"<<endl;
//#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=3e5+9;
const double pi=acos(-1);
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);n++;
	printf("%d\n",n/2);
}

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


class Program {

	static long mod = 998244353;
	static int[] ans;
	static void Main(string[] args) {

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

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);
		

		long res = 0;
		long[] vals = parseAryL(Console.ReadLine().Split(cs));
		long low = vals[0];
		long high = vals[1];

		long c = ( high / vals[2] ) - ( (low-1) / vals[2] );
		long d = ( high / vals[3] ) - ( (low-1) / vals[3] );

		long vt = lcm(vals[2], vals[3]);
		long cd = ( high / vt ) - ( (low-1) / vt );

		long div = c + d - cd;

		res = high - low + 1 - div;

			Console.WriteLine(res);
				return;

	}


	static public long gcd(long a, long b) {
		if ( b == 0 ) { return a; }
		return gcd(b, a % b);
	}
	//	最小公倍数
	static long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}


}

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

#define ll long long
#define Max 100005
#define fastread  ios_base::sync_with_stdio(false),cin.tie(NULL);
int main()
{
//  fastread();

  ll n,k;

  cin>>n>>k;

  if(k==1 || n==k)cout<<0<<endl;
  else cout<<n-k<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

struct Edge {
  int to, id;
};

vector<vector<Edge>> graph;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1) {
  int k = 1;
  rep(i, graph[v].size()) {
    int u = graph[v][i].to, ei = graph[v][i].id;
    if (u == p) continue;
    if (k == c) k++;
    ans[ei] = k;
    k++;
    dfs(u, ans[ei], v);
  }
}

int main() {
  int n;
  cin >> n;
  graph.resize(n);
  ans.resize(n - 1);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(Edge{b, i});
    graph[b].push_back(Edge{a, i});
  }
  dfs(0);
  int mx = 0;
  rep(i, n) mx = max(mx, int(graph[i].size()));
  cout << mx << endl;
  rep(i, n - 1) cout << ans[i] << endl;
  return 0;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;cin>>n;
  map<ll,int>mp;
  ll a;
  bool flag=true;
  rep(i,n){
    cin>>a;
    auto itr = mp.find(a);
    if( itr != mp.end() ) {
      flag=false;
    } else {
      mp[a]=0;
    }
  }
  flag3func(flag);
}

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

int main() {
  string s;
  int count;
  cin >> s;
  for (int i = 0; i < 3; i++) {
  char c = s.at(i);
    if (c == '1') {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys


def main(argv=sys.argv):
  a, b = map(int, input().split())
  
  if (a * b) % 2 == 0:
    print('Even')
  
  else:
    print('Odd')
  
  return 0


if __name__ == '__main__':
  sys.exit(main())
  

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll A, B;
  cin >> A >> B;

  map<ll, int> cnt;

  for (ll i = 2; i * i <= A; i++) {
    if (A % i == 0) {
      cnt[i]++;
      while (A % i == 0) A /= i;
    }
  }
  if (A != 1) cnt[A]++;

  for (ll i = 2; i * i <= B; i++) {
    if (B % i == 0) {
      cnt[i]++;
      while (B % i == 0) B /= i;
    }
  }
  if (B != 1) cnt[B]++;

  ll ans = 1;
  for (auto x : cnt) {
    if (x.S == 2) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

LL dp[1009][1009];
LL f[1009],inv[1009];

LL expo(LL a,LL b){
	if(b==0)return 1;
	LL h=expo(a,b/2);
	h=(h*h)%MOD;
	if(b%2)h=(h*a)%MOD;
	return h;
}

LL nPk(int n,int k){
	return (f[n]*inv[n-k])%MOD;
}

int main(){
	f[0]=1;
	REPP(i,1,1009){
		f[i]=(f[i-1]*i)%MOD;
	}
	REP(i,1009)inv[i]=expo(f[i],MOD-2);
	DRIII(n,a,b);DRII(c,d);
	dp[a-1][0]=1;
	REPP(i,a,b+1){
		REP(j,n+1){
			dp[i][j]=dp[i-1][j];
			REPP(k,c,d+1){
				if(j<k*i)break;
				LL coeff=((nPk(j,k*i)*expo(inv[i],k))%MOD*inv[k])%MOD;
				dp[i][j]=(dp[i][j]+(dp[i-1][j-k*i])*coeff)%MOD;
			}
		}
	}
	/*REPP(i,a-1,b+1){
		REP(j,n+1){
			printf("%lld ",dp[i][j]);
		}puts("");
	}*/
	printf("%lld",dp[b][n]);
}


Measured memory_bytes: 8192