akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7,M=4e3+7,p=1e9+7;
int n,k,a[N],b[N],f[N],g[N],gt[M][M]; long long ft[N];
inline int getans(int a,int b){
	if(a<b||a<0||b<0) return 0; return 1ll*f[a]*g[b]%p*g[a-b]%p;
}
int main(){
	f[0]=g[0]=f[1]=g[1]=1,k=2e3+7;
	for(int i=2;i<=1e6;i++) g[i]=1ll*(p-p/i)*g[p%i]%p;
	for(int i=2;i<=1e6;i++) f[i]=1ll*i*f[i-1]%p,g[i]=1ll*g[i-1]*g[i]%p;
	for(int i=0;i<=4e3;i++)
		for(int j=0;j<=4e3;j++) gt[i][j]=getans(i,j);
	cin>>n; for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++)
		for(int x=1;x<=2*k;x++) if(b[i]-x+k>=0) ft[x]=ft[x]+gt[a[i]+b[i]][b[i]-x+k];
	for(int x=1;x<=2*k;x++) ft[x]%=p;
	int ans=0;
	for(int x=1;x<=2*k;x++) ans=(ans+1ll*ft[x]*ft[2*k-x])%p;
	for(int i=1;i<=n;i++) ans=(ans-getans(a[i]*2+b[i]*2,b[i]*2))%p;
	long long inv2=(p+1)/2;
	cout<<(ans+p)*inv2%p<<endl;
}

Measured memory_bytes: 76032
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define mp make_pair
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007LL
#define MAXN 300002
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
ll row[200002],col[200002];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    set<ll>s;
    map<ll,ll> my;
    for(ll i = 0 ; i < n ; i ++){
        ll x;
        cin>>x;
        s.insert(x);
        my[x]++;
    }
    vector<ll> v(all(s));
    if(sz(s)==1 and v[0]==0){
       cout<<"Yes";
       return 0;    
    }
    if(s.size()>3 or n%3){
        cout<<"No";
        return 0;
    }
    if(sz(s)==3){
        if((v[0]^v[1])!=v[2] or my[v[0]]!=my[v[1]] or my[v[1]]!=my[v[2]]) cout<<"No";
        else cout<<"Yes";
        return 0;
    }
    if(sz(s)==2){
              if(v[0]==0 and my[v[1]]==2*my[v[0]])
                cout<<"Yes";
            else cout<<"No";
    }
    if(sz(s)==1){
        if(v[0]) cout<<"No";
        else cout<<"Yes";
    }
 }


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

ll saiki(ll kaisuu, ll n, ll moji, string str, ll max)
{
    if (moji > max)
    {
        max = moji;
    }
    if (moji == 0)
    {
        str += "a";
        cout << "a";
    }
    else if (moji == 1)
    {
        str += "b";
        cout << "b";
    }
    else if (moji == 2)
    {
        str += "c";
        cout << "c";
    }
    else if (moji == 3)
    {
        str += "d";
        cout << "d";
    }
    else if (moji == 4)
    {
        str += "e";
        cout << "e";
    }
    else if (moji == 5)
    {
        str += "f";
        cout << "f";
    }
    else if (moji == 6)
    {
        str += "g";
        cout << "g";
    }
    else if (moji == 7)
    {
        str += "h";
        cout << "h";
    }
    else if (moji == 8)
    {
        str += "i";
        cout << "i";
    }
    else if (moji == 9)
    {
        str += "j";
        cout << "j";
    }
    else
    {
        str += "k";
        cout << "k";
    }
    kaisuu++;
    if (kaisuu == n)
    {
        cout << endl;
        return 0;
    }
    for (ll i = 10; i > 0; i--)
    {
        if (moji - i >= 0)
        {
            saiki(kaisuu, n, moji - i, str, max);
            cout << str;
        }
    }
    saiki(kaisuu, n, moji, str, max);
    for (ll i = 1; i <= 10; i++)
    {
        if (moji + i <= max + 1)
        {
            cout << str;
            saiki(kaisuu, n, moji + i, str, max);
        }
    }

    return 0;
}

