akhauriyash/Code-Regression huggingface dataset:
a = []
for i in range(3):
    a1 = list(map(int,input().split()))
    a.append(a1)
l = [[0,0,0] for i in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                l[j][k] = 1
ans = "No"
naname1 = 0
naname2 = 0
for i in range(3):
    tate = 0
    yoko = 0
    for j in range(3):
        if l[i][j] == 1:
            tate += 1
        if l[j][i] == 1:
            yoko += 1
    if tate == 3 or yoko == 3:
        ans = "Yes"
    if l[i][i] == 1:
        naname1 += 1
    if l[2-i][i] == 1:
        naname2 += 1
if naname2 == 3 or naname1 == 3:
    ans = "Yes"
print(ans)

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

#define rep(i,s,e) for(int i = (s);i <= (e);i++)
typedef long long i64;

int n;
int k;
vector<i64> a;

i64 sum[200010];

i64 ma_s[200010];

int main()
{
	cin >> n >> k;
	a.resize(n + 1,0);
	rep(i,1,n) cin >> a[i];
	rep(i,1,n) sum[i] = sum[i - 1] + a[i];
	rep(i,1,n) ma_s[i] = ma_s[i - 1]+ max(a[i],0LL);

	i64 result = 0;
	//final range ... [l,l + K]
	rep(l,1,n - k + 1)
	{
		int r = l + k - 1;
		result = max(result , ma_s[l - 1] + max(sum[r] - sum[l - 1],0LL) + ma_s[n] - ma_s[r]);

	}
	cout << result << endl;

	
	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <map>
using namespace std;
int main(void){
    // Your code here!

    int N;
    cin >> N;
    vector<int> B(N);
    map<long, long> M;
    
    for(int i = 0; i < N; i++){
        cin >> B[i];
        M[B[i]]++;
    }
    
    long long ans = 0;
    
    for(auto A : M){
        auto count = A.second;
        ans += count * (count - 1) / 2;
    }
    
    for(int i = 0; i < N; i++){
        
        long long kari = ans - (M[B[i]] * (M[B[i]] - 1) / 2) + ((M[B[i]] - 1) * (M[B[i]] - 2) / 2); 
        
        cout << kari << endl;

    }
    
    
}



Measured memory_bytes: 10240
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds; 
using 		namespace std;

ll gcd (ll a, ll b) { return b ? gcd (b, a % b) : a; }
ll lcm (ll a, ll b) { return a / gcd(a, b) * b; }

//code start from here 

int main() {
	fast;
	read(a)
	read(b)
	if(b>=a) cout<<"unsafe";
	else cout<<"safe";
	return 0;
}

//ends here 

Measured memory_bytes: 3648
#include <stdio.h>
#include <math.h>
main(){
  int i,j,n,c; char m[7],o,d[262145];
  for(i=0,scanf("%d %s",&n,m);i<n;i++,scanf("%s",m)){
    for(j=c=o=0;o!='\n';scanf("%c",&o))
      if(o=='A')c+=1*pow(4,j++);
      else if(o=='C')c+=2*pow(4,j++);
      else if(o=='G')c+=3*pow(4,j++);
      else if(o=='T')c+=4*pow(4,j++);
    m[0]=='i'?d[c]=1:(d[c]?printf("yes\n"):printf("no\n"));
  }
  return 0;
}

Measured memory_bytes: 496
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.next();
            boolean ac = true;
            if (S.charAt(0) == 'A') {
            } else {
                ac = false;
            }
            int count = 0;
            int index = -1;
            for (int i = 2; i <= S.length() - 2; i++) {
                if (S.charAt(i) == 'C') {
                    count++;
                    index = i;
                }
            }
            if (count == 1) {
            } else {
                ac = false;
            }
            for (int i = 1; i < S.length(); i++) {
                if (i == index) {
                    continue;
                }
                if (S.charAt(i) >= 'a' && S.charAt(i) <= 'z') {
                } else {
                    ac = false;
                }
            }
            System.out.println(ac ? "AC" : "WA");
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include<algorithm>
#include <set>
#include <stdlib.h>

using namespace std;

int main()
{
    map<string,int>m;
    string a[4]={"AC","WA","TLE","RE"};
    int n;
    string arr;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr;
        m[arr]++;
    }
    for(int i=0;i<4;i++)
        {cout<<a[i]<<" x "<<m[a[i]]<<endl;}
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        double w,v,a,b,ti;
        cin>>a>>v;
        cin>>b>>w;
        cin>>ti;
        if((v-w)*ti>=abs(a-b))
        cout<<"YES\n";
        else
        cout<<"NO\n";
    }
    return 0;
}

