akhauriyash/Code-Regression huggingface dataset:
#coding:utf-8
#1_7_B
class Node():
    def __init__(self, node_id):
        self.node_id    =   node_id
        self.parent     =   -1
        self.sibling    =   -1
        self.degree     =   0
        self.depth      =   0
        self.height     =   0
        self.typ        =   'root'
        self.children   =   []

    def set_parent(self, child):
        child.parent = self.node_id
        self.degree += 1
        self.children.append(child)

        if child.degree:
            child.typ = 'internal node'
        else:
            child.typ = 'leaf'

        if self.parent != -1:
            self.typ = 'internal node'

    def set_sibling(self, sibling):
        self.sibling = sibling

def set_depth(tree):
    for node in tree:
        if node.typ == 'root':
            root = node
            break
    queue = []
    queue.extend(root.children)
    while queue:
        node = queue.pop(0)
        node.depth = tree[node.parent].depth + 1
        queue.extend(node.children)

def set_height(tree):
    queue = []
    for node in tree:
        if node.typ == 'leaf':
            queue.append(node)
    while queue:
        leaf = queue.pop(0)
        if leaf.parent != -1 and tree[leaf.parent].height < leaf.height + 1:
            tree[leaf.parent].height = leaf.height + 1
            queue.append(tree[leaf.parent])

n = int(input())
tree = [Node(i) for i in range(n)]

for i in range(n):
    node_id, left, right = map(int, input().split())
    if left != -1:
        tree[node_id].set_parent(tree[left])
        tree[left].set_sibling(right)
    if right != -1:
        tree[node_id].set_parent(tree[right])
        tree[right].set_sibling(left)

set_depth(tree)
set_height(tree)

for node in tree:
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node.node_id, node.parent, node.sibling, node.degree, node.depth, node.height, node.typ))

Measured memory_bytes: 7876
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k;
    int x[3];
    string t;
    cin>>n>>k>>x[0]>>x[1]>>x[2]>>t;
    vector<vector<ll>> dp(n+1, vector<ll>(3, 0));
    int y[] = {2,0,1};
    rep(i,n) {
        rep(j,3) {
            if (t[i]=='r') {
                bool a = true;
                if (i+1-k>=0) {
                    if (dp[i+1-k][2] > dp[i+1-k][y[2]]) {
                        chmax(dp[i+1][2],dp[i][j]);
                        a = false;
                    }    
                }
                if (a) chmax(dp[i+1][2],dp[i][j]+x[2]);
            }
            else if (t[i]=='s') {
                bool a = true;
                if (i+1-k>=0) {
                    if (dp[i+1-k][0] > dp[i+1-k][y[0]]) {
                        chmax(dp[i+1][0],dp[i][j]);
                        a = false;
                    }    
                }
                if (a) chmax(dp[i+1][0],dp[i][j]+x[0]);
            }
            else if (t[i]=='p') {
                bool a = true;
                if (i+1-k>=0) {
                    if (dp[i+1-k][1] > dp[i+1-k][y[1]]) {
                        chmax(dp[i+1][1],dp[i][j]);
                        a = false;
                    }    
                }
                if (a) chmax(dp[i+1][1],dp[i][j]+x[1]);
            }
        }
        rep(j,3) rep(l,3) chmax(dp[i+1][l],dp[i][j]);
    }
    ll ans = 0;
    rep(i,3) chmax(ans,dp[n][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
// #include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
void solve(){
    int n, s=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;++i){
      cin>>v[i];
      s^=v[i];
    }

    for(int i=0;i<n;++i){
      cout<<(s^v[i])<<" ";
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // cout << solve() << "\n";
  solve();
  return 0;
} 

Measured memory_bytes: 3984
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
using namespace std;

typedef long long ll;

int H,W;
string s[100];

int main() {
  cin >> H >> W;
  for ( int i = 0; i < H; i++ ) cin >> s[i];
  bool f = true;
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      if( (s[i][j] == '#' &&  i-1 >= 0 && s[i-1][j] == '.' ) &&
	  (s[i][j] == '#' &&  i+1 < H  && s[i+1][j] == '.' )  &&
	  (s[i][j] == '#' &&  j-1 >= 0 && s[i][j-1] == '.' ) &&
	  (s[i][j] == '#' &&  j+1 < W && s[i][j+1] == '.' ) )  {
	f = false;
	break;
      }
    }
  }


  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

long long gcd(long long a,long long b){
    while(a&&b){
        if(a>b)a = a%b;
        else b = b%a;
    }
    return a+b;
}

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

    std::vector<int> l(n + 1), r(n + 1);
    for(int i = 1; i <= n; i++)l[i] = gcd(a[i - 1],l[i - 1]);    
    a.insert(a.begin(),0);
    for(int i = n-1; i >= 0; i--)r[i] = gcd(a[i+1], r[i+1]);
    int max = 0;
    for(int i = 0; i <= n-1; i++)max = std::max(gcd(l[i],r[i + 1]), (long long)max);
    std::cout << max << std::endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	int n, m;
	cin >> n >> m;
	vector<int> imos(n + 10, 0);
	for (int i = 0; i < m; i++)
	{
		int c, d;
		cin >> c >> d;
		if (c < d)
		{
			imos[c]++;
			imos[d]--;
		}
	}
	for (int i = 0; i < n; i++)
	{
		imos[i + 1] += imos[i];
	}
	int res = n + 1;
	for (int i = 0; i < n; i++)
	{
		if (imos[i])
			res += 2;
	}
	cout << res << endl;
}



