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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl




signed main(){

	int A, B, T;
	cin >> A >> B >> T;
	cout << (T / A)*B << endl;

	return 0;
}


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

int sabs(int a,int b){
  int c = max(a,b)-min(a,b);
  return c;
}

int main() {
  int n; cin >>n;
  vector<int> a(n+1);
  for (int i=1; i<n+1; i++) cin >>a.at(i);
  int sum = 0;
  for (int i=0; i<n; i++){
    sum += sabs(a.at(i), a.at(i+1));
  }
  vector<int> cancel(n+1);
  /* at(4) at(5) at(6) at(7) at(8)
        |5-4|+|6-5|+|7-6|+|8-7|
     at(4) at(5)       at(7) at(8)
        |5-4|  + |7-5| +  |8-7|
     偏差：-|6-5|-|7-6|+|7-5|
  */
  int sub, retu;
  for (int i=1; i<=n; i++){
    if (i==n){
      sub = -sabs(a.at(i),a.at(i-1));
      retu = sabs(a.at(0),a.at(i-1));
    }else{
      sub = sabs(a.at(i-1),a.at(i+1))-sabs(a.at(i),a.at(i-1))-sabs(a.at(i),a.at(i+1));
      retu = sabs(a.at(0),a.at(n));
    }
    cancel.at(i) = sum + sub + retu;
    cout <<cancel.at(i) <<endl;
  }
  
  //cout <<ans;
  //cout <<endl;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll s,w;
  std::cin>>s>>w;

  if(s<=w)std::cout<<"unsafe\n";
  else std::cout<<"safe\n";

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  cout << ((a == b && b == c) || (a != b && a != c && b != c) ? "No" : "Yes")
       << endl;
  return 0;
}


Measured memory_bytes: 256
/* Worldwide Combos, free and competitive block-stacking game! 
https://www.worldwide-combos.com */
 
#include<iostream>
#include<vector>
#include<array>
#include<string>
#include<sstream>
#include<map>
#include<unordered_map>
#include<chrono>
#include<set>
#include<unordered_set>
#include<ctime>
#include<bitset>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<random>
#include<cassert>
#include<complex>
#include<fstream>
#include<pthread.h>

#pragma GCC optimize "-O3"
#pragma GCC target "tune=native"
 
#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = b-1; i >= a; i--)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
 
#define si(n) scanf("%d", &n)
#define sii(n,m) scanf("%d %d", &n, &m)
#define siii(n,m,k) scanf("%d %d %d", &n, &m, &k)
#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf("%c", &c)
#define ss(s) scanf("%s", s)
#define sai(t,n) fin(iz,n) { scanf("%d", &t[iz]); }
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
 
#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pi(n) printf("%d\n", n)
#define pii(n,m) printf("%d %d\n", n, m)
#define piii(n,m,k) printf("%d %d %d\n", n, m, k)
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pai(t,n) fin(rz,n) { printf("%d ", t[rz]); } printf("\n")
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")
 
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define L long long int
#define D double
#define PII pair<int, int>
#define VPII vector<PII>
#define VL vector<L>
#define VI vector<int>
#define VVI vector<VI>
#define VD vector<D>
#define VVD vector<VD>
#define VVPII vector<VPII>
#define VC vector<char>

using namespace std;

int main() {
    //freopen("assessment.in", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,x;
    sii(n,x);
    int a[200];
    sai(a, n);
    int s = 0;
    sort(a, a+n);
    fin(i, n) {
        s += a[i];
        if (s > x) { pi(i); return 0; }
    }
    if (s == x) { pi(n); return 0; }
    pi(n-1); return 0;
    return 0; 
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {

			int[] rails = new int[10];
			int total = 0;

			int v1 = 0;
			int v2 = 0;

			//
			int i = 0;
			for (String s : line.split(",")) {
				if (i < 10) {
					rails[i] = Integer.parseInt(s);
					total += rails[i];
				} else if (i == 10) {
					v1 = Integer.parseInt(s);
				} else if (i == 11) {
					v2 = Integer.parseInt(s);
				}
				i++;
			}

			//
			double across = (double) total * (double) v1 / (double) (v1 + v2);

			int sum = 0;
			for (int j = 0; j < rails.length; j++) {
				sum += rails[j];
				if (across <= sum) {
					System.out.println(j + 1);
					break;
				}
			}
		}
	}
}

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

using namespace std;
using ll = long long;

const int N = 200005;