Measured memory_bytes: 3688
n = int(input())

cnt = 0
ans = 0
for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        ans += i

print(ans)

Measured memory_bytes: 9168
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> a(4);
while(cin >> a[0] >> a[1] >> a[2] >> a[3])
{
int hit=0, blow=0;
for(int i = 0; i< 4; i++)
  {
    int b;
    cin >> b;
    for(int j = 0;j<4;j++)
    {
      if(a[j] == b)
      {
        if(i == j)hit++;
        else blow++;
      }
    }
  }
  cout << hit << " " << blow << endl;
}
return 0;
}

Measured memory_bytes: 1192
use std::cmp;
use std::collections::VecDeque;

const INF: i64 = 1e15 as i64;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let k: usize = sc.read();

    let mut has_number = vec![false; n];
    let mut min = vec![-INF; n];
    let mut max = vec![INF; n];
    for _ in 0..k {
        let v = sc.read::<usize>() - 1;
        let p: i64 = sc.read();
        has_number[v] = true;
        min[v] = p;
        max[v] = p;
    }

    let mut q = VecDeque::new();
    for i in (0..n).filter(|&i| has_number[i]) {
        q.push_back(i);
    }
    while let Some(v) = q.pop_front() {
        for &next in graph[v].iter() {
            if min[next] < min[v] - 1 {
                min[next] = min[v] - 1;
                q.push_back(next);
            }
        }
    }

    for i in (0..n).filter(|&i| has_number[i]) {
        q.push_back(i);
    }
    while let Some(v) = q.pop_front() {
        for &next in graph[v].iter() {
            if max[next] > max[v] + 1 {
                max[next] = max[v] + 1;
                q.push_back(next);
            }
        }
    }

    let mut ans = vec![INF; n];
    let start = (0..n).find(|&i| has_number[i]).unwrap();
    ans[start] = min[start];
    q.push_back(start);
    while let Some(v) = q.pop_front() {
        for &next in graph[v].iter() {
            if ans[next] == INF {
                if min[next] <= ans[v] - 1 && ans[v] - 1 <= max[next] {
                    ans[next] = ans[v] - 1;
                } else if min[next] <= ans[v] + 1 && ans[v] + 1 <= max[next] {
                    ans[next] = ans[v] + 1;
                } else {
                    println!("No");
                    return;
                }
                q.push_back(next);
            }
        }
    }

    println!("Yes");
    for ans in ans.into_iter() {
        println!("{}", ans);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
	

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    string S;
    
    cin >> N;
    cin >> S;

    ll R = 0;
    ll G = 0;
    ll B = 0;
    REP(i, N){
        if(S[i] == 'R') R++;
        if(S[i] == 'G') G++;
        if(S[i] == 'B') B++;
    }
    ll dis = 0;
    for(ll i=0; i<N; i++){
        for(ll j=i+1; j<N; j++){
            ll k = 2*j-i;
            if(k >= N) continue;
            if((S[i] != S[j]) && (S[j] != S[k]) && (S[k] != S[i])) dis++;
        }
    }
    cout << R*G*B - dis << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if ((x - r) >= 0 && (x + r) <= W && (y - r) >= 0 && (y + r) <= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
process.stdin.resume();
process.stdin.setEncoding("utf8");
let input = "";
process.stdin.on("data", function(chunk) {input += chunk;});
process.stdin.on("end", function() {main(input.split("\n"));});

function allocNode(key) {
	p = {};
	p.key = key;
	p.left = null;
	p.right = null;
	return p;
}
function insert(p,c) {
	if (p === null) return c;
	if (c.key < p.key) p.left = insert(p.left,c);
	else p.right = insert(p.right,c);
	return p;
}
function inset(p,ary) {
	if (p === null) return;
	inset(p.left,ary);
	ary.push(p.key);
	inset(p.right,ary);
}
function preset(p,ary) {
	if (p === null) return;
	ary.push(p.key);
	preset(p.left,ary);
	preset(p.right,ary);
}
function dump(p,setfunc) {
	let ary = [];
	setfunc(p,ary);
	console.log(ary.map(x => ` ${x}`).join(""));
}
function main(lines){
	let n = Number(lines[0]);
	let root = null;
	for (let i = 0; i < n; i++) {
		let line = lines[i+1].split(" ");
		switch(line[0][0]) {
		case "i":
			let key = Number(line[1]);
			let p = allocNode(key);
			root = insert(root,p);
			break;
		case "p":
			dump(root,inset);
			dump(root,preset);
			break;			
		}
	}
}



Measured memory_bytes: 223984
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll                  long long int
#define ull                 unsigned long long int
#define ld                  long double
#define fi                  first
#define se                  second
#define pb                  push_back
#define pbb                 pop_back
#define mp                  make_pair
#define pii     	        pair<int,int>
#define all(x)              x.begin(), x.end()
#define uniq(x)             x.erase(unique(x.begin(),x.end()),x.end())
#define mem(array, value)   memset(array, value, sizeof(array))
#define lcm(a,b)            (abs(a)/gcd(a,b))*abs(b)
#define PI      	        2*acos(0.0)
#define INF     	        1e9
#define EPS     	        1e-8
#define line                cout << "\n==========\n"
#define fastRead 	        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet; 

const int MOD = 1e9+7;
char grid[1009][1009];
int dp[1009][1009];
int h, w;

ll call(int i, int j)
{
    if (dp[i][j] != -1){
        return dp[i][j];
    }
    if (i == h-1 && j == w-1){
        return 1;
    }
    if (i < 0 || i >= h || j < 0 || j >= w || grid[i][j] == '#'){
        return 0;
    }
    int &res = dp[i][j];
    int res1, res2;
    res1 = call(i+1, j);
    res2 = call(i, j+1);
    res = (res1+res2)%MOD;
    return res;
}

int main ()
{
    #ifdef Lollipop
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    #endif
    mem(dp, -1);
    cin >> h >> w;
    for (int i = 0; i<h; i++){
        for (int j = 0; j<w; j++){
            cin >> grid[i][j];
        }
    }
    cout << call(0, 0) << endl;
    return 0;
}



Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

#define MAX 3000
#define mod 1000000007

ll add(ll a,ll b)
{
	return (mod+(a+b)%mod)%mod;
}


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

	ll n;
	cin>>n;
	
	ll arr[n];
	
	for(ll i=0;i<n;i++)cin>>arr[i];
	
	map <ll,ll> mp;
	ll sum = 0;
	for(ll i=0;i<n;i++)
	{
		mp[arr[i]]++;
		sum += arr[i];
	}
	
	ll Q;
	cin>>Q;
	
	while(Q--)
	{
		ll b, c;
		cin>>b>>c;
		
		sum -= b*mp[b];
		sum += c*mp[b];
		mp[c] += mp[b];
		mp[b] = 0;
		
		cout<<sum<<'\n';
	}
	
	
}















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

int main() {
  string n;
  cin >> n;
  ll len = n.length();
  ll sum = 0;
  rep(i,len) sum += n[i] - '0';
  cout << (sum % 9 ? "No" : "Yes") << endl;
  
  return 0;
}

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

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
const int maxn = 2e5+100;

const ll inf = 1e18;
int mask[maxn][50][2];
int raw[50][2];

int main()
{
    ll n , k;
    cin >> n >> k;
    for(int i = 1; i<=n; i++){
        ll p; cin >> p;
        for(int j = 0; j<50; j++){
            ll bit = (p & (1ll << j)) > 0 ? 1 : 0;
            raw[j][bit]++;
        }
    }
    ll K = 0 , ans = 0;
    for(ll i = 50; i>=0; i--){
        ll one = raw[i][1];
        ll zero = raw[i][0];
        if(one > zero){
            ans += (1ll << i) * one;
        }
        else if(((1ll << i)+K)<=k){
            K += (1ll << i);
            ans += (1ll<<i) * zero;
        }
        else{
            ans += (1ll << i) * one;
        }
    }
    cout << ans << endl;



}



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

ll max(ll a, ll b) {
    return (a > b) ? a : b;
}

int main(){
    int n;
    cin >> n;
    int *a, *b, *c;
    a = new int[n];
    b = new int[n];
    c = new int[n];
    for (int i = 0; i < n;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }

    ll **dp = new ll *[n];
    for (int i = 0; i < n;i++)
    {
        dp[i] = new ll[3];
    }
    for (int i = 0; i < n;i++)
    {
        for (int j = 0; j < 3;j++)
        {
            dp[i][j] = -__LONG_LONG_MAX__;
        }
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i = 1; i < n; i++)
    {
        dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
        dp[i][1] = max(dp[i - 1][2] + b[i], dp[i - 1][0] + b[i]);
        dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
    return 0;
}

Measured memory_bytes: 8628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				int cnt = 0;
				for(int j = 1; j <= i; j++) {
					if(i % j == 0) cnt++;
				}
				if(cnt == 8) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  ll h, w;std::cin >> h >> w;
  char k;
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      if(i==0||j==0||i==h+1||j==w+1) std::cout << '#';
      else{
        std::cin >> k;
        std::cout << k;
      }
    }
    std::cout << '\n';
  }
}