Measured memory_bytes: 3212
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define inf 1000000000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;
	int a[n];
	forr(i, n) {
		cin >> a[i];
	}
	int pref[n + 1];
	pref[0] = 0;
	forr(i, n) {
		pref[i + 1] = pref[i] + a[i];
	}
	int mat[n][n];
	ms(mat, 0);
	for (int k = 2; k <= n; k++) {
		for (int i = 0; i < n - k + 1; i++) {
			int j = i + k - 1;
			mat[i][j] = inf;
			for (int x = i; x < j; x++) {
				mat[i][j] = min(mat[i][j], mat[i][x] + mat[x + 1][j]);
			}
			mat[i][j] += (pref[j + 1] - pref[i]);
		}
	}
	cout << mat[0][n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 4880
#include <iostream>

using namespace std;

int main()
{
	int x, y, z;
	cin >> x >> y >> z;

	int num = 0;
	int p = 0;
	for (;;)
	{
		if (num >= x)
		{
			p--;
		    break;
		}
		
		num += z + y;
		p++;
	}
	num -=z+y;
	if (num + z > x)
	{
		p--;
	}
	cout << p << endl;
}

Measured memory_bytes: 256
program abc155b
  implicit none
  integer :: n
  integer,dimension(:),allocatable :: a
  logical,dimension(:),allocatable :: odd, three, five
  read *, n
  allocate(a(n))
  read *, a
  odd   = mod(a,2) /= 0
  three = mod(a,3) == 0
  five  = mod(a,5) == 0
  if (all(odd.or.three.or.five)) then
     print *, 'APPROVED'
  else
     print *, 'DENIED'
  end if
end program abc155b


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};int dy[4] = {0,-1,0,1};
int main() {
    int n;cin >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) b[i] = a[n-i-1];
    vector<int> dp(n+1,INF);
    for(int i=0;i<n;i++){
	vector<int>::iterator itr2 = upper_bound(dp.begin(),dp.end(),b[i]);
	*itr2 = b[i];
    }

    int ans = lower_bound(dp.begin(),dp.end(),INF)-dp.begin();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4544
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
typedef long long li;

const int maxn = 100000;

int n, m;
char s[maxn + 1], t[maxn + 1];

int main(void) {
  scanf("%d%d", &n, &m);
  scanf("%s%s", s, t);
  int d = __gcd(n, m);
  for (int i = 0; i < d; ++i) {
    if (s[n / d * i] != t[m / d * i]) {
      puts("-1");
      return 0;
    }
  }
  printf("%lld\n",(li) n * m / d);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    char c = '_';
    while(c!='\n'){
        scanf("%c", &c);
        if('a'<=c and c<='z'){
            c -= 32;
            cout << c;
        }
        else if('A'<=c and c<='Z'){
            c += 32;
            cout << c;
        }
        else{
            cout << c;
        }
    }
}


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

namespace C
{
    class Program
    {
        static int points;
        static HashSet<int>[] routes;

        static void Main(string[] args)
        {

            var vls = IOUtils.ReadNums().ToArray();
            points = vls[0];
            var sides = vls[1];
            routes = Enumerable.Range(0, sides)
                               .Select(_ => new HashSet<int>(IOUtils.ReadNums()))
                               .ToArray();

            var found = getPathCount(1, new int[] { 1 });

            IOUtils.WriteNums(found);
        }

