akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

inline static int read_int() {
    int x = 0, k;
    while ((k = getchar_unlocked() - 'L') >= 0) x = x * 10 + k;
    return x;
}

inline static void put_int(int x) {
    int s = 0;
    char f[6] = {'0', '0', '0', '0', '0', '0'};
    if (!x) {
        putchar_unlocked('0');
        return;
    }
    while (x) {
        f[s++] += x % 10;
        x /= 10;
    }

    while (s--) putchar_unlocked(f[s]);
}

int main() {
    int flag = 0, l = 0, r = 0, i = 0, tmp, first = 1;

    for (;(tmp = getchar_unlocked() - 'L') >= 0; i++) {
        if (tmp) {
            // if c is R
            if (flag) {
                flag = 0;

                if ((tmp = r + 1) < l) {
                    if (first) {
                        first = 0;
                    } else {
                        putchar_unlocked(' ');
                    }
                    putchar_unlocked('0');

                    for (tmp++; tmp < l; tmp++) {
                        putchar_unlocked(' ');
                        putchar_unlocked('0');
                    }
                }

                if (first) {
                    first = 0;
                } else {
                    putchar_unlocked(' ');
                }
                tmp = (l - r + 1) / 2 + (i - l) / 2;
                put_int(tmp);
                putchar_unlocked(' ');
                tmp = (i - r) - tmp;
                put_int(tmp);

                for (tmp = l + 1; tmp < i; tmp++) {
                    putchar_unlocked(' ');
                    putchar_unlocked('0');
                }
                r = i;
            }
        } else {
            // if c is L
            if (!flag) {
                flag = 1;
                l = i;
            }
        }
    }

    if ((tmp = r + 1) < l) {
        if (first) {
            first = 0;
        } else {
            putchar_unlocked(' ');
        }
        putchar_unlocked('0');

        for (tmp++; tmp < l; tmp++) {
            putchar_unlocked(' ');
            putchar_unlocked('0');
        }
    }

    if (first) {
        first = 0;
    } else {
        putchar_unlocked(' ');
    }
    tmp = (l - r + 1) / 2 + (i - l) / 2;
    put_int(tmp);
    putchar_unlocked(' ');
    tmp = (i - r) - tmp;
    put_int(tmp);

    for (tmp = l + 1; tmp < i; tmp++) {
        putchar_unlocked(' ');
        putchar_unlocked('0');
    }

    putchar_unlocked('\n');
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
int s = 0;
    char a;
    for (int i=0;i<4;i++){
            cin >> a;

        if (a == '+'){
            s++;
         }else if (a == '-'){
            s--;
         }
    }
cout << s << endl;
return 0;
}

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