Measured memory_bytes: 504
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a 

  
N = int(input())

d =[0] * (N+1)
for i in range(1,N+1):
  div = collections.Counter(prime_factorize(i))
  index = list(div.values())
  s = 1
  for j in range(len(index)):
    s *= (index[j]+1)
  d[i] = s
sum = 0
for i in range(1,N):
  sum += d[N-i]
  
print(sum)

Measured memory_bytes: 78416
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

bool Prime[1000001] = {};
void createPrime() {
	ll n = 1000001;
	rep(i, 0, n) Prime[i] = true;
	Prime[0] = false;
	Prime[1] = false;
	rep(i, 2, n) {
		if (Prime[i]) {
			rep(j, 2, n) {
				if (j*i >= n)break;
				Prime[j*i] = false;
			}
		}
	}
}
bool isPrime(ll n) {
	rep(i, 2, sqrt(n)) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}
ll POW(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;

	ll t = POW(n, p / 2);
	//if (p & 1) return (t * t % MOD) * n % MOD;
	//else return t * t % MOD;
	if (p & 1) return (t * t) * n;
	else return t * t;
}
int main() {
	ll n, p; cin >> n >> p;
	map<ll, ll> mp;
	createPrime();

	if (n == 1) {
		cout << p << endl;
		return 0;
	}

	if (isPrime(p)) {
		cout << 1 << endl;
		return 0;
	}

	repe(i, 2, sqrt(p)) {
		if (Prime[i] && p % i == 0) {
			ll cnt = 0;
			ll k = p;
			while (k) {
				if (k % i == 0) {
					k /= i;
					cnt++;
				}
				else {
					break;
				}
			}
			mp[i] = cnt;
		}
	}

	ll ans = 1;
	for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
		if (it->second >= n) {
			ll t = it->second / n;
			t = POW(it->first, t);
			ans *= t;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<set>
using namespace std;

int a[13];
signed main() {
	a[4] = a[6] = a[9] = a[11] = 1;
	a[2] = 2;
	int b, c; cin >> b >> c;
	if (a[b] == a[c])puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
package main

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

func main() {
	var x, a int
	sc := bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		line := sc.Text()
		arr := strings.Fields(line)
		x, _ = strconv.Atoi(arr[0])
		a, _ = strconv.Atoi(arr[1])
	}

	if x < a {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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 string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<((f)?YES:NO)<<"\n";


int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    string t=string(T.begin(),T.end()-1);
    judge(S==t);
    return 0;
}


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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int N,Y;cin>>N>>Y;
    int x,y,z;
    for(x = 0; x*10000<=Y; x++){
        for(y = 0; x*10000+y*5000<=Y; ++y){
            if((Y-x*10000-y*5000)/1000 == N-x-y){printf("%d %d %d\n",x,y,N-x-y); return 0;}
        }
    }
    cout<<"-1 -1 -1"<<endl; return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0) {
    printf("%d\n", x2-1);
  }
  else if (x2 == 0) {
    printf("%d\n", x3-1);
  }
  else if (x3 == 0) {
    printf("%d\n", x4-1);
  }
  else if (x4 == 0) {
    printf("%d\n", x5-1);
  }
  else {
    printf("%d\n", x4+1);
  }
  return 0;
}

Measured memory_bytes: 3696
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let H = buf_it.next().unwrap().parse::<usize>().unwrap();
    let W = buf_it.next().unwrap().parse::<usize>().unwrap();

    let S:Vec<_> = (0..H).map(|_|
         buf_it.next().unwrap().chars().collect::<Vec<_>>()
    ).collect();

    let mut S2 = Vec::new();

    for i in 0..H{
        S2.push(Vec::new());
        for j in 0..W{
            S2[i].push(S[i][j] == '.');
        }
    }

    let INF = 100000;
    let N = H*W;
    let mut d = (0..N).map(|_| (0..N).map(|_| INF).collect::<Vec<_>>()).collect::<Vec<_>>();
    for i in 0..N{
        d[i][i] = 0;
    }

    for i in 0..H{
        for j in 0..W{
            if i<H-1{
                if S2[i][j] && S2[i+1][j]{
                    let k1 = idx(i,j,W);
                    let k2 = idx(i+1,j,W);
                    d[k1][k2] = 1;
                    d[k2][k1] = 1;
                }
            }
            if j<W-1{
                if S2[i][j] && S2[i][j+1]{
                    let k1 = idx(i,j,W);
                    let k2 = idx(i,j+1,W);
                    d[k1][k2] = 1;
                    d[k2][k1] = 1;
                }
            }
        }
    }

    for k in 0..N{
        for i in 0..N{
            for j in 0..N{
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }

    for i in 0..N{
        for j in 0..N{
            if d[i][j] == INF{
                d[i][j] = -1;
            }
        }
    }
    let ans = d.iter().map(|r| r.iter().max().unwrap()).max().unwrap();
    println!("{}",ans);

}

fn idx(i:usize,j:usize,W:usize) -> usize{
    i*W + j
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

int selectionSort(int A[],int N){
	int i,j,t,sw=0,minj;
	for(i=0;i<N-1;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj])	minj=j;
		}
		t = A[i];A[i]=A[minj];A[minj]=t;
		if(i!=minj)	sw++;
	}
	return sw;
}