int n;
ll k;

ll div_floor(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll div_ceil(ll a, ll b) {
	return a / b + (((a ^ b) >= 0) and a % b);
}
int a[N];

ll f(ll lim) {

	ll ans = 0;
	
	for(int i = 0; i < n; i++) {
		if(a[i] == 0) {
			if(lim >= 0) ans += n - 1;
		}
		else if(a[i] > 0) {
			// a[i] * x <= lim
			// x <= lim / a[i]
			ll tmp = div_floor(lim, a[i]);
			int id = int(upper_bound(a, a + n, tmp) - a);
			if(i < id) ans += id - 1;
			else ans += id;
		}
		else { // a[i] < 0
			// a[i] * x <= lim
			// x >= lim / a[i];
			ll tmp = div_ceil(lim, a[i]);
			int id = int(lower_bound(a, a + n, tmp) - a);
			if(i >= id) ans += n - id - 1;
			else ans += n - id;
		}
	}
	assert(ans % 2 == 0);
	return ans / 2;
}

int main() {
	scanf("%d %lld", &n, &k);

	for(int i = 0; i < n; i++) scanf("%d", a + i);

	sort(a, a + n);

	ll lo = -1e18, hi = 1e18, ans = 0;

	while(lo <= hi) {
		ll mid = (lo + hi) / 2;
		if(f(mid) >= k) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	printf("%lld\n", ans);
	
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

template<typename T>
struct bit {
  int size, pow2n;
  vector<T> data;
  bit(int sz) {
    size = sz;
    pow2n = 1;
    while(pow2n*2 <= size) pow2n *= 2;
    data.assign(++sz, 0);
  }
  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return ret;
  }
  T lowerBound(int w){
    if(w <= 0) return 0;
    int x = 0;
    for(int k = pow2n; k > 0; k /= 2){
      if(x+k <= size && data[x+k] < w){
        w -= data[x+k];
        x += k;
      }
    }
    return x;
  }
  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

signed main() {
  int N, Q;
  cin >> N >> Q;

  vector<int> c(N);
  REP(i, N){
    cin >> c[i];
    c[i]--;
  }

  vector<int> l(Q), r(Q);
  REP(i, Q) cin >> l[i] >> r[i];

  vector<int> o(Q);
  iota(ALL(o), 0);
  sort(ALL(o), [&](int const & ll, int const & rr){
      if(r[ll] == r[rr]) return l[ll] < l[rr];
      return r[ll] < r[rr];
      });


  bit<int> bit(N+1);
  vector<int> ans(Q);
  vector<int> last(N+1, -1);

  int now = 0;
  REP(i, Q){
    int I = o[i];
    while(now < r[I]){
      if(last[c[now]] != -1){
        bit.add(last[c[now]], -1);
      }
      last[c[now]] = now+1;

      bit.add(last[c[now]], 1);
      now++;
    }
    ans[I] = bit.sum(r[I])-bit.sum(l[I]-1);
  }

  REP(i, Q){
    cout << ans[i] << "\n";
  }

  return 0;
}


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

int main(){
    int n,T;cin>>n>>T;
    int ans=1001;
    int c,t;
    for(int i=0;i<=n;i++){
        cin>>c>>t;
        if(t<=T) ans=min(ans,c);
    }

    if(ans!=1001) cout<<ans<<endl;
    else cout<<"TLE"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int prod=a*b*c;
  int sum=a+b+c;
  if(sum==17 && prod==175){
    cout<<"YES"<<endl;
  }
  else
    cout<<"NO"<<endl;
}

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

ll m = 1000000007;

ll modexp(ll a, ll b){
	if (b==0){
		return 1;
	}
	if (b%2==0){
		ll tmp = modexp(a,b/2);
		return (tmp*tmp)%m;
	} else {
		ll tmp = modexp(a,(b-1)/2);
		return (((tmp*tmp)%m)*a)%m;
	}
}

ll inv(ll x){
	return modexp(x,m-2);
}


int main(){
	ll n,k;
	cin>>n>>k;
	k=min(k,n-1);
	ll nx = 1;
	ll n1x = 1;
	ll s = 0;
	for (int i = 0; i<=k; i++){
		s+=(nx*n1x)%m;
		s%=m;
		nx*=(n-i);
		nx%=m;
		nx*=inv(i+1);
		nx%=m;
		n1x*=(n-i-1);
		n1x%=m;
		n1x*=inv(i+1);
		n1x%=m;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(string, s);
    const int x = count(all(s), '0');
    print(min<i64>(x, s.length() - x) * 2);

    return 0;
}


Measured memory_bytes: 512
N = int(input())
A = [int(v) for v in input().split()]

ans = []

x1 = A[0]

for i in range(1,len(A)):
    if i % 2 == 0:
        x1 += A[i]
    else:
        x1 -= A[i]
ans.append(x1)

prev = x1
for i in range(1,len(A)):
    prev = ((A[i-1]-prev//2) * 2)
    ans.append(prev)

print(*ans)


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

int main() {
    int64_t X, A, B;
    cin >> X;
    for (int64_t i = 0; i < 1000; i++) {
        for (int64_t j = 0; j < 1000 ; j++) {
            if (pow(i, 5) - pow(j, 5) == X) {
                cout << i << " " << j << endl;
                return 0;
            } else if (pow(i, 5) + pow(j, 5) == X) {
                cout << i << " " << - j << endl;
                return 0;
            } else if (- pow(i, 5) + pow(j, 5) == X) {
                cout << - i << " " << - j << endl;
                return 0;
            } else if (- pow(i, 5) - pow(j, 5) == X) {
                cout << - i << " " << j << endl;
                return 0;
            }
        }        
    }
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

bool WarshallFloyd(vector<vector<int>> &D, vector<vector<int>> &G) {
    REP(k, 0, D.size()) {
        REP(i, 0, D.size()) {
            REP(j, 0, D.size()) {
                if (k == i || i == j || j == k) continue;
                if (G[i][k] == (1 << 30) || G[k][j] == (1 << 30)) continue;
                if (G[i][k] + G[k][j] == D[i][j]) {
                    G[i][j] = 1 << 30;
                } else if (G[i][k] + G[k][j] < D[i][j]) {
                    return false;
                }
            }
        }
    }
    return true;
}

int main() {
    int N; cin >> N;
    vector<vector<int>> A(N, vector<int>(N)), G(N, vector<int>(N));
    REP(i, 0, N) {
        REP(j, 0, N) {
            cin >> A[i][j];
            G[i][j] = A[i][j];
        }
    }

    bool ok = WarshallFloyd(A, G);
    if (ok) {
        ll ans = 0;
        REP(i, 0, N) REP(j, 0, N) {
            if (G[i][j] < (1 << 30)) ans += G[i][j];
        }
        cout << ans / 2 << endl;
    } else {
        cout << -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int i, n, x, y, h, w, l, sum;

  while(1){
    scanf("%d", &n);
    if(n == 0) break;

    sum = 0;
    for(i=0; i<n; i++){
      scanf("%d %d %d %d", &x, &y, &h, &w);
      l = x + y + h;

      if(l <= 60 && w <= 2)
	sum += 600;
      else if(l <= 80 && w <= 5)
	sum += 800;
      else if(l <= 100 && w <= 10)
	sum += 1000;
      else if(l <= 120 && w <= 15)
	sum += 1200;
      else if(l <= 140 && w <= 20)
	sum += 1400;
      else if(l <= 160 && w <= 25)
	sum += 1600;
    }

    printf("%d\n", sum);
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int sum[100010];
int main()
{
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	for (int i = 1; i < N; i++) {
		sum[i] = sum[i - 1];
		if (S[i] == 'C' && S[i - 1] == 'A') sum[i]++;
	}
	while (Q--) {
		int l, r;
		cin >> l >> r;
		cout << sum[r - 1] - sum[l - 1] << endl;
	}
}


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

bool check(int n, string &s, string &ans){
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'o'){
            if (ans[i+1] == 'S') ans += ans[i];
            else {
                if (ans[i] == 'S') ans += 'W';
                else ans += 'S';
            }
        }
        else {
            if (ans[i+1] == 'W') ans += ans[i];
            else {
                if (ans[i] == 'S') ans += 'W';
                else ans += 'S';
            }
        }
    }
    if (ans[n] == ans[0] && ans[n+1] == ans[1]) cout << ans.substr(1, n) << endl;
    return (ans[n] == ans[0] && ans[n+1] == ans[1]);
}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string one = "SS";
    string two = "WW";
    string three = "SW";
    string four = "WS";
    if (check(n, s, one));
    else if (check(n, s, two));
    else if (check(n, s, three));
    else if (check(n, s, four));
    else cout << - 1 << endl;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 5e5 + 5;
ll fact[MAXN];
void init()
{
    fact[0] = 1;
    for(int i = 1; i < MAXN; i++)
        fact[i] = (i % mod * fact[i - 1] % mod) % mod;
}

ll fpow(ll x, ll y)
{
    ll res = 1;
    while(y > 0)
    {
        if(y & 1)
            res = (res % mod * x % mod) % mod;
        x = (x % mod * x % mod) % mod;
        y = y / 2;
    }
    return res;
}

ll inv(ll a)
{
    return fpow(a, mod - 2) % mod;
}

ll ncr(ll n, ll r)
{
    ll ans = fact[n];
    ans = (ans * inv(fact[n - r])) % mod;
    ans = (ans * inv(fact[r])) % mod;
    return ans % mod;
}

void cp()
{
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    ll sg;
    for(int i = 0; i <= n; i++)
    {
        sg = (i % 2 ? -1 : 1);
        ll p = ncr(n, i);
        ll q = (fact[m] % mod * inv(fact[m - i]) % mod) % mod;
        ll r = ncr(m - i, n - i);
        ll s = fact[n - i];

        ll t = (r % mod * s % mod) % mod;
        t = fpow(t, 2) % mod;

        ll here = (p % mod * q % mod) % mod;
        here = (here % mod * t % mod) % mod;
        here *= sg;
        ans = (ans + here + mod) % mod;
    }
    cout << ans % mod;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    init();
    while(t--)
    {
        cp();
    }
    return 0;
}


Measured memory_bytes: 7536
s=input()
length=len(s)
s_list=[int(s[i]) for i in range(length)]
s_dimlist=[s[i+1]==s[i] for i in range(length-1)]
# print(s_dimlist)
pre=0
isDone=True
cnt=0
for i in range(length-1):
    if s_dimlist[i]:
        if isDone:
            pre=i
            isDone=False
        else:
            cnt+=i-pre
            isDone=True
if not isDone:
    cnt+=length-1-pre
    # print(pre,length)
print(cnt)


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	vector<int> W(N);
	int sum = 0;
	REP(i,N){ 
		cin >> W[i];
		sum += W[i];
	}


	int a = W[0];
	int b = sum - W[0];
	int ans = abs(a-b);
	FOR(i,1,N-1){
		a += W[i];
		b -= W[i];
		ans = min(ans, abs(a-b));
	}

	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int LCS(string s, string t);

int main(void){
  int n;
  string s;
  string t;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    cin>>t;
    cout<<LCS(s,t)<<endl;
  }
}

int LCS(string s, string t){
  int a[s.length()+1][t.length()+1];
  for(int i=0;i<s.length()+1;i++){
    for(int j=0;j<t.length()+1;j++){
      a[i][j]=0;
    }
  }
  char S,T;
  for(int i=1;i<s.length()+1;i++){
    for(int j=1;j<t.length()+1;j++){
      S=s[i-1];
      T=t[j-1];
      if(S!=T){
        a[i][j]=max({a[i-1][j-1],a[i-1][j],a[i][j-1]});
      }
      else{
        a[i][j]=max({a[i-1][j-1]+1,a[i-1][j],a[i][j-1]});
      }
    }
  }
  return a[s.length()][t.length()];
}



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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;

multiset<int,greater<int>> A[3];

LL B[3][maxn];

LL sum[3][maxn];

int main()
{
    MEM(B,0);
    MEM(sum,0);
    int N;

    cin >> N;
    _for(i,0,3){
        _for(j,0,N){
            int num;
            cin >> num;
            A[i].insert(num);
        }
    }

    _for(i,0,3){
        int cnt = 1;
        for(auto a:A[i]){
            B[i][cnt++] = a;
        }
    }

    B[2][0] = INF;
    B[1][0] = INF;
    B[0][0] = INF;

    _rep(i,1,N){
        if(B[2][i] != INF) {
            sum[2][i] = sum[2][i-1] + 1;
        }
    }

    _rep(i,1,N){
        if(B[1][i] != 0){
            //cout << B[1][i] << endl;
            auto lb = lower_bound(B[2],B[2] + N + 1,B[1][i],greater<LL>());
            int k = lb - B[2];
            //cout << *lb << endl;
            sum[1][i] = sum[2][k-1];
            sum[1][i] += sum[1][i-1];
        }
    }

    LL ans = 0;

    _rep(i,1,N){
        if(B[0][i] != 0){
            auto lb = lower_bound(B[1],B[1] + N + 1,B[0][i],greater<LL>());
            int k = lb - B[1];
            //cout << k << endl;
            sum[0][i] = sum[1][k-1];
            //sum[0][i] += sum[0][i-1];
        }
    }

    _rep(i,1,N){
        ans += sum[0][i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


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

ll cube (ll a){
  return a*a*a ;  
}
int main() {

ll n,x;
cin>>n>>x;
ll a[n];
REP(i,n){
  cin>>a[i];
}

vector<ll > vect;

REP(i,n){
  vect.push_back(abs(a[i]-x));
}

ll gcdd = vect[0];

REP(i,n){
  gcdd = gcd(gcdd,vect[i]);
}

cout<<gcdd<<"\n";



  
  return 0;
}


Measured memory_bytes: 5028
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b[]=new int[a];
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		Arrays.sort(b);
		int ans=0;
		for(int i=0;i!=a-1;i++) {
			ans+=b[i];
		}
		if(b[a-1]>=ans) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
		}
}

Measured memory_bytes: 25556
// Problem : D - Knapsack 1
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define maxm 1e18
#define minm -1e18
#define pr pair<ll,ll>
#define mod 1000000007
 
void solve()
{
	ll n,w,ans=0,weight,value;
	cin>>n>>w;
	// dp[i]=max total value of items with total weight exactly i
	vector<ll> dp(w+1);
	for(ll i=0;i<n;i++)
	{
		cin>>weight>>value;
		for(ll j=w-weight;j>=0;j--)
		{
			dp[j+weight]=max(dp[j+weight],dp[j]+value);
		}
	}
	for(ll i=0;i<=w;i++)
		ans=max(ans,dp[i]);
	cout<<ans<<endl;
}
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 1024
object Main{
  def warshallfloyd(graph : Array[Array[Long]]) : Array[Array[Long]] = {
    val d = graph.map(_.clone)
    val V = graph.length
    for(k <- 0 until V; i <- 0 until V; j <- 0 until V){
      d(i)(j) = d(i)(j).min(d(i)(k)+d(k)(j))
    }
    return d
  }

  def main(args:Array[String]){
    val sc = new java.util.Scanner(System.in)
    val V,E = sc.nextInt

    val g = Array.fill[Long](V,V)(Long.MaxValue / 10)
    for(i <- 0 until V) g(i)(i) = 0

    for(i <- 0 until E){
      val s,t,d = sc.nextInt
      g(s)(t) = d
    }

    val res = warshallfloyd(g)

    for(i <- 0 until V if res(i)(i) < 0){
      println("NEGATIVE CYCLE")
      return ()
    }

    for(i <- 0 until V){
      for(j <- 0 until V){
        if(j!=0) print(" ")
        print(if(res(i)(j) > 3000000000L) "INF" else res(i)(j))
      }
      println()
    }
  }
}

Measured memory_bytes: 78824
s = input()
n = len(s)-1

for i in range(2**n):
  op = ['-']*n
  for j in range(n):
    if (i >> j) & 1:
      op[j] = '+'

  formula = ''
  op = op + ['']
  for s_, p_ in zip(list(s), op):
      formula += s_ + p_
  if eval(formula) == 7:
      print(formula+'=7')
      exit()

Measured memory_bytes: 3064
parseInt(x) = parse(Int,x)

function main()
  S = chomp(readline())
  n = length(S)
  N = n-1
  a = 0
  for bit = 0:((1<<N)-1)
    l = []
    for i = 0:(N-1)
      if (bit >>> i) & 1 == 1
        push!(l,i+1)
      end
    end
    m = length(l)
    s = []
    if m > 0
      push!(s,parseInt(S[1:l[1]]))
      if m > 1
        for i = 2:m
          push!(s,parseInt(S[(l[i-1]+1):l[i]]))
        end
      end
      l[m] != n ? push!(s,parseInt(S[(l[m]+1):n])): tmp = 0
    else
      s = parseInt(S)
    end
    a += sum(s)
  end
  println(a)
end

main()

Measured memory_bytes: 112496
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x,y,ans,sum=0;
    cin>>x>>y;
    ans=((long long)(y/x));
    while(ans>=1)
    {
        ans/=2;
    sum++;
    }
    cout<<sum<<endl;
    return 0;
}

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

int main()
{
    int a,b,c;cin>>a>>b>>c;
    int ma=max(a,max(b,c));
    int dis=(ma-a)+(ma-b)+(ma-c);
    int ans;
    if(dis%2==0)ans=dis/2;
    else ans=(dis+3)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;

int N, M, Q;
int a[55], b[55], c[55], d[55];
int ans = 0;

int check(int A[11])
{
  int p = 0;
  rep(i, Q)
  {
    if (c[i] == A[b[i] - 1] - A[a[i] - 1])
    {
      p += d[i];
    }
  }

  return p;
}

void dfs(int depth, int A[11], int start)
{
  if (depth == N)
  {
    ans = max(ans, check(A));
    return;
  }

  repd(num, start, M + 1)
  {
    A[depth] = num;
    dfs(depth + 1, A, num);
  }
}

int main()
{
  cin >> N >> M >> Q;
  rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];

  int A[11] = {0};
  dfs(0, A, 1);

  cout << ans << endl;
}

Measured memory_bytes: 3608
/**
*    created: 11.05.2020 23:51:19
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1) {
    for(int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, q; cin >> n >> q;
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main(){
    int n,ans1;
    cin >>n;
    vector<vector<int>>a(2,vector<int>(n));
    for(int i=0; i<n ;i++){
        cin >> a.at(0).at(i);
    }
    for(int i=0; i<n;i++){
        cin >>a.at(1).at(i);
    }

    int ans = 0;
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j <= i;j++){
            sum += a.at(0).at(j);
        }
        for(int k =i; k<n;k++){
            sum += a.at(1).at(k);
        }
        ans = max(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

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

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<int> a(N);
    readint(N, a);
    vector<int> b(N);
    readint(N, b);

    int d = 29;
    vector<int> xorv(d, 0);

    vector<int> b2(N);
    REP(k, 29){
        REP(i, N){
            b2[i] = b[i] % (1 << (k + 1));
        }
        sort(b2.begin(), b2.end());
        REP(i, N){
            int a2 = a[i] % (1 << (k + 1));
            //x1<= b < x2 or x3 <= b < x4
            int x1 = (1 << k) - a2;
            int x2 = (1 << (k + 1)) - a2;
            int x3 = x1 + (1 << (k + 1));
            int x4 = x2 + (1 << (k + 1));

            vector<int>::iterator i1 = lower_bound(b2.begin(), b2.end(), x1);
            vector<int>::iterator i2 = lower_bound(b2.begin(), b2.end(), x2);
            vector<int>::iterator i3 = lower_bound(b2.begin(), b2.end(), x3);
            vector<int>::iterator i4 = lower_bound(b2.begin(), b2.end(), x4);

            xorv[k] = (xorv[k] + distance(i1, i2) + distance(i3, i4)) % 2;

        }
    }

    int ans = 0;
    REP(i, d){
        ans += xorv[i] * (1 << i);
    }

    cout << ans;
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 4992
import Control.Applicative
import Control.Monad
import Text.Printf

main :: IO ()
main = do
  [n, t] <- f
  solve t <$> replicateM n f >>= printf "%.10f\n"
  where
    f = map read <$> words <$> getLine

solve :: Int -> [[Int]] -> Double
solve t = g . foldl f (0, 1)
  where
    f (mn, md) [d, n] = if n * md > d * mn then (n, d) else (mn, md)
    g (mn, md) = fromIntegral t * fromIntegral mn / (fromIntegral md)



Measured memory_bytes: 4880
#include <iostream>
#include <string>
using namespace std;

string DELETE = "delete";
string INSERT = "insert";
string DELETEFIRST = "deleteFirst";
string DELETELAST = "deleteLast";

struct Node {
	int key;
	Node *prev, *next;
};

Node *head;

Node* insertX(Node* head, int val){
	// key?????????????????\?????????????????????????????????????????????
	if(head	-> key == -1){
		head -> key = val;
		return head;
	}else{
		Node *newhead;
		newhead = new Node[1];
		newhead -> key = val;
		newhead -> prev = head -> prev;
		newhead -> next = head;

		(head -> prev) -> next = newhead;
		head -> prev = newhead;
		return newhead;
	}

}

Node* deleteX(Node* head, int val){
	// key??????????????????????????????????????????????????????
	
	
	//?????????val???????´¢
	if(head -> key == val){
		if(head -> next == head){
			head -> key = -1;
			return head;
		}
		
		(head -> prev) -> next = head -> next;
		(head -> next) -> prev = head -> prev;
		return head -> next;
	}else{
		Node* search;
//		search = (Node*)malloc(sizeof(Node));
		search = head -> next;
		while(head != search){ 
			if(search -> key == val){
				(search -> prev) -> next = search -> next;
				(search -> next) -> prev = search -> prev;
				break;
			}
			search = search -> next;
		}
		return head;
	}

}

Node* deleteFirst(Node* head){
	if(head -> next == head){
		head -> key = -1;
		return head;
	}
	head -> prev -> next = head -> next;
	head -> next -> prev = head -> prev;
	return head -> next;
}

Node* deleteLast(Node* head){
	if(head -> next == head){
		head -> key = -1;
		return head;
	}
	head -> prev = head -> prev -> prev;
	head -> prev -> next = head;
	return head;
}

void printElements(Node* head){
	if(head -> key == -1){
		return;
	}
	cout << head -> key;

	Node *p = head -> next;
	while(p != head){
		cout << " " << p -> key;
		p = p -> next;
	}
	cout << endl;
}

int main(){

	// ?????????
	head = new Node[1];
	head -> key = -1;
	head -> prev = head;
	head -> next = head;
	
	int n;
	cin >> n;

	string instruction;
	int key;

	for(int i=0; i<n; i++){	
		cin >> instruction;

		if(instruction == DELETE){
			cin >> key;
			head = deleteX(head, key);
		}else if(instruction == INSERT){
			cin >> key;
			head = insertX(head, key);

		}else if(instruction == DELETEFIRST){
			head = deleteFirst(head);
		}else if(instruction == DELETELAST){
			head = deleteLast(head);
		}
	}
		
	printElements(head);
		
	return 0;

}

Measured memory_bytes: 37428
# include "cstdio"
# include "iostream"

using namespace std;

long long d,n; 

int main(){
	long long ans=1; 
	scanf("%lld%lld",&d,&n);
	if(n==100){
		n++; 
	} 
	for(int i=1;i<=d;i++){
		ans*=100; 
	} 
	printf("%lld",ans*n); 
	return 0; 
} 

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(I,N) for(int I=0;I<N;I++)
using ll=long long int;
using namespace std;
int redn=0;
int rightR=0;
int main(){
	int n;
	cin>>n;
	char c[n];
	rep(i,n){
		cin>>c[i];
		if(c[i]=='R')redn++;
	}
	for(int j=redn;j<n;j++){
		if(c[j]=='R')rightR++;
	}
	cout<<rightR;
}


Measured memory_bytes: 3772
#include<stdio.h>

int main()
{
	unsigned int a,b,sum;
	unsigned char digits;

	while(scanf("%d %d",&a,&b) == 2)
	{
		sum = a + b;
		digits = 0;

		while(sum != 0)	
		{
			digits++;
			sum = sum / 10;
		}
		printf("%d\n",digits);
	}
	return 0;
}

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

typedef long long ll;
typedef pair<ll,ll> P;

int const MAX_N = 1000010;
vector<ll> prime;
vector<bool> is_prime(MAX_N,true);
void Eratosthenes() {
    is_prime[0] = is_prime[1] = false;
    for (ll i = 2;i*i < MAX_N;++i) if (is_prime[i]) for (ll j = 2*i;j < MAX_N;j += i) is_prime[j] = false;
    for (ll i = 0;i < MAX_N;++i) if (is_prime[i]) prime.push_back(i);
}

vector<pair<ll,int>> prime_factorization(ll a) {
    vector<pair<ll,int>> prime_factor;
    if (is_prime[0]) Eratosthenes();
    for (ll& i : prime) {
        if (i*i > a) break;
        if (a%i == 0) {
            P p = P(i,0);
            while (a%i == 0) {
                a /= i;
                p.second++;
            }
            prime_factor.push_back(p);
        }
    }
    if (a != 1) prime_factor.push_back(P(a,1));
    return prime_factor;
}

void rec(vector<ll>& div,vector<pair<ll,int>>& fact,int i,ll d) {
    if (i == fact.size()) {
        div.push_back(d);
        return;
    }
    for (int j = 0;j <= fact[i].second;++j) {
        rec(div,fact,i+1,d);
        d *= fact[i].first;
    }
}

// unsorted
vector<ll> divisor(ll a) {
    vector<ll> div;
    vector<pair<ll,int>> prime_factor = prime_factorization(a);
    rec(div,prime_factor,0,1);
    return div;
}

int main() {
    ll n,j = 1;cin >> n;
    int ans = 0;
    for (ll i = 2;i*i <= n;++i) {
        ll m = n;
        while (m%i == 0) m /= i;
        if (m%i == 1) ans++;
        j = i;
    }
    vector<ll> div = divisor(n-1);
    for (ll d : div) if (d > j) ans++;
    cout << ans+1 << endl;
}

Measured memory_bytes: 1528
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<ll, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int n, dis, atk;
ll ans;
int ps[N * 2];
Pair mon[N * 2];

int main() {
    cin >> n >> dis >> atk;
    for (int i = 1; i <= n; i++) {
        scanf("%lld %d", &mon[i].fi, &mon[i].se);
    }
    std::sort(mon + 1, mon + n + 1);
    for (int i = 1; i <= n; i++) {
        ps[i] += ps[i - 1];
        int gap = mon[i].se - ps[i], ts, rb;
        Pair tmp = mp(mon[i].fi + dis * 2, INT_MAX);

        if (gap <= 0) continue;

        ts = gap / atk + (gap % atk != 0);
        ans += ts;

        rb = std::upper_bound(mon + 1, mon + n + 1, tmp) - mon;
        ps[i] += ts * atk, ps[rb] -= ts * atk;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	vector<ll> H(N);
	rep(i, N)cin >> H[i];
	
	ll M = 0;
	ll cnt = 1;
	bool J = true;
	for(int i = 1; i < N; i++){
		if(H[i - 1] >= H[i]){
			cnt++;
			if(J)J = false;
		} else {
			M = max(cnt, M);
			cnt = 1;
		}
		if(i == N - 1){
			M = max(M, cnt);
		}
	}
	ll a = 0;
	cout << max(a, M - 1) << endl;
}


Measured memory_bytes: 1024
/* AOJ0002 */
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
  int a, b, sum;
  while(cin >> a >> b){
    sum = a + b;
    switch(sum){
    case 0 ... 9:
      cout << 1 << endl;
      break;
    case 10 ... 99:
      cout << 2 << endl;
      break;
    case 100 ... 999:
      cout << 3 << endl;
      break;
    case 1000 ... 9999:
      cout << 4 << endl;
      break;
    case 10000 ... 99999:
      cout << 5 << endl;
      break;
    case 100000 ... 999999:
      cout << 6 << endl;
      break;
    default:
      cout << 7 << endl;
    }
  }
  return 0;
}

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




























int main () {
    int N;
    cin >> N;

    string s;
    cin >> s;

    vector<char> c(N);
    for (int i = 0; i < N; i++) {
        c[i] = s[i];
    }
    
    int result = 0;
    while (c.size()) {
        for (int i = 0; c.size() != 0 && c[i] == 'R';){
            c.erase(c.begin());
        }
        for (int i = c.size() - 1; c.size() != 0 && c[i] == 'W'; i--) {
            c.pop_back();
        }

        if (c.size() == 0) {
            break;
        }
        else {
            c.erase(c.begin());
            if (c.size() != 0) c.pop_back();
            result++;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 3860
n,*a=$<.map &:to_i
s=m=0
b=[m]+b||=[]until n<m=m*3+1
b.map{|g|(g...n).map{|j|v=a[j];a[j]=a[j-=g]while j-g>=0&&a[j-g]>v&&s+=1;a[j]=v}}
puts b.size,b*" ",s,a

Measured memory_bytes: 117696
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
        public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        String tmp = t.substring(0, t.length()-1);
        if(s.equals(tmp)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
    
}


Measured memory_bytes: 35712
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(Math.Max(abc[2] - (abc[0] - abc[1]), 0));
        }
    }
}


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

int main(){
    string S, T;
    cin >> S >> T;

    int sum=0;
    rep(i, min(S.size(), T.size())){
        if(S[i] != T[i]) sum++;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3932
#include<algorithm>
#include<stack>
#include<ctime>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<queue>
using namespace std;
inline int read(){
	int num=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9'){num=num*10+x-'0';x=getchar();}
	return num*f;
}
const int maxn=200005;
char s[maxn];
int main(){
	scanf("%s",s);
	int t=0;
	for(int i=0;s[i]!='\0';++i){
		t=(t+s[i]-'0')%9;
	}
	if(t==0)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3880
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b,ans=0,now=0,x;
  cin >> n >> a >> b;
  x=n/(a+b)*a;
  x+=min(a,n-n/(a+b)*(a+b));
  cout << x << endl;
}

Measured memory_bytes: 256