akhauriyash/Code-Regression huggingface dataset:
import bisect
N =int(input())
A =sorted(list(map(int,input().split())))
B =sorted(list(map(int,input().split())))
C =sorted(list(map(int,input().split())))
counter = 0
for i in range(len(B)):
    #Bより小さいAの探索
    Ind_A = bisect.bisect_left(A,B[i])
    if A[Ind_A-1] == B[i]:
        Ind_A -= 1
    
    #Bより大きいCの探索
    Ind_C = bisect.bisect_right(C,B[i])
    num_C = len(C)-Ind_C
    counter += round(Ind_A*num_C)
    #print('B[i] =' +str(B[i]),end='')
    #print(' Ind_A =' +str(Ind_A),end='')
    #print(' Ind_C =' +str(Ind_C),end = '')
    #print(' num_C =' +str(num_C),end = '')    
    #print(' 総数 ' + str(Ind_A*num_C))
print(counter)


Measured memory_bytes: 28828
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll t,n,a,b,c,d;
map<ll,ll> cc;
ll chg(ll x)
{
    if(x==0) return 0;
    if(x==1) return d;
    if(cc[x]) return cc[x];
    ll res = 1e18;
    if(x<res/d) res = x*d;
    res = min(res,chg(x/2) + (x%2)*d + a);
    if(x>2&&x%2)res = min(res,chg(x/2+1) + (2 - x%2) * d + a);
    if(x%3<2)res = min(res,chg(x/3) + (x%3)*d + b);
    if(x%3>1&&x>1)res = min(res,chg(x/3+1) + (3 - x%3) * d + b);
    if(x%5<3)res = min(res,chg(x/5) + (x%5)*d + c);
    if(x%5>2&&x>1)res = min(res,chg(x/5+1) + (5 - x%5) * d + c);
    cc[x] = res;
    return res;
}
int main(void)
{
    scanf("%lld",&t);
    while(t--)
    {
        cc.clear();
        scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
        printf("%lld\n",chg(n));
    }
    return 0;
}


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