using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	int group[13] = {-1, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
	if (group[x] == group[y])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

const int mod = (int) (1e9 + 7);

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    vector<ll> b(n + 1, 0);
    rep(i, n){
        b.at(i + 1) = b.at(i) + a.at(i);
    }
    ll ans = 0;
    rep(i, n){
        ll sum = (b.at(n) - b.at(i + 1)) % mod; // A[i] + ... + A[N - 1] = B[N] - B[i]
        ans += a.at(i) * sum;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5648
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int q;
	cin >> q;
	rep(t, q){
		int k;
		cin >> k;
		ll d = 0, m = 0, c = 0, M = 0;
		rep(i, n){
			if(i >= k){
				if(s[i - k] == 'D') d--, m -= M;
				if(s[i - k] == 'M') M--;
			}
			if(s[i] == 'D') d++;
			if(s[i] == 'M'){
				M++;
				m += d;
			}
			if(s[i] == 'C') c += m;
		}
		cout << c << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]

def judge(m) :
    s = 0
    for i in range(N) :
        t = max(0, (h[i]-m*B+A-B-1)//(A-B))
        s += t
        if s > m :
            return False
    return True    

h.sort(reverse=True)
l, r = -1, 10 ** 9 + 1
while r - l > 1 :
    m = (l + r) // 2
    if judge(m) :
        r = m
    else :
        l = m

print(r)

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

const long long MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
vector<int> adj[MAXN];
int parent[MAXN];
long long dp[MAXN][2];

void dfs(int u) {
	dp[u][0] = dp[u][1] = 1;
	for (int v : adj[u]) {
		if (v != parent[u]) {
			parent[v] = u;
			dfs(v);
			dp[u][0] = (dp[u][0] * dp[v][1]) % MOD;
			dp[u][1] = (dp[u][1] * (dp[v][0] + dp[v][1])) % MOD;
		}
	}
}

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

	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dfs(1);
	long long answer = (dp[1][0] + dp[1][1]) % MOD;
	cout << answer << endl;
}


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

int main() {
    
    int M, K;
    cin >> M >> K;
    
    vector<int> ans;
	int ub = 1 << M;
    if (K >= ub) {
        ans = {-1};
	} else if (K == 0) {
		for (int i = 0; i < ub; ++i) {
			ans.push_back(i);
			ans.push_back(i);
		}
	} else if (M == 0) {
        ans = {0};
    } else if (M == 1) {
        if (K == 0) {
            ans = {0, 0, 1, 1};        
        } else {
            ans = {-1};
        }
    } else {
        vector<pair<int, int>> p;
        vector<bool> vis(ub, false);
        for (int i = 0; i < ub; ++i) {
            if (!vis[i]) {
                p.push_back({i, i ^ K});
                vis[i] = vis[i ^ K] = true;
            }
        }
        for (int i = 0; i < (int)p.size(); i += 2) {
            ans.push_back(p[i].first);
            ans.push_back(p[i].second);
            ans.push_back(p[i + 1].first);
            ans.push_back(p[i + 1].second);
            ans.push_back(p[i].second);
            ans.push_back(p[i].first);
            ans.push_back(p[i + 1].second);
            ans.push_back(p[i + 1].first);
        }
    }
 
    for (int i = 0; i < (int)ans.size(); ++i) {
        cout << ans[i] << " ";
    }
    cout << endl;
 
    return 0;
}


Measured memory_bytes: 2932
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int dp[1000000][2];
bool num[1000000];
int main(){
    int n,k;
    while(cin>>n>>k,n){
        bool flg=false;
        rep(i,k){
            int a;
            cin>>a;
            if(a)num[a-1]=true;
            else flg=true;
        }
        if(flg)dp[0][1]=1;
        if(num[0])dp[0][0]=1;
        int ret=0;
        reep(i,n,1){
            if(num[i]){
                dp[i][0]=dp[i-1][0]+1;
                dp[i][1]=max(dp[i-1][0],dp[i-1][1])+1;
                ret=max(dp[i][0],max(ret,dp[i][1]));
            }
            else if(flg){
                dp[i][1]=dp[i-1][0]+1;
                ret=max(dp[i][1],ret);
            }
        }
        cout<<ret<<endl;
        rep(i,n){
            dp[i][1]=0;
            dp[i][0]=0;
            num[i]=false;
        }
    }
}

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

int main() {
  string S,T,U;
  int A,B;
  cin >> S >> T >> A >> B >> U;
  if(S==U){
    cout << A-1 << " " << B;
  }
  if(T==U){
    cout << A << " " << B-1;
  }

return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A;
    int B;
    cin >> A;
    cin >> B;
    int eatA = 0;
    int eatB = 0;
    for (int i = 0; i < 16; i++) {
        if (i % 2 == 0) {
            eatA++;
        } else {
            eatB++;
        }
    }
    if (eatA >= A && eatB >= B) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int n,m;
 
char a[55][55],b[55][55];
 
int main(){
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#') continue;
            a[i][j]='0';
            if(a[i+1][j]=='#') a[i][j]++;
            if(a[i-1][j]=='#') a[i][j]++;
            if(a[i][j+1]=='#') a[i][j]++;
            if(a[i][j-1]=='#') a[i][j]++;
            if(a[i+1][j+1]=='#') a[i][j]++;
            if(a[i+1][j-1]=='#') a[i][j]++;
            if(a[i-1][j+1]=='#') a[i][j]++;
            if(a[i-1][j-1]=='#') a[i][j]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cout << a[i][j];
        }
        cout << '\n';
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int mx=0;
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(A[i] == 1){
            cnt++;
        }else{
            chmax(mx,cnt);
            cnt = 0;
        }
    }
    chmax(mx,cnt);
    cout << mx+1 << enld;
    return 0;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>

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



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int N, C;
  cin >> N >> C;
  vector<vector<int>> Ds(C, vector<int>(C));
  vector<vector<int>> cs(N, vector<int>(N));
  rep (j, C) {
    rep (i, C) {
      cin >> Ds[i][j];
    }
  }
  rep (j, N) {
    rep (i, N) {
      cin >> cs[i][j];
    }
  }

  vector<vector<int>> counts(3, vector<int>(C, 0));
  rep (j, N) {
    rep (i, N) {
      counts[(i+1+j+1)%3][cs[j][i]-1]++;
    }
  }

  /*
  rep (i, C) {
    cout << counts[0][i] << " ";
  }
  cout << endl;
  */

  vector<vector<int>> subs(3, vector<int>(C, 0));
  rep (p, 3) {
    rep (to, C) {
      rep (from, C) {
	if (from==to) continue;
	subs[p][to] += counts[p][from] * Ds[to][from];
      }
    }
  }
/*
  rep (p, 3) {
    rep (to, C) {
      cout << subs[p][to] << " ";
    }
    cout << endl;
  }
  */
  int ans = 0xfffffff;
  rep (c0, C) {
    rep (c1, C) {
      if (c1==c0) continue;
      rep (c2, C) {
	if (c2==c0 || c2==c1) continue;
	ans = min(ans, subs[0][c0]+subs[1][c1]+subs[2][c2]);
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}








Measured memory_bytes: 1280
#pragma GCC optimize(2)
#include <cstdio>
#include <set>
#include <algorithm>
#include <cmath>

int cnt[500005];
int a[500005];
int block;

struct A{
    int l, r;
    int idx;
    int ans;
}q[500005];

bool cmp(A a, A b){
    if(a.l / block != b.l / block)
        return a.l / block < b.l / block;
    return a.r < b.r;
}

bool cmp2(A a, A b){return a.idx < b.idx;}

int main(){
    int N, Q;
    int i;
    scanf("%d%d", &N, &Q);
    for(i = 1; i <= N; ++i)
        scanf("%d", &a[i]);
    for(i = 0; i < Q; ++i){
        scanf("%d%d", &q[i].l, &q[i].r);
        q[i].idx = i;
    }
    block = sqrt(N);
    std::sort(q, q + Q, cmp);
    int curL = q[0].l;
    int curR = q[0].l;
    int num = 1;
    cnt[a[curL]] = 1;
    for(i = 0; i < Q; ++i){
        while(curR < q[i].r){
            ++curR;
            if(cnt[a[curR]] == 0)
                ++num;
            ++cnt[a[curR]];
        }
        while(curR > q[i].r){
            if(cnt[a[curR]] == 1)
                --num;
            --cnt[a[curR]];
            --curR;
        }
        while(curL < q[i].l){
            if(cnt[a[curL]] == 1)
                --num;
            --cnt[a[curL]];
            ++curL;
        }
        while(curL > q[i].l){
            --curL;
            if(cnt[a[curL]] == 0){
                ++num;
            }
            ++cnt[a[curL]];
        }
        q[i].ans = num;
    }
    std::sort(q, q + Q, cmp2);
    for(i = 0; i < Q; ++i)
        printf("%d\n", q[i].ans);
    return 0;
}

Measured memory_bytes: 15396
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 3e5 + 1;

int n, m, k;
int a[N], f[N];

main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n;
	cout << setprecision(9) << fixed << (ld)((n + 1)/2)/(ld)n;	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc097/tasks/abc097_b

int expp[10005];

int main() {
    int x; cin >> x;
    expp[1] = 1;
    for (int i = 2; i <= x; i++) {
        int v = i * i;
        while(v<=x) {
            expp[v] = 1;
            v = v * i;
        }
    }

    for (int i = x; i >=0 ; i--) if (expp[i]){
            cout << i << "\n";
            return 0;
    }

    return 0;
}


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

int main(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int count=0;

    for(int r=0;r<=N;r++){
        for(int g=0;g<=N;g++){

            if(r*R+g*G<=N && (N-(r*R+g*G))%B==0){
                count++;
            }

            
            
        }
        
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
typedef long long LL;

const int MAXN = 2e5 + 5;

int n , Q , vis[MAXN ][3];
int tr[MAXN << 3][2] , tag[MAXN << 3][2];
void build(int l , int r , int now) {
	tag[now][0] = 1e9;tag[now][1] = 1e9;
	if(l == r) {
		tr[now][0] = tr[now][1] = n;
		return;
	}
	int mid = (l + r) >> 1;
	build(l , mid , now << 1);
	build(mid + 1 , r , now << 1 | 1);
	tr[now][0] = min(tr[now << 1][0] , tr[now << 1 | 1][0]);
	tr[now][1] = min(tr[now << 1][1] , tr[now << 1 | 1][1]);
}
void push_down(int now) {
	if(tag[now][0] != 1e9) {
		int v = tag[now][0];
		tr[now << 1][0] = min(tr[now << 1][0] , v);tag[now << 1][0] = min(tag[now << 1][0] , v);
		tr[now << 1 | 1][0] = min(tr[now << 1 | 1][0] , v);tag[now << 1 | 1][0] = min(tag[now << 1 | 1][0] , v);
		tag[now][0] = 1e9;
	}
	if(tag[now][1] != 1e9) {
		int v = tag[now][1];
		tr[now << 1][1] = min(tr[now << 1][1] , v);tag[now << 1][1] = min(tag[now << 1][1] , v);
		tr[now << 1 | 1][1] = min(tr[now << 1 | 1][1] , v);tag[now << 1 | 1][1] = min(tag[now << 1 | 1][1] , v);
		tag[now][1] = 1e9;
	}
}
void update(int l , int r , int now , int x , int y , int v , int t) {
	if(l >= x && r <= y) {
		if(t == 0) tr[now][t] = min(tr[now][t] , v) , tag[now][t] = min(tag[now][t] , v);
		if(t == 1) tr[now][t] = min(tr[now][t] , v) , tag[now][t] = min(tag[now][t] , v);
		return;
	}
	int mid = (l + r) >> 1;
	push_down(now);
	if(x <= mid) update(l , mid , now << 1 , x , y , v , t);
	if(y > mid) update(mid + 1 , r , now << 1 | 1 , x , y , v , t);
	tr[now][0] = min(tr[now << 1][0] , tr[now << 1 | 1][0]);
	tr[now][1] = min(tr[now << 1][1] , tr[now << 1 | 1][1]);
}
int find(int l , int r , int now , int x , int t) {
	if(l == r) return tr[now][t];
	push_down(now);
	int mid = (l + r) >> 1;
	if(x <= mid) return find(l , mid , now << 1 , x , t);
	else return find(mid + 1 , r , now << 1 | 1 , x , t);
}
signed main() {
	scanf("%lld %lld" , &n , &Q);
	LL ans = (LL)(n - 2ll) * (LL)(n - 2ll);
	build(1 , n , 1);
	while(Q -- > 0) {
		int op , x;
		scanf("%lld %lld" , &op , &x);
		if(vis[x][op]) continue;
		vis[x][op] = 1;
		if(op == 1) {
			int now = find(1 , n , 1 , x , 0);
			update(1 , n , 1 , x , x , 1 , 0);
			if(now >= 2) ans -= (now - 2);
			if(now > 2) update(1 , n , 1 , 2 , now - 1 , x , 1);
		}
		else {
			int now = find(1 , n , 1 , x , 1);
			update(1 , n , 1 , x , x , 1 , 1);
			if(now >= 2) ans -= (now - 2);
			if(now > 2) update(1 , n , 1 , 2 , now - 1 , x , 0);
		}
	}	
	printf("%lld" , ans);
	return 0;
}

Measured memory_bytes: 24292
#define taskname ""
#include <bits/stdc++.h>

using namespace std;

const int maxN = 1e5;

int n, d;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    cin >> n >> d;
    cout << ceil((double)n / (d * 2 + 1));
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int N, C;
int a[101], b[101], c[101];

int dp[10005][105];
// dp[x][y] : max(max(A, B) | min(A, B) = x, cost = y)

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> C;
    for (int j = 0; j < N; ++j) {
        cin >> a[j] >> b[j] >> c[j];
    }

    for (int j = 0; j < 10005; ++j) {
        fill(dp[j], dp[j]+105, -1);
    }

    dp[0][0] = 0;
    int ans = 0;
    if (c[0] <= C) {
        ans = b[0];
        dp[b[0]][c[0]] = a[0];
    }

    for (int j = 1; j < N; ++j) {
        for (int k = 10000; k >= 0; --k) {
            for (int l = C; l >= 0; --l) {
                if (dp[k][l] >= 0 && l+c[j] <= C) {
                    int v[2];
                    v[0] = k+a[j], v[1] = dp[k][l]+b[j];
                    if (v[0] > v[1]) swap(v[0], v[1]);
                    if (v[0] > ans) {
                        ans = v[0];
                    }
                    dp[v[0]][l+c[j]] = max(dp[v[0]][l+c[j]], v[1]);

                    v[0] = k+b[j], v[1] = dp[k][l]+a[j];
                    if (v[0] > v[1]) swap(v[0], v[1]);
                    ans = max(ans, v[0]);
                    if (v[0] > ans) {
                        ans = v[0];
                    }
                    dp[v[0]][l+c[j]] = max(dp[v[0]][l+c[j]], v[1]);
                }
            }
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 7300
#include<stdio.h>

int main(void){
	int x,j,k,in[20];

	j = 0;
	while(scanf("%d",&x) != EOF){
		if(x != 0){
			in[j] = x;
			j ++;
		}else{
			printf("%d\n",in[j - 1]);
			j --;
		}
	}
	return 0;
}

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

int dp[3001][3001];

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

	string s, t;
	cin >> s >> t;
	for(int i=1; i<=s.size(); ++i) {
		for(int j=1; j<=t.size(); ++j) {
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
		}
	}
	//cout << dp[s.size()][t.size()];
	int i=s.size(), j=t.size();
	string ans;
	while(i&&j) {
		if(s[i-1]==t[j-1]) {
			ans=s[i-1]+ans;
			--i;
			--j;
			continue;
		}
		if(dp[i-1][j]>dp[i][j-1])
			--i;
		else
			--j;
	}
	cout << ans;
}


Measured memory_bytes: 38860
s = list(input())
t = list(input())

for i in range(len(s)-len(t),-1,-1):
    if (s[i] == '?') or (s[i] == t[0]):
        cnt = 0
        for j in range(len(t)):
            if (s[i+j] == '?') or (s[i+j] == t[j]):
                cnt += 1
            else:
                break
        
        if cnt == len(t):
            s[i:i+len(t)] = t
            break
else:
    print('UNRESTORABLE')
    exit()
        
for i in range(len(s)):
    if s[i] == '?':
        s[i] = 'a'
print(''.join(s))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

const int MAX = 200001;
const int INF = (1<<25);

int A,B,D;

struct Info{
  int a,b;
  bool operator < (const Info& info) const {
    if(a+b != info.a+info.b) return a+b < info.a+info.b;
    return a*A+b*B < info.a*A+info.b*B;
  }

  bool operator > (const Info& info) const {
    return !((*this)<info);
  }
};

struct State{
  Info info;
  int weight;
  bool operator < (const State& s) const{
    return info > s.info;
  }
};

Info T[MAX];

void solve(){
  fill(T,T+MAX,(Info){INF,INF});
  T[0] = (Info){0,0};
  priority_queue<State> Q;
  Q.push((State){(Info){0,0},0});
  while(!Q.empty()){
    const State now = Q.top();
    Q.pop();
    if(T[now.weight] < now.info) continue;
    
    int add[] = {A,B,-A,-B};

    for(int i = 0; i < 4; i++){
      State nex = now;
      if(i%2) nex.info.b++;
      else nex.info.a++;

      nex.weight += add[i];
      
      if(nex.weight >= 0 && nex.weight < MAX && nex.info < T[nex.weight]){
	T[nex.weight] = nex.info;
	Q.push(nex);
      }
    }
  }
  cout << T[D].a << " " << T[D].b << endl;
}

int main(){

  while(cin >> A >> B >> D && A+B+D){
    solve();
  }
  return 0;
}

Measured memory_bytes: 2804
def readinput():
    a,b,c=map(int,input().split())
    return a,b,c

def main(a,b,c):
    amari=[0]*b
    looped=False
    x=a
    while(not looped):
        r=x%b
        if r==c:
            return 'YES'
        if amari[r]>0:
            looped=True
            return 'NO'
        else:
            amari[r]+=1
        x=x+a

if __name__=='__main__':
    a,b,c=readinput()
    ans=main(a,b,c)
    print(ans)


Measured memory_bytes: 9192
#include <iostream>
#include <stdio.h>
#define llint long long

using namespace std;

int main(void)
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	int n;
	cin >> n;
	printf("%.11f\n", ((n+1)/2)/(double)n);
	
	return 0;
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(x, 0, k + 1) rep(y, 0, k + 1)
    if (x + y <= s && s - x - y <= k) ++ans;
    cout << ans << '\n';
}

Measured memory_bytes: 256
n = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"  # x番目がほしいときにchars[x-1]としたくないので、chars[0]は使わないことにします

n_rem = n  # 入力を直接操作すると、もし後々必要になったときに面倒なので
res = ""

while True:
    x = n_rem % 26
    # 余りが0、つまりzの場合は、26にします
    if x == 0:
        x = 26
    res += chars[x]

    # xを引いて、26で割ります
    n_rem -= x

    # 0なら終了します
    if n_rem == 0:
        break

    n_rem //= 26

# 0桁目が先頭で、最後の桁が末尾になっているので、反転させます
print(res[::-1])


Measured memory_bytes: 9148
S = input()
T = input()

def match(L):
    for l, t in zip(L, T):
        if l == '?':
            pass
        elif l != t:
            return False
        else:
            pass
    return True

res = []
for i in range(len(S)-len(T)+1):
    if match(S[i:i+len(T)]):
        res.append((S[:i] + T + S[i+len(T):]).replace('?', 'a'))

if len(res):
    print(sorted(res)[0])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 38256
import java.io.*;
class Main
{
public static void main(String args[])throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
String str;
int i=0,sum=0;
while(!((str=input.readLine()).equals("=")))
{
if(i==0)sum+=Integer.parseInt(str);
if(str.equals("+"))
{
int x=Integer.parseInt(input.readLine());
sum+=x;
}
if(str.equals("-"))
{
int x=Integer.parseInt(input.readLine());
sum-=x;
}
if(str.equals("*"))
{
int x=Integer.parseInt(input.readLine());
sum*=x;
}
if(str.equals("/"))
{
int x=Integer.parseInt(input.readLine());
sum/=x;
}
i++;
}
System.out.println(sum);
}
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define ff first
#define ss second
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
#define d(a,b,c) cout<<a<<" "<<b<<" "<<c<<'\n'
#define IO ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define mem(a, b) memset(a,b,sizeof(a))

int main()
{
    int n, m; cin >> n >> m;
    vector<int> adj[n+1];
    for(int i = 0,u,v; i < m; i++)
    {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int p[n+1];
    bool visit[n+1];
    memset(visit, 0, sizeof(visit));
    queue<int>q;
    q.push(1);
    visit[1] = true;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        for(int i = 0; i < adj[u].size(); i++)
        {
            int v = adj[u][i];
            if(!visit[v])
            {
                visit[v] = true;
                q.push(v);
                p[v] = u;
            }
        }
    }
    for(int i = 1; i <= n; i++)
        if(!visit[i])
            return !(cout << "No" << endl);
    cout << "Yes" << endl;
    for(int i = 2; i <= n; i++)
        cout << p[i] << endl;
    return 0;
}


Measured memory_bytes: 10644
package main

import (
	"fmt"
)

func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

func count(N int, abc [100000][3]int) int {
	// Definition of DP
	var dp [100001][3]int

	for i := 0; i < N; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				chmax(&dp[i+1][k], dp[i][j]+abc[i][k])
			}
		}
	}

	var result int
	for i := 0; i < 3; i++ {
		chmax(&result, dp[N][i])
	}

	return result
}

func main() {
	var N int
	fmt.Scan(&N)

	var abc [100000][3]int
	for i := 0; i < N; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&abc[i][j])
		}
	}

	fmt.Println(count(N, abc))
}


