akhauriyash/Code-Regression huggingface dataset:
/*à¥à¥*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* â€œStrength is the only thing that matters in this world. Everything else is just a delusion for the weak.â€ â€“ Vegeta */

#include<bits/stdc++.h>
using namespace std;
#define ll long long 



ll N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>N;
 string a,b,s;
 cin>>a>>b;

for(ll i = 0 ; i<N ; i++){
   cout<<a[i]<<b[i];
}


}



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

  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int p[n];
    rep(i, 0, n) cin >> p[i];
    int mn = p[0];
    int ans = 0;
    rep(i, 0, n) {
        if (p[i] <= mn) ans++;
        mn = min(mn, p[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
x=int(input())
y=input()
z=y.split()
e=0
for i in z:
    w=int(i)
    if w%2 == 0:
        if w%5 == 0:
            continue
        elif w%3 ==0:
            continue
        else:
            e=1
        
if e == 1:
    print("DENIED")
else:
    print("APPROVED")
    


Measured memory_bytes: 3060
#include<iostream>
#include<string.h>

char out[ 100000 + 1 ] ;
char change[ 100000 ] ;

using namespace std ;


int main( void )
{
	char now ,next ;
	
	int n ;
	while( 1 )
	{
		cin >> n ;
		
		if( n == 0 )
		{
			return 0 ;
		}
		
		memset( change ,0 ,sizeof change ) ;
		memset( out ,0 ,sizeof out ) ;
		
		int i ;
		for( i = 0 ; i < n ; ++i )
		{
			cin >> now ;
			cin >> next ;
			
			change[ now ] = next ;
		}
		
		cin >> n ;
		
		for( i = 0 ; i < n ; ++i )
		{
			cin >> now ;
			
			out[ i ] = change[ now ] == '\0' ? now : change[ now ] ;
		}
		
		cout << out << endl ;
	}
}

Measured memory_bytes: 3260
n,k=map(int,input().split())
a=list(map(int,input().split()))
mp={}
for e in a:
    if e in mp:
        mp[e]+=1
    else:
        mp[e]=1
l=len(mp)
ans=0
for e,cnt in sorted(mp.items(),key=lambda x:x[1]):
    if l <= k:
        break
    ans+=cnt
    l-=1
print(ans)


Measured memory_bytes: 39068
#include<algorithm>
#include<cmath>
#include<functional> //sortのgreater
#include<iostream>
#include<numeric> //iota(整数列の生成),gcdとlcm(c++17)
#include<string> //文字列
#include<vector>

using namespace std;
typedef long long ll;

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

    vector<string> vec;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        vec.push_back(s);
    }

    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

    cout << vec.size();

    return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> s(m),c(m);
  for (int i = 0; i < m; i++)
  {
    cin >> s[i] >> c[i];
  }

  for (int i = 0; i < 1000; i++)
  {
    bool flg = true;
    string is = to_string(i);
    if(is.size()==n){
      for (int j = 0; j < m; j++)
      {
        if(is[s[j]-1]-'0'!=c[j]) flg=false;
      }
      if(flg){
        cout << is << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

int main()
{

  int A[12];
  
  for(int i=0; i<12; i++)
    {
      scanf("%d", &A[i]);
    }
  

  /*  for(i=0; i<12; i++)
    {
      minj=i;
	for(j=i+1; j<12; j++)
	  {
	    if(A[j]<A[minj]) minj=j;
	  }

      A[i]=tmp;
      A[minj]=tmp;
      A[minj]=A[i];
      }   */



  
  std::sort(A,A+12);

  /* for(int i=0; i<12; i++)
    printf("%d ", A[i]);
  */
  if(A[0]==A[3]&&A[4]==A[7]&&A[8]==A[11])
    {
      printf("yes\n");
    }

  else printf("no\n");
  
  
}



Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int n,h,w;cin>>n>>h>>w;
  cout << (n-h+1)*(n-w+1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        {
            cin>>a[i];
            b[i]=a[i];
        }
    sort(a,a+n);
    for(int i=0;i<n;i++)
        if(b[i]<=a[n/2-1])cout<<a[n/2]<<endl;
        else cout<<a[n/2-1]<<endl;
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
void cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,M;
int A[100005];
vector<int>G[100005];
signed main(){
	cin>>N>>M;
	rep(i,N)cin>>A[i];
	rep(i,M){
		int a,b;cin>>a>>b;a--;b--;
		G[a].pb(b);G[b].pb(a);
	}
	int ans=0;
	rep(i,N){
		bool flag=true;
		for(int j:G[i]){
			if(A[i]<=A[j])flag=false;
		}
		if(flag)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 10256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }
ll mod = 1000000007;

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod; 
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}

vector<ll> fac(10000010);
vector<ll> inv(10000010);
vector<ll> facinv(10000010);

void modcalc(int n) {
	fac[0] = fac[1] = 1; inv[1] = 1;
	facinv[0] = facinv[1] = 1;
	for (int i = 2; i <= n; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0; 
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0) return 0;
	if (n == 0 && k == 0) return 1;
	return modcomb(n + k - 1, k);
}

template<class T>
class segtree {
	int n;
	vector<T> data;
	T def;
	function<T(T, T)> operation;
	function<T(T, T)> update;
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return data[k];
		T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operation(c1, c2);
	}
public:
	segtree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
		:def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}
	T operator[](int i) {
		return data[i + n - 1];
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	modcalc(2000010);
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	ll ans = 0;
	for (ll i = r1; i <= r2; i++) {
		ans += modcomb(c2 + i + 1, i + 1);
		ans -= modcomb(c1 + i, i + 1);
		if (ans < 0) ans += mod;
		if (ans >= mod) ans -= mod;
	}
	cout << ans << endl;
}


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

using namespace std;
using ll = long long;

int main() {
    int h1,m1,h2,m2,k = 0;
    cin >> h1 >> m1 >>h2 >> m2 >> k;
    int M = (h2 * 60 + m2) - (h1 * 60 + m1);
    cout << M - k << endl;
    
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

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

		int N=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();

		System.out.println(Math.min(A*N, B));

		sc.close();
	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int k,x;
  cin>>k>>x;
  if(500*k>=x)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 3e5 + 5;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int k, a, b;
	cin >> k >> a >> b;
	int t = a / k;
	if(a % k) t++;
	if(t * k >= a && t * k <= b) cout << "OK";
	else cout << "NG";
}


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

// int main()
// {
//   int n, k, q, a;
//   cin >> n >> k >> q;
//   vector<int> X(n, 0);

//   for (int i = 0; i < q; i++)
//   {
//     cin >> a;
//     X[a - 1]++;
//   }
//   for (int i = 0; i < n; i++)
//   {
//     if (X[i] + k - q > 0)
//       cout << "Yes" << endl;
//     else
//       cout << "No" << endl;
//   }
// }
int main()
{
  int n, k, q, a;
  cin >> n >> k >> q;
  vector<int> X(n, k - q);

  for (int i = 0; i < q; i++)
  {
    cin >> a;
    X[a - 1]++;
  }
  for (int i = 0; i < n; i++)
  {
    if (X[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n;
    cin >> n;
    vector< pair<int, int> > v;
    for(int i=0;i<n;i++) {
        int x, l;
        cin >> x >> l;
        v.push_back(pair<int, int>(x + l, x - l));
    }
    sort(v.begin(), v.end());
    int ans = 0;
    int idx = -INT_MAX / 2;
    for(auto x : v) {
        if(x.second >= idx) {
            ans++;
            idx = x.first;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1400
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM (long long)10000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    ll x, y, i;
};
int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};



void solve()
{
    ll x,y;
    cin>>x>>y;
    ll ans=1;
    if(y%2==1)
    {
        ans=0;
    }
    else
    {
        if(y>=2*x && y<=4*x)
        {

        }
        else
        {
            ans=0;
        }
    }
    if(ans)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
#endif // ONLINE_JUDGE
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x, n, p, check[110]={0}, min, sub = -1;

    scanf("%d %d", &x, &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &p);
        check[p]++;
    }

    if (n == 0)
    {
        printf("%d", x);
        return 0;
    }

    for (int i = 0; i <= 101; i++)
    {
        if (check[i] == 0)
        {
            if (abs(x - i) < sub || sub == -1)
            {
                min = i;
                sub = abs(x - i);
            }
        }
    }

    printf("%d", min);
    return 0;
}

Measured memory_bytes: 1684
n=int(input())
l=list()
for i in range(n):
    s,p=input().split()
    p=int(p)
    l.append([i+1,s,p])
l.sort(key=lambda x:(x[1],-x[2]))# 複数のキーでソートしたい時　昇順と降順を混ぜたい時はマイナスつける
for i in l:
    print(i[0])

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

int main()
{
    char a[2][2];
    for(int i = 0;i < 3; i ++){
        for(int j = 0; j < 3; j++){
            cin >> a[j][i];
        }
    }
    cout << a[0][0] << a[1][1] << a[2][2];
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
counta = 0
countb = 0
for i in range(n):
    for j in range(n-i-1):
        if a[i]>a[j+i+1]:
            counta += 1
b = sorted(a)[::-1]
for i in range(n):
    for j in range(n-i-1):
        if b[i]>b[j+i+1]:
            countb += 1
print((counta*k+countb*((k*(k-1))//2))%(10**9+7))


Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static int LCS(String i, String j) {
        int[][] table = new int[i.length()+1][j.length()+1];
        for (int x = 1; x <= i.length(); x++) {
            for (int y = 1; y <= j.length(); y++) {
                table[x][y] = (i.charAt(x-1) == j.charAt(y-1)) 
                    ? table[x-1][y-1] + 1
                    : Math.max(table[x-1][y], table[x][y-1]);
            }
        }
        return table[i.length()][j.length()];
    }
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt() * 2;
        String[] sequences = new String[q];
        for (int i = 0; i < q; i++)
            sequences[i] = in.next();
        for (int i = 0; i < q; i += 2)
            System.out.println(LCS(sequences[i], sequences[i+1]));
    }
}



Measured memory_bytes: 64364
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>
#include <fstream>
#include <cstdlib>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // freopen("a_in", "r", stdin);
    // freopen("a_out", "w", stdout);
    string s, t = "";
    cin >> s;
    for (int i = 0; i < (int) s.size(); ++i) {
    	t += 'x';
    }
    cout << t << "\n";
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false;}

const int MAX_N = 1e5 + 103;
const ll INF = 1LL << 60;
ll dp[MAX_N];

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  rep(i,MAX_N) dp[i] = INF;
  dp[0] = 0;
  rep(i,n) {
    for (int j=1; j<=k; ++j) {
      chmin(dp[i+j], dp[i] + abs(h[i+j]-h[i]));
    }
  }

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


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			int C = in.nextInt();
			int D = in.nextInt();
			int start = A > C ? A : C;
			int stop  = B < D ? B : D;
			out.println(start < stop ? stop - start : 0);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public char nextChar() {
			return next().charAt(0);
		}

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

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

	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    string S;
    cin >> N >> S;
    for (int i = 0; i < S.length(); i++){
        char x = S[i]+N;
        if(90 < S[i]+N){
            x = S[i]+N - 26;
        }
        cout << x;
    }

}


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

ul gcd(ul a, ul b) {
  if (a<b) swap(a, b);
  while (a%b>0) {
    a%=b;
    swap(a, b);
  }
  return b;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul a, b, c, d;
  cin >> a >> b >> c >> d;
  ul cd = c*d/gcd(c, d);
  //cerr << cd << endl;
  cout << (b-a+1) - (b/c-(a-1)/c) - (b/d-(a-1)/d) + (b/cd-(a-1)/cd) << endl;
  return 0;
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class X> inline bool chmax(T& a, X b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int N;
    cin >> N;
    
    vli a(N), b(N), c(N);
    rep(i, N) cin >> a[i] >> b[i] >> c[i];
    
    vector<vli> dp(N + 1, vli(3, 0));
    dp[0] = { 0,0,0 };
    rep(i, N) {
        chmax(dp[i + 1][0], dp[i][1] + a[i]);
        chmax(dp[i + 1][0], dp[i][2] + a[i]);
        chmax(dp[i + 1][1], dp[i][0] + b[i]);
        chmax(dp[i + 1][1], dp[i][2] + b[i]);
        chmax(dp[i + 1][2], dp[i][0] + c[i]);
        chmax(dp[i + 1][2], dp[i][1] + c[i]);
    }
    cou(max(dp[N][0], max(dp[N][1], dp[N][2])));
}

Measured memory_bytes: 8064
import sys
input = sys.stdin.readline

n,k = map(int, input().split())
r,s,p = map(int, input().split())
p = {'s': r, 'p':s, 'r':p}
T = input()

kk = [[] for _ in range(k)]
for i in range(n):
	kk[i % k].append(T[i])
ans = 0
for i in range(len(kk)):
	ans += p[kk[i][0]]
	j = 1
	while j < len(kk[i]):
		pj = kk[i][j-1]
		if(kk[i][j]==pj):
			if(j+1 < len(kk[i])):
				nj = kk[i][j+1]
				ans += p[kk[i][j+1]]
				j+=2
			else : j+=1
		else:
			ans += p[kk[i][j]]
			j+=1

print(ans)

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

int main()
{
    vector<int> v, v_odd;
    for (int i = 1; i < 1000; i++)
    {
        int tmp = (i * (i + 1) * (i + 2)) / 6;
        if (tmp > 1000000)
        {
            break;
        }
        v.push_back(tmp);
        if (tmp % 2 == 1)
        {
            v_odd.push_back(tmp);
        }
    }
    vector<int> dp(2000000, 10000000);
    vector<int> dp_odd(2000000, 10000000);
    dp[0] = 0;
    dp[1] = 1;
    dp_odd[0] = 0;
    dp_odd[1] = 1;
    for (int i = 0; i < 1000000; i++)
    {
        for (int j : v)
        {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
        for (int j : v_odd)
        {
            dp_odd[i + j] = min(dp_odd[i + j], dp_odd[i] + 1);
        }
    }

    while (1)
    {
        int n;
        cin >> n;
        if (n == 0)
        {
            break;
        }
        cout << dp[n] << " " << dp_odd[n] << endl;
    }
}



Measured memory_bytes: 18284
# Author: cr4zjh0bp
# Created: Sat Mar 28 11:53:27 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

k, n = na()
a = na()

ans = inf

for i in range(n):
    if i + 1 == n:
        ans = min(ans, k - ((k - a[i]) + a[0]), k - abs(a[i] - a[i - 1]))
    elif i == 0:
        ans = min(ans, k - (a[i] + (k - a[-1])), k - abs(a[i] - a[i + 1]))
    else:
        ans = min(ans, k - abs(a[i] - a[i - 1]), k - abs(a[i] - a[i + 1]))
print(ans)

Measured memory_bytes: 25176
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;

int main() {
	string s;
	cin>>s;
	int l = s.length(), ans = 0;
	for(int i=0;i<l;i++) {
		ans = (ans + s[i] - '0') % 9;
	}
	if(!ans) puts("Yes");
	else puts("No");
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;

struct UnionFind{

	std::vector<int> data;
	// dataの各要素について
	// 負の値:その集合のルートであること示す(spaghetti sourceではその絶対値は集合の要素数となっている)
	// 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

	//初期化 size:最大要素数
	UnionFind(int size): data(size, -1){ }

	// 集合を併合する
	// すでに同じ集合だった場合は、falseが返る
	bool unite(int x, int y){
		x=root(x); y=root(y);
		if( x != y ){
			// yの属する集合のルートをxに変更
			data[y] = x;
		}
		return x!=y;
	}

	// 同じ集合かどうか判定
	bool find(int x, int y){
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	int root(int x){
		// 負の値を持つものがその集合のルート
		// 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}

};


int main(){
	//ios_base::sync_with_stdio(0);
	int N, ans=0;
	ll x[100005], y[100005];
	vector<pair<pll,int>> vx, vy;

	cin >> N;
	rep(i,N){
		ll x, y;
		cin >> x >> y;
		vx.eb(pll(x, y), i);
		vy.eb(pll(y, x), i);
	}
	sort(all(vx));
	sort(all(vy));

	vector<pair<ll,pll>> v;
	rep(i,N-1){
		v.eb( vx[i+1].X.X - vx[i].X.X, pll(vx[i+1].Y, vx[i].Y) );
		v.eb( vy[i+1].X.X - vy[i].X.X, pll(vy[i+1].Y, vy[i].Y) );
	}
	sort(all(v));

	bool used[100005]={};
	UnionFind uf(N);
	for(auto t: v){
		int i = t.Y.X;
		int j = t.Y.Y;
		if( !uf.find(i, j) ){
			uf.unite(i,j);
			ans += t.X;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13988
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] times = new int[n];
    
        boolean isOdd = (n % 2 == 1);
        int num = 0;
        for(int i = 0; i < n; i++) {
            times[i] = sc.nextInt();
        }
        Arrays.sort(times);
        
        if(times[0] != 0 && isOdd){
			System.out.println(0);
			return;
		}
		
        for(int i=n - 1; i>0; i-=2){
			if(times[i] != times[i-1]){
				System.out.println(0);
				return;
			}
		}
		
        long ans=1;
		for(int i=0; i<n/2; i++)ans = 2*ans%1000000007;
		System.out.println(ans);
    }
    
}


Measured memory_bytes: 48912
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int query(int y1, int x1, int y2, int x2)
{
    int ans;
    cout << "? " << y1 << ' ' << x1 << ' ' << y2 << ' ' << x2 << endl;
    cin >> ans;
    return ans;
}

void solve(int y1, int x1, int y2, int x2, int n, vector<vector<bool> >& isBomb)
{
    if(n == 0)
        return;

    int h = y2 - y1 + 1;
    int w = x2 - x1 + 1;

    if(h == 1 && w == 1){
        isBomb[y1][x1] = true;
        return;
    }
    else if(h > w){
        int y3 = y1 + h / 2;
        int m = query(y1, x1, y3 - 1, x2);
        solve(y1, x1, y3 - 1, x2, m, isBomb);
        solve(y3, x1, y2, x2, n - m, isBomb);
    }
    else{
        int x3 = x1 + w / 2;
        int m = query(y1, x1, y2, x3 - 1);
        solve(y1, x1, y2, x3 - 1, m, isBomb);
        solve(y1, x3, y2, x2, n - m, isBomb);
    }
}

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

    vector<vector<bool> > isBomb(h, vector<bool>(w, false));
    solve(0, 0, h - 1, w - 1, n, isBomb);

    long long ans = 0;
    long long tmp = 1;
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            if(isBomb[y][x]){
                ans += tmp;
                ans %= k;
            }
            tmp *= 2;
            tmp %= k;
        }
    }
    cout << "! " << ans << endl;

    return 0;
}


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

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
ll n,k;
int main()
{
    scanf("%lld%lld",&n,&k);
    ll ans=0;
    for(ll i=1;i<k;i++){
        if(1ll*2*i%k!=0)
            continue ;
        ll t1=(n+k-i)/k;
        ll t2=(n+i)/k;
        ans+=t1*t2*t2;
    }
    ll z=n/k;
    ans+=z*z*z;
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
n = int(input())
a_array = list(map(int, input().split()))
for i in range(n):
    a_array[i] = (a_array[i], i + 1)
a_array.sort(key=lambda x:x[0])
buf=""
for _,i in a_array:
    print(buf,end="")
    print(i,end="")
    buf=" "

Measured memory_bytes: 19264
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int n, V;
ll W;
const ll inf = 1LL << 60;
const int maxV = 1000;
vll dp;

void init()
{
	cin >> n >> W;
	V = n * maxV;
	dp.resize(V + 1, inf);
	dp[0] = 0;
}

int main()
{
	init();

	REP(_i, n)
	{
		ll w;
		int v;
		cin >> w >> v;

		RREPC(i, V - v)
			chmin(dp[i + v], dp[i] + w);
	}

	int ans = 0;
	REPC(i, V)
		if (dp[i] <= W)
			ans = i;

	cout << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
ll x[2], y[2]; 
int main() {
	cin >> x[0] >> x[1];
	cin >> y[0] >> y[1];
	ll ans = -1LL << 60;

	rep(i,2) rep(j,2) ans = max(ans,x[i]*y[j]);

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    int sum=0;
    REP(i,N){
        int a; cin>>a;
        sum+=a;
    }
    cout<<(sum%2==0? "YES":"NO")<<endl;
}


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

int main() {

    int n, m, p;
    while (cin >> n >> m >> p and (n or m or p)) {

        int sum=0, hit=0;
        rep(i, n) { int t; cin >> t; sum += 100*t; if (i == m-1) hit += t; }
        if (hit == 0) cout << 0 << endl;
        else cout << (int)(sum * (100.0 - p) / 100 / hit) << endl;

    }

    return 0;

}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=100005;
ll tree[3*N];
ll prev(ll x)
{
    return (x&(x-1));
}
ll next(ll x)
{
    return 2*x-prev(x);
}
void update(ll ind, ll diff)
{
    while(ind<=2*N)
    {
        tree[ind]+=diff;
        ind=next(ind);
    }
}
ll get(ll ind1, ll ind2)
{
    ll ans=0;
    while(ind2)
    {
        ans+=tree[ind2];
        ind2=prev(ind2);
    }
    ind1--;
    while(ind1)
    {
        ans-=tree[ind1];
        ind1=prev(ind1);
    }
    return ans;
}
long long a[N],b[N],sum[N];
int main()
{
    #define int long long
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    if(n==1)
    {
        cout<<a[0]<<endl;
        return 0;
    }
    int ans;
    int low=0, high=1e9;
    while(low<=high)
    {
        int mid=(low+high)/2;
        for(int i=0;i<n;i++)
            if(a[i]>=mid)
                b[i]=1;
            else
                b[i]=-1;
        sum[0]=b[0];
        int neg=0,pos=0;
        if(sum[0]<0)
            neg++;
        else
            pos++;
        for(int i=1;i<n;i++)
        {
            sum[i]=sum[i-1]+b[i];
            if(sum[i]<0)
                neg++;
            else
                pos++;
        }
        long long tot=0;
        update(sum[0]+N,1);
        for(int i=1;i<n;i++)
        {
            tot+=get(1,sum[i]+N);
            pos+=get(1,sum[i]+N);
            neg+=i-get(1,sum[i]+N);
            update(sum[i]+N,1);
        }
        for(int i=0;i<n;i++)
            update(sum[i]+N,-1);
        if(pos>=neg)
        {
            ans=mid;
            low=mid+1;
        }
        else
            high=mid-1;
        continue;
        long long mn=1LL*n*(n-1)/2;
        mn=(mn+1)/2;
        if(tot>=mn)
        {
            ans=mid;
            low=mid+1;
        }
        else
            high=mid-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 3e5+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second

char s[maxN];
int main() {
	int n;
	scanf("%d",&n);
	scanf("%s",s+1);
	int cnt = 0;
	for(int i=1;i+2<=n;i++)
	{
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int nt[N << 1], to[N << 1], head[N], w[N << 1], cnt = 1;

void add(int x, int y, int z) {
  to[++cnt] = y;
  w[cnt] = z;
  nt[cnt] = head[x];
  head[x] = cnt;
}

ll sub(ll x, ll y) {
  return (x -= y) < 0 ? x + mod :x;
}

void Sub(ll &x, ll y) {
  x = sub(x, y);
}

ll mul(ll x, ll y) {
  return x * y % mod;
}

ll add(ll x, ll y) {
  return (x += y) >= mod ? x - mod : x;
}

void Add(ll &x, ll y) {
  x = add(x, y);
}

ll js(ll x) {
  return mul(x, x - 1);
}

ll inf = 1e18;
typedef pair<ll, int> P;
priority_queue<P, vector<P>, greater<P> > q;

void dij(int S, int T, ll dis[], ll fg[]) {
  for(int i = 1; i < N; ++i) dis[i] = inf;
  dis[S] = 0, fg[S] = 1;
  q.push(P(0, S));
  while(!q.empty()) {
    P h = q.top(); q.pop();
    int u = h.second;
    ll d = h.first;
    if(dis[u] < d) continue;
    for(int i = head[u]; i; i = nt[i]) {
      if(dis[to[i]] > d + w[i]) {
        dis[to[i]] = d + w[i];
        fg[to[i]] = fg[u];
        q.push(P(dis[to[i]], to[i]));
      } else if(dis[to[i]] == d + w[i]) {
        Add(fg[to[i]], fg[u]);
      }
    }
  }
}

ll dis[2][N], fg[2][N];
int main() {
  int n, m, S, T;
  cin >> n >> m >> S >> T;
  for(int i = 1, x, y, z; i <= m; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, z), add(y, x, z);
  }
  dij(S, T, dis[0], fg[0]), dij(T, S, dis[1], fg[1]);
  ll D = dis[0][T], ans = js(fg[0][T]);
  double gg = D / 2.0;
  for(int i = 1; i <= m; ++i) {
    int u = to[i * 2 + 1], v = to[i * 2], val = w[i * 2];
    if(dis[1][u] + val + dis[0][v] == D) {
      ll mn = dis[0][v], mx = mn + val;
      if(mx > gg && mn < gg) {
        Sub(ans, js(mul(fg[1][u], fg[0][v])));
      }
    } else if(dis[1][v] + val + dis[0][u] == D) {
      ll mn = dis[0][u], mx = mn + val;
      if(mx > gg && mn < gg) {
        Sub(ans, js(mul(fg[1][v], fg[0][u])));
      }
    }
  }
  if(D % 2 == 0) {
    for(int i = 1; i <= n; ++i) {
      if(dis[1][i] + dis[0][i] == D && dis[1][i] == D / 2) {
        Sub(ans, js(mul(fg[1][i], fg[0][i])));
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 12916
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=100100;
bool ex[N];
int cnt[N];
int n,m,ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)cnt[i]=1;
	ex[1]=1;
	for(int x,y;m--;)
	{
		scanf("%d%d",&x,&y);
		cnt[x]--;cnt[y]++;
		if(ex[x])ex[y]=1;
		if(!cnt[x])ex[x]=0;
	}
	for(int i=1;i<=n;i++)
		ans+=ex[i];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <queue>
using namespace std;
typedef pair<string,int> psi;

int main() {
    int n,q;
    cin >> n >> q;
    queue<psi> Q;
    for(int i=0; i<n; i++) {
        string str;
        int t;
        cin >> str >> t;
        Q.push(psi(str,t));
    }

    int cur = 0;
    while(!(Q.empty())) {
        psi x = Q.front(); Q.pop();
        if(x.second <= q) {
            cur += x.second;
            cout << x.first << " " << cur << endl;
        } else {
            cur += q;
            Q.push(psi(x.first, x.second - q));
        }
    }
    return 0;
}


Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	ll m=1000000000000000000;
	int n; cin >> n;
	VI a(n); REP(i,n) cin >> a[i];
	sort(ALL(a));
	if(a[0]==0){
		cout << 0 << endl;
		return 0;
	}
	ll ans=1;
	REP(i,n){
		if(m/ans<a[i]){
			cout << -1 << endl;
			return 0;
		}
		ans*=a[i];
	}
	if(ans<=m)
		cout << ans << endl;
	else
		cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int a,b;

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

	if(a+b <= 9){

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

	}else{

		printf("error\n");
	}

	return 0;
}


Measured memory_bytes: 3820
#include<stdio.h>

 
int main(void)
{
    int N,sum;
    scanf("%d",&N);
    sum = N / 1000 ;
    if(N % 1000 == 0)
    {
    	printf("0\n");
    	return 0 ;
    }
    printf("%d\n",1000*(sum+1)-N);
    
    
    
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
using namespace std;
int main()
{
	int i,j,n,m,k,l,o,p;
	cin>>n;
	m=n;
	while (m!=0)
	{
		k=m%10;
		if(k==9){cout<<"Yes";return 0;}
		m=m/10;
	}
	cout<<"No";
}

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

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<ll,ll> mp;
  mp[0]++;
  ll sum = 0;
  rep(i,n) {
    sum += a[i];
    mp[sum % m]++;
  }
  ll res = 0;
  for (auto e : mp) res += e.second * (e.second - 1)/2;
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 4608
class Combi
  def initialize(max_n, mod = 10**9+7)
      @mod = mod
      @max_n = max_n

      @fac = Array.new(@max_n+1)
      @inv = Array.new(@max_n+1)
      @finv = Array.new(@max_n+1)

      @fac[0] = @fac[1] = 1
      @finv[0] = @finv[1] = 1
      @inv[1] = 1
      2.upto(@max_n) do |i|
          @fac[i] = @fac[i-1] * i % @mod
          @inv[i] = @mod - @inv[@mod%i] * (@mod/i) % @mod
          @finv[i] = @finv[i-1] * @inv[i] % @mod
      end
  end

  def nCk(n,k)
      @fac[n] * @finv[n - k] * @finv[k] % @mod
  end
end

x,y=gets.chomp.split.map(&:to_i)

if((2*x-y)%3!=0)
  puts 0
  exit
end

s=(2*x-y)/3;

if s<0
  puts 0
  exit
end


t=x-2*s

if(s<0 || t < 0)
  puts 0
  exit
end


combi = Combi.new(1000000)

puts combi.nCk(s+t,t)

Measured memory_bytes: 25212
#include <iostream>

using namespace std;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    D -= 1;

    for (int i = 0; i < N; ++i) {
        int ai;
        cin >> ai;

        X += D / ai + 1;
    }

    cout << X << endl;
    return 0;
}


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

int main() {
 int N;
 cin >> N;
 vector<char> A(N);
 bool tf = true;
 for(int i=0; i<A.size(); i++) {
  cin >> A.at(i);
 }
  
 for(int i=0; i<A.size(); i++) {
  if(A.at(i) == 'Y') {
   tf = false;
   break;
  }
 }
  
 if(tf) {
  cout << "Three"; 
 }
  
  else {
   cout << "Four"; 
  }
}

Measured memory_bytes: 256
MOD = 10**9 + 7
n, a, b = map(int, input().split())


def pow(x, n, MOD):
    res = 1
    while n:
        if n & 1:
            res *= x
            res %= MOD
        x *= x
        x %= MOD
        n >>= 1
    return res    


def fact(a, b, MOD):
    res = 1
    for i in range(a, b+1):
        res *= i
        res %= MOD
    return res


def combi(n, k, MOD):
    x = fact(n - k + 1, n, MOD)
    y = fact(1, k, MOD)
    return x * pow(y, MOD - 2, MOD) % MOD
    

def solve():
    ans = pow(2, n, MOD) - 1 - combi(n, a, MOD) - combi(n, b, MOD)
    print(ans % MOD)
    #print(pow(2, MOD, MOD))


if __name__ == "__main__":
    solve()

Measured memory_bytes: 63076
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
ll solve(ll w, ll h)
{
    ll ans = 9223372036854775807;
    vector<ll> area(3);
    {
        ll w1 = w / 3;
        area[0] = w1 * h;
        {
            ll w2 = (w - w1) / 2;
            area[1] = w2 * h;
            ll w3 = w - w1 - w2;
            area[2] = w3 * h;
            sort(area.begin(), area.end());
            if (area[0] != 0) ans = min(ans, area[2] - area[0]);
        }
    }
    {
        ll w1 = w / 3 + 1;
        area[0] = w1 * h;
        {
            ll w2 = (w - w1) / 2;
            area[1] = w2 * h;
            ll w3 = w - w1 - w2;
            area[2] = w3 * h;
            sort(area.begin(), area.end());
            if (area[0] != 0) ans = min(ans, area[2] - area[0]);
        }
    }
    {
        ll w1 = w / 3;
        ll w2 = w - w1;
        area[0] = w1 * h;
        {
            ll h2 = h / 2;
            area[1] = h2 * w2;
            ll h3 = h - h2;
            area[2] = h3 * w2;
            sort(area.begin(), area.end());
            if (area[0] != 0) ans = min(ans, area[2] - area[0]);
        }
    }
    {
        ll w1 = w / 3 + 1;
        ll w2 = w - w1;
        area[0] = w1 * h;
        {
            ll h2 = h / 2;
            area[1] = h2 * w2;
            ll h3 = h - h2;
            area[2] = h3 * w2;
            sort(area.begin(), area.end());
            if (area[0] != 0) ans = min(ans, area[2] - area[0]);
        }
    }
    return ans;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    ll ans = min(solve(h, w), solve(w, h));
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
void solve()
{
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for (int i=0; i<n; i++)
		cout<<s[i]<<t[i];
}   
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import math
def Koch(tops):
    n = len(tops)
    new_tops = [tops[0]]
    for i in range(n-1):
        b = [0,0]
        a = [2*tops[i][0]/3 + tops[i+1][0]/3, 2*tops[i][1]/3 + tops[i+1][1]/3]
        c = [tops[i][0]/3 + 2*tops[i+1][0]/3, tops[i][1]/3 + 2*tops[i+1][1]/3]
        b[0] = (c[0]-a[0])*math.cos(math.radians(60)) - (c[1]-a[1])*math.sin(math.radians(60)) + a[0]
        b[1] = (c[0]-a[0])*math.sin(math.radians(60)) + (c[1]-a[1])*math.cos(math.radians(60)) + a[1]
        new_tops.append(a)
        new_tops.append(b)
        new_tops.append(c)
        new_tops.append(tops[i+1])
    return new_tops

n = int(input())
tops = [[0.,0.],[100.,0.]]
for i in range(n):
    tops = Koch(tops)

for j in range(len(tops)):
    print(*tops[j], sep=' ')



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

int main() {
  int N, M, T; cin >> N >> M >> T;
  int ans = 0;
  int pv = 0;
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    ans += max(0, max(0, a - M) - pv);
    pv = min(T, a + M);
  }
  cout << ans + T - pv << endl;
  return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[100];
  for(int i=0;i<n;i++) cin>>a[i];

  for(int i=0;i<n-1-i;i++) swap(a[i],a[n-1-i]);

  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 3076