int main(){
	int A[100],N,i,sw;
	
	scanf("%d",&N);
	for(i=0;i<N;i++)	scanf("%d",&A[i]);
	
	sw = selectionSort(A,N);
	
	for(i=0;i<N;i++){
		if(i>0)	printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);

	return 0;
}




Measured memory_bytes: 3216
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main(void) {
    char S[11];
    char T[12];

    scanf("%s", S);
    scanf("%s", T);

    if(strncmp(S, T, strlen(S)) != 0) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1712
# ABC164c


def main():
    import sys
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    n = int(input())
    s = [input() for _ in range(n)]
    print(len(set(s)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 107480
#!/usr/bin/env python3
import numpy as np
stdin = open(0)

N, K = map(int, stdin.readline().split())
A = np.array(stdin.read().split(), np.int64)


A = np.sort(A)
zero = A[A == 0]
pos = A[A > 0]
neg = A[A < 0]


def f(x):
    """count the number of products , <= x"""
    cnt_tpl = 0
    # zero and ...
    if x >= 0:
        cnt_tpl += len(zero) * N
    # positive and ...
    cnt_tpl += np.searchsorted(A, x // pos, side='right').sum()
    # negative and ...
    cnt_tpl += (N - np.searchsorted(A, (-x - 1) // (-neg), side='right')).sum()
    # a^2
    cnt_tpl -= np.count_nonzero(A * A <= x)
    assert cnt_tpl % 2 == 0
    return cnt_tpl // 2


left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= K:
        right = x
    else:
        left = x


print(right)


Measured memory_bytes: 34324
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,a; string b; cin>>N>>M;
  vector<int>A(N+1,0); vector<bool>C(N+1,false);
  int ac=0, wa=0;
  for(int i=0; i<M; i++){
    cin>>a>>b;
    if(C[a]==false){
      if(b=="WA") A[a]++;
      else if(b=="AC"){
        ac++;
        C[a]=true;
        wa+=A[a];
      }
    }
  }
  cout<<ac<<" "<<wa<<endl;
}


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

int main () {
    int n; cin >> n;
    string a,b,c; cin >> a >> b >>c;
    int ans =0;
    for (int i=0;i<n;++i) {
        set<int> st;
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        ans += (int)st.size() - 1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
AC
*/

ll n,a[100010],sum=0,ans=-1e18,t=0;

void init(){
	cin>>n;
	reg(i,1,n)cin>>a[i];
	reg(i,1,n)if(a[i]<0)t++;
	reg(i,1,n)sum+=abs(a[i]);
}

int main(void){
	init();
	if(t%2==0){
		ans=sum;
	}else{
		reg(i,1,n){
			ans=max({ans,sum-2*abs(a[i])});
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main()
{
  int a,b,c,k,cou=0;
  cin>>a>>b>>c>>k;
  while(b<=a){
    b*=2;
    cou++;
  }
  while(c<=b){
    c*=2;
    cou++;
  }
  if(cou<=k){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

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

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

ll K;
int main() {
    int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> K;
    rep(i, 32) {
        if (i + 1 == K) {
            cout << a[i] << endl;
            return 0; 
        }
    }
}

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

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

    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    int cnt = s[0] == '0';
    int r = 0;
    int ans = 0;
    REP(l, s.size()) {
        while (r + 1 < s.size()) {
            if (s[r + 1] == '0' && s[r] == '1' && cnt == K) break;
            r++;

            if (s[r-1] == '1' && s[r] =='0') {
                cnt++;
            }
        }

        ans = max(ans, r - l + 1);
        if (l == r) r++;
        if (l + 1 < s.size() && s[l] == '0' && s[l + 1] == '1') {
            cnt--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  int ans=0;
  cin>>K;
  for (int i=1; i<=K; i++){
    for (int j=1; j<=K; j++){
      for (int k=1; k<=K; k++){
        ans += gcd(i, gcd(j,k));
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;

#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 2e5+5;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

int main()
{
	int d, t, s;
	scanf("%d %d %d", &d, &t, &s);
	if(1LL*s*t>= 1LL*d) puts("Yes");
	else puts("No");
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
    }
    else { // 発見できなかったとき
        return 0;
    }
}

int main() {
    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 0, 3){
        rep(j, 0, 3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, 0, n){
        cin >> b[i];
    }
    rep(i, 0, 3){
        int cnt = 0;
        rep(j, 0, 3){
            if(vector_finder(b, a[i][j])) cnt++;
        }
        if(cnt == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(i, 0, 3){
        int cnt = 0;
        rep(j, 0, 3){
            if(vector_finder(b, a[j][i])) cnt++;
        }
        if(cnt == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    int cnt = 0;
    rep(i, 0, 3){
        if(vector_finder(b, a[i][i])) cnt++;
        if(cnt == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cnt = 0;
    rep(i, 0, 3){
        if(vector_finder(b, a[2 - i][i])) cnt++;
        if(cnt == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}


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

const int N = 1e5 + 100;

int n, dex, A, B, a[N];

int f(int dex) {
	return min(abs(a[dex] - A), abs(a[dex] - B));
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	A = a[n - 1] >> 1, B = (a[n - 1] + 1) >> 1;
	for (int i = 1; i < n - 1; i++)
		if(f(i) < f(dex))
			dex = i;
	cout << a[n - 1] << ' ' << a[dex];
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std ;
#define ll long long
const int maxn=110;
void dfs(){}
int dp[maxn][maxn];
signed main()
{
    
    int num;
    cin>>num;
    memset(dp,0, sizeof(dp));
    for (int k = 0; k <=9 ; ++k) {
        dp[1][k]=1;
    }
    for (int i = 2; i <=10 ; ++i) {
        for (int j = 0; j <=9 ; ++j) {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
        }
    }
    queue<int> ans;
    int l=0, r = 0,fl=0;
    for (int j = 1; j <=10 ; ++j) {
        for (int i = 1; i <=9 ; ++i) {
            if(num<=dp[j][i]){
                l=j;
                r=i;
                fl=1;
                break;
            }
            num-=dp[j][i];
        }
        if(fl==1)break;
    }
    l--;
    ans.push(r);
    while(l!=0){
        if(num<=dp[l][r-1]){
            r--;
            ans.push(r);
        }else{
            num-=dp[l][r-1];
            if(num<=dp[l][r]){
                ans.push(r);
            }else{
                num-=dp[l][r];
                r++;
                ans.push(r);
            }
        }
        l--;
    }
    while(!ans.empty()){
        int now=ans.front();
        cout<<now;
        ans.pop();
    }
    return 0 ;
}

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

bool right(int a,int b,int c){
	return ((c*c==a*a+b*b)?1:0);
}

int main(){
	int n;
	cin>>n;
	int a[3];
	bool ans[n];
	for(int i=0;i<n;i++){
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		ans[i]=right(a[0],a[1],a[2]);
	}
	for(int i=0;i<n;i++) cout<<((ans[i])?"YES":"NO")<<endl;
	return 0;
}



Measured memory_bytes: 3128
#include <cstdio>
#include <algorithm>
#include <utility>
#include <functional>

using namespace std;

typedef pair <int, int> ii;

int N;
ii ab[200005], ba[200005];
int lo, hi, lo2, hi2;
long long ans;

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        int a, b; scanf("%d%d", &a, &b);
        ab[i] = ii(a, b); ba[i] = ii(b, a);
    }
    sort(ab, ab + N);
    sort(ba, ba + N, greater <ii>());
    lo = ab[(N - 1) / 2].first;
    lo2 = ab[(N - 1) / 2 + 1].first;
    hi = ba[(N - 1) / 2].first;
    hi2 = ba[(N - 1) / 2 + 1].first;
    //printf("%d %d\n%d %d\n", wide.first, wide.second, secondWide.first, secondWide.second);
    if (N % 2 == 1) {
        ans = hi - lo + 1;
    } else {
        ans = (hi + hi2) - (lo + lo2) + 1;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 6352
// C
#include <bits/stdc++.h>
using namespace std;
long long A,B,C,D;

//nで割り切れるものの個数
long long div(long long  n){
    long long  ans;
    ans = B/n - (A-1)/n;
    return ans;
}

long long  LCM(long long  a, long long  b){
    long long  tmp,r;
    long long x = a*b;
    if(a < b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a%b;
    }
    return x/b;
}

int main(){  
    cin >> A >> B >> C >> D;
    long long  ans,l;
    l = LCM(C,D);
    //cout << l << endl;
    ans = (B-A+1) - div(C) - div(D) + div(l);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
 #define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{ 
	FIO;
	int str ,str2;
	cin>>str>>str2;
	
	 if((str2 - 1) % (str - 1) == 0){
    cout << (str2 - 1) / (str - 1) << endl;
  }
 
  else{
    cout << (str2 - 1) / (str - 1) + 1 << endl;
	
	}}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vector<int> hs(n+1),ws(m+1);
		for(int i=0;i<n;i++) cin>>hs[i+1],hs[i+1]+=hs[i];
		for(int i=0;i<m;i++) cin>>ws[i+1],ws[i+1]+=ws[i];;
		
		map<int,int> d;
		for(int i=0;i<=n;i++)
			for(int j=0;j<=m;j++)
				d[hs[i]-ws[j]]++;
		long long res=0;
		for(auto kv:d){
			int v=kv.second;
			res+=(long long)v*(v-1)/2;
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 28004
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=2e5+10;
int n;
ll sum[MAXN];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
		sum[i]=sum[i-1]+read();
	ll ans=(ll)(9e18);
	for(int i=1;i<n;++i) // s[1,i] = s[i+1,n]
	{
		ll x=sum[i],y=sum[n]-sum[i];
		ans=min(ans,abs(x-y));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	int cnt[n] = {};
	while(m--){
		int a, b;
		scanf("%d %d", &a, &b);
		cnt[a-1]++;
		cnt[b-1]++;
	}
	REP(i, 0, n) printf("%d\n", cnt[i]);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int d,n;
  cin >> d >> n;
  long long ans = 0;
  if(n < 100) ans = pow(100,d) * n;
  else ans = pow(100,d) * (n+1) ;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

memo1 = {}
memo2 = {}
memo3 = {}

for i_inv in range(N):
    i = N - 1 - i_inv
    # print("#", S[i])
    # print("#", memo1)
    # print("#", memo2)
    # print("#", memo3)
    if i_inv >= 2:
        for key2 in memo2.keys():
            key3 = S[i] + key2
            memo3[key3] = memo3.setdefault(key3, 0) + 1
    if i_inv >= 1:
        for key1 in memo1.keys():
            key2 = S[i] + key1
            memo2[key2] = memo2.setdefault(key2, 0) + 1
    #
    key1 = S[i]
    memo1[key1] = memo1.setdefault(key1, 0) + 1

# print("#", memo3)
print(len(memo3.keys()))


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

using namespace std;

int main() {

	int n;
	string s;
	cin >> n;
	cin >> s;

	vector<long long> al(26,1);

	for (int i = 0; i < n; i++) {
		al[s[i] - 'a']++;
	}
	long long res = 1;
	for (int i = 0; i < 26; i ++ ) {
		res = (res*al[i]) % 1000000007;
	}
	cout << res - 1 << endl;

}

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

int main() {
  int N,A; cin >>N >>A;
  cout <<(N*N)-A <<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int K = Integer.parseInt(scanner.next());
        int X = Integer.parseInt(scanner.next());
        System.out.println(500 * K >= X ? "Yes" : "No");
    }

}



Measured memory_bytes: 21716
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        BigInteger A = new BigInteger(sc.nextLine());
        BigInteger B = new BigInteger(sc.nextLine());
 
        int r;
        if ((r = A.compareTo(B)) > 0) {
            _out.println("GREATER");
        } else if (r < 0) {
            _out.println("LESS");
        } else {
            _out.println("EQUAL");
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

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

	unordered_map <string,bool> seen;
	string s;
	for (int i=0;i<n;i++)
	{	
		cin>>s;
		if (seen.count(s)!=0)
		{
			continue;
		}

		seen[s]=true;
	}

	cout<<seen.size();
}

void monsters()
{
	int h1,s1,h2,s2;
	cin>>h1>>s1>>h2>>s2;
	bool turn=true;
	while (h1>0 && h2>0)
	{
		if (turn)
		{
			h2=h2-s1;
		}

		else
		{
			h1=h1-s2;
		}

		turn=!turn;
	}

	if (h1>0)
	{
		cout<<"Yes"<<endl;
	}

	else
	{
		cout<<"No"<<endl;
	}
}

void goats()
{
	int s,w;
	cin>>s>>w;
	if (s>w)
	{
		cout<<"safe"<<endl;
	}	

	else
	{
		cout<<"unsafe"<<endl;
	}

}
int main()
{
	//goats();
	//monsters();
	lottery();
}

Measured memory_bytes: 17596
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
    long long N, Z, W; cin >> N >> Z >> W;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    long long res = abs(W - a[N-1]);
    if (N > 1) chmax(res, abs(a[N-2] - a[N-1]));
    cout << res << endl;
}


Measured memory_bytes: 256