akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl "\n";
#define lb lower_bound
#define ub upper_bound
const int mod = 1000000007;
using namespace std;
// const int N = 1e5 + 5; 
// int n;
// int a[N];

int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){

char pp;
cin >>pp;
if(pp >= 'a' && pp <='z'){
	cout << 'a' <<endl;
}
else if(pp >= 'A' && pp <= 'Z'){
	cout << 'A' <<endl;
}








}
return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <map>

#define Nmax int(1e5 + 5)
using namespace std;

typedef long long ll;
int N;
long long nr;
string s[Nmax];
map <string,ll> m;

int main()
{
    cin >> N;
    for(int i = 1; i <= N; ++i)
    {
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        m[s[i]]++;
    }
    for(map < string,ll>::iterator it = m.begin(); it != m.end(); ++it)
        nr += (it -> second)  * (it -> second - 1) / 2;
    cout << nr;
    return 0;
}


Measured memory_bytes: 18176
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, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
As=list(map(int,input().rstrip().split(" ")))
#A=list(reversed(As))
#print(As)
ans=[0 for i in range(n)]
for i in range(n//2,n):
    ans[i]=As[i]
#print(ans)
for j in range(n//2):
    k=n//2-j-1
    ball=0
    for l in range(2,n//(k+1)+1):
        ball+=ans[(k+1)*l-1]
        if ball%2==As[k]:
            ans[k]=0
        else:
            ans[k]=1
print(sum(ans))
for i in range(n):
    if ans[i]==1:
        print(i+1,end=" ")

Measured memory_bytes: 7504
while True:
  H,W=map(int,input().split())
  if (H,W)==(0,0):
    break
  for i in range(H):
    for j in range(W):
      if (i+j)%2 == 0:
        print("#",end='')
      else:
        print(".",end='')
    print()
  print()


Measured memory_bytes: 7008
#include <stdio.h>
int main() {

  int j,tmp,flag,N,count=0;

  //entering the number
  scanf("%d",&N);
  int A[N];

  for(j=0;j<N;j++) scanf("%d",&A[j]);
  //Here is end of entering


  //judgement
  flag=1;
  while (flag) {
    flag = 0;
    for (j = N-1; j>0; j--) {
      if (A[j] < A[j-1]) {
	tmp = A[j-1];
	A[j-1] = A[j];
	A[j] = tmp;
	flag = 1;
	count++;
      }
    }
  }

  for(j=0;j<N-1;j++)
    printf("%d ",A[j]);
  
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2140
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, K;

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

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

    int ans = 0;
    for (int k = 0; k <= min(K, N); k++) {
        // いったん、k個取る
        for (int i = 0; i <= k; i++) {
            // i個左から取る
            vi g(0);
            for (int j = 0; j < i; j++) {
                g.push_back(V[j]);
            }
            // k-i個右から取る
            for (int j = 0; j < k - i; j++) {
                g.push_back(V[N - j - 1]);
            }

            // いらない順
            sort(g.begin(), g.end());

            int s = 0, t = K - k;  // t個捨てれる
            for (int j = 0; j < k; j++) {
                if (g[j] < 0 && t > 0) {
                    t--;
                } else {
                    s += g[j];
                }
            }
            ans = max(ans, s);
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const int N = 305, mod = 1e9 + 7;
const int inf = 1e9;

void solve(int p){
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);//cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve(p);
    }
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>

using namespace std;

void Run(int&, int&, int&, int&);

int main(){
  int i, n, top, bottom, north, south, west, east;
  string str;

  while(1){
    cin >> n;
    if(n == 0) break;

    top = 1;
    bottom = 6;
    north = 2;
    south = 5;
    west = 3;
    east = 4;

    for(i=0; i<n; ++i){
      cin >> str;

      if(str == "south")
        Run(top, north, bottom, south);
      else if(str == "north")
        Run(top, south, bottom, north);
      else if(str == "east")
        Run(top, west, bottom, east);
      else if(str == "west")
        Run(top, east, bottom, west);
    }

    cout << top << endl;
  }

  return 0;
}

void Run(int& a, int& b, int& c, int& d){
  int e;
  e = a;
  a = b;
  b = c;
  c = d;
  d = e;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  sort(all(a));
  ll ans = 0;
  rep(i,n){
    for(int j = i+1;j < n;++j){
      int tmp = lower_bound(all(a),a[i]+a[j]) - a.begin() - 1;
      ans += tmp - j;
    }
  }
  print(ans);
  return 0;
}


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

long long a[100009], b[100009], n, E, F;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> b[i];
	for (int i = 1; i <= n; i++) {
		if (a[i] > b[i]) {
			E += a[i] - b[i];
		}
		if (a[i] < b[i]) {
			if ((b[i] - a[i]) % 2 == 0) {
				F += (b[i] - a[i]) / 2;
			}
			else {
				F += (b[i] - a[i] + 1) / 2;
				E++;
			}
		}
	}
	if (E > F) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

int n, a, b, c, d;
string s;
int main()
{
	int i;
	cin >> n >> a >> b >> c >> d >> s;
	s = '#' + s;
	for (i = b + 1; i <= d; i++) {
		if (s[i] == '#' && s[i - 1] == '#') {cout << "No" << endl; return 0;}
	}
	for (i = a + 1; i <= c; i++) {
		if (s[i] == '#' && s[i - 1] == '#') {cout << "No" << endl; return 0;}
	}
	if (a < b && c < d || a > b && c > d) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a < b && c > d) {
		for (i = b; i <= d; i++) {
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}
	if (a > b && c < d) {
		for (i = a; i <= c; i++) {
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}
    return 0;
}

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


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

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	int input[5] ;
	for(int i = 0 ; i < 5 ; ++i)
	{
		cin >> input[i] ; 
		if(input[i] == 0)
		{
			cout << (i + 1) ; 
			break ; 
		}
	} 
}



Measured memory_bytes: 3620
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/*Link Problem : */
/*Author : Althafa Dhia Syauqi */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef uint64_t uint64;
typedef int64_t  int64;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define MAX 100009
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll stone[MAX],q,dp[MAX];
int main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	gunakan saat OJ membutuhkan file eksternal */
	optimization();
	cin >> q;
	for(int i=1;i<=q;i++)
        cin >> stone[i];
    dp[1]=0;
    for(int i=2;i<=q;i++)
    {
        if(i>2)
            dp[i]=min(dp[i-1]+abs(stone[i]-stone[i-1]),abs(dp[i-2]+abs(stone[i]-stone[i-2])));
        else
            dp[i]=abs(stone[i]-stone[i-1]);
    }
    cout << dp[q]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include <assert.h>

int main(void){
		int a,b,c;
		int tmp;

		scanf("%d",&a);
		scanf("%d",&b);
		scanf("%d",&c);

		tmp = b;
		int tmp2 = c;
		b = a;
		a = tmp;
		c = a;
		a = tmp2;


printf("%d %d %d\n",a,b,c);

		return 0;
}


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

int main() {
  vector<vector<int>> a(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  bool ans = false;
  if (a.at(0).at(1) - a.at(0).at(0) == a.at(1).at(1) - a.at(1).at(0)
      && a.at(0).at(1) - a.at(0).at(0) == a.at(2).at(1) - a.at(2).at(0)) {
    if (a.at(0).at(2) - a.at(0).at(1) == a.at(1).at(2) - a.at(1).at(1)
        && a.at(0).at(2) - a.at(0).at(1) == a.at(2).at(2) - a.at(2).at(1)) {
      ans = true;
    }
  }
  
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

constexpr int N = 524288;
ll v[N], w[N];
using vpl = vector<pair<ll, ll>>;
vpl x, y, zz;

void op(vpl &z, int a, int k){
	z.clear();
	z.EB(0, 0);
	REP(i, k){
		zz.clear();
		int b = a >> i;
		auto it = z.begin();
		for(auto [ww, vv] : z){
			while(it != z.end() && it->first + w[b] < ww){
				zz.EB(it->first + w[b], it->second + v[b]);
				it++;
			}
			zz.EB(ww, vv);
		}
			while(it != z.end()){
				zz.EB(it->first + w[b], it->second + v[b]);
				it++;
			}
		swap(z, zz);
	}
	// REP(h, (1<<k)){
	// 	ll vv = 0, ww = 0;
	// 	REP(i, k){
	// 		if(h & (1<<i)){
	// 			vv += v[a>>i];
	// 			ww += w[a>>i];
	// 		}
	// 	}
	// 	z.EB(ww, vv);
	// }
	sort(ALL(z));
	DEBUG(" (%d, %d):\n", a, k);
	for(auto [ww, vv] : z) DEBUG("    %lld %lld\n", ww, vv);
}

int main(){
	int n;  scanf("%d", &n);
	FOR(i, 1, n+1) scanf("%lld%lld", v+i, w+i);
	int q; scanf("%d", &q);
	REP(iq, q){
		int a; ll l; scanf("%d%lld", &a, &l);
		int k = 32 - __builtin_clz(a);
		DEBUG("Q: %d %lld %d\n", a, l, k);
		op(x, a, k/2);
		op(y, a>>(k/2), k-k/2);
		
		FOR(i, 1, (int)y.size())
			LAR(y[i].second, y[i-1].second);

		ll ans = 0;
		int j = y.size() - 1;
		for(auto [ww, vv] : x){
			if(ww > l) break;
			while(y[j].first + ww > l) j--;
			LAR(ans, vv + y[j].second);
		}

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





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

int par[10000], cnt;

int find(int x) {
	if (x == par[x])return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x); y = find(y);
	if (x == y)return;
	cnt--; par[x] = y;
}
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n*n)par[i] = i;
		cnt = n*n;
		rep(i, n*n) {
			int x, y; scanf("%d%d", &y, &x);
			unite(i, x*n + y);
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3220
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
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;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;

//トポロジカルソート 隣接リスト　頂点の入次数 頂点数 O(N+M)
vll topological_sort(vvll next, vll &indegree, ll N) {
    vll sorted_vertices;

    queue<ll> que;
    for (int i = 0; i < N; i++) {
        if (indegree[i] == 0) {
            que.push(i);
        }
    }

    while (que.empty() == false) {
        ll v = que.front();
        que.pop();

        for (ll i = 0; i < next[v].size(); i++) {
            ll u = next[v][i];
            indegree[u] -= 1;
            if (indegree[u] == 0) que.push(u);
        }
        sorted_vertices.push_back(v);
    }

    return sorted_vertices;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    vll A(N-1+M),B(N-1+M);
    vvll next(N);
    vll indegree(N,0);
    for(ll i=0;i<N-1+M;i++){
        cin>>A[i]>>B[i];
        A[i]--;B[i]--;
        next[A[i]].push_back(B[i]);
        indegree[B[i]]++;
    }
    
    vll sorted=topological_sort(next, indegree, N);
    
    vll ans(N,0);
    
    for(ll i=0;i<N;i++){
        for(ll j=0;j<next[sorted[i]].size();j++){
            ans[next[sorted[i]][j]]=sorted[i]+1;
        }
    }
    for(ll i=0;i<N;i++){
        printf("%lld\n",ans[i]);
    }
    
    return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> r(N,0);
  for(int i=0;i<M;++i){
    int a,b;
    cin >> a >> b;
    ++r.at(a-1); ++r.at(b-1);
  }
  for(int i=0;i<N;++i){
    cout << r.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;

 ll findGCD(ll a, ll b)
{
    if(a == 0) return b;
    findGCD(b % a, a);
}


ll countb(ll x, ll c, ll d){
	//numbers div by c (or d) in range x
	ll numa = x/c;
	ll numb = x/d;
	ll lcm= (c*d)/__gcd(c, d);
	ll both = x/lcm;
	return (numa+numb)-both;	
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll a,b, c,d;
cin >> a >> b >> c >>d;
// range between a and b (inclusive)
ll ans = b-a+1;
ll ans1 = ans - (countb(b, c, d)- countb(a-1, c, d));
cout << abs(ans1);
return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
A, B = [], []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

friends = [-1] * (N+1)
number = [1] * (N+1)

for i in range(M):
    k = A[i]
    l = B[i]
    while True:
        if friends[k] == -1:
            break
        k = friends[k]

    while True:
        if friends[l] == -1:
            break
        l = friends[l]
    if k == l:
        continue
    if number[k] >= number[l]:
        friends[l] = k
        number[k] += number[l]
        number[l] = 0
    else:
        friends[k] = l
        number[l] += number[k]
        number[k] = 0

print(max(number))


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];

typedef unsigned int Hash1;
typedef unsigned short Hash2;
struct Hash{
  Hash1 first;
  Hash2 second;
  Hash():first(0),second(0){}
  Hash(Hash1 first,Hash2 second):first(first),second(second){}
};
bool operator==(const Hash &a,const Hash &b){
  return a.first==b.first && a.second==b.second;
}
const Hash1 b1 = 29;
const Hash2 b2 = 29;
const Hash2 m2 = 127;
const int MAX = 100001;
Hash hsh[MAX];
Hash bpow[MAX];

struct HashHash {
  size_t operator()(const Hash &yey) const {
    hash<int> hasher;
    return hasher((int)yey.first)^hasher((int)yey.second);
  }
};

unordered_set<Hash,HashHash> S;
int calc(int x){
  S.clear();
  REP(i,n-x+1){
    // substr
    int l = i;
    int r = l+x;
    Hash h(0,0);
    h.first += hsh[l].first;
    h.second+= hsh[l].second;
    h.first *= bpow[x].first;
    h.second*= bpow[x].second;
    // mod & negative
    h.first = -h.first;
    h.second= m2 - h.second%m2;
    h.first += hsh[r].first;
    h.second+= hsh[r].second;
    h.second= h.second%m2;
    S.insert(h);
  }
  return S.size();
}

int main(){
  scanf("%s",s);
  n = strlen(s);
  // create hash
  REP(i,n){
    int id = s[i]-'a';
    hsh[i+1].first = hsh[i].first*b1 + (Hash1)id;
    hsh[i+1].second= (hsh[i].second*b2+ (Hash2)id)%m2;
  }
  // base pow
  bpow[0] = Hash(1,1);
  REP(i,n){
    bpow[i+1].first = bpow[i].first*b1;
    bpow[i+1].second= bpow[i].second*b2%m2;
  }
  // go
  int low = 1, high = n;
  while(low+2<high){
    int ml = (low+high)/2;
    int mh = ml+1;
    if(calc(ml)<calc(mh)){
      low = ml;
    }else{
      high = mh;
    }
  }
  int ans = 0;
  FOR(i,low,high+1)CHMAX(ans,calc(i));
  printf("%d\n",ans);
  return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	string S;
	
	cin >> S;
	
	bool ans = true;
	
	rep(i, S.length()){
		if(i % 2 == 0 && S[i] == 'L')
			ans = false;
		else if(i % 2 == 1 && S[i] == 'R')
			ans = false;
	}
	
	if(ans)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}

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

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int x = scanner.nextInt();
        System.out.println(x>=30?"Yes":"No");
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

Measured memory_bytes: 32664
x1, y1, x2, y2 = [int(i) for i in input().split()]

x_diff = x2 - x1
y_diff = y2 - y1

x3 = x2 - y_diff
y3 = y2 + x_diff
x4 = x1 - y_diff
y4 = y1 + x_diff

print(x3, y3, x4, y4)
        

Measured memory_bytes: 2940
import sys

while (True):
    height, width = map(int, sys.stdin.readline().split())
    if (height!=0 and width!=0) :
        for i in range (height):
            if (i==0 or i==height-1) : print('#'*width)
            else :print('#'+'.'*(width-2)+'#')  
        print('')
    else : break
      


Measured memory_bytes: 5620
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back


const int N = 2e6 + 51 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

//gp_hash_table<int, int> table;

vi g[N];
int dp[N][2];

void dfs (int v, int p) {
    vi b;
    for (auto to : g[v]) {
        if (to == p) continue;
        b.pb(to);
        dfs(to, v);
    }
    dp[v][1] = dp[v][0] = 1;
    for (auto to : b) {
        dp[v][1] *= dp[to][0];
        dp[v][0] *= (dp[to][1] + dp[to][0]);
        dp[v][1] %= MOD, dp[v][0] %= MOD;
    }
}

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int l, r;
        cin >> l >> r;
        g[l].pb(r);
        g[r].pb(l);
    }
    dfs(1, -1);
    int ans = dp[1][1] + dp[1][0];
    ans %= MOD;
    cout << ans;
}


Measured memory_bytes: 63488
import sys
sys.setrecursionlimit(2**20)  # 再帰回数上限の向上 かなり多くしないとREになる


class Node:
    def __init__(self,
                 parent,
                 left,
                 right):
        self.parent = parent
        self.left = left  # 一番左の**子**ノードということに注意
        self.right = right


def get_depth(T: dict, u: int):
    '''
    Tは木の構造と見立てたdict
    uはTのノード
    '''
    d = 0
    while T[u].parent is not None:
        u = T[u].parent
        d += 1  # 親をたどりながらdを増やしていく。


D = {}  # 深さを保存しておく用のdict


def get_all_depth(T: dict, u: int, p: int):
    '''
    一度にすべてのノードの深さを取得する関数(再帰的に処理を行う)。
    一気に全体の深さを求めるならばこちらの方がオーダーが小さい。
    pは現在扱う深さ
    '''
    D[u] = p
    # ココらへんの動きは図を参照、ふさごとに深さ優先探索している感じ
    if T[u].right is not None:
        # 右の兄弟ノード(深さは同じ)から入れていく
        get_all_depth(T, T[u].right, p)
    if T[u].left is not None:
        # 兄弟を入れ終わったら次は下のふさへ
        get_all_depth(T, T[u].left, p+1)


def ret_children(T, u):
    chilren = []
    c = T[u].left
    while c is not None:
        chilren.append(c)
        c = T[c].right
    return chilren

# 答え出力用

def print_for_a_node(T: dict, node: int, D: dict):
    node_type = 'internal node' if T[node].left is not None else 'leaf'
    if T[node].parent is None:
        parent = -1
        node_type = 'root'
    else:
        parent = T[node].parent
    children = ret_children(T, node)

    print(
        f'node {node}: parent = {parent}, depth = {D[node]}, {node_type}, {children}')


# この問題は入力をNoneに適する形に整形するのも少し難しい
n = int(input())

T = {k: Node(None, None, None) for k in range(n)}  # pythonぽくないけど初期化
for _ in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] == 0:  # もし子ノードがなければ次へ
        continue
    T[tmp[0]].left = tmp[2]  # 一番左の子ノードは即座にわかる
    T[tmp[2]].parent = tmp[0]  # 子の親ノードも即座に与えられる
    prev_sibling = tmp[2]  # 前のノード番号を覚えておく用
    for sib in tmp[3:]:
        T[prev_sibling].right = sib
        T[sib].parent = tmp[0]  # 子から親を与えている
        prev_sibling = sib

for node in range(n):
    if T[node].parent is None:
        get_all_depth(T, node, 0)  # rootを入れなければいけないことに注意
        # Dに深さが入った
        break
for node in range(n):
    print_for_a_node(T,node,D)


Measured memory_bytes: 142160
#include <bits/stdc++.h>
using namespace std;
    
int main(){
    long long a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    long long l = abs(a-b);
    
    if((w-v) >= 0){
        cout << "NO" << endl;
    }
    else{
        if((v-w)*t >= l){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
}

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

//DP[Cantidad de Cifras][Posicion];
long long int DP[15];
long long int Array[15];
long long int P2[10];
long long int n;

long long int solve(long long int x){
	if (x==n){
		return 0;
	}
	long long int Sum=0;
	if (DP[x]!=-1) return DP[x];
	long long int Aux=0;
	for (int i = x; i < n; ++i)
	{
		Aux = Aux*10 + Array[i];
		Sum = Sum + ( P2[n-i-1]*Aux ) + solve(i+1);
	}
	DP[x]=Sum;
	return DP[x];
}

int main(){
	for (int i = 0; i < 15; ++i)
	{
		DP[i]=-1;
	}
	P2[0]=1;
	P2[1]=1;
	P2[2]=2;
	P2[3]=4;
	P2[4]=8;
	P2[5]=16;
	P2[6]=32;
	P2[7]=64;
	P2[8]=128;
	P2[9]=256;
	string A;
	cin >> A;
	n=A.length();
	for(int i=0 ; i<n ; i++){
		Array[i]=A[i]-'0';
	}
	cout << solve(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 200010


    
int main(){
	IOS;
	tihs;

	ll n,m,v,p;cin>>n>>m>>v>>p;
	ll a[n];
	rep(i,0,n)cin>>a[i];
	sort(a,a+n,greater<int>());
	ll ans=p;
	ll b[n];
	b[0]=a[0];
	rep(i,1,n)b[i]=b[i-1]+a[i];
	auto get=[&](ll i,ll j){
		ll ans=b[j];
		if(i)ans-=b[i-1];
		return ans;
	};
	rep(i,p,n){
		if(a[i]+m<a[p-1])continue;
		ll rem=m*v-m*p-m*(n-i-1),mx=a[i]+m;
		ll sum=get(p-1,i-1),terms=i-p+1;
		rem-=(mx*terms-sum);
		if(rem<=0)ans++;
	}
	cout<<ans;


	return 0;
}

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

#include <atcoder/all>

using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  dsu d(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    d.merge(a, b);
  }

  auto grp = d.groups();

  cout << grp.size() - 1 << endl;
}

Measured memory_bytes: 9008
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long l,r;
    cin >>l>>r;
    r = min(r, l+4038);
    int ans = 2018;
    for(long long i = l; i<=r;i++){
        for(long long j = i+1; j<=r; j++){
            int x = i*j%2019;
            ans=min(ans,x);
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const int MAXN = 200000;
int N, A, B, C;
/*
int N, M;

struct Edge {
    int to;
    int weight;
    int next;
};

vector<Edge> edges(MAXN);
vector<int> head(MAXN, -1);
vector<int> matchingx(MAXN, -1);
vector<int> matchingy(MAXN, -1);
vector<bool> check(MAXN);
vector<int> dis(MAXN);
vector<bool> vis(MAXN, false);

int cnt = 1;

void addEdge(int from, int to, int weight) {
    edges[cnt].to = to;
    edges[cnt].weight = weight;
    edges[cnt].next = head[from];
    head[from] = cnt++;
}

bool dfs(int u) {
    for (int i = head[u]; i != -1; i = edges[i].next) {
        int v = edges[i].to;
        if (!check[v]) {
            check[v] = true;
            if (matchingy[v] == -1 || dfs(matchingy[v])) {
                matchingy[v] = u;
                matchingx[u] = v;
                return true;
            }
        }
    }
    return false;
}

int hungarian() {
    int ans = 0;
    fill(matchingx.begin(), matchingx.end(), -1);
    fill(matchingy.begin(), matchingy.end(), -1);
    for (int u = 1; u <= N; ++u) {
//        if (matchingx[u] == -1) {
        {
            fill(check.begin(), check.end(), false);
            if (dfs(u)) {
                ++ans;
            }
        }
    }
    return ans;
}

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<>> que;
    fill(dis.begin(), dis.end(), INF);
    dis[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int u = p.second;
        if (vis[u]) continue;
        vis[u] = true;
        for (int i = head[u]; i != -1; i = edges[i].next) {
            int v = edges[i].to;
            if (dis[v] > dis[u] + edges[i].weight && !vis[v]) {
                dis[v] = dis[u] + edges[i].weight;
                que.push(P(dis[v], v));
            }
        }
    }
}

struct TreeNode {
    int val;
    TreeNode* left = nullptr;
    TreeNode* right = nullptr;
    TreeNode(int val_) : val(val_) {}
};
*/
int dfs(int cur, int a, int b, int c, const vector<int> &nums) {
    if (cur >= N) {
        return (min({a, b, c}) > 0 ? (abs(a - A) + abs(b - B) + abs(c - C) - 30) : INF);
    }
    int ret0 = dfs(cur + 1, a, b, c, nums);
    int ret1 = dfs(cur + 1, a + nums[cur], b, c, nums) + 10;
    int ret2 = dfs(cur + 1, a, b + nums[cur], c, nums) + 10;
    int ret3 = dfs(cur + 1, a, b, c + nums[cur], nums) + 10;
    return min({ret0, ret1, ret2, ret3});
}

int main() {
    cin >> N >> A >> B >> C;
    vector<int> nums(N);
    for (int i = 0; i < N; ++i) {
        cin >> nums[i];
    }
    cout << dfs(0, 0, 0, 0, nums) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=100005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n;

int main(){
	Init();
	ll res=0;
	cin>>n;
	for(int i=1;3*i<=n;i++) (res+=nCk(i+n-3*i-1,i-1))%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define shalaby ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(0);
///#define mod 1e9+7
using namespace std;

inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
 ll mod=1e9+7;
const int OO=-1e6;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
////////////////////////////////////////////////////////////////////////////////////

ll mem[100005][3],a[200005],b[105],n,m,k;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
void init()
{
    memset(mem,-1,sizeof mem);
}

/////////////////////////////////////////////////////////////////////




int main()
{
    init();
    int T=1;
///   T=D();
    while(T-->0)
    {

        cin>>n;
        ll sum=0,ans=0,k;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        for(int i=0;i<n-2;i++)
        {
            sum-=a[i];
            k=((sum%mod)*(a[i]%mod))%mod;
            k%=mod;
            ans%=mod;
            ans+=k;
            ans%=mod;
        }
        k=((a[n-1]%mod)*(a[n-2]%mod))%mod;
         k%=mod;
            ans%=mod;
            ans+=k;
            ans%=mod;



cout<<ans;
    }
}


Measured memory_bytes: 7460
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Point
{
public:
    double x, y, z;
    double dist(const Point& p) const{
        return sqrt(pow(x-p.x, 2) + pow(y-p.y, 2) + pow(z-p.z, 2));
    }
};

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

    while(--n >= 0){
        vector<double> len(3);
        for(int i=0; i<3; ++i)
            cin >> len[i];

        int m;
        cin >> m;
        vector<Point> p(m);
        for(int i=0; i<m; ++i)
            cin >> p[i].x >> p[i].y >> p[i].z;

        double minDiff = DBL_MAX;
        pair<pair<int, int>, int> ret;
        for(int i=0; i<m; ++i){
            for(int j=0; j<m; ++j){
                if(j == i)
                    continue;
                for(int k=0; k<m; ++k){
                    if(k == i || k == j)
                        continue;
                    double len0 = p[j].dist(p[k]);
                    double len1 = p[k].dist(p[i]);
                    double len2 = p[i].dist(p[j]);
                    len1 *= len[0] / len0;
                    len2 *= len[0] / len0;
                    double diff = abs(len1 - len[1]) + abs(len2 - len[2]);
                    if(diff < minDiff){
                        minDiff = diff;
                        ret = make_pair(make_pair(i+1, j+1), k+1);
                    }
                }
            }
        }

        cout << ret.first.first << ' ' << ret.first.second << ' ' << ret.second << endl;
    }

    return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */

    static final long MOD = (long) (1e9 + 7);

    private static void getAns(MyScanner sc){
        char[] ar = sc.nn().toCharArray();
        int[] count = new int[26];
        for(char ch: ar) count[ch - 'A']++;

        ArrayList<Integer> list = new ArrayList<>();
        for(int in: count) if(in > 0) list.add(in);

        out.println(list.size() == 2 && list.get(0) == 2? "Yes": "No");

    }

    static class MyScanner{
        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
        }

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

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

        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc(){
            return nn().charAt(0);
        }

        int ni(){
            return Integer.parseInt(nn());
        }

        long nl(){
            return Long.parseLong(nn());
        }

        double nd(){
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
        }

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
        }

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;


int main(){
    int x;cin >> x;
    for(int i=1;i<=360;++i){
        if(x * i % 360 == 0){
            cout << i << "\n";
            return 0;
        }
    }
}

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

int main(){
  int N,i;
  long long m,l,t;
  t = 1e18;
  cin >> N;
  vector<long long> a(N);
  m = 1;
  for(i=0;i<N;i++)
    cin >> a[i];
  sort(a.begin(),a.end());
  for(i=0;i<N;i++){
    if (a[i] == 0){
      m = 0;
      break;
    }
    if (m > t/a[i]){
      m = -1;
      break;
    }
    m *= a[i];
  }
  cout << m << endl;
}

Measured memory_bytes: 4032
N, M = map(int,input().split())
l=1
r=N
for i in range(M):
  L,R = map(int,input().split())
  l = max(l,L)
  r = min(r,R)
ans = r-l+1
if ans >= 0:
  print(ans)
else:
  print(0)
  

Measured memory_bytes: 9188
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 2620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
 
using namespace std;

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

    int A, B;
    int first;
    int second;

    cin >> A >> B;

    if(A > B)
    {
        cout << A * 2 - 1;
    } else if(A == B)
    {
        cout << A * 2;
    } else {
        cout << B * 2 - 1;
    }
}

Measured memory_bytes: 888
{-# OPTIONS_GHC -Wall #-}

readInt :: String -> Int
readInt = read

solve :: Int -> String
solve r
    | r < 1200  = "ABC"
    | r < 2800  = "ARC"
    | otherwise = "AGC"

main :: IO ()
main = do
    r <- fmap readInt getLine

    let ans = solve r

    putStrLn ans


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


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

  vector<int> v(101);
  v[1] = 0;
  for (int i = 2; i <= 100; ++i) {
    int j = i;
    int count = 0;
    while (j % 2 == 0) {
      count++;
      j /= 2;
    }
    v[i] = count;
  }

  int ans = 1;
  for (int i = 1; i <= n; ++i) {
    if (v[ans] < v[i]) {
      ans = i;
    }
  }

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

Measured memory_bytes: 3624
word_list = []
s = input()
ls = len(s)
l, r = None, None
for i in range(ls-4):
    if s[i:i+5] in ["dream","erase"]:
        l = r
        r = i
        if l != None:
            word_list.append(s[l:r])
word_list.append(s[r:])
correct_word = ["dream", "dreamer", "erase", "eraser"]
word_list = [ i in correct_word for i in word_list ]
if all(word_list):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 41456
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void solve(int N, int M, vector<vector<int>> vec, vector<int> p);

void solve(int N, int M, vector<vector<int>> vec, vector<int> p) {
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bool ok = true;
    for (int j = 0; j < M; j++) {
      int cnt = 0;
      for (int x : vec[j]) {
        if ((i >> x) & 1) {
          cnt += 1;
        }
      }
      if (cnt % 2 != p[j]) {
        ok = false;
      }
    }
    if (ok) {
      ans += 1;
    }
  }
  cout << ans << endl;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    vec[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> vec[i][j];
      vec[i][j] -= 1;
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  solve(N, M, vec, p);
  return 0;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

b_counter = [0]
for _b in b :
    b_counter.append(b_counter[-1]+_b)

res = 0
cur = 0
for i in range(N+1):    
    left = K-cur
    _i = 0
    _j = len(b_counter)-1
    while _i < _j :
        m = (_i+_j+1)//2
        if b_counter[m] <= left :
            _i = m
        else :
            _j = m-1
    if b_counter[_i] <= left :
        res = max(i+_i, res)

    if i == N : break 
    cur += a[i]

print(res)

Measured memory_bytes: 40684
s = input()
if len(s) % 2 == 1:
    print("No")
else:
    for i, e in enumerate(s[:len(s) // 2]):
        rev = s[-i - 1]
        if e == "b" and rev != "d":
            break
        elif e == "d" and rev != "b":
            break
        elif e == "p" and rev != "q":
            break
        elif e == "q" and rev != "p":
            break
    else:
        print("Yes")
        exit()
    print("No")


Measured memory_bytes: 3188
#include<cstdio>
#include<numeric>
using namespace std;

double p[3010];
double f[3010][3010]={1};

int main(){
	int N;
	scanf("%d\n",&N);
	for(int i=1;i<=N;i++) scanf("%lf",p+i);
	
	for(int i=1;i<=N;i++){
		f[i][0]=f[i-1][0]*(1-p[i]);
		for(int j=1;j<=i;j++) f[i][j]=f[i-1][j]*(1-p[i])+f[i-1][j-1]*p[i];
	}
	return printf("%.9f\n",accumulate(f[N]+((N+1)>>1),f[N]+N+1,.0))&0;
}

Measured memory_bytes: 46336