int main(){
 int a, b, c, k;
 cin>>a>>b>>c>>k;
 int n = max(max(a, b), c);
 int m = a+b+c-n;
 for(int i = 0; i<k; i++)n*=2;
 cout<<m+n<<endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>

using namespace std;
int main() {
  int men,day,las,x,cnt;
  cnt = 0;
  cin >> men >> day >> las;
  vector<int> a(men);
  for(int i=0;i<men;i++){
    cin >> a[i];
  }
  
  
  for(int j=0;j<men;j++){
    for(int k=0;k<day;k++){
      x = k*a[j] + 1;
      if(x<=day){
        cnt++;
        continue;
      }else{
        break;
      }
    }
  }
  
  cout << cnt + las << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

int main(void){
    ll N, K;
    cin >> N >> K;
    ll a = N % K;
    ll b = abs(K - a);
    cout << min(a, b) << endl;
}


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

int main(){
  int n,i,ans;
  cin >> n;
  string a[n],b;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  ans=1;
  b=a[0];
  for(i=1;i<n;i++){
    if(b!=a[i]){
      ans+=1;
      b=a[i];
    }
  }
  cout << ans;
}

Measured memory_bytes: 9852
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int n;
    cin>>n;
    pair<long long int,long long int> lr[n];
    for(int i=0;i<n;i++){
        cin>>lr[i].first>>lr[i].second;
    }
    sort(lr,lr+n);
    /*for(int i=0;i<n;i++){
        cout<<lr[i].first<<lr[i].second<<endl;
    }*/

    //'外'の排除
    vector <pair<long long int,long long int> > v;
    v.push_back(lr[0]);
    for(int i=1;i<n;i++){
        if(v.back().second>=lr[i].second){
            while((!v.empty())&&v.back().second>=lr[i].second){
                v.pop_back();
            }
            v.push_back(lr[i]);
        }
        else{
            if(v.back().first!=lr[i].first){
                v.push_back(lr[i]);
            }
        }
    }
    /*for(int i=0;i<v.size();i++){
        cout<<v[i].first<<v[i].second<<endl;
    }*/

    int k=v.size();//大きさが1で例外処理。高々10^5なのでforで回して良い。
    long long int ans=0;
    long long int max0=0;
    long long int max1=0;
    long long int x,y;
    for(int i=0;i<n;i++){
        if(lr[i].second-lr[i].first>max0){
            max0=lr[i].second-lr[i].first;
        }
    }
    if(k==1){
        ans=v[0].second-v[0].first+max0+2;
    }
    else{
        x=v[0].second-v[k-1].first+1;
        if(x<0){x=0;}
        max0=x+max0+1;
        for(int i=0;i<k-1;i++){
            x=v[0].second-v[i].first+1;
            y=v[i+1].second-v[k-1].first+1;
            if(x<0){x=0;}
            if(y<0){y=0;}
            if(x+y>max1){
                max1=x+y;
            }
        }
        if(max1>max0){
            ans=max1;
        }
        else{
            ans=max0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3956
N = int(input())
A_list = list(input().split())

A_list.sort()

for i in range(len(A_list) - 1):
    if A_list[i] == A_list[i + 1]:
        print('NO')
        break
    elif i == len(A_list) - 2 and A_list[i] != A_list[i+1]:
        print('YES')
        break
    else:
        continue



Measured memory_bytes: 20796
C = input() 

if C== "a" :
  print("b")
elif C== "b":
  print("c")
elif C== "c":
  print("d")
elif C== "d":
  print("e")
elif C== "e":
  print("f")
elif C== "f":
  print("g")
elif C== "g":
  print("h")
elif C== "h":
  print("i")
elif C== "i":
  print("j")
elif C== "j":
  print("k")
elif C== "k":
  print("l")
elif C== "l":
  print("m")
elif C== "m":
  print("n")
elif C== "n":
  print("o")
elif C== "o":
  print("p")
elif C== "p":
  print("q")
elif C== "q":
  print("r")
elif C== "r":
  print("s")
elif C== "s":
  print("t")
elif C== "t":
  print("u")
elif C== "u":
  print("v")
elif C== "v":
  print("w")
elif C== "w":
  print("x")
elif C== "x":
  print("y")
elif C== "y":
  print("z")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int a,b,c,d ;
int arr[500005] ;
string str ;

void solve()
{
    cin >> a >> b >> c >> d ;
    int ans = -2000000000000000000 ;
    if(b>=0&&d>=0)
    {
        ans = max(ans,b*d) ;
    }
    if(a<0 && c<0)
    {
        ans = max(ans,a*c) ;
    }
    if(b<0&&d>=0)
    {
        ans = max(ans,b*max(c,0LL)) ;
    }
    if(d<0&&b>=0)
    {
        ans = max(ans,d*max(a,0LL)) ;
    }
    cout << ans ;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}


Measured memory_bytes: 3648
object Main extends App {
	val s = scala.io.StdIn.readLine.toList.toArray
	val size = s.size
 
	val A = Array('B', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')

	if(s(0) == 'A'){
		var flag = false
		var cnt  = 0

		if(A.contains(s(1))) flag = true
		if(A.contains(s(size-1))) flag = true

		for(i<-2 to size-2){
			if(s(i) == 'C') cnt += 1
			if(A.contains(s(i))) flag = true
		}

		if(flag) println("WA")
		else if(cnt == 1) println("AC")
		else println("WA")
	}else{
		println("WA")
	}
}


Measured memory_bytes: 25532
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int i=0, s=0;
		while(n){
			s+=(n%2)*pow(10, i);
			n/=2;
			i++;
		}
		i=0;
		while(s){
			if(s%10){
				if(s/10)	cout<<pow(2, i)<<" ";
				else	cout<<pow(2,i)<<endl;
			}
			s/=10;
			i++;
		}
	}
	return 0;
}



Measured memory_bytes: 3360
import java.io.*;
import java.util.*;

public class Main {
    static List<Integer>[] edges;
    static boolean[] inCycle;
    static int[] val;
    public static boolean dfs(int u, int[] state) {
        state[u] = 1;
        for (int v: edges[u]) {
            if (state[v] == 1) {
                state[u] = 2;
                inCycle[v] = true;
                return true;
            } else if (state[v] == 0) {
                if (dfs(v, state)) {
                    inCycle[v] = true;
                    return !inCycle[u];
                }
            }
        }
        state[u] = 2;
        return false;
    }

    public static void dfs2(int u, int p) {
        Set<Integer> fb = new HashSet<>();
        for (int v: edges[u]) {
            if (v == p || inCycle[v]) continue;
            dfs2(v, p);
            fb.add(val[v]);

        }
        for (int i = 0;; i++) {
            if (!fb.contains(i)) {
                val[u] = i;
                return;
            }
        }
    }

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        inCycle = new boolean[n];
        val = new int[n];
        edges = new List[n];
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            edges[i] = new ArrayList<>();
        }
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt() - 1;
            edges[p[i]].add(i);
        }
        int[] state = new int[n];
        for (int i = 0; i < n; i++) {
            if (state[i] != 2) dfs(i, state);
        }
        int cntCycleSize = 0;

        for (int i = 0; i < n; i++) {
            if (inCycle[i]) cntCycleSize++;
        }

        for (int i = 0; i < n; i++) {
            if (inCycle[i]) dfs2(i, -1);
        }
        Set<Integer> ss = new HashSet<>();
        for (int i = 0; i < n; i++) {
            if (inCycle[i]) {
                ss.add(val[i]);
            }
        }
        if (ss.size() != 1 || cntCycleSize % 2 == 0) {
            System.out.println("POSSIBLE");
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }

    public static class Scanner {
        StringTokenizer st;
        BufferedReader br;
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }
        public int nextInt() throws IOException{
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 95380
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  int N = readln.chomp.to!int;
  string S = readln.chomp;

  int ans = 0;
  char prev = '0';
  foreach(c; S) {
    if(c != prev) ans++;
    prev = c;
  }
  ans.writeln;
}


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

using namespace std;

#define ll long long

int bin_pow(int a, int pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        int tmp = bin_pow(a, pow / 2);
        return tmp * tmp;
    }
    return a * bin_pow(a, pow - 1);
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

ll m = 1000000007;

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

    string s, t; cin >> s >> t; cout << t << s;
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef pair<int ,int > pii;
typedef long long LL;
const long long oo = 1e9 + 7;

int n;
long long t,ans;
int x[223456];


int main() {
 //   freopen("test.txt","r",stdin);
    cin >> n >> t;
    for (int i = 1; i<= n ; i++) {
        cin >> x[i];
    }
    x[n +1] = oo + t;
    for (int i =1 ; i <= n; i++) {
        ans += min(t,1LL*(x[i+1] - x[i]));
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int tmp=0,mx=0;
    string s;
    cin >> s;
    rep(i,s.length()){
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
            tmp++;
        }
        else{
            tmp=0;
        }
      	mx=max(mx,tmp);
    }
    cout << mx << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		long n=scanner.nextLong();
		long k=scanner.nextLong();
		long a=n%k;
		long b=k-a;
		if(a>b)a=b;
		System.out.println(a);
	}

}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &_a, T _b){
    if(_a < _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

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

    int n;
    cin >> n;

    vector<int> rev(n);
    rep(i, n){
        int p;
        cin >> p;
        rev[--p] = i;
    }

    int maxi = 0, cnt = 1;
    rep(i, n - 1){
        if(rev[i] < rev[i + 1]){
            ++cnt;
        }else{
            chmax(maxi, cnt);
            cnt = 1;
        }
    }
    chmax(maxi, cnt);

    int ans = n - maxi;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2585&lang=jp
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60

struct edge{
	int u;
	int v;
	int cost;
	int h;
	int r;
	edge() {}
	edge(int u, int v, int c, int h, int r) :u(u), v(v), cost(c), h(h), r(r) {}
};


int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, M, H, K;
	while (cin >> N >> M >> H >> K, N | M | H | K) {
		vector<vector<edge>> G(N);
		int exist = 0;
		/* input */
		for (int i = 0; i < M;i++) {
			int a, b, c, h, r; cin >> a >> b >> c >> h >> r;
			a--; b--; r--;
			G[a].push_back(edge(a, b, c, h, r));
			G[b].push_back(edge(b, a, c, h, r));
		}
		int S, T; cin >> S >> T; S--; T--;
		int P; cin >> P;
		vector<pair<int, int>> pass(P); // {bit,cost}
		for (int i = 0; i < P;i++) {
			int l, d; cin >> l >> d;
			int bit = 0;
			for (int j = 0; j < l; j++) {
				int k; cin >> k; k--;
				bit += (1 << k);
				exist |= (1 << k);
			}
			pass[i] = { bit,d };

		}

		/* preprocessing */
		// dijkstra
		vector<ll> d_st(1 << K, LINF);
		queue<pair<int, int>> q;
		for (int i = 0; i < (1 << K);i++) {
			if ((i & exist) != i)continue;
			q.push({ S,0 }); // {n-th city, hour}
			vector<vector<ll>> dist(N, vector<ll>(H + 1, LINF));
			dist[S][0] = 0;
			while (!q.empty()) {
				auto p = q.front(); q.pop();
				int n = p.first, h = p.second;
				for (auto e : G[n]) {
					if (H < h + e.h)continue;
					int cost = e.cost;
					if ((1 << e.r)&i) cost = 0;
					if (dist[e.v][h+e.h] > dist[e.u][h] + cost) {
						dist[e.v][h+e.h] = dist[e.u][h] + cost;
						q.push({ e.v,h + e.h });
					}
				}
			}
			for (int j = 0; j <= H;j++) {
				d_st[i] = min(d_st[i], dist[T][j]);
			}
		}

		// bitdp
		vector<ll> bitdp(1 << K, LINF);
		bitdp[0] = 0;
		for (int i = 0; i < (1 << K);i++) {
			if (bitdp[i] == LINF)continue;
			for (int j = 0; j < P;j++) {
				bitdp[i | pass[j].first] = min(bitdp[i | pass[j].first], bitdp[i] + pass[j].second);
			}
		}

		/* solve */
		ll ans = d_st[0];
		for (int i = 1; i < (1 << K);i++) {
			if ((i & exist) != i)continue;
			ans = min(ans, d_st[i] + bitdp[i]);
		}
		cout << (ans == LINF ? -1:ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 3208
//123 B
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

//B
int main(){
    int a,b; cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+5;
 
int main()
{
    fastio;
    ll i, j, k, n, m=7, c=0;
    vll a;

    cin>>k;

    ll ans=0;
    for ( i = 0; i < k; i++)
    {
        if(m%k==0){
            c=1;
            break;
        }

        else{
            ans++;
            m=((((m%k)*10)%k)+7)%k;
        }
    }

    if(c==1)
    cout<<ans+1<<endl;
    else
    cout<<-1<<endl;
    
    
    


    return 0;
}

Measured memory_bytes: 3608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CTsundoku {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n, m, k; cin >> n >> m >> k;
      vector<ll> a(n+1), b(m+1);
      rep(i, n) {
        int x; cin >> x;
        a[i+1] = a[i] + x;
      }
      rep(i, m) {
        int x; cin >> x;
        b[i+1] = b[i] + x;
      }

      ll mi = 0;
      ll ma = n+m+1;
      while(mi+1 < ma) {
        ll med = (mi+ma)/2;
        bool flag = false;
        for(int i=0; i<=med; i++) {
          if (i<=n && med-i<=m) {
            if (a[i] + b[med-i] <= k) {
              flag = true;
              break;
            }
          }
        }
        if (flag) {
          mi = med;
        } else {
          ma = med;
        }
      }
      cout << mi << endl;
    }
};

signed main() {
  CTsundoku solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 6380
class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n)
        for i in range(len(A)):
            self.__node[i + n] = A[i]
        for i in range(n - 1, 0, -1):
            self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])
    
    def update(self, i, c):
        i += self.__n
        node = self.__node
        node[i] = c
        while i > 1:
            i //= 2
            node[i] = self.__dot(node[2 * i], node[2 * i + 1])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n
        r += self.__n
        while (l < r):
            if l & 1:
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l //= 2
            if r & 1:
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r //= 2
        return self.__dot(vl, vr)


N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
max_A = max(A)

st = SegmentTree([0] * (max_A + 1), max, 0)
for i, a in enumerate(A):
    l = max(0, a - K)
    r = min(max_A, a + K)
    ns = st.get(l, r + 1)
    st.update(a, ns + 1)

print(st.get(0, max_A + 1))


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int[][][] houses = new int[4][3][10];
		int n = Integer.parseInt(in.readLine());
		for (int i = 0; i < n; i += 1) {
			String[] info = in.readLine().split(" ");
			int b = Integer.parseInt(info[0]);
			int f = Integer.parseInt(info[1]);
			int r = Integer.parseInt(info[2]);
			int v = Integer.parseInt(info[3]);
			houses[b - 1][f - 1][r - 1] += v;
		}
		for (int x = 0; x < 4; x += 1) {
			for (int y = 0; y < 3; y += 1) {
				for (int z = 0; z < 10; z += 1) {
					sb.append(" ");
					sb.append(Integer.toString(houses[x][y][z]));
				}
				sb.append(System.getProperty("line.separator"));
			}
			if (x != 3) {
				sb.append("####################"
						+ System.getProperty("line.separator"));
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 19204
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

int main(){
	
	int N;
	cin>>N;
	string S;
	cin>>S;
	
	vector<vector<int>> dp(N,vector<int>(N,0));
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(S[i]!=S[j]){
				dp[i][j]=0;
				continue;
			}
			if(i==0||j==0){
				dp[i][j]=1;
				continue;
			}
			dp[i][j] = dp[i-1][j-1]+1;
		}
	}
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			ans = max(ans,min(dp[i][j],abs(i-j)));
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

struct edge {
    int from, to, cost;
};

vector<vector<int>> G; // nから到達可能な点を求める
vector<bool> R;

void dfs(int v) {
    R[v] = true;
    for (auto nv : G[v]) {
        if (R[nv]) continue;
        dfs(nv);
    }
}

int main(){
    int n, m, p;
    cin >> n >> m >> p;
    vector<edge> es(m);
    G.resize(n);
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        es[i] = edge{a, b, -(c-p)};
        G[b].push_back(a);
    }

    R.assign(n, false);
    dfs(n-1);

    vector<int> d(n, INF);
    d[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            edge e = es[j];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == n - 1 && R[e.to]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    cout << max(0, -d[n-1]) << endl;
}

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

int main(){
  int a,b,k,ans; cin>>k>>a>>b;
  //string s; cin>>s;
  bool ok=false;
  for(int i=a;i<=b;i++)if(i%k==0)ok=true;
 // cout<<ans;

  cout<<(  ok?"OK":"NG")<<endl;

}

Measured memory_bytes: 3620
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 4e5 + 10;
ll n, Xor;
ll B[MXN], A[MXN];
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> B[i];
    for(int i = 1; i <= n; i += 2){
        ll now = (B[i] ^ B[i + 1]);
        Xor = Xor ^ now;
    }
    for(int i = 1; i <= n; i ++){
        ll now = (B[i] ^ Xor);
        cout << now << ' ';
    }
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


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

int main(){
    int n, sum = 0, ans = 0;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        ans++;
        sum += i;
        if(sum >= n) break;
    }
    printf("%d\n", ans);
}

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

int main(){
	
	
	int score[100]={0};
	int n;cin>>n;
	int m;cin>>m;
	int target[100];
	for(int i=0;i<m;i++)cin>>target[i];
	for(int i=0;i<m;i++){
		int miss=0;
		for(int j=0;j<n;j++){
			int t;cin>>t;
			if(t!=target[i])miss++;
			else score[j]++;
		}
		score[target[i]-1]+=miss;
	}
	for(int i=0;i<n;i++){
		cout<<score[i]<<endl;
	}
	
	return 0;
}


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

int main() {
    ll a,b;
    std::cin >> a>>b;
    std::cout << max({a-b,a+b,a*b}) << std::endl;
}
 

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N;
  string S;
  cin>>N>>S;
  
  int ans=0;
  
  // 000-999のうちSから作ることができるのものをカウント
  for(int i=0;i<1000;++i){
    
    int c[3]={i/100,(i/10)%10,i%10};	// 暗証番号の各桁の数字
    
    // Sの左端から調べて暗証番号の左から一つ目の数字と一致したらカウント
    int f=0;
    for(int j=0;j<N;++j){
      if(S[j]==char(48+c[f]))
        ++f;
      if(f==3){
        ++ans;
        break;
      }
    }
  }
  

  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 200005;
int total[N];
vector<int> g[N];

void dfs(int v, int p) {
	for(auto i : g[v]) {
		if(i == p) continue;
		total[i] += total[v];
		dfs(i, v);
	}
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int n,q;
	cin >> n >> q;

	int a,b;
	rep(i,n-1) {
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}

	rep(i,q) {
		cin >> a >> b;
		total[a] += b;
	}

	dfs(1, -1);

	repA(i,1,n)
		cout << total[i] << ' ';
	cout << '\n';
}

// Mistakes
// j or k --> i
// read question again

Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 1000001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair 
#define ll long long
#define ull unsigned ll 
#define pb push_back
#define db double
const int mod=1e9+7;
int read()
{
	int x=0,f=1;char ch=gc;
	while(!isdigit(ch)){ch=gc;if(ch=='-')f=-1;}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(int x)
{
	if(x>9)print(x/10);
	putchar(x%10+48);
}
int main()
{  
    int n=rd,m=rd;
    printf("%d",2*m-n);puts(" ");
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI

using namespace std;

int main() {

	double R;
	cin >> R;

	cout << fixed << setprecision(15) << R * 2 * M_PI << endl;

	return 0;

}

Measured memory_bytes: 3768
# coding:utf-8
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf')] * n

#後者が前者よりも小さい時に更新→DPテーブルをinfに初期化(先頭は0)
def chmin(a,b):
    if(a > b):
        return b
    else:
        return a

#後者が前者よりも大きい時に更新→DPテーブルを-infに初期化
def chmax(a,b):
    if(a< b):
        return b
    else:
        return a

def main():
    dp[0] = 0
    for i in range(1,n):
        dp[i] = chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
        if i > 1:
            dp[i] = chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
    
    print(dp[n-1])

if __name__ == '__main__' :
    main()

Measured memory_bytes: 13908
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        int[][] cell = new int[r + 1][c + 1];
        for(int i = 0; i < r; i++){
            for(int j = 0; j < c; j++){
                cell[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i < r; i++){
            int sum = 0;
            for(int j = 0; j < c; j++){
                sum += cell[i][j];
            }
            cell[i][c] = sum;
        }
        for(int i = 0; i < c + 1; i++){
            int sum = 0;
            for(int j = 0; j < r; j++){
                sum += cell[j][i];
            }
            cell[r][i] = sum;
        }
        for(int i = 0; i < r + 1; i++){
            for(int j = 0; j < c + 1; j++){
                System.out.print(cell[i][j]);
                if(j != c){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}


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

#define lint long long

using namespace std;

int main(){
    int N;
    cin >> N;
    
    vector<lint> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end(), greater<lint>());
    
    lint longest = 0;
    
    for(int i = 0; i < N - 1; ++i){
        if(A[i] == A[i + 1]){
            if(longest == 0){
                longest = A[i];
                i++;
            } else {
                cout << longest * A[i] << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int second = sc.nextInt();
		
		int minute = second/60;
		second = second%60;
		
		int hour = minute/60;
		minute = minute%60;
		
		System.out.println(hour + ":" + minute + ":" + second);
	}
}

Measured memory_bytes: 26276
#                               #
    # author : samars_diary #
    # 16-09-2020 │ 18:28:11 #
#                               #

import sys, os.path, math

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

mod =  1000000007
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=ii();print((pow(10,a,mod)+pow(8,a,mod)-2*pow(9,a,mod))%mod)
for _ in range(1):
    solve()

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 998244353;

int main() {
    // your code goes here
    ll k,n,pba=0,os=0,ans=0;
    vcl v;
    string si;
    cin >> si >> k;
    chmin(k,305ll);
    n=si.size();
    rep(i,0,n-1){
        if(si[i]=='1'){
            pba++;
        } else {
            os++;
            v.pb(pba);
            pba=0;
        }
    }
    v.pb(pba);
    n=v.size();
    ll dp[310][310]={0},lla[310][310]={0},r[310][310]={0};
    rep(i,0,k){
        dp[i][0]=1;
    }
    rep(j,0,k){
        rep(l,0,j){
            lla[j][l+1]=(lla[j][l]+dp[j][l])%mod;
        }
    }
    rep(l,0,k){
        rep(j,l,k){
            r[j+1][l]=(r[j][l]+dp[j][l])%mod;
        }
    }
    rep(i,1,n-1){
        rep(j,0,k){
            rep(l,0,j){
                dp[j][l]=(dp[j][l]+r[j][l]-r[l][l]+mod)%mod;
                dp[j][l]=(dp[j][l]+lla[j][l]-lla[j][max(0ll,l-v[i])]+mod)%mod;
            }
        }
        rep(j,0,k){
            rep(l,0,j){
                lla[j][l+1]=(lla[j][l]+dp[j][l])%mod;
            }
        }
        rep(l,0,k){
            rep(j,l,k){
                r[j+1][l]=(r[j][l]+dp[j][l])%mod;
            }
        }
    }
    rep(i,0,k){
        ans=(ans+dp[i][i])%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5892
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    string a;
    cin  >> a;
    if(a[0]==a[a.length()-1])QECHO("Yes\n"); else QECHO("No\n");
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
n = int(input())
s = input()

an = s.count('R') *s.count('G') *s.count('B')

for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2*j-i
        if (k<n) and (s[i]!=s[j]) and (s[j]!=s[k])and(s[i]!=s[k]):
                an -= 1

print(an)

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

int main() {
    int n,k;cin >> n >> k;
    int l[n];

    for (int i=0;i<n;i++){
        cin >> l[i];
    }

    sort(l,l+n);
    reverse(l,l+n);

    int result = 0;
    for(int i=0;i<k;i++){
        result += l[i];
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>

// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  int N;
  string S;
  cin>>N;
  cin>>S;

  int count = 1;
  for (int i = 0; i < N-1; i++)
  {
    if(S[i] != S[i+1])count++;
  }

  cout<<count;
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}


Measured memory_bytes: 512
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = numeric_limits<int>::max())
{return uniform_int_distribution<int> (l, r)(rng);}

template <typename T, typename G>
ostream& operator << (ostream& out, const pair<T, G> &a) 
{return out << "( " << a.x << ", " << a.y << ")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out << "{ "; for(const auto &i: a) out << i << ", "; return out << "}" << endl;}

template <typename T, typename G>
ostream& operator << (ostream& out, const map<T, G> &a) 
{out << "< "; for(const auto &i: a) out << i << ", "; return out << ">" << endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator << (ostream& out, T (&a)[N])
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

void debug_out(){cerr << endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr << (H) << ' '; debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr << '#' << #__VA_ARGS__ << ":\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

vector <int> nums;
int sieve(int n) {
	nums.assign(n, 0);
	for (int i = 1; i < n;  ++i) {
		for (int j = i; j < n; j+= i) {
			nums[j]++;
		}
		nums[i]*= i;
		nums[i]+=nums[i - 1]; 
	}
	return nums[n - 1];
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	cout << sieve(n + 1) << '\n';
	return 0;
}


Measured memory_bytes: 81364
// Created by js0805
#include <bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<string>
#define ll long long
#define fr(a,b) for(ll i=a;i<b;i++)
#define prDouble(x) cout << fixed << setprecision(10) <<x
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
double dp[3001][3001];
double solve(double a[], int i, int x) {
    if (x == 0) {
        return 1;
    }
    if (i == 0) {
        return 0;
    }
    if (dp[i][x] > -0.9) {
        return dp[i][x];
    }
    return dp[i][x] = a[i] * solve(a, i - 1, x - 1) + (1 - a[i]) * solve(a, i - 1, x);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    double a[n + 1];
    fr(1, n + 1) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof dp);

    prDouble(solve(a, n, (n + 1) / 2));

    return 0;
}

Measured memory_bytes: 74372
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>




#define f first
#define s second
#define pb push_back
#define sz(a) (int)(a).size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 4000000000000000005ll
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
//typedef pair<point, point> line;
typedef pair<double , point> Circle;



const int N = 2000002;

int n,a;


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

    n %= 500;
    if(n > a)printf("No\n");
    else printf("Yes\n");
    return 0;
}

/*
 
 
 7
 10
 5 7 1
 5 6 2
 7 7 2
 6 7 2
 5 5 1
 3 6 2
 1 3 2
 5 6 1
 1 3 1
 6 7 1
 
 
 
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


Measured memory_bytes: 256
S = input()
if S == 'SUN':
    A = 7
elif S == 'MON':
    A = 6
elif S == 'TUE':
    A = 5
elif S == 'WED':
    A = 4
elif S == 'THU':
    A = 3
elif S == 'FRI':
    A = 2
elif S == 'SAT':
    A = 1
print(A)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
 
using ll = long long;
#define int ll
 
signed main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin >> X[i];
  
  int ret = 0;
  for (int i = 0; i < N - 1; i++) {
    ret += min(B, A * abs(X[i] - X[i+1]));
  }
  
  cout << ret << endl;
}

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

int main () {
  int n = 10;
  char S[n];
  cin >> S;
  if (S[0] != 'A') {
    cout << "WA" << endl;
    return 0;  
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (S[i]) {
      
    }
    else {
      n = i;
      break;  
    }  
  }

  for (int i = 1; i < n; i++) {
    if (S[i] < 91) {
      if (i >= 2 && i <= (n - 2) && S[i] == 'C')  {
        count++;    
      }  
      else {
        cout << "WA" << endl;
        return 0;
      }
    }   
  }
  if (count == 1) {
    cout << "AC" << endl;  
  }
  else {
    cout << "WA" << endl;  
  } 
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    int t = 111;
    REP(i,10) {
        if (i*t>=N) {
            cout<<i*t<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256