        private static int getPathCount(int current, int[] accessed)
        {
            if (accessed.Length == points) return 1; //goal

            var res = 0;
            foreach (var side in routes.Where(r => r.Contains(current)))
            {
                var next = side.Where(p => p != current).Single();
                if (accessed.Contains(next)) continue;

                res += getPathCount(next, accessed.Concat(new[] { next }).ToArray());
            }
            return res;
        }
    }

    static class IOUtils
    {
        public static IEnumerable<int> ReadNums()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v));
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 17860
import math
from decimal import Decimal

def get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d

def main():
    A, B, H, M = map(int, input().split())
    deg_H = (360 // 12) * H + 0.5 * M
    deg_M = (360 // 60) * M
    
    x_A = A * Decimal(math.sin(math.radians(deg_H)))
    y_A = A * Decimal(math.cos(math.radians(deg_H)))
    x_B = B * Decimal(math.sin(math.radians(deg_M)))
    y_B = B * Decimal(math.cos(math.radians(deg_M)))
    
    ans = float((Decimal(x_A) - Decimal(x_B)) ** 2 + (Decimal(y_A) - Decimal(y_B)) ** 2) ** 0.5
    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 71868
import collections, heapq
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
XY = [[int(_) for _ in input().split()] for _ in range(M)]
G = collections.defaultdict(list)
for x, y in XY:
    G[x] += [y]
    G[y] += [x]
B = sorted([v, i] for i, v in enumerate(A))
visited = [0] * N
ans = 0
H = []
t = 0
for b in B:
    v, i = b
    if not visited[i]:
        visited[i] = 1
        ans += v
        q = G[i]
        t += 1
        while q:
            i = q.pop()
            if not visited[i]:
                visited[i] = 1
                heapq.heappush(H, [A[i], i])
                q += G[i]
if len(H) < t - 2:
    print('Impossible')
    exit()
elif t == 1:
    print(0)
    exit()
for _ in range(t - 2):
    v, i = heapq.heappop(H)
    ans += v
print(ans)


Measured memory_bytes: 67640
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

using Position = pair<int, int>;

int main()
{
  string S;

  cin >> S;

  int N = S.size();

  for (int i = 0; i < (N + 1) / 4; i++) {
    if (S[i] == S[(N - 1) / 2 - 1 - i] &&
        S[i] == S[(N + 3) / 2 - 1 + i] &&
        S[i] == S[(N - 1) - i]) {
      continue;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    while(true){
        int w;
        cin >>w;
        if(w==-1)break;
        if(w<=10){
            cout <<4280-1150<<endl;
        }
        else if(10<w&&w<=20){
            cout <<4280-(1150+(w-10)*125)<<endl;
        }
        else if(20<w&&w<=30){
            cout <<4280-(1150+(10*125)+(w-20)*140)<<endl;
        }
        else if(30<w){
            cout <<4280-(1150+(10*125)+(10*140)+(w-30)*160)<<endl;
        }
    }
}



Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std;
 
int dp[3005][3005]; 
pair<int,int> trc[3005][3005];

int main(){
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	for(int i = 0; i < n; i++){
		for(int j = 0;  j < m; j++){
			if(s[i] == t[j]){
				dp[i+1][j+1] = dp[i][j] + 1;
				trc[i+1][j+1] = make_pair(i,j);
			}else{
				if(dp[i+1][j] > dp[i][j+1]){
					dp[i+1][j+1] = dp[i+1][j];
					trc[i+1][j+1] = trc[i+1][j];
				}else{
					dp[i+1][j+1] = dp[i][j+1];
					trc[i+1][j+1] = trc[i][j+1];
				}
			}				
		}
	}
	int c = dp[n][m];
	int k = 0;
	string ans = "";
	int i = trc[n][m].first, j = trc[n][m].second;
	while(k < c){
		ans += s[i];
		pair<int,int> p = trc[i][j];
		i = p.first;
		j = p.second;
		k++;
	}
	reverse(ans.begin(), ans.end());
	cout <<  ans << endl;
		
}


Measured memory_bytes: 105984
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;

int l[10000];

long double w, h, x, y;


int main() {
	cin >> w >> h >> x >> y;
	long double a = w * h / 2.0;
	if (w == 2.0 * x&&h == 2.0 * y) {
		std::cout << std::fixed;
		cout << setprecision(9)<<a<< " " << 1 << endl;
	}
	else {
		std::cout << std::fixed;
		cout << setprecision(9)<<a << " "<<0<< endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int cnt[1100000];
vin prime(1000000,1);

map<int,int> bunnkai(int x){
 map<int,int> ans;
  while(x>=2){
   ans[prime[x]]++;
    x/=prime[x];
  }
  //cout<<prime[2]<<endl;
  return ans;
}

int main(){cout<<fixed<<setprecision(20);
		   ll n;
           cin>>n;
           vll a(n);
           rep(i,0,n)cin>>a[i];
              
     	     for (int i = 2; i<=1000000; ++i) {
       				 if (prime[i]==1) {
                       prime[i]=i;
          				  for (int j = i * 2; j <= 1000000; j += i) {
              					 prime[j]=i; 
         				   }
       				 }
  			 	 }
           //////////////////
           ll g=a[0];
           rep(i,0,n){
            g=__gcd(g,a[i]);
           }
           if(g!=1){
            cout<<"not coprime"<<endl;
             return 0;
           }
           rep(i,0,n){
             map<int,int> p;
             
             p=bunnkai(a[i]); 
             for(auto v:p){
              cnt[v.first]++; 
               //cout<<v.first<<" "<<v.second<<endl;
              // cout<<prime[3]<<endl;
              //return 0;
             }
           }
           rep(i,2,1000000){
            if(cnt[i]>1){
              //cout<<cnt[i]<<" "<<i<<endl;
             cout<<"setwise coprime"<<endl; 
              return 0;
            }
           }
           cout<<"pairwise coprime"<<endl;
}

Measured memory_bytes: 18608
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using P = pair<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
//const ll MOD=1e9+7;
const ll MOD=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll C;
    cin >> C;
    ll D;
    cin >> D;
    vector<vector<ll>> dp(C+1, vector<ll>(D+1, -1));
    for(ll i=0;i<=A;++i)
        for(ll j=0;j<=B;++j)dp[i][j]=1;
    function<ll(ll,ll)> F = [&](ll i,ll j){
        if(dp[i][j]!=-1)return dp[i][j];
        if(i==A) return dp[i][j]=F(i,j-1)*i%MOD;
        if(j==B) return dp[i][j]=F(i-1,j)*j%MOD;
        else return dp[i][j]=(F(i-1,j)*(j)%MOD+F(i,j-1)*(i)%MOD+MOD-F(i-1,j-1)*(i-1)*(j-1)%MOD)%MOD;
    };
    prt(F(C,D));



    return 0;
}



Measured memory_bytes: 74676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,s;
    cin>>n;
    if(n==1)
        cout<<"Hello World"<<endl;
    else
    {
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int len = S.length();
		int win = 0;
		for (int i = 0; i < len; ++i) {
			if (S.charAt(i) == 'o') ++win;
		}
		if (win+15-len >= 8)System.out.println("YES");
		else System.out.println("NO");
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>


int main (void) {
  int A, B, T;
  std::cin >> A >> B >> T;

  int times = T/A;
  std::cout << B *times << std::endl;

  return 0;
}

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

// move-and-win.cpp
// author: Seong Yong-ju ( @sei40kr )
// Copyright (c) 2018 Seong Yong-ju

using namespace std;

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

  int N, A, B;
  cin >> N >> A >> B;

 cout << ((B - A) % 2 == 0 ? "Alice" : "Borys") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
using namespace std;
const int N=1e5+10;
int p[N];
int find(int x){
	if(x==p[x])return p[x];
	return p[x]=find(p[x]);
}
int n,k;
int a[N];
vector<int>g[N];
set<int>s[N];
int main(){
	cin>>n>>k;
	FOR(i,1,n)cin>>a[i],p[i]=i;
	REP(i,k){
		int u,v;cin>>u>>v;u=find(u),v=find(v);
		p[u]=v;
	}
	int t=0;
	FOR(i,1,n){
		find(i);
		if(s[p[i]].find(i)!=s[p[i]].end()){
			t++;
		}
		else s[p[i]].insert(i);
		
		if(s[p[i]].find(a[i])!=s[p[i]].end()){
			t++;
		}
		else s[p[i]].insert(a[i]);
		
	}
	cout<<t<<endl;

}

Measured memory_bytes: 17408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int n, a[3];

void solve(){
	scanf("%d", &n);
	rep(i, n) {
		int x; scanf("%d", &x);
		int c = 0;
		while(x % 2 == 0) ++c, x /= 2;
		a[min(c, 2)]++;
	}
	if(a[1] == 0) {
		if(a[0] > a[2] + 1) puts("No");
		else puts("Yes");
	}
	else {
		if(a[0] > a[2]) puts("No");
		else puts("Yes");
	}
}

int main(){
	int T = 1; //scanf("%d", &T);
	while(T--) {
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

const int MAX = 1000001;

int main() {
    bool h[MAX] = {};
    for(int i = 1;i < MAX; i *= 2){
        for(int j = i; j < MAX; j *= 3){
            for(int k = j; k < MAX; k *= 5 ) h[k]=1;
        }
    }
    int m;
    while(cin >> m, m) {
        int n, count = 0;
        cin >> n;
        for(int i = m;i <= n; i++) if(h[i]) count++;
        cout << count << endl;
    }
}


Measured memory_bytes: 3936
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[100010];
    rep(i,0,N) cin >> a[i];
    vector<lpair> lp;
    rep(i,0,N) lp.push_back({a[i], i});
    sort(lp.begin(),lp.end());
    print(lp[0].second+1);
    

}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			string str = "";
			string tempStr = "temp";
			while (string.IsNullOrWhiteSpace(tempStr) == false) {
				tempStr = Console.ReadLine();
				if (string.IsNullOrWhiteSpace(tempStr)) {
					break;
				}

				str += tempStr.ToLower();
			};

			//Console.WriteLine(str);
			List<string> alphabets = new List<string>();
			char[] chars = str.ToArray();
			for (char alpha = 'a'; alpha <= 'z'; ++alpha) {
				char[] finds = Array.FindAll(chars, item => item == alpha);
				int sum = finds.Length;
				alphabets.Add($"{alpha.ToString()} : {sum}");
			}

			for (int i = 0; i < alphabets.Count; ++i) {
				Console.WriteLine($"{alphabets[i]}");
			}

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 16176
class SegmentTree:

    def __init__(self, n, fn=lambda x, y: min(x, y), unity=(1 << 31) - 1):
        self.n = 1
        while self.n < n:
            self.n *= 2

        self.arr = [unity] * (2 * self.n - 1)
        self.fn = fn
        self.unity = unity

    def update(self, i, x):
        k = self.n + i - 1
        self.arr[k] = x

        while k > 0:
            k = (k - 1) // 2
            self.arr[k] = self.fn(self.arr[2 * k + 1], self.arr[2 * k + 2])

    def query(self, l, r):
        return self._inner_query(l, r, 0, 0, self.n)

    def _inner_query(self, l, r, k, il, ir):
        if ir <= l or r <= il:
            return self.unity

        elif l <= il and ir <= r:
            return self.arr[k]

        vl = self._inner_query(l, r, k * 2 + 1, il, (il + ir) // 2)
        vr = self._inner_query(l, r, k * 2 + 2, (il + ir) // 2, ir)
        return self.fn(vl, vr)

    def __str__(self):
        return self.arr[0: 2 * self.n].__str__()

N = int(input())
S = list(input())

sts = [SegmentTree(N + 1, fn=lambda x, y: max(x, y), unity=0) for _ in range(10)]

minmax = [(N + 1, 0) for _ in range(10)]

for i in range(N):
    c = int(S[i])
    sts[c].update(i, 1)
    minmax[c] = (min(minmax[c][0], i), max(minmax[c][1], i))

cnt = 0
for l in range(10):
    for r in range(10):
        for c in range(10):
            if sts[c].query(minmax[l][0] + 1, minmax[r][1]) > 0:
                cnt += 1
print(cnt)

Measured memory_bytes: 72796
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    int ans = 0, j = 1;
    while(j < n){
        j += k;
        ans++;
        if(j <= n){
            j--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<set>

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

using namespace std;

char d[30][3];
int n;

set<int> ss[7];

bool solve(int cnt, char prev, int f){
  if(cnt == n) return true;
  if(ss[prev-'0'].count(f)) return false;

  ss[prev-'0'].insert(f);

  REP(i,n) if(f & (1<<i)){
    if(prev == d[i][0]){
      if(solve(cnt+1, d[i][1], f ^ (1<<i))) return true;
    }else if(prev == d[i][1]){
      if(solve(cnt+1, d[i][0], f ^ (1<<i))) return true;      
    }
  }
  return false;
}

int main(){
  while(~scanf("%d",&n)){
    REP(i,n) scanf("%s",d[i]);
    
    bool ans = false;
    REP(i,7) ss[i].clear();

    REP(i,7) if(solve(0, i+'0', (1<<n)-1)){
      ans = true; break;
    }

    puts(ans ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 3524
#include<stdio.h>
#define N 100
int main(){
int i,j,lengh,key,A[N],mini,count=0,k;
 
scanf("%d",&lengh);
for(i=1;i<=lengh;i++){
scanf("%d",&A[i]);}
     
for(i=1;i<=lengh;i++){
    mini=i;
    for(j=i;j<=lengh;j++){
        if(A[j]<A[mini]){
        mini=j;
        }}         
    if(A[mini]<A[i]){
    key=A[i];
    A[i]=A[mini];
    A[mini]=key;
    count++;}}
    for(i=1;i<=lengh;i++){
        printf("%d",A[i]);
	if(i<lengh) printf(" ");}
    printf("\n%d\n",count);
    return 0;
}

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

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

  if(A + B<=B + C && A+ B<= A + C)
  cout << A + B << endl;
else   if(A + C<=B + C && A+ C<= A + B)
  cout << A + C << endl;
else
  cout << C + B << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<int, pii> viii; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef vector<vector<vl>> vvvl; 
vi groups;
int find(int i){
    int p=i;
    while(groups[i]>0)i=groups[i];
    if(p!=i)groups[p]=i;
    return i;
}
void join(int j, int k){
    int g1=find(j),g2=find(k);
    if(g1!=g2){
        if(-groups[g1]>-groups[g2]){
            // groups[j]=g2;
            groups[g1]=-(-groups[g2]-groups[g1]);
            groups[g2]=g1;
            groups[k]=g1;
        }else{
            groups[g2]=-(-groups[g2]-groups[g1]);
            groups[g1]=g2;
            groups[j]=g2;
        }
    }
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL);
    int n,m,i,j,k;
    cin>>n>>m;
    groups.assign(n+1,-1);
    for(i=0;i<m;i++){
        cin>>j>>k;
        join(j,k);
    }
    // for(i=1;i<=n;i++)cout<<groups[i]<<" ";cout<<endl;
    vi g(n+1,0);int ans=0;
    for(i=1;i<=n;i++){
        g[find(i)]++;
    }
    // cout<<find1(1);
    for(i=1;i<=n;i++)ans=max(g[i],ans);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4772
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
hn = list(map(int, input().split()))

max_move = 0
move = 0

for i in reversed(range(1, N)):
    if hn[i-1] >= hn[i]:
        move += 1
    else:
        if move >= max_move:
            max_move = move
        move = 0
if move >= max_move:
    max_move = move
print(max_move)


Measured memory_bytes: 63856
n = input()
for i in range(n):
    a = 0
    y, m, d = map(int, raw_input().split())
    a += 195 * (999 - y)
    a += (999 / 3 - y / 3) * 5
    if y % 3 :
        a += (10 - m) * 19 + (10 - m) / 2
        a += 20 - d - (m + 1) % 2 + 1
    else:
        a += (10 - m) * 20
        a += 20 - d + 1
    print a

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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    set<char> a;
    while (n > 0) {
        char c;
        cin >> c;
        a.insert(c);
        --n;
    }
    if (a.size() == 3)
        cout << "Three";
    else
        cout << "Four";
    return 0;
}

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

int main() {
	
	     ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	  
	   long long n,i,j,k,count=0,ans=0;
	   cin>>n;
	  long long a[n];
	  map<long long ,long long>m;
	  for(i=0;i<n;i++)
	  {
	      cin>>a[i];
	      m[a[i]]++;
	  }
	  for(i=0;i<n;i++)
	  {
	      if(m[a[i]]>0)
	      ans+=(m[a[i]]*(m[a[i]]-1))/2;
	      m[a[i]]=0;
	      
	  }

	  for(i=0;i<n;i++)
	  m[a[i]]++;
	  for(i=0;i<n;i++)
	  {
	     cout<<ans-m[a[i]]+1<<endl;;  
	  }
	return 0;
}

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

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

    int flag = 0;
    int count_b[n];
    int count_w[n];
    int count1 = 0;
    int count2 = 0;
    fill_n(count_b, n, 0);
    fill_n(count_w, n, 0);
    for(int i = 0; i < n; i++){
        //cout << count_b[i] << count_w[i] << endl;
        if(s[i] == '#'){
            count1++;
        }
        else {
            count2++;
        }
        count_b[i] = count1;
        count_w[i] = count2;

    }

    
    int ans = 10000;
    int cb_r = 0;
    int cw_r = 0;
    int cb_l = 0;
    int cw_l = 0;

    ans = min(count1, count2);
    ans = min(ans, count_w[n-1]);
    for(int i = 1; i < n; i++){
       
        if(i == 0){
            ans = min(count_b[i] + count_w[n-1] + count_w[i], ans);
        }
        else {
            ans = min(count_b[i-1] + count_w[n-1] - count_w[i-1], ans);

        }
        
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2180
N = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = [i-1 for i in A]

ans = 0
pre = A[0]
for a in A:
    ans += B[a]
    if a==pre+1:
        ans += C[pre]
    pre = a

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <set>
#include <utility>
#include <vector>

#define ii std::pair<int,int>


int pos[200000];
int main(void){
  int n;  
  scanf("%d",&n);
  int p;
  for(int i = 0;i<n;i++){
    scanf("%d",&p);  
    pos[p] = i+1;
  };
  std::set<ii> s;
  s.insert(ii(pos[n],n));
  long long erg=0;
  for(int i = n-1;i>0;i--){
    auto it = s.insert(ii(pos[i],i)); 
    int p1,p2,p3,p4;
    if(it.first == s.begin()){
      p1 = 0;  
      p2 = 0;
    }else{
      it.first--;  
      p1 = it.first->first;
      if(it.first != s.begin()){
        it.first--;  
        p2 = it.first->first;
        it.first++;
      }else{
        p2 = 0;  
      };
      it.first++;
    };
    it.first++;
    if(it.first == s.end()){
      p3 = n+1;  
      p4 = n+1;  
    }else{
      p3 = it.first->first;  
      it.first++;
      if(it.first == s.end()){
        p4 = n+1;  
      }else{
        p4 = it.first->first;  
      };
      it.first--;
    };
    it.first--;
    long long d =  p4-p3;
    long long v = p1 - p2;
    long long vv = pos[i] - p1;
    long long dd = p3 - pos[i];
    erg += d * vv * i;
    erg += dd * v * i;
  };
  printf("%lld\n",erg);
  return 0;
};


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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  
  if(A/K > 2 || B/K > 2 || A%K ==0 || B%K ==0) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3508
using System;
 
public class abcB
{
	public static void Main()
	{
		char[] str = Console.ReadLine().ToCharArray();
		int flag = 1;
		for (int i = 0; i < str.Length; ++i) {
			for (int j = 0; j < str.Length; ++j) {
				if (str[i] == str[j] && i != j) {
				flag = flag * 0;
			} else {
				flag = flag * 1;
			}
			}
		}
		if (flag == 0) {
			Console.Write("no");
		} else {
			Console.Write("yes");
		}
		
	
	}
}

Measured memory_bytes: 11092
#include<iostream>
int main()
{
    char out[4]={'T','C','A','G'};
    enum inpu:int{A=0,G=1,T=2,C=3} intt;
    char in;
    std::cin>>in;
    if(in=='A')in=0;
    else if(in=='G')in=1;
    else if(in=='T')in=2;
    else if(in=='C')in=3;
    std::cout<<out[in];
    return 0;
}

Measured memory_bytes: 256
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let s = match N % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => unreachable!(),
    };

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


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

int main(void) {
    int n, count=1;
    cin >> n;
    vector<string> s(n);
    vector<vector<int>> num(n, vector<int>(10, 0));
    for (int i=0; i<n; i++) {
        cin >> s.at(i);
        for (int j=0; j<(int)(s.at(i).length()); j++) {
            num.at(i).at(j) = (int)(s.at(i).at(j));
        }
    }
    sort(num.begin(), num.end());
    for (int i=1; i<n; i++) {
        if (num.at(i) != num.at(i-1)) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 23600
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        Deque<Integer> Stack = new ArrayDeque<>();
        String S = sc.nextLine();
        String list [] = S.split(" ");
        for(int i=0;i<list.length;i++){
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        }
        System.out.println(Stack.pop());
    }
}


Measured memory_bytes: 26136
/*
2017_03_14_AC
????????????
????????§???????????§??°???????????°?????????????????§??????????????°??§AC??????????????£????????????

*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {
  int a, b, c;
  cin>>a>>b>>c;
  if((a + b) % 60 == 0 && a < c){
    cout<<-1<<endl;
    return 0;
  }

  for(int i=0; ;i++){
    if((a + b)*i % 60 <= c && c <= (a + b)*i % 60 + a){
        cout<<c + 60*((a+b)*i/60)<<endl;
        return 0;
    }
    if(i > 0 && (a + b)*i % 60== 0){
      cout<<-1<<endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cerr << #x << " " << x << endl;
#define debugtwo(x) cerr << #x << "-------------" << endl;for(auto &it: x) cerr << it << " ";cerr << endl;
#define debugthree(x, i, j) cerr << #x << "------------" << endl;cerr << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cerr << x[k] << " ";cout << endl;


int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll gcd = (c * d) / __gcd(c, d);

	ll both = b / gcd - (a - 1) / gcd, cOnly = b / c - (a - 1) / c, dOnly = b / d - (a - 1) / d;
	ll totalDivide = cOnly + dOnly - both;

	cout << b - a + 1 - totalDivide << endl;
}			

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc073/tasks/abc073_c

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, A;
set<ll> s;

int main()
{
  cin >> N;
  REP(i, N)
  {
    cin >> A;
    auto r = s.insert(A);
    if (!r.second)
      s.erase(A);
  }

  cout << s.size() << '\n';

  return 0;
}


Measured memory_bytes: 4864
A,B,K = map(int,input().split())
S = []
#list(range(A,B+1))
for i in range(K):
	S.append(A+i)
	S.append(B-i)

S = sorted(list(set(S)))

for i in range(len(S)):
	if A<=S[i]<=B:
		print(S[i])

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

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

    int d,g;
    cin>>d>>g;
    vector<int> p(d),c(d);
    for(int i=0;i<d;i++)cin>>p[i]>>c[i];

    int ans=INF;
    for(int i=0;i<1<<d;i++){
        int sum=0,cost=0;
        for(int j=0;j<d;j++){
            int score=100*(1+j);
            if(i & 1<<j){
                cost+=p[j];
                sum+=score*p[j]+c[j];
            }
        }
        for(int j=d-1;j>=0;j--){
            int score=100*(j+1);
            if(! (i & 1<<j)){
                if(sum>=g)continue;
                int t=min(p[j]-1,(g-sum+score-1)/score);
                cost+=t;
                sum+=score*t;
            }
        }
        if(sum>=g)ans=min(ans,cost);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b;
    cin >> a >> b;
    REP(i,0,1001) {
        if (floor(0.08 * i) == a && floor(0.1 * i) == b) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include<math.h>

main(){
	double x=0,y=0,r,th,th_acc=90;
	while(scanf("%lf,%lf",&r,&th),r||th){
		x+=r*cos(M_PI*th_acc/180);
		y+=r*sin(M_PI*th_acc/180);
		th_acc-=th;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	exit(0);
}

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

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int[] a = new int[n];
		str = br.readLine().split(" ");
		for(int i = 0; i < n; i++) a[i] = Integer.parseInt(str[i]);
		str = br.readLine().split(" ");
		int q = Integer.parseInt(str[0]);
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			int k = Integer.parseInt(str[0]);
			if(Arrays.binarySearch(a, k) >= 0) System.out.println(1);
			else System.out.println(0);
		}
	}
}



Measured memory_bytes: 90880
/**
 * ????????¢?????????

??????H cm ?????? W cm ???????????¢?????????????????°?????????????????????????????????

1 cm ?? 1cm ???????????¢??? '#'??§??¨????????????

Input
??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????

H W

H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????

Output
????????????????????????????????????H ?? W ?????? '#' ??§????????????????????¢???????????????????????????

?????????????????????????????????????????????????????\??????????????????

Constraints
1 ??? H, W ??? 300

Sample Input
3 4
5 6
2 2
0 0
Sample Output
####
####
####

######
######
######
######
######

##
##
 */

#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  unsigned int H, W;

  while (true) {
    while (true) {
      std::string Param;

      getline(std::cin, Param);
      std::istringstream iss(Param);
      iss >> H >> W;

      if (H > 300 || W > 300) {
        std::cout << "Error: 1 <= H, W <= 300" << std::endl;
      } else {
        break;
      }
    }
    if (H == 0 && W == 0) {
      break;
    } else {
      for (size_t i = 0; i < H; i++) {
        for (size_t j = 0; j < W; j++) {
          std::cout << "#";
        }
        std::cout << std::endl;
      }
      std::cout << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3192