akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=n-1;i>=m;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-9

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

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int sx, sy, tx, ty;
	string s = "";
	cin >> sx >> sy >> tx >> ty;
	tx -= sx;
	ty -= sy;
	sx = 0;
	sy = 0;
	REP(i, ty) s += 'U';
	REP(i, tx) s += 'R';
	REP(i, ty) s += 'D';
	REP(i, tx) s += 'L';
	s += 'L';
	REP(i, ty + 1) s += 'U';
	REP(i, tx + 1) s += 'R';
	s += 'D';
	s += 'R';
	REP(i, ty + 1) s += 'D';
	REP(i, tx + 1) s += 'L';
	s += 'U';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

ll N, M, V, P;
ll A[100000], S[100001];

signed main(){
    cin >> N >> M >> V >> P;
    rep(i, N) cin >> A[i];
    sort(A, A+N);
    rep(i, N) S[i+1] = S[i] + A[i];

    ll ans = 0;
    rep(i, N){
        if(i >= N-P){
            ans++;
            continue;
        }
        if(A[i]+M < A[N-P]){
            continue;
        }
        ll v = V - 1 - i - (P-1);
        if(v <= 0){
            ans++;
            continue;
        }
        if((A[i]+M)*(N-P-i) - (S[N-P+1]-S[i+1]) >= v*M){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5200
def main(n,a):
    s=a[0]+a[1]
    z=0
    for ai in a[2:]:
        z^=ai
    # i+j=s,i<=a[0],i^j=z となるi,jを探す
    # i+j=i^j+2*(i & j)
    # s = z + 2*(i & j)
    # i & j = (s-z)/2 = d
    # z = 2*(i & j) - s = i ^ j
    # d = (s-z) / 2
    # z = x^y , x&y=0
    # d^x,d^yは条件を満たす。d^x+d^y=d^x^d^y + 2*((d^x)&(d^y))= z + 2*d = s
    # (d^x)^(d^y)=x^y=z
    # (d^x)&(d^y)=d (z & d = 0 のときのみ)
    if s-z<0 or (s-z)%2==1:return -1
    d=(s-z)//2
    if d&z!=0:return -1
    if not d<=a[0]:return -1
    part=[]
    i=0
    while z//pow(2,i):
        if (z//pow(2,i))%2==1:part.append(pow(2,i))
        i+=1
    ans=float('inf')
    k=len(part)
    x=0
    while part:
        tmp=part.pop()
        if d^(x+tmp)<=a[0]:
            x+=tmp
    return a[0]-(d^x) if d^x else -1


n=int(input())
a=list(map(int,input().split()))
print(main(n,a))

Measured memory_bytes: 9244
N = int(input())
D = {}
A = [int(a) for a in input().split()]
ans = 0
for i, a in enumerate(A):
    if i - a in D:
        ans += D[i-a]
    if i + a in D:
        D[i+a] += 1
    else:
        D[i+a] = 1
print(ans)

Measured memory_bytes: 40448
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX=3000;

signed main(){
    int N;cin>>N;
    int F[N][10];
    int P[N][11];
    REP(i,N)REP(j,10)cin>>F[i][j];
    REP(i,N)REP(j,11)cin>>P[i][j];
    int ans=-INF;
    for(int tmp=1;tmp<(1<<10);tmp++){
        bitset<10> s(tmp);
        int preans=0;
        REP(i,N){
            int count=0;
            REP(j,10){
                if(s.test(j)&&F[i][j]==1)count++;
            }
            preans+=P[i][count]; 	
        }
        ans=max(preans,ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
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 int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int dp[40];

int solve(int n){
	memset (dp, 0, sizeof(dp));
	
	dp[0] = 1;
	rep(i,n){
		dp[i+1] += dp[i];
		dp[i+2] += dp[i];
		dp[i+3] += dp[i];
	}
	return dp[n];
	
	}
	
int main(){
	while(true){
		int n=0;
		scanf("%d", &n);
		
		if(!n) break;
		
	
	
	
		printf("%d\n", (int)ceil((double) solve(n)/10/365));
		
	}
		return 0;
		
		
	}
		

Measured memory_bytes: 1032
N = int(input())
X1, X2 = int(N / 1.08), int((N + 1) / 1.08)
if int(X1 * 1.08) == N:
  print(X1)
elif int(X2 * 1.08) == N:
  print(X2)
else:
  print(":(")

Measured memory_bytes: 3060
#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  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const auto MOD = 1000000007;
//sort(all(x))とするとソートできるよ

//壊れた階段を０と設定し、n-1 n-2 段目までの到達数を足し合わせる。

//1000000007MODをとるときは、途中計算の時にMODを取っておいていい時とそうでないときがあることに注意。
//今回は加法なので、MODを加算することはおｋ。
//逆に、途中でとっておかないと、値がおかしなことになる。


vector<LL> L;

int DFS(int i){
    if(i == 0)return L[i] = 1;
    if(i == 1 && L[1] != 0)return L[1] = 1;

    if(L[i] != -1)return L[i]; //メモ化再帰

    return L[i] = (DFS(i-1) + DFS(i-2)) % MOD;
}


int main(){
    int N,M;
    cin >> N >> M;
    L.assign(N+1,-1);
    int a;
    rep(i,M){
        cin >> a;L[a] = 0;
    }
    cout << DFS(N) << endl;

}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
const int N=5000+10;
typedef long long ll;
int n;
ll ans,mod;
int coe[N];
int dp[2][N];
void pri(int ind){
	for(int i=0;i<=n;i++)cout<<dp[ind][i]<<" ";
	puts("");
}
void add(int &x,int y){
	x+=y;
	if(x>mod)x-=mod;
}
int main(){
	//n=5000,mod=1e9+7;
	cin>>n>>mod;
	coe[2]=1;
	int l=3,r=n,nw=2;
	while(l<=r)coe[l++]=coe[r--]=nw++;
	int pre=0,now=1;
	dp[pre][0]=1;
	for(int i=2;i<=n;i++){
		memset(dp[now],0,sizeof(dp[now]));
		for(int j=0;j*coe[i]<=n;j++)
			for(int k=0;k+j*coe[i]<=n;k++)
				add(dp[now][k+j*coe[i]],dp[pre][k]);
		//pri(now);
		swap(pre,now);
	}
	for(int i=0;i<=n;i++)
		ans=(ans+(ll)dp[pre][i]*(n-i)%mod)%mod;
	cout<<(ans%mod+mod)%mod;
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    vector<vector<int>> v(m);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if (a > m) continue;
        v[m-a].push_back(b);
    }
    int ans = 0;
    for (int i = m-1; i >= 0; i--) {
        for (int x : v[i]) {
            q.push(x);
        }
        if (!q.empty()) {
            ans += q.top(); q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

void hawawa()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto&& i : a) {
		cin >> i;
	}
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			ans++;
			a[i] = 0;
		}
	}
	cout << ans << "\n";
}

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


Measured memory_bytes: 256
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
#define DEBUG(x) cerr << '>' << #x << ':' << x << endl;
#define ll long long int
#define endl '\n'
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef queue<int> qii;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define all(x) x.begin(),x.end()
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
double pi = 2 * acos(0.0); 

void solve(){
    int a;
    cin>>a;
    cout<<a+pow(a,2)+pow(a,3);
}

int main(){ 
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 4148
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define all(c) (c).begin(), (c).end()
const int inf = 1 << 28;

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

int solve(int n, vector<int>& d){
    sort(all(d));
    vector<int> dp(n + 1, inf); dp[0] = 0;
    for(int v=0; v<=n; ++v){
        for(const auto x: d){
            if(v < x)continue;
            chmin(dp[v], dp[v - x] + 1);
        }
    }
    return dp[n];
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> d(m);
    for(auto& e: d)cin >> e;
    cout << solve(n, d) << '\n';
    return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 256
'use strict';
        (function(stdin) {
          var inputs  = stdin.toString();
          var cols = inputs.split('\n')[0].split(' ').map(Number);
var array = cols.sort(function(a,b){
    return a - b;
});
    console.log(array.join(' '));
      }(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7644
S = input()

n = S.count('N')
w = S.count('W')
s = S.count('S')
e = S.count('E')

def f(n,s):
  return (n==0 and s==0) or (n>0 and s>0)

b = f(n,s) and f(e,w)

if b:
  print("Yes")
else:
  print("No")







Measured memory_bytes: 9120
#include<iostream>
using namespace std;
 
int main(){
  int S;
  
  int h,m,s;

  cin >> S;
  
  h = S/3600;
  
  m = (S%3600)/60;
  
  s = (S%3600)%60;

  cout << h << ":" << m << ":" << s << endl;

  return 0;		 
}
		   


Measured memory_bytes: 3052
/*
    Author : manu_sy
*/
#include "bits/stdc++.h"
using namespace std;
 
/** Template Begins **/
 
typedef long long        ll;
typedef pair<int,int>    PII;
 
#define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(a)      (a).begin(), (a).end()
#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define LP(i,n)     for(int i=0;i< n;i++)
 
/* Debug */
 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.F << "," << P.S << ")";
} 
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }
 
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr << *sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
/* Debug Ends */
 
const int N = 5e6+7;
 
/** Template Ends **/
int n, a[N];
 
signed main() {
 
    IOS;
    cin >> n;
    FOR(i,1,n) {
    	char c;	cin >> c;
    	if (c == 'R')	a[i] = 1;
    	a[i] += a[i - 1];
    }
    auto count = [&] (int l, int r, int c) {
    	if (l > r)	return 0;
    	int h = a[r];
    	if (l > 0)	h -= a[l - 1];
    	if (!c)	h = (r - l + 1) - h;
    	debug(l, r, c, h);
    	return h;
    };
    int ans = n;
    FOR(i,0,n) {
    	int w1 = count(1, i, 0);
    	int r2 = count(i + 1, n, 1);
    	int mx = max(w1, r2);
    	int mn = min(w1, r2);
    	int cur = mn + mx - mn;
    	ans = min(ans, cur);
    }
    cout << ans << endl;
 
    return 0;
}























Measured memory_bytes: 4292
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;


//constant
const int MOD = 1e9+7;
const int INF = 1e18;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};
const double pi = acos(-1);


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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n
//memset(obj,value,sizeof(obj));




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,T; cin >> n >> T;
    int t[n]; rep(i,n) cin >> t[i];
    
    int ans = 0;
    for (int i = 0; i < n-1; i++) {
        ans += min(T,t[i+1]-t[i]);
    }ans += T;
    
    cout << ans << endl;
    
    
}





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




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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
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 gcd(int a, int b) {
  if (a % b == 0) {
    return(b);
  } else {
    return(gcd(b, a % b));
  }
}
int main() {
  ll N, K; cin >> N >> K;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  ll g = A[0]; ll max_n = *max_element(all(A));
  for(int i = 1; i < N; ++i) {
    g = gcd(A[i], g);
  }
  if(K % g == 0 && max_n >= K) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 3876
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    rep(i, M) cin >> L[i] >> R[i];
    int AR = *std::min_element(R.begin(), R.end());
    int AL = *std::max_element(L.begin(), L.end());
    cout << (AR-AL+1>=0?AR-AL+1:0);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
	int A[3][3];
	int N;
	for(int i = 0;i < 3; ++i){
		for(int j = 0; j < 3; ++j){
			cin >> A[i][j];
		}
	}
	cin >> N;
	int b[N];
	int fill[3][3];
	for(int i = 0;i < 3; ++i){
		for(int j = 0; j < 3; ++j){
			fill[i][j] = 0;
		}
	}
	for(int i = 0; i < N; ++i){
		cin >> b[i];
		for(int j = 0;j < 3; ++j){
			for(int k = 0; k < 3; ++k){
				if(b[i] == A[j][k]){
					fill[j][k] = 1;
				}
			}
		}
	}
	bool bingo = false;
	if((fill[0][0] == 1 && fill[0][1] == 1 && fill[0][2] == 1) || (fill[1][0] == 1 && fill[1][1] == 1 && fill[1][2] == 1) || (fill[2][0] == 1 && fill[2][1] == 1 && fill[2][2] == 1) || (fill[0][0] == 1 && fill[1][0] == 1 && fill[2][0] == 1) || (fill[0][1] == 1 && fill[1][1] == 1 && fill[2][1] == 1) || (fill[0][2] == 1 && fill[1][2] == 1 && fill[2][2] == 1) || (fill[0][0] == 1 && fill[1][1] == 1 && fill[2][2] == 1) || (fill[0][2] == 1 && fill[1][1] == 1 && fill[2][0] == 1)){
		bingo = true;
	}
	if(bingo){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


}


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

using namespace std;

int main(void){
    int N;
    cin>>N;
    int result;
    for(int a=1;a<=9;a++){
        for(int b=1;b<=9;b++){
            if(a*b==N) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>

int main(void){
	std::int64_t N;//,A,B;
	std::cin >> N;

	if(N == 1){
		std::cout << 1 << std::endl;
		return 0;
	}

	int ctr = 1;
	int tmp = 2;
	while(tmp <= N){
		tmp *= 2;
		ctr++;
	}
	std::cout << tmp/2 << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define N 220000
using namespace std;
struct node{
	int x,y;
}q[N];
int dep[N],p[N],a[N],f[N][21];
int Next[N],h[N],v[N],tot,k,n;
int dfs(int x,int fa){
	dep[x]=dep[fa]+1;
	f[x][0]=fa;
	for(int i=1;i<=20;i++)f[x][i]=f[f[x][i-1]][i-1];
	for(int i=h[x];i;i=Next[i]){
		if(v[i]==fa)continue;
		dfs(v[i],x);
	}
}
bool cmp(node x,node y){
	return x.y>y.y;
}
int lfs(int x){
	if(p[x]==1)return 0;
	p[x]=1;
	for(int i=h[x];i;i=Next[i]){
		if(dep[v[i]]<dep[x])continue;
		lfs(v[i]);
	}
}
int add(int x,int y){
	tot++;
	Next[tot]=h[x];
	v[tot]=y;
	h[x]=tot;
}
int find(int x,int k){
	for(int i=20;i>=0;i--)if(dep[f[x][i]]>=k)x=f[x][i];
	return x;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(i>=2)add(i,a[i]),add(a[i],i);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)q[i].x=i,q[i].y=dep[i];
	sort(q+1,q+1+n,cmp);
	int ans=0;
//	for(int i=1;i<=n;i++)printf("%d %d\n",q[i].x,q[i].y);
//	printf("\n");
	for(int i=1;i<=n;i++){
		int o=q[i].x;
		if(p[o]==1)continue;
		if(dep[o]<=1+k)continue;
		o=find(o,dep[o]-k+1);
//		printf("%d %d\n",q[i].x,o);
		lfs(o);
		ans++;
	}
	if(a[1]!=1)ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    ll ans = 0;
    rep(k, N) {
        bool flag = true;
        // (A, B) = (0, k)
        rep(y, N) {
            rep(x, N) {
                char ct1 = S[y][x];
                int tox = (y + k) % N, toy = x;
                toy -= k;
                if (toy < 0) toy += N;
                char ct2 = S[toy][tox];
                if (ct1 != ct2) flag = false;
            }
        }
        if (flag) ans += N;
    }

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

Measured memory_bytes: 384
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int x,y;
	int a[7]={1,3,5,7,8,10,12};
	int b[4]={4,6,9,11};
	int c[1]={2};
	cin>>x>>y;
	char p,q;
	rep(i,7){
		if(x==a[i])p='a';
		if(y==a[i])q='a';
	}
	rep(i,4){
		if(x==b[i])p='b';
		if(y==b[i])q='b';
	}
	if(x==c[0])p='c';
	if(y==c[0])q='c';
	if(p==q)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

int n, m;
int A[2000];

// i 番目以降の要素を用いて数値mを作ることができるかどうか (True/False)
bool solve(int i, int m) {

    if (i == n && m == A[i]) {
        return true;
    } else if (i == n) {
        return false;
    }
    
    if (solve(i + 1, m) || solve(i + 1, m - A[i])) return true;
    else return false;
}

int main(void) {
    int w;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> w;
        string ans = solve(0, w) ? "yes":"no";
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

ll n;
ll a[100010];

ll gcdL[100010], gcdR[100010];

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

int main(void){
	cin>>n;
	for (int i = 0; i < n; i++) cin>>a[i];
	
	gcdL[0] = a[0];
	gcdR[n - 1] = a[n - 1];

	for (int i = 1; i < n; i++) gcdL[i] = gcd(a[i], gcdL[i - 1]);
	for (int i = n - 2; i >= 0; i--) gcdR[i] = gcd(a[i], gcdR[i + 1]);

	ll maxi = max(gcdR[1], gcdL[n - 2]);
	for (int i = 1; i < n - 1; i++) {
		ll g = gcd(gcdL[i - 1], gcdR[i + 1]);
		maxi = max(maxi, g);
	}

	cout<< maxi <<endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

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

int main()
{
    int a, b, c;
    while (cin >> a >> b >> c, a != -1) {
        int time = (a * 60 + b ) * 60 + c;
        time = (120 * 60) - time;
        a = time/3600;
        b = (time - a*3600)/60;
        c = time - a * 3600 - b * 60;
        cout << "0" << a << ":";
        if (b < 10) {
            cout << "0" << b << ":";
        } else {
            cout << b << ":";
        }
        if (c < 10) {
            cout << "0" << c << endl;
        } else {
            cout << c << endl;
        }
        time *= 3;
        a = time/3600;
        b = (time - a*3600)/60;
        c = time - a * 3600 - b * 60;
        cout << "0" << a << ":";
        if (b < 10) {
            cout << "0" << b << ":";
        } else {
            cout << b << ":";
        }
        if (c < 10) {
            cout << "0" << c << endl;
        } else {
            cout << c << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3068
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


MOD = 10**9 + 7
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

S = input()
N = len(S)


def is_kaibun(ss):
    return ss == ss[::-1]


flg = True
flg = flg and is_kaibun(S)
flg = flg and is_kaibun(S[:N // 2])
flg = flg and is_kaibun(S[N // 2 + 1:])
print('Yes' if flg else 'No')


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;

void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}

int main() {
    int N, K, C;
    cin >> N >> K >> C;
    string s;
    cin >> s;
    int l = s.size();
    vector<int> t;
    int last = l+C+1;
    rep(i, l) {
        if (s[l-i-1] == 'o' && l - i - 1 + C < last) {
            t.push_back(l-i-1);
            last = l-i-1;
        }
    }
    ll count = 0;
    for(auto i: t) {
        count++;
    }
    if (count > K) {
        cout << endl;
    } else {
        if (K == 1) {
            rep(i, l) {
                if (s[i] == 'o' && i != t[0]) {
                    cout << endl;
                    return 0;
                }
            }
            cout << t[0]+1 << endl;
        } else {
            vector<ll> ans;
            sort(t.begin(), t.end());
            ll count = 0;
            ll tmp1 = -(2*C);
            ll tmp2 = t[count];
            rep(i, l) {
//                cout << tmp2 << endl;
                if (i == tmp2) {
                    ans.push_back(i+1);
                    count++;
                    if (count == K) {
                        break;
                    } else {
                        tmp1 = i;
                        tmp2 = t[count];
                    }
                } else if (s[i] == 'o' && abs(i - tmp1) > C) {
                    count++;
                    if (count == K) {
                        break;
                    } else {
                        tmp1 = i;
                        tmp2 = t[count];
                    }
                }
            }

            for (auto i : ans) {
                cout << i << endl;
            }
        }

    }



}

Measured memory_bytes: 4212
input_num = input().split()
N = int(input_num[0])
A = int(input_num[1])
B = int(input_num[2])

result = 0

for num in range(1, N+1):
  str_num = str(num)
  cur_sum = 0
  for i in range(len(str_num)):
    cur_sum += int(str_num[i])
  if cur_sum >= A and cur_sum <= B:
    result += num
        
print(result)

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>

using namespace std;
typedef long long ll;
 

int main(){
	ll n;
	cin >> n;
	ll sum = 0, m;
	for(int i = 1; i <= n; i++){
		m = n/i;
		sum += i * (m*(m+1))/2;
	} 
	cout << sum;
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
  int n,k;
  cin >> n >> k;
  int p,r,s;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  ll pt=0;
  int rc=0,sc=0,pc=0;
  Vb win(t.size(),0);
  rep(i,t.size()){
    char c=t[i];
    if(i<k){
      if(c=='r') pt+=p;
      else if(c=='s') pt+=r;
      else pt+=s;
      win[i]=1;

    }
    else{
      if(t[i-k]!=t[i]||win[i-k]==0){
        if(c=='r') pt+=p;
        else if(c=='s') pt+=r;
        else pt+=s;
        win[i]=1;

      }
    }
  }
  cout << pt << endl;
      
}

Measured memory_bytes: 3752
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, ans, sum, last, cnt,d[1000000];
struct Edge { LL to,cost; };
vector<Edge>vec[100000];
string str;
bool f=0;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct edge { LL to, cap, rev; };
//g[e.to][e.rev]で逆辺
void addedge(vector<vector<edge>> &g, LL from, LL to, LL cap) {
	g[from].push_back(edge{ to, cap, (LL)g[to].size() });
	g[to].push_back(edge{ from, 0, (LL)g[from].size() - 1 });
}
LL dfs(vector<vector<edge>> &g, vector<bool> &used, LL v, LL t, LL f) {
	if (v == t)return f;
	used[v] = true;
	rep(i, g[v].size()) {
		edge& e = g[v][i];
		if (!used[e.to] && e.cap > 0) {
			LL d = dfs(g, used, e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
LL ford(vector<vector<edge>> &g, LL s, LL t) {
	LL flow = 0;
	for (;;) {
		vector<bool> used(g.size(), false);
		LL f = dfs(g, used, s, t, INF);
		if (f == 0)return flow;
		flow += f;
	}
}

int main() {
	cin >> n >> m;
	vector<vector<edge>> g(n);
	rep(i, m) {
		LL x, y, z;
		cin >> x >> y >> z;
		addedge(g, x, y, z);
	}
	cout << ford(g, 0, n - 1) << endl;;
	return 0;
}


Measured memory_bytes: 5588
from bisect import bisect_left
from collections import defaultdict as dd
N = int(input())
As = list(map(int, input().split()))
Es = dd(dict)
for _ in range(N-1):
    f, t = map(int, input().split())
    Es[f-1][t-1] = Es[t-1][f-1] = 1

INF = float('inf')
RET = 0
PROC = 1

stack = []
lismin = [INF] * N
anss = [INF] * N
visited = [False] * N

stack.append((RET, 0, INF))
stack.append((PROC, 0, 0))
while stack:
    cmd, *v = stack.pop()
    if cmd == RET:
        i, backup = v
        lismin[i] = backup
    else:
        node, i = v
        lismin[i] = As[node]
        anss[node] = bisect_left(lismin, INF)
        visited[node] = True
        for to in Es[node].keys():
            if not visited[to]:
                x = bisect_left(lismin, As[to])
                stack.append((RET, x, lismin[x]))
                stack.append((PROC, to, x))
for ans in anss:
    print(ans)



Measured memory_bytes: 123032
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define in cin >>
#define out cout <<
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll modpow(ll a,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1)res=a*res%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}
void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}


int main(){
    int s,w;
    cin >> s >> w;
    if(s<=w){
        cout << "unsafe";
    }else{
        cout << "safe";
    }


}


Measured memory_bytes: 3636
#include <iostream>
#include<algorithm>
using namespace std;
#define max_n 7368791
int prime[max_n];
bool is_prime[max_n+1];
int m,n,i,j;
int sieve(){
	int p=0;
	for(i=m;p<n+1;i++){
		if(is_prime[i]){
			prime[p]=i;
			p++;
			for(j=2*i; j<=max_n; j+=i){
				is_prime[j] = false;
			}
		}
	}
    return p;
}

int main() {
while(cin>>m>>n){
	for(i=0;i<max_n+1;i++){
		is_prime[i]=true;
		prime[i]=0;
}
	if(m==0 && n==0){break;}
	int k=sieve();
	cout<<prime[n]<<endl;
}
	return 0;
}

Measured memory_bytes: 39096
N=input()

def prime(n):
    seq = list(range(2, n))
    while len(seq) > 0:
        prime = seq.pop(0)
        yield prime
        seq = [i for i in seq if not i % prime == 0]


s=list(prime(55556))

a=[]
cnt=0
for i in s:
	if i%5==1:
		a.append(i)
		cnt+=1
	if cnt==N: break

for i in a: print i,

Measured memory_bytes: 41884
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

int n;
V<int> a;
V<V<ll>> dp;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    rep(i,0,n) cin >> a[i];
    dp.resize(n, V<ll>(n, 0));
    for (int i = 0; i < n; ++i) {
        dp[i][i] = n % 2 == 1 ? a[i] : -a[i];
    }
    for (int l = n-2; l >= 0; --l) {
        for (int r = l+1; r < n; ++r) {
            bool turn = (r-l+1) % 2 == n % 2;
            if (turn) {
                dp[l][r] = max(dp[l+1][r] + a[l], dp[l][r-1] + a[r]);
            }
            else {
                dp[l][r] = min(dp[l+1][r] - a[l], dp[l][r-1] - a[r]);
            }
        }   
    }
    cout << dp[0][n-1] << endl;
}


Measured memory_bytes: 70784
#include <stdio.h>

int main(void) {
    int i, a;
    int s = 0;
    for (i = 0; i < 5; i++) {
        scanf("%d", &a);
        if (a < 40)
            s += 40;
        else
            s += a;
    }

    printf("%d\n", s / 5);
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;


ll A, B, C, D, ans,ansC, ansD, ansCD;
string S;


int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> A >> B;
	cin >> C >> D;


	ansC = B / C - (A - 1) / C;
	ansD = B / D - (A - 1) / D;
	
	ll c = C, d = D;
	if (d > c)swap(d, c);
	ll ama = c % d;
	while (ama != 0) {
		c = d;
		d = ama;
		ama = c % d;
	}
	ll G = C * D / d;
	ansCD = B / G - (A - 1) / G;


	cout << B-A+1-ansC-ansD+ansCD << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define t first
#define v second
#define wrap make_pair
using namespace std;
typedef double db;
typedef pair<db,int> pint;
typedef const pint& cpr;
typedef long long ll;
const int siz=5e5+1;

int n,L;
ll Vsum;
db Esum;
pint a[siz];
deque<pint> q;

inline
db mix(cpr a,cpr b){return (a.t*a.v+b.t*b.v)/(a.v+b.v);}

int main()
{
#ifdef DEBUG
	freopen("AT2402.in","r",stdin);
#endif
	scanf("%d%d",&n,&L);
	for(int i=1,y;i<=n;i++){
		db x;
		scanf("%lf%d",&x,&y);
		a[i]=wrap(x,y);
		while(a[i].v+Vsum>L){
			pint now=q.front();
			q.pop_front();
			int pour=min(a[i].v+Vsum-L,(ll)now.v);
			Vsum-=pour;
			Esum-=pour*now.t;
			now=wrap(now.t,now.v-pour);
			if(now.v!=0)
				q.push_front(now);
		}
		q.push_back(a[i]);
		while(q.size()>1&&q[q.size()-2].t>q.back().t){
			pint b=q.back();
			q.pop_back();
			pint c=q.back();
			q.pop_back();
			q.push_back(wrap(mix(b,c),b.v+c.v));
		}
		Esum+=a[i].t*a[i].v;
		Vsum+=a[i].v;
		printf("%.7f\n",Esum/L);
	}
	return 0;
}

Measured memory_bytes: 24976
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
int n, q;
vector<int> data;


void add(int pos, int val, int num, int l, int r){
	if (l > pos || r <= pos)
		return;

	data[num] += val;

	if (r - l > 1){
		add(pos, val, num * 2 + 1,  l, (l + r) / 2);
		add(pos, val, num * 2 + 2, (l + r) / 2, r);
	}
}

int  sum(int num, int kl, int kr, int l, int r){
	int ret = 0;

	if (l >= kl && r <= kr)
		return data[num];

	int mid = (l + r) / 2;
	if (mid > kl){
		ret += sum(num * 2 + 1, kl, kr, l, mid);
	}
	if (mid < kr){
		ret += sum(num * 2 + 2, kl, kr, mid, r);
	}
	return ret;
}

signed main() {
	scanf("%d %d", &n, &q);



	int cur = 1;
	while (cur < n)
		cur *= 2;

	data.resize(cur*2+1, 0);

	REP(i, q){
		int t, a, b;
		cin >> t >> a >> b;
		
		if (t == 0)
			add(a-1, b, 0, 0, cur);
		else
			printf("%d\n", sum(0, a-1, b, 0, cur));

	}
	


	return 0;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
#define int long long
#define vin vector<int>
#define vcn vector<char>
#define ver pair<int,int>
#define ld long double
#define pb push_back
#define x first
#define y second
#define blush fflush(stdout);fflush(stdin);
#define $(a) (int)a.size()
#define scanf ;
#define printf ;
using namespace std;
void i_love_misaka_mikoto();
int32_t main(){
    #ifdef RNS
        freopen("input.txt","r",stdin);
        #ifndef DBG
        freopen("output.txt","w",stdout);
        #endif
    #else
        ios_base::sync_with_stdio(false);
    #endif
    i_love_misaka_mikoto();
    #ifdef RNS
        cout<<'\n'<<(ld)clock()/CLOCKS_PER_SEC<<" セクンド\n";
    #endif
    return 0;
}

vector<ld> in;
ld sp[3013][3013];

void i_love_misaka_mikoto(){
    int n;
    cin>>n;
    in.resize(n+1);
    for(int i=1;i<=n;i++)
        cin>>in[i];
    sp[1][1]=in[1];
    sp[1][0]=1-in[1];
    for(int i=3;i<=n;i+=2){
        sp[i][0]=sp[i-2][0]*(1-in[i])*(1-in[i-1]);
        sp[i][1]=sp[i-2][0]*in[i]*(1-in[i-1])+sp[i-2][0]*in[i-1]*(1-in[i])+sp[i-2][1]*(1-in[i-1])*(1-in[i]);
        for(int j=2;j<=i;j++){
            sp[i][j]=sp[i-2][j-1]*in[i]*(1-in[i-1])+sp[i-2][j-1]*in[i-1]*(1-in[i])+sp[i-2][j-2]*in[i]*in[i-1]+sp[i-2][j]*(1-in[i])*(1-in[i-1]);
        }
    }
    ld ans=0.0;
    for(int i=(n+1)/2;i<=n;i++)
        ans+=sp[n][i];
    cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 139776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CNotSoDiverse solver = new CNotSoDiverse();
        solver.solve(1, in, out);
        out.close();
    }

    static class CNotSoDiverse {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();
            Map<Integer, Integer> p = new HashMap<>();
            Map<Integer, Integer> r = new TreeMap<>();
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                p.merge(a, 1, (x, y) -> x + y);
            }
            int d = p.size() - k;
            if (d <= 0) {
                out.println(0);
                return;
            }
            for (Map.Entry<Integer, Integer> e : p.entrySet()) {
                r.merge(e.getValue(), 1, (x, y) -> x + y);
            }
            Iterator<Map.Entry<Integer, Integer>> it = r.entrySet().iterator();
            long ans = 0;
            while (d > 0) {
                Map.Entry<Integer, Integer> e = it.next();
                if (d <= e.getValue()) {
                    ans += d * e.getKey();
                    break;
                }
                d -= e.getValue();
                ans += e.getKey() * e.getValue();
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 101544
import java.util.Scanner;

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

        int[] array;
        array = new int[100];
        int  n = sc.nextInt();

        for(int i=0; i<n ;i++){
            array[i] = sc.nextInt();
        }

        int[] copy;
        copy = new int[100];
        int cnt=0;
        for(int i=n-1; i>=0; i--){
            copy[cnt] = array[i];
            cnt++;
        }

        for(int i=0; i<n; i++){
            if(i!=n-1)
                System.out.print(copy[i] + " ");
            else
                System.out.print(copy[i]);
        }
        System.out.println("");

        sc.close();

    }
}


Measured memory_bytes: 26420
X,N = map(int,input().split())

if N==0:
  print(X)

else:
  P = list(map(int,input().split()))
  if X not in P:
    print(X)
  
  else:
      a = X+1
      b = X-1
      
      while a in P:
        a+=1
      while b in P:
        b-=1
      
      if abs(X-a)<abs(X-b):
        print(a)
      else:
        print(b)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b=0,c,x=0;
  cin>>x>>a;
  cout<<(x*x)-a<<endl;
  
  
  
  

}
return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
L, R = [0] * M, [0] * M
Lmax, Rmin = 0, 1e10
for i in range(M):
    L, R = map(int, input().split())
    if L > Lmax:
        Lmax = L
    if R < Rmin:
        Rmin = R

print(max(Rmin - Lmax + 1, 0))

Measured memory_bytes: 4596