Measured memory_bytes: 14464
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
const int MAX = 2e5 + 10;

int main(){
    int N, K;cin>>N>>K;
    int ans = (N-1)%(K-1) == 0 ? (N-1)/(K-1) : (N-1)/(K-1)+1;
    cout<<ans<<endl;
}

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

using namespace std;

int main(void){

    int X = 0;
    cin >> X;

    // 500で割る 
    int n500 = 0;
    for(; X >= 500; X -= 500){
        n500++;
    }

    // 5で割る 
    int n5 = 0;
    for(; X >= 5; X -= 5){
        n5++;
    }

    int ans = (n500 * 1000) + (n5 * 5);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>

using namespace std;

bool cmp(const tuple<string,int,int>& a,const tuple<string,int,int>& b)
{
	int x=get<1>(a)*get<2>(b),y=get<1>(b)*get<2>(a);
	return x>y || x==y && get<0>(a)<get<0>(b);
}

int main()
{
	for(int n;cin>>n,n;){
		tuple<string,int,int> crops[n]; // name,income,time
		for(int i=0;i<n;i++){
			int p,a,b,c,d,e,f,s,m;
			cin>>get<0>(crops[i])>>p>>a>>b>>c>>d>>e>>f>>s>>m;
			get<1>(crops[i])=f*s*m-p;
			get<2>(crops[i])=a+b+c+(d+e)*m;
		}
		sort(crops,crops+n,cmp);
		for(int i=0;i<n;i++)
			cout<<get<0>(crops[i])<<endl;
		cout<<'#'<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

using namespace std;

void solve()
{
    int arr[5];
    for(int i=0;i<5;i++) cin >> arr[i];
    for(int i=0;i<5;i++)
    {
        if(arr[i]==0) cout << i+1 ;
    }
}

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


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

struct UnionFindTree{
  int par[MAX_N],rank[MAX_N],size[MAX_N];
  UnionFindTree(int N){
    fill(rank,rank+N,0);
    fill(size,size+N,1);
    rep(i,N) par[i]=i;
  }
  int find(int x){
    if(par[x]==x) return x;
    else  return par[x]=find(par[x]);
  }
  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)  return ;
    if(rank[x]<rank[y]){
      par[x]=y;
    }else{
      par[y]=x;
      if(rank[x]==rank[y])  ++rank[x];
    }
    size[x]=size[y]=size[x]+size[y];
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
};

Pl a[MAX_N];
bool used[MAX_N];

int main(){
  int N,M; cin >> N >> M;
  UnionFindTree uft(N);
  rep(i,N){
    scanf("%lld",&a[i].first);
    a[i].second = i;
  }
  rep(i,M){
    int x,y; scanf("%d%d",&x,&y);
    uft.unite(x,y);
  }
  if(2*(N-M-1)>N){
    cout << "Impossible" << endl;
    return 0;
  }else if(M==N-1){
    cout << "0" << endl;
    return 0;
  }
  sort(a,a+N);
  set<int> st;
  ll ans = 0LL; int cnt = 0;
  rep(i,N){
    if(st.count(uft.find(a[i].second))){
      if(cnt < N-M-2) ans += a[i].first, cnt++;
    }else{
      st.insert(uft.find(a[i].second));
      ans += a[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
using namespace std;
const int N=3005;
int dp[N][N];
int main(){
	string s,t,ans="";
	cin>>s>>t;
	int i,j;
	s=" "+s;
	t=" "+t;
	for(int i=1;i<s.length();i++){
		dp[i][0]=0;
	}
	for(int i=1;i<t.length();i++){
		dp[0][i]=0;
	}
	dp[0][0]=0;
	for(i=1;i<s.length();i++){
		for(j=1;j<t.length();j++){
			if(s[i]==t[j]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	i=s.length()-1;
	j=t.length()-1;
	while(i>0&&j>0){
		if(s[i]==t[j]){
			ans=s[i]+ans;
			i--;
			j--;
		}
		else{
			if(dp[i][j]==dp[i-1][j]){
				i--;
			}
			else{
				j--;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll po[100] = {2, 1};
	ll n; cin >> n;
	for(ll i = 2; i <= n; ++i) po[i] = po[i - 1] + po[i - 2];
	cout << po[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

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

	int N, M;
	cin >> N >> M;

	int ans = 0;
	for(int i = 0; i < N; i++) {
		int k;
		cout << "lst " << i << endl;
		cin >> k;
		for(int j = 0; j < k; j++) {
			int a;
			cin >> a;
		}
		ans += k * (k - 1);
	}

	cout << "ans " << ans << endl;
}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const ll N = (ll)5e2+77;
const ll inf = (ll) 1e16+7;
const ll mod = (ll) 1e8;
const ld pi = acos(-1);

int main() {
    fast;
    int t, s = 0, a[22];
    cin >> t;
    forn(i, t) {
        cin >> a[i];
    }
    sort(a, a + t);
    forn(i, t - 1) {
        s += a[i];
    }
    s += a[t - 1] / 2;
    cout << s << endl;
    return 0;
}

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

void fnInput(vector<int>& rvnSort)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  
  rvnSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnSelectionSort(vector<int>& rvnSort, int& rnSortCnt)
{
  for (int nxed = 0; nxed < rvnSort.size() - 1; nxed++)
  {
    int nxMin = nxed;
    bool bSwap = false;

    for (int nxing = nxed + 1; nxing < rvnSort.size(); nxing++)
    {
      if (rvnSort[nxing] < rvnSort[nxMin])
      {
        nxMin = nxing;
        bSwap = true;
      }
    }
    if (bSwap)
    {
      swap(rvnSort[nxed], rvnSort[nxMin]);
      rnSortCnt++;
    }
  }
}

void fnOutput(const vector<int>& cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}

int main()
{ 
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int nSortCnt = 0;
  vector<int> vnSort;

  fnInput(vnSort);
  fnSelectionSort(vnSort, nSortCnt);
  fnOutput(vnSort, nSortCnt);

  return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int gcd(int a,int b);
int chose(int a,int b,int c);

int main(){
  int N,A[100000];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  if(N == 1){
    cout << A[0];
  }
  else if(N == 2){
    cout << max(A[0],A[1]);
  }
  else{
    //sort(A,A+N);
    int ans = gcd(A[1],A[2]);
    for(int i=1;i<N;i++){
      ans = gcd(ans,A[i]);
    }// 0 habuku
    int temp = gcd(A[0],A[2]);
    for(int i=3;i<N;i++){
      temp = gcd(temp,A[i]);
    }// 1 habuku
    ans = max(temp,ans);
    for(int i=2;i<N;i++){
      temp = gcd(A[0],A[1]);
      for(int j=0;j<N;j++){
        if(j == i) continue;
        temp = gcd(temp,A[j]);
        if(temp < ans) break;
        if(j == 1000) break;
      }
      ans = max(temp,ans);
    }
    cout << ans;
  }
  return 0;
}

int gcd(int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int gcd3(int a,int b,int c){
  return gcd(gcd(a,b),c);
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	for (int i = 0; i < n; i++)
		cin >> l[i];
	sort(l.rbegin(), l.rend());
	int sum = 0;
	for (int i = 0; i < k; i++)
		sum += l[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
var i,j,k,m,n,t,ok,tt:longint;
a,tar:real;
ar:array [0..110] of longint;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    read(ar[i]);
    tt:=tt+ar[i];
  end;  
  for i:=1 to n do
    for j:=1 to n-1 do
      if ar[j]>ar[j+1] then
      begin
        t:=ar[j];
        ar[j]:=ar[j+1];
        ar[j+1]:=t;
      end;   
  tar:=(1/(4*m));
  for i:=n downto (n-m)+1 do
  begin
    a:=(ar[i]/tt);
    if a>=tar then
      inc(ok);
  end;    
  if ok=m then  
    writeln('Yes')
  else 
    writeln('No'); 
end.  
      
      

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        ArrayList<Integer> p = new ArrayList<>();
        for (int i=0;i<n;i++){
            p.add(sc.nextInt());
        }
        int answer=0;
        int count = 0;
        boolean b = true;
        while (b){

            if (!p.contains(x-count)){
                answer=x-count;
                b=false;
            }
            if (b&&!p.contains(x+count)){
                answer=x+count;
                b=false;
            }
            count++;
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 35944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
#define deg_to_rad(deg) (((deg)/360)*2*PI);
#define rad_to_deg(rad) (((rad)/2/PI)*360);
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)

void Main(){
	int a, b;
	cin >> a >> b;
	cout << lcm(a, b);
	
}

signed main() {
	Main();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        s[i]=((s[i]-'A'+n)%26)+'A';
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  
  
  pt(0);
  string s0;
  cin >> s0;
  
  if(s0=="Vacant") return 0;
  
  ll l=0, r=N;
  while(l+1<r) {
    ll m=(l+r)/2;
    
    pt(m);
    string sm;
    cin >> sm;
    
    if(sm=="Vacant") return 0;
    
    if(m%2==0) {
      if(sm==s0) l=m;
      else       r=m;
    }else {
      if(sm!=s0) l=m;
      else       r=m;
    }
    
  }
  
}



Measured memory_bytes: 852
s = str(input())
t = 'keyence'

if len(s) < len(t):
    print('NO')
    exit()

if s[0:len(t)] == t:
    print('YES')
    exit()

if s[len(s)-len(t):len(s)] == t:
    print('YES')
    exit()

for i in range(len(t)):
    if s[0:i+1] == t[0:i+1] and s[len(s)-len(t)+(i+1):len(s)] == t[(i+1):len(t)]:
        print('YES')
        exit()
else:
    print('NO')


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

std::vector<int> add(std::vector<int>& A, std::vector<int>& B)
{
	int carry{}, length{(int)A.size()};
	std::vector<int> ans(length);
	for (int i{}; i < length; i++)
	{
		ans[i] = A[i] + B[i] + carry;
		if (ans[i] >= 10)
		{
			carry = 1;
			ans[i] -= 10;
		}
		else
			carry = 0;
	}
	if (carry == 1) ans.push_back(1);
	return std::move(ans);
}

void borrow(std::vector<int>& A, int a_i)
{
	if (A[a_i] == 0) borrow(A, a_i + 1);
	A[a_i]--;
	A[a_i - 1] += 10;
}

// A >= B
std::vector<int> diff(std::vector<int>& A, std::vector<int>& B)
{
	int length{(int)A.size()};
	std::vector<int> ans(length);
	for (int i{}; i < length; i++)
	{
		if (A[i] < B[i])
			borrow(A, i + 1);
		ans[i] = A[i] - B[i];
	}
	while (ans.size() > 1 && ans.back() == 0) ans.pop_back();
	return std::move(ans);
}

bool larger(std::vector<int>& A, std::vector<int>& B)
{
	for (int i{(int)A.size() - 1}; i >= 0; i--)
		if (A[i] != B[i])
			return A[i] > B[i];
	return true;
}
int main()
{
	std::vector<int> A, B;
	int a_sign{1}, b_sign{1};
	char input;
	scanf("%c", &input);
	if (input == '-') a_sign = -1;
	else A.push_back(input - '0');
	while (true)
	{
		scanf("%c", &input);
		if (!isdigit(input)) break;
		A.push_back(input - '0');
	}
	scanf(" %c", &input);
	if (input == '-') b_sign = -1;
	else B.push_back(input - '0');
	while (true)
	{
		scanf("%c", &input);
		if (!isdigit(input)) break;
		B.push_back(input - '0');
	}
	std::reverse(A.begin(), A.end());
	std::reverse(B.begin(), B.end());
	int length{(int)std::max(A.size(), B.size())};
	A.resize(length);
	B.resize(length);

	std::vector<int> ans;
	if (a_sign * b_sign == 1)
	{
		ans = add(A, B);
		if (a_sign == -1) putchar('-');
		for (int i{(int)ans.size() - 1}; i >= 0; i--)
			printf("%d", ans[i]);
	}
	else if (a_sign == 1)
	{
		if (larger(A, B))
		{
			ans = diff(A, B);
			for (int i{(int)ans.size() - 1}; i >= 0; i--)
				printf("%d", ans[i]);
		}
		else
		{
			ans = diff(B, A);
			putchar('-');
			for (int i{(int)ans.size() - 1}; i >= 0; i--)
				printf("%d", ans[i]);
		}
	}
	else
	{
		if (larger(B, A))
		{
			ans = diff(B, A);
			for (int i{(int)ans.size() - 1}; i >= 0; i--)
				printf("%d", ans[i]);
		}
		else
		{
			ans = diff(A, B);
			putchar('-');
			for (int i{(int)ans.size() - 1}; i >= 0; i--)
				printf("%d", ans[i]);
		}
	}
	putchar('\n');

	return 0;
}


Measured memory_bytes: 7296
import heapq

n, m = map(int,input().split())
A = list(map(int,input().split()))

Q = []
for i in range(n):
    heapq.heappush(Q,-A[i])
for i in range(m):
    j = -heapq.heappop(Q)
    j //= 2
    heapq.heappush(Q,-j)

print(-sum(Q))

Measured memory_bytes: 64792
let judge k (a: int []) =
    let slice s e a = Array.sub a s (e - s + 1)

    Array.append a [| k + a.[0] |]
    |> Array.pairwise // 小区間の端点のペアを作る
    |> Array.map (fun (s, e) -> e - s |> abs)
    |> Array.sort
    |> slice 0 (a.Length - 2)
    |> Array.sum

//let input = [| 20, 3, [| 5; 10; 15 |]; 20, 3, [| 0; 5; 15 |] |]
//let k, _, a = input.[1]
//for (k, _, a) in input do judge k a |> printfn "%d"
// expected 10; 10

[<EntryPoint>]
let main argv =
    let k =
        stdin.ReadLine().Split() |> fun x -> x.[0] |> int

    let a =
        stdin.ReadLine().Split() |> Array.map int

    judge k a |> printfn "%d"
    0


Measured memory_bytes: 55016
from fractions import gcd
from math import ceil
def f(x):
  cnt=0
  while x%2==0:
    x//=2
    cnt+=1
  return cnt
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[a[i]//2 for i in range(n)]
g=b[0]
for i in range(1,n):
  g=g*b[i]//gcd(g,b[i])
t=f(a[0])
for i in range(n):
  if t!=f(a[i]):
    print(0)
    exit()
else:
  print(int((m/g+1)//2))

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

int main() {
  int A, B, C, ss=0, fin=0;
  cin >> A >> B >> C;
  set<int> S;
  for (int i=1; i<=100000; i++) {
    if (A*i%B==C) {
      fin=1;
      break;
    }
  }
  if (fin==1) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3560
#https://qiita.com/drken/items/dc53c683d6de8aeacf5a(DP問題集)
#https://atcoder.jp/contests/dp/tasks/dp_b
#ボトムアップ的
N, K = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N,1):
    dp[i] = min([dp[i-j] + abs(h[i] - h[i-j]) for j in range(1,min(i+1,K+1))])

print(dp[N-1])

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

#define NMAX 200000
vector<int> b[NMAX];
_LL sum[NMAX];
_LL c[NMAX];
_LL cc[NMAX];
_LL totalcount = 0;
 
void search(int current, int p)
{
    _LL index = 1;
    _LL pcc = cc[c[current]] + totalcount;
    totalcount++;

    for( auto itr = b[current].begin(); itr != b[current].end(); itr++ )
    {
        if( *itr != p ) 
        {
            cc[c[current]] = -totalcount;
            search(*itr, current);
            _LL subc = cc[c[current]] + totalcount;
            sum[c[current]] += subc * (subc + 1) / 2;
        }
    }

    cc[c[current]] = pcc - totalcount;
}
 
int main()
{
    _LL n;
    cin >> n;
    rep(i, n) 
    {
        cin >> c[i];
        c[i]--;
    }
    rep(i, n) sum[i] = 0;
    rep(i, n) cc[i] = 0;
    rep(i, n - 1)
    {
        int u, v;
        cin >> u >> v;
        u--; v--;
        b[u].push_back(v);
        b[v].push_back(u);
    }
    search(0, -1);
    rep(i, n)
    {
            _LL subc = cc[i] + totalcount;
            sum[i] += subc * (subc + 1) / 2;  
    }

    _LL total = n * (n + 1) / 2;

    rep(i, n) cout << total - sum[i] << endl;
    
}

Measured memory_bytes: 34808
K,N = map(int,input().split())
A = input().split()
B = list()
for i in range(N-1):
    B.append(int(A[i+1]) - int(A[i]))
B.append(K - int(A[N-1]) + int(A[0]))
C = max(B)
print(K-C)


Measured memory_bytes: 20148