/****** define variable start ******/
ll n;
/******* define variable end *******/
ll solve()
{

    cin >> n;
    ll first = 0;
    string kara = "";
    ll res = saiki(0, n, first, kara, 0);

    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int x[N];
  for(int i = 0; i < N; ++i) cin >> x[i];
  int L;
  cin >> L;
  //Doubling
  int table[N][30];
  for(int i = 0; i < N; ++i){
    fill(table[i],table[i]+30,0);
    table[i][0] = upper_bound(x,x+N,x[i]+L) - x - 1;
  }

  for(int j = 1; j < 30; ++j){
    for(int i = 0; i < N; ++i){
      table[i][j] = table[table[i][j-1]][j-1];
    }
  }
  /*
  for(int i = 0; i < N; ++i){
    cout << i << " | ";
    for(int j = 0; j < 30; ++j){
      cout << table[i][j] << " ";
    }cout << endl;
  }
  */
  //Query
  int Q;
  cin >> Q;
  int a, b;
  for(int i = 0; i < Q; ++i){
    cin >> a >> b;
    if(a > b) swap(a,b);
    --a;--b;
    int ans = 0, r = 29;
    while(r > 0){
      while(r >= 0 && table[a][r] >= b) --r;
      //cout << r << " ";
      if(r >= 0)
	ans += 1<<r;
      a = table[a][r];
    }
    ++ans;
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;

using u128 = __uint128_t;

#define int long long
#define MOD 1000000007

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

    int n, k;
    cin>>n>>k;
    int * a= new int [n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a , a + n);
    int count = 0;
    for(int i = n-1 - k ; i>= 0; i--){
        count += a[i];
    }
    cout<<count<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    vector<int> v;
    int a,b,c;
    cin >> a >> b >> c;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(),v.end());

    cout << v[0] << " " << v[1] << " " << v[2] << endl;
}
    

Measured memory_bytes: 1224
#include <stdio.h>
#include <string.h>

#define YEN_500 500
#define YEN_5 5
#define HAPPINESS_POINTS_LARGE 1000
#define HAPPINESS_POINTS_SMALL 5

int main()
{
    long moneyInput, fiveHundreadCoinsAmount, fiveCoinsAmount;

    scanf("%ld", &moneyInput);

    if (moneyInput / YEN_500 > 0)
    {   // Count amount of 500 and 5 Yen coins
        fiveHundreadCoinsAmount = moneyInput / YEN_500;
        fiveCoinsAmount = (moneyInput % YEN_500) / YEN_5;
        // Counts points for every coin
        printf("%ld \n", (fiveHundreadCoinsAmount * HAPPINESS_POINTS_LARGE) + (fiveCoinsAmount * HAPPINESS_POINTS_SMALL));
    }
    else if (moneyInput / YEN_500 <= 0)
    {
        // Count amount of 5 Yen coins
        fiveCoinsAmount = (moneyInput % YEN_500) / YEN_5;
        // Counts points for every coin
        printf("%ld \n",(fiveCoinsAmount * HAPPINESS_POINTS_SMALL));
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int a[500][500], num[500];
bool vis[500];
int m, n;
bool judge(int x) {
    memset(vis, 0, sizeof(vis));
    int cnt = m;
    while (cnt > 0) {
        bool flag = false;
        memset(num, 0, sizeof(num));
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (vis[a[i][j]]) continue;
                num[a[i][j]]++;
                break;
            }
        }
        for (int j = 1; j <= m; j++) {
            if (num[j] > x) {
                vis[j] = true;
                flag = true;
                cnt--;
            }
        }
        if (!flag) return true;
    }
    return false;
}
int erfen() {
    int l = 1, r = n, ans = n;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (judge(mid)) {
            ans = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }
    return ans;
}
int main() {
    memset(a, 0, sizeof(a));
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    printf("%d\n", erfen());
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    int n, m;
    float thres;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    thres = accumulate(a.begin(), a.end(), 0) / float(4 * m) ;
    int cnt = 0;
    rep(i, n){
        if(a[i] >= thres){
            cnt++;
        }
    }
    if (cnt >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
 
 
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
 
mod = 10**9+7  # 出力の制限
n = 2*10**3
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
 
for i in range(2, n + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


for i in range(1, K+1):
    print(cmb(N-K+1, i, mod) * cmb(K-1, i-1, mod) % mod)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define avjo ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    avjo;
    long long n,i;
    cin>>n;
    map<string,long long> m;
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        m[s]=1;
    }
    cout<<m.size();
    return 0;
}


Measured memory_bytes: 19144
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double t = sc.nextDouble();
        int a = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
        }
        double ans = 10000;
        int ans_no = 0;
        for(int i = 0; i < n; i++){
            double temp = t - h[i] * 0.006;
            if(ans > Math.abs(a - temp)){
                ans_no = i + 1;
                ans = Math.abs(a - temp);
            }
        }
        System.out.println(ans_no);
    }
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

//update k th element,get rmin
template<class T> class segtree{
public:
    int n,size_;
    vector<T> dat;
    function<T(T,T)> fun_;
    T id_;
    segtree()=default;
    segtree(int size,function<T(T,T)> fun,T id,T initial_value){ init(size,fun,id,initial_value); }
    void init(int size,function<T(T,T)> fun,T id,T initial_value){
        size_=size;
        fun_=fun;
        id_=id;
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,0);
        for(int i=0; i<size; ++i) update(i,initial_value);
    }
    void update(int k, T a) {
        k+=n-1; // leaf
        dat[k]=a;
        while(k>0) {
            k=(k-1)/2;
            dat[k]=fun_(dat[k*2+1],dat[k*2+2]);
        }
    }
    T query(int a,int b) { return query(a,b,0,0,n); }
    T query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return id_;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return fun_(query(a,b,k*2+1,l,m),query(a,b,k*2+2,m,r));
    }
};

void solve(){
    int n,q;
    cin >> n >> q;
    segtree<int> seg(n,[](int x,int y){ return min(x,y); },numeric_limits<int>::max(),numeric_limits<int>::max());
    rep(i,0,q){
        int com,x,y;
        cin >> com >> x >> y;
        if(com==0) seg.update(x,y);
        else cout << seg.query(x,y+1) << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(100005);
    rep(i,n) {
        int ai;
        cin >> ai;
        a.at(ai)++;
    }
    
    ll sum = 0;
    rep(i, 100001) {
        sum += (ll) a.at(i) * i;
    }

    int q;
    cin >> q;
    queue<ll> ans;
    rep(i, q) {
        int b, c;
        cin >> b >> c;
        sum -= (ll) b * a.at(b);
        sum += (ll) c * a.at(b);
        a.at(c) += a.at(b);
        a.at(b) = 0;
        ans.push(sum);
    }

    while(!ans.empty()) {
        cout << ans.front() << endl;
        ans.pop();
    }
    return 0;
}

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

int main() {
  int a, ans;
  cin >> a;
  ans = a + a * a + a * a * a;
  cout << ans << endl;
  return 0;
}

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

int main(){

    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, ans;
vector<int> g[N];
int vis[N];
int dfs(int u, int fa) {
	if(g[u].size() > 2) return u;
	else for(int v: g[u]) if(v != fa) return dfs(v, u);
	return u;
}
int main() {
	scanf("%d", &n);
	for(int i = 1, u, v ; i < n ; ++ i) {
		scanf("%d%d", &u, &v);
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	for(int i = 0 ; i < n ; ++ i) {
		if(g[i].size() == 1) {
			vis[dfs(i, -1)] = 1;
			++ ans;
		}
	}
	for(int i = 0 ; i < n ; ++ i) {
		ans -= vis[i];
	}
	printf("%d\n", max(1, ans));
}


Measured memory_bytes: 6656
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,key,cnt,ans;
int t[1000001];
int main(){
  while(scanf("%d",&n)&&n){
    for(int i=0;i<n;i++)scanf("%d",&t[i]);
    t[n]=ans=-1;
    sort(t,t+n);
    key=t[0];
    cnt=1;
    for(int i=1;i<=n;i++){
      if(key==t[i])cnt++;
      else{
	if(cnt>n/2){ans=key;break;}
	key=t[i];
	cnt=1;
      }
    }
    if(ans==-1)printf("NO COLOR\n");
    else printf("%d\n",ans);
  }
  return 0;
}

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

int g(int x, int k) {
    if (k == 1) return x;
    while (x >= k) {
        if (x % k == 0) return x / k;
        else {
            int d = x / k + 1, r = x % k;
            if (r >= d) x = x / k * k + r % d;
            else x -= d;
        }
    }
    return 0;
}

int main() {
    int n; cin >> n;
    int gn = 0;
    while (n--) {
        int a, k; cin >> a >> k;
        gn ^= g(a, k);
    }
    cout << (gn == 0 ? "Aoki\n" : "Takahashi\n");
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;
int r_,s_,p_;
int getP(char c, int i)
{
  if(c == 'r' && i == 2)
  {
    return p_;
  }
  else if(c == 's' && i == 0)
  {
    return r_;
  }
  else if(c == 'p' && i == 1)
  {
    return s_;
  }
  else return 0;

}

int main()
{
  int n, k;
  int r, s, p;
  string t;

  cin>>n>>k>>r>>s>>p;
  r_=r, s_=s, p_=p;

  cin>>t;

  vector<vector<int>> dp(n, vector<int>(3, 0));

  for(int i = 0; i < n; i ++)
  {
    for(int j = 0; j < 3; j ++)
    {
      if(i-k >= 0)
      {
        for(int x = 0; x < 3; x++)
        {
          if(x != j)
          {
            dp[i][j] = max(dp[i][j], dp[i-k][x]);
          }
        }
      }
      dp[i][j] += getP(t[i], j);
    }
  }
  int res = 0;
  for(int i = n-1; i >= n-k; i--)
    res += max(max(dp[i][1], dp[i][0]), dp[i][2]);
  cout<<res<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;
#define N (ll)(1e9+7)
ll mypower(ll a, ll b, ll mod = N)
{
    ll ans = 1;
    while(b)
    {
        if(b%2)
            ans = (ans*a)%mod;
        b=b/2;
        a=(a*a)%mod;
    }
    return ans;
}
bool comp(pair<ll,ll> a, pair<ll,ll> b)
{
    return a.first > b.first;
}
int main() {
    ll k, n;
    cin >> k >> n;
    ll a[n+1];
    ll i;
    for(i=1;i<=n;i++)
        cin >> a[i];
    ll ans = 1e9;
    ans = min(ans, k - (a[2] - a[1]));
    ans = min(ans, a[n] - a[1]);
    ans = min(ans, k - (a[n] - a[n-1]));
    for(i=2;i<=n-1;i++)
    {
        ans = min(ans, k - (a[i] - a[i-1]));
        ans = min(ans, k - (a[i+1] - a[i]));
    }
    cout << ans;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const long long LL_INF = (long long) 2e18 + 5;

struct convex_piecewise_linear {
    priority_queue<long long> negatives;
    priority_queue<long long, vector<long long>, greater<long long>> positives;
    long long negative_offset, positive_offset;
    long long zero_y;

    convex_piecewise_linear() {
        negatives = priority_queue<long long>();
        positives = priority_queue<long long, vector<long long>, greater<long long>>();
        negatives.push(-LL_INF);
        positives.push(LL_INF);
        negative_offset = positive_offset = zero_y = 0;
    }

    void add_shift(long long left, long long right) {
        negative_offset -= left;
        positive_offset += right;
    }

    void add_abs(long long center) {
        long long left = negatives.top() + negative_offset;
        long long right = positives.top() + positive_offset;
        assert(left <= right);

        if (left <= center && center <= right) {
            negatives.push(center - negative_offset);
            positives.push(center - positive_offset);
            return;
        }

        if (center < left) {
            negatives.push(center - negative_offset);
            negatives.push(center - negative_offset);
            long long move = negatives.top() + negative_offset; negatives.pop();
            zero_y += move - center;
            positives.push(move - positive_offset);
        } else {
            assert(center > right);
            positives.push(center - positive_offset);
            positives.push(center - positive_offset);
            long long move = positives.top() + positive_offset; positives.pop();
            zero_y += center - move;
            negatives.push(move - negative_offset);
        }
    }

    void print() {
        auto negatives_copy = negatives;
        auto positives_copy = positives;

        cerr << "Negatives:";

        while (!negatives_copy.empty()) {
            cerr << ' ' << negatives_copy.top() + negative_offset;
            negatives_copy.pop();
        }

        cerr << endl;
        cerr << "Positives:";

        while (!positives_copy.empty()) {
            cerr << ' ' << positives_copy.top() + positive_offset;
            positives_copy.pop();
        }

        cerr << endl;
        cerr << "Zero y: " << zero_y << endl;
    }
};

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

    int N;
    cin >> N;
    convex_piecewise_linear DS;
    long long prev_L, prev_R;

    for (int i = 0; i < N; i++) {
        long long L, R;
        cin >> L >> R;
        // cerr << L << ' ' << R << endl;

        if (i > 0)
            DS.add_shift(R - L, prev_R - prev_L);

        // DS.print();
        DS.add_abs(L);
        prev_L = L;
        prev_R = R;
        // DS.print();
    }

    cout << DS.zero_y << '\n';
}


Measured memory_bytes: 2036
// problem: "https://atcoder.jp/contests/abc122/tasks/abc122_d"

#include<iostream>
#include<vector>
#include<string>
#include<map>
#define ll long long
#define p 1000000007

using namespace std;

vector<string>C = {"A","C","G","T"};
vector<map<string,ll>>M(101);

ll num(ll n,string s)
{
    if(s=="AGC")
        return 0;
    else if(s=="ACG")
        return 0;
    else if(s=="GAC")
        return 0;
    else if(n==0)
        return 1;


    if(M[n].find(s) == M[n].end())
    {
        if(s=="AGC")
            M[n][s] = 0;
        else if(s=="ACG")
            M[n][s] = 0;
        else if(s=="GAC")
            M[n][s] = 0;
        else if(s[2]=='C' && (s[1]=='G' || s[0]=='G'))
        {
            M[n][s] = 0;
            ll i;
            for(i=1;i!=4;i++)
                M[n][s] = (M[n][s]+num(n-1,C[i]+s[0]+s[1]))%p;
        }
        else
        {
            M[n][s] = 0;
            ll i;
            for(i=0;i!=4;i++)
                M[n][s] = (M[n][s]+num(n-1,C[i]+s[0]+s[1]))%p;
        }
    }

    return M[n][s];
}

int main()
{
    ll n;
    cin>>n;

    ll ans,i,j,k;
    ans = 0;
    for(i=0;i!=4;i++)
        for(j=0;j!=4;j++)
            for(k=0;k!=4;k++)
                ans = (ans+num(n-3,C[i]+C[j]+C[k]))%p;      // define num()

    cout<<ans;
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long long ll;

int main(void){
    
    int n;
    vector<int> v;
    cin>>n;
    for(int i=2;i<=31;i++){
        int num=i;
        while(num*i<=n){
            num*=i;
            v.push_back(num);
        }
    }
    sort(v.begin(),v.end());
    int ans=1;
    for(auto x:v){
       if(x>n)break;
       ans=x; 
    }
    cout<<ans<<endl;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) begin(n),end(n)

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int a,b;
	cin >> a >> b;
	int ans = max(a+b, a*b);
	ans = max(ans, a-b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
class Dice():
    def __init__(self, l):
        self.value = l
    def roll(self,s):
        new_list = [0]*6
        if s == "W":
            new_list[0] = self.value[2]
            new_list[1] = self.value[1]
            new_list[2] = self.value[5]
            new_list[3] = self.value[0]
            new_list[4] = self.value[4]
            new_list[5] = self.value[3]
        if s == "E":
            new_list[0] = self.value[3]
            new_list[1] = self.value[1]
            new_list[2] = self.value[0]
            new_list[3] = self.value[5]
            new_list[4] = self.value[4]
            new_list[5] = self.value[2]
        if s == "N":
            new_list[0] = self.value[1]
            new_list[1] = self.value[5]
            new_list[2] = self.value[2]
            new_list[3] = self.value[3]
            new_list[4] = self.value[0]
            new_list[5] = self.value[4]
        if s == "S":
            new_list[0] = self.value[4]
            new_list[1] = self.value[0]
            new_list[2] = self.value[2]
            new_list[3] = self.value[3]
            new_list[4] = self.value[5]
            new_list[5] = self.value[1]
        self.value = new_list

l = list(map(int,input().split()))
Dice1 = Dice(l)
quary = input()

for q in quary:
    Dice1.roll(q)
print(Dice1.value[0])


Measured memory_bytes: 5612
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	string S;
	cin >> S;
	ll k = 0;
	rep(i, S.size()) {
		k += ll(S.at(i) - '0');
	}
	if (k % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
   // freopen("input.txt", "r", stdin);
    SPEED
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    FOR(i, 0, n) {
        ans += s[i] == t[i];
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define EPS 1e-10
int equals(double a, double b) { return fabs(a - b) < EPS; };
class Point {
public:
	double x, y;
	Point(double x=0, double y=0) :x(x), y(y) { };
	Point operator + (Point& p) {
		return Point(p.x + x, p.y + y);
	}
	Point operator - (Point& p) {
		
		return Point(p.x - x, p.y - y);
	}
	Point operator * (double k) {
		return Point(k*x, k*y);
	}
	double abs() {					//向量长度;
		return sqrt(x * x + y * y);
	}
};
typedef Point Vector;
double dot(Vector a, Vector b) {			//内积 x1*x2 + y1*y2
	return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b) {		  //外积  x1*y2 - x2*y1
	return a.x * b.y - a.y * b.x;
}
struct Segment           //线段
{
	Point a, b;
};
typedef Segment Line;   //线段表示直线；
class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double x = 0) :c(c), r(x) {};
};
void Parallel_Orthogonal() {				//判断平行或正交
	Point a, b,c,d;
	Point e, f;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a.x >> a.y >> b.x >> b.y>>c.x>>c.y>>d.x>>d.y;
		e = a - b;
		f = c - d;
		if (equals(dot(e, f), 0)) cout << "1" << endl;
		else if (equals(cross(e, f), 0))cout << "2" << endl;
		else cout <<"0" <<endl;
	}
}
int main(void) {
	Parallel_Orthogonal();
}


Measured memory_bytes: 3228
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;
typedef std::vector<std::set<index_t>> edge_t;

class memoization_t
{
	std::vector<std::int64_t> value;
	edge_t edge;
	auto run(index_t i, std::int64_t v, std::vector<boost::optional<std::int64_t>>& result)
	{
		if (result[i])
		{
			return;
		}
		result[i] = v + value[i];
		for (auto n : edge[i])
		{
			run(n, *result[i], result);
		}
	}
public:
	memoization_t(std::vector<std::int64_t> _value, edge_t _edge) :value(_value), edge(_edge)
	{

	}
	memoization_t(memoization_t const&) = delete;
	memoization_t(memoization_t&&) = delete;

	auto operator()()
	{
		std::vector<boost::optional<std::int64_t>> result(value.size());
		run(0, 0, result);
		return result;
	}
};


void Main()
{
	int N, Q;
	std::cin >> N >> Q;
	std::vector<std::set<index_t>> edge(N);
	for (auto i : boost::irange(1, N))
	{
		int a, b;
		std::cin >> a >> b;
		--a; --b;
		edge[a].emplace(b);
		edge[b].emplace(a);
	}
	std::vector<std::int64_t> value(N);
	for (auto i : boost::irange(0, Q))
	{
		index_t index;
		std::int64_t x;
		std::cin >> index >> x;
		--index;
		value[index] += x;
	}
	memoization_t func(std::move(value), std::move(edge));
	auto result = func();
	for (auto&& v : result)
	{
		std::cout << *v << " ";
	}
	std::cout << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

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

    int t[N];
    rep(i,N)cin >> t[i];

    int ans=0;
    
    rep(i,N){
        if(i==N-1)ans+=T;
        else {
            int tem = t[i+1] - t[i];
            ans += min(T,tem);
        }
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int a; cin >> a;
	cout << (a * a * a + a * a + a) << endl;

	return 0;
}

Measured memory_bytes: 3648
n, m = map(int, input().split())
mod = 10 ** 9 + 7

f = [1, 1]
f_inv = [1, 1]
inv = [0, 1]
 
for i in range(2, m+1):
    f.append((f[-1] * i ) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    f_inv.append((f_inv[-1] * inv[-1]) % mod)

def comb(n, k):
    return f[n] * f_inv[k] * f_inv[n-k] % mod

def per(n, k):
    return f[n] * f_inv[n-k] % mod

ans = 0
for i in range(0, n+1):
    res = comb(n, i) *  per(m, i) * (per(m-i, n-i) ** 2)
    if i % 2 == 1:
        res *= -1
    ans += res
    ans %= mod

print(ans)

Measured memory_bytes: 193024
#include <bits/stdc++.h>
const int mod = 1000000007;
const int modx = 998244353;
#define ll long long
#define readi(x) scanf("%d", &x)
#define reads(x) scanf("%s", x)
#define readl(x) scanf("%I64d", &x)
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, a, b) for (i = a; i < b; i++)
#define rep2(i, a, b) for (i = b; i >= a; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bpc(x) __builtin_popcount(x)
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pdd pair<double, double>
#define pic pair<int, char>
#define ddouble long double
#define PI 3.1415926535
#define endl "\n"
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define prod(x, y) ((x % mod) * (y % mod)) % mod
#define add(x, y) ((x % mod) + (y % mod)) % mod
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define pqs priority_queue<int, vector<int>, greater<int>>
#define pqb priority_queue<int>
#define mii map<int, int>
#define mll map<ll, ll>
using namespace std;
//using namespace __gnu_pbds;
/*ll power(ll x, ll y)
{
    ll r = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            r = (r*x) % mod;

        y = y>>1;
        x = (x*x) % mod;
    }
    return r;
}*/

void thunder()
{
    ll n, W;
    cin >> n >> W;
    vll w(n + 1), v(n + 1);
    ll i, j, k;
    rep(i, n)
    {
        cin >> w[i] >> v[i];
    }
    ll dp[n + 5][W + 5] = {};
    rep1(i, 1, n + 1)
    {
        rep(j, W + 1)
        {
            dp[i][j] = dp[i - 1][j];
            if (j - w[i - 1] >= 0)
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
        }
    }
    cout << dp[n][W] << endl;

    return;
}
int main()
{
    /*#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif*/
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--)
        thunder();
}


Measured memory_bytes: 85640
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let mut a: Vec<usize> = (0..n).map(|_| sc.read()).collect();

    let mut ans = 0;
    loop {
        let s: usize = a.iter().map(|&a| a / n).sum();
        if s == 0 {
            break;
        }
        for i in 0..n {
            let t = a[i] / n;
            a[i] = a[i] + s - t - n * t;
        }
        ans += s;
    }
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>

std::vector<std::vector<long long>> dp(200005, std::vector<long long>(2, 0));
std::vector<std::vector<std::vector<long long>>> dp_skip(200005,
                                                         std::vector<std::vector<long long>>(2,
                                                                                             std::vector<long long>(2, 0)));

int main() {
  unsigned int N;
  std::cin >> N;

  std::vector<long long> A_array(N);
  for (unsigned int i = 0; i < N; ++i) {
    std::cin >> A_array.at(i);
  }

  if (N % 2 == 0) {
    // initialization
    dp.at(0).at(0) = A_array.at(0);
    dp.at(0).at(1) = A_array.at(1);
    // dp loop
    for (unsigned int i = 1; i < N / 2; ++i) {
      dp.at(i).at(0) = dp.at(i - 1).at(0) + A_array.at(i * 2);
      dp.at(i).at(1) = std::max(dp.at(i - 1).at(0), dp.at(i - 1).at(1)) + A_array.at(i * 2 + 1);
    }
    // get answer
    std::cout << std::max(dp.at(N / 2 - 1).at(0), dp.at(N / 2 - 1).at(1)) << std::endl;
  } else {
    // initialization
    dp_skip.at(0).at(0).at(0) = A_array.at(0);
    dp_skip.at(0).at(1).at(0) = A_array.at(1);
    dp_skip.at(0).at(0).at(1) = 0;
    dp_skip.at(0).at(1).at(1) = 0;
    // dp loop
    for (unsigned int i = 1; i < N / 2; ++i) {
      dp_skip.at(i).at(0).at(0) = dp_skip.at(i - 1).at(0).at(0) + A_array.at(i * 2);
      dp_skip.at(i).at(1).at(0) = std::max(dp_skip.at(i - 1).at(0).at(0),
                                           dp_skip.at(i - 1).at(1).at(0))
        + A_array.at(i * 2 + 1);
      const long long prev_max = std::max(dp_skip.at(i - 1).at(0).at(0),
                                          dp_skip.at(i - 1).at(1).at(0));
      dp_skip.at(i).at(0).at(1) = std::max(dp_skip.at(i - 1).at(0).at(1) + A_array.at(i * 2),
                                           prev_max);
      dp_skip.at(i).at(1).at(1) = std::max(std::max(dp_skip.at(i - 1).at(0).at(1),
                                                    dp_skip.at(i - 1).at(1).at(1))
                                           + A_array.at(i * 2 + 1),
                                           prev_max);
    }
    // get answer
    dp_skip.at(N / 2 - 1).at(0).at(1) += A_array.at(N - 1);
    const long long no_skip_max = std::max(dp_skip.at(N / 2 - 1).at(0).at(0), dp_skip.at(N / 2 - 1).at(1).at(0));
    std::cout << std::max(no_skip_max, dp_skip.at(N / 2 - 1).at(0).at(1)) << std::endl;
  }

  return 0;
}


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

int main()
{
    long long arrays[12],i;
    for(i=0;i<10;i++)
    {
        cin>>arrays[i];
    }
    sort(arrays,arrays+10);
    for(i=9;i>6;i--)
    {
        cout<<arrays[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ax = max({a,b,c});
    int in = min({a,b,c});
    int me = a+b+c - ax - in;
    cout << in << ' ' << me << ' ' << ax << endl;
}


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

int main() {
	int n[4];
	cin >> n[0] >> n[1] >> n[2] >> n[3];

	sort(n, n + 4);
	if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) cout << "YES";
	else cout << "NO";
	cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long int;
#define pb push_back

int N, val;
vector<lint> spf;
lint res = 1;

int main(){
    cin >> N;
    spf.assign(N+1, 0);
    for(int i = 0; i <= N; i++) spf[i] = i;
    for(int i = 2; i * i <= N; i++){
        if(spf[i] == i){
            for(int j = i * i; j <= N; j+= i){
                if(spf[j] == j) spf[j] = i;
            }
        }
    }


    for(int i = 2; i <= N; i++){
        map<lint, lint> m;
        lint j = i, cn = 1;
        while(j != 1){
            m[spf[j]]++;
            j /= spf[j];
        }
        lint mul = 1;
        for(auto iter = m.begin(); iter != m.end(); ++iter) mul *= (iter->second+1);
        res += i * mul;
    }

    cout << res << endl;
    return 0;

}



Measured memory_bytes: 81400
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt()-1;
        int y = sc.nextInt()-1;
        int[] dist = new int[n+1];
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                dist[Math.min(j-i,Math.abs(j-y)+Math.abs(i-x)+1)]++;
            }
        }
        for(int i = 1; i < n; i++){
            System.out.println(dist[i]);
        }
    }
}

class Point{
    double x,y;
    public Point(double x, double y){
        this.x = x;
        this.y = y;
    }
}
class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

using namespace std;

int n, m, q;
int a[110][10];
int ch[110];
int maxx;

void f(int here, int prev)
{
	if(here >= n)
	{
		int summ = 0;
		
		for(int i = 0 ; i < q ; i++)
		{
			if(ch[a[i][1] - 1] - ch[a[i][0] - 1] == a[i][2])
				summ += a[i][3];
		}
		
		maxx = max(maxx, summ);
		return;
	}
	
	for(int i = prev ; i <= m ; i++)
	{
		ch[here] = i;
		f(here + 1, i);
	}
}

int main(void)
{
	scanf("%d %d %d", &n, &m, &q);
	
	for(int i = 0 ; i < q ; i++)
		scanf("%d %d %d %d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]);
	
	f(0, 1);
	
	printf("%d", maxx);
	return 0;
}

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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

const int N = 1e4 + 5;

string n;
ll d, dp[N][2][105];

ll solve(int i, int j, ll val) {
    if (i == (int) n.size()) 
        return val == 0;
    ll& ret = dp[i][j][val];
    if (~ret) return ret;
    ret = 0;
    int cur = n[i] - '0';
    if (j) {
        for (int nxt = 0; nxt < 10; ++nxt)
            (ret += solve(i + 1, 1, (val + nxt) % d)) %= MOD;
    } else {
        (ret += solve(i + 1, 0, (val + cur) % d)) %= MOD;
        for (int nxt = 0; nxt < cur; ++nxt)
            (ret += solve(i + 1, 1, (val + nxt) % d)) %= MOD;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n >> d;
    memset(dp, -1, sizeof(dp));
    cout << ((solve(0, 0, 0) - 1) % MOD + MOD) % MOD << endl;
}


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

using namespace std;

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

  int n, x, t;
  cin >> n >> x >> t;

  int ans = ((n - 1) / x + 1) * t;

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3652
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

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

        final int N = Integer.parseInt(sc.next());
        Object[] s = IntStream.range(0, N).mapToObj(i -> sc.next()).toArray();
        final int M = Integer.parseInt(sc.next());
        Object[] t = IntStream.range(0, M).mapToObj(i -> sc.next()).toArray();
        int ans = 0;
        
        for (int i = 0; i < N; i++) {
            int blue = 0;
            int red = 0;
            for (int j = 0; j < N; j++) {
                if (s[i].equals(s[j])) {
                    blue++;
                }
            }
            for (int k = 0; k < M; k++) {
                if (s[i].equals(t[k])) {
                    red++;
                }
            }
            ans = Math.max(ans, blue - red);
        }
        
        out.println(ans);

        out.flush();
    }
}

Measured memory_bytes: 28372