akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  ll k;
  scanf("%lld", &k);
  ll p = k / 50;
  ll q = k % 50;
  ll base = p + 49;
  int n = 50;
  printf("50\n");
  rep (i, q) {
    printf("%lld ", base + 51 - q);
  }
  rep (i, n-q) {
    printf("%lld ", base - q);
  }
  printf("\n");

  return 0;
}


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

N,K=map(int,input().split())
A=list(map(int,input().split()))

x=sum(A)
import math
xr=math.ceil(math.sqrt(x))

LIST=[]
for i in range(1,xr+1):
    if x%i==0:
        LIST.append(i)
        LIST.append(x//i)

ANS=1

for l in LIST:
    count=0

    B=[a%l for a in A]
    B.sort()

    i=0
    j=N-1

    for i in range(N):
        if B[i]%l==0:
            continue
        else:
            count_temp=B[i]
            count+=count_temp
            B[i]=0

            while count_temp:
                while B[j]%l==0:
                    j-=1
                MINUS=min(count_temp,l-B[j])
                B[j]+=MINUS
                count_temp-=MINUS

    if count<=K:
        ANS=max(ANS,l)

print(ANS)


Measured memory_bytes: 46172
use std::io;


fn main() {
    let n = read_one::<usize>();
    let mut dn = read::<usize>();
    dn.sort();
    println!("{}", dn[n / 2] - dn[n / 2 - 1]);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(void){
    int n, x;
    std::cin >> n >> x;
    std::vector<int> l(n);
    for(int i = 0; i < n; i++){
        std::cin >> l[i];
    }
    int d = 0;
    int cnt = 1;
    for(int i = 0; i < n; i++){
        d = d + l[i];
        if(d > x){
            break;
        }
        cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2000010,M=1e9+7;
ll in[N],jc[N],jcin[N],r1,r2,c1,c2,n1,n2,ans;
ll quickexp(ll base,ll exp){
	if(exp==0) return 1;
	ll tmp=quickexp(base,exp/2);
	if(exp&1) return tmp*tmp%M*base%M;
	else return tmp*tmp%M;
}
ll cal(ll x,ll y){
	if(x<0||y<0) return 0;
	else return jc[x+y]*jcin[x]%M*jcin[y]%M;
}
ll tri(ll x,ll y,ll l){
	if(x<0||y<0) return 0;
	ll ans=0;
	for(ll i=0;i<=l;++i){
		ans+=(quickexp(2,l-i+1)-1)*cal(x+i,y-1)%M;
		ans%=M;
		ans+=(quickexp(2,l-i+1)-1)*cal(x-1,y+i)%M;
		ans%=M;
	}
	return ans;
}
ll rec(ll x,ll y){
	if(x<0||y<0) return 0;
	ll ans=quickexp(2,x+y+1)-1;
	//printf("ans=%lld\n",ans);
	ans+=M-tri(x+1,0,y-1);
	//printf("ans=%lld\n",ans);
	ans%=M;
	//printf("ans=%lld\n",ans);
	ans+=M-tri(0,y+1,x-1);
	//printf("ans=%lld\n",ans);
	ans%=M;
	//printf("ans=%lld\n",ans);
	return ans;
}
int main()
{
	scanf("%lld%lld%lld%lld",&r1,&c1,&r2,&c2);
	n2=r2+c2;n1=r1+c1;
	jc[0]=jcin[0]=1;
	jc[1]=in[1]=jcin[1]=1;
	for(ll i=2;i<N;++i){
		jc[i]=jc[i-1]*i%M;
		in[i]=in[M%i]*(M-M/i)%M;
		jcin[i]=in[i]*jcin[i-1]%M;
	}
	//printf("%lld\n\n",tri(4,0,2));
	//printf("%lld\n\n",rec(3,3));
	ans=rec(r2,c2);
	ans+=M-rec(r2,c1-1);ans%=M;
	ans+=M-rec(r1-1,c2);ans%=M;
	ans+=rec(r1-1,c1-1);ans%=M;
	printf("%lld\n",ans);
}

Measured memory_bytes: 47104
using System;
using System.Collections.Generic;
using System.Linq;
public class AtCoder
{
	int W,H,N;
	int minX,maxX,minY,maxY;
	public void Solve()
	{
		int[] tmp = ReadsInt();
		W = tmp[0];
		H = tmp[1];
		N = tmp[2];
		
		minX = 0;
		maxX = W;
		minY = 0;
		maxY = H;
		
		for(int i = 0;i < N;i++)
		{
			tmp = ReadsInt();
			int x = tmp[0];
			int y = tmp[1];
			int a = tmp[2];
			
			if(a == 1)
			{
				minX = Math.Max(minX,x);
			}else if(a == 2)
			{
				maxX = Math.Min(maxX,x);
			}else if(a == 3)
			{
				minY = Math.Max(minY,y);
			}else
			{
				maxY = Math.Min(maxY,y);
			}
		}
		
		if(minX >= maxX || minY >= maxY)
		{
			Console.WriteLine(0);
			return;
		}
		Console.WriteLine((maxX - minX) * (maxY - minY));
	}
	
	public static void Main()
	{
		new AtCoder().Solve();
	}
	
	public string Read()
	{
		return Console.ReadLine();
	}
	
	public string[] Reads()
	{
		return Console.ReadLine().Split();
	}
	
	public int ReadInt()
	{
		return Int32.Parse(Read());
	}
	
	public int[] ReadsInt()
	{
		return Reads().Select(s => Int32.Parse(s)).ToArray();
	}
}

Measured memory_bytes: 2904
#include<stdio.h>
#include<math.h>

int isPrime(int x){
  int i;

  if(x == 2) return 1;

  if((x < 2) || (x % 2 == 0)) return 0;

  i = 3;
  while(i <= sqrt((double)x)){
    if(x % i == 0) return 0;
    i = i + 2;
  }
  
  return 1;
}

int main(){
  int cnt = 0, i, m, n;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&m);
    if(isPrime(m) == 1) cnt++;
  }

  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
struct dsu_t {
  vector<int> fa;
  dsu_t(int n) {
    fa.resize(n);
    for (int i = 0; i < n; i++) {
      fa[i] = i;
    }
  }
  int get_fa(int u) {
    if (u != fa[u]) {
      fa[u] = get_fa(fa[u]);
    }
    return fa[u];
  }
  void unite(int u, int v) {
    u = get_fa(u);
    v = get_fa(v);
    if (u != v) {
      fa[u] = v;
    }
  }
  bool in_same(int u, int v) {
    return get_fa(u) == get_fa(v);
  }
};
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n, m, q, p;
  cin >> n >> m >> q >> p;
  int g = p;
  vector<int> U(m), V(m), W(m);
  for (int i = 0; i < m; i++) {
    cin >> U[i] >> V[i] >> W[i];
    U[i]--;
    V[i]--;
    g = __gcd(g, abs(W[i] - W[0]));
  }
  p = __gcd(p, g * 3);
  int z = W[0] % g;
  vector<vector<bool> > visit(p, vector<bool>(2));
  for (int i = 0, j = z; !visit[j][i]; i ^= 1, j = j * 2 % p) {
    visit[j][i] = true;
  }
  dsu_t dsu(n * 6);
  auto get = [&] (int u, int a, int b) {
    return u * 6 + a * 2 + b;
  };
  for (int i = 0; i < m; i++) {
    int w = (W[i] - z) / g % 3;
    for (int u : {U[i], V[i]}) {
      int v = U[i] + V[i] - u;
      for (int a = 0; a < 3; a++) {
        for (int b = 0; b < 2; b++) {
          dsu.unite(get(u, a, b), get(v, (a * 2 + w) % 3, b ^ 1));
        }
      }
    }
  }
  while (q--) {
    int S, T, R;
    cin >> S >> T >> R;
    S--;
    T--;
    bool ans = false;
    for (int a = 0; a < 3; a++) {
      for (int b = 0; b < 2; b++) {
        if (dsu.in_same(get(S, a, b), get(T, 0, 0))) {
          if (visit[(R + z + (3 - a) * g) % p][b]) {
            ans = true;
          }
        }
      }
    }
    if (ans) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}


Measured memory_bytes: 71680
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<algorithm>
#include<stack>
#include<unordered_map>
#include<cstdlib>
#include<unordered_map>
#include<algorithm>
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
		
#define ii pair	<long long ,long long >
#define i64ii pair< long long, pair<int,int> >
#define i64i pair<long long , int >
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >	
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
 
typedef long long ll;	
typedef vector< int> vi;
typedef long double ld;
 
const int MAX = 800;
const int maxn = 2e5+100;

char a[maxn], b[maxn];
int n, k , r, p, s;

char win ( char x ){
	if ( x == 'r')return 'p';
	if ( x == 's')return 'r';
	return 's';
}

int val (char x ){
	if ( x == 'r') return r;
	if ( x == 'p') return p;
	if ( x == 's') return s;
	
	return 0;
}

int main (){
	//~ in
	
	scanf("%d %d %d %d %d", &n, &k, &r, &s , &p);
	scanf("%s", a );
	
	int n = strlen(a);
	ll ans = 0;
	for(int i = 0 ;i < n;i++){
		if (i < k){
			b[i] = win ( a[i]);
		}else {
			if ( b[i-k] == win(a[i])){
				b[i] = 'x';
			}else{
				b[i] = win (a[i] );
			}
		}
		ans += val ( b[i] );
	}
	
	printf("%lld\n", ans );
	
	return 0;
}


Measured memory_bytes: 384
// #include <iostream>
// #include <string>
// #include <math.h>
// #include <map>
// #include <vector>
// #include <tuple>
// #include <algorithm>
// #include <queue>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;
int main(){
  int N;
  cin >> N;
  lli a[N];
  auto c = [](plli ai,plli bi){return ai.second > bi.second;}; // reverse: ai.second < bi.second
  priority_queue<lli, vector<plli>, decltype(c)> pqp(c);
  F(i, N){
    cin >> a[i];
    pqp.push(make_pair(i+1,a[i]));
  }
  while (!pqp.empty()) {
    cout << pqp.top().first << " ";
    pqp.pop();
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int ara[200009];
int temp[200009];
int main()
{
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>ara[i];
    }
    int mx=0;
    for(int i=0;i<n;i++)
    {
        if(mx<ara[i])
        {
            mx=ara[i];
        }
    }
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(ara[i]==mx)
        {
            cnt++;
        }
    }
    if(cnt>1)
    {
        for(int i=0;i<n;i++)cout<<mx<<endl;
    }
    else
    {
        int dd=0;
        for(int i=0;i<n;i++)
        {
            if(dd<ara[i]&&ara[i]!=mx)
            {
                dd=ara[i];
            }
        }
        for(int i=0;i<n;i++)
        {
            if(ara[i]==mx)cout<<dd<<endl;
            else cout<<mx<<endl;
        }
    }
}


Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s;
    long long k;
    cin >> s >> k;
    -- k;

    int n = s.size();
    int i = 0;
    while(i < n && s[i] == '1')
        ++ i;

    if(k < i)
        cout << s[k] << endl;
    else
        cout << s[i] << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

ll n, k, a,b;
ll dat[100005];
int main(){
	cin >> n >> k;
	FORI(0,n){
		cin >> a >> b;
		dat[a] += b;
	}
	for(ll i=1;i<=100000;i++){
		if (k <= dat[i]) {
			cout << i << endl;
			return 0;
		}
		k -= dat[i];
	}
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main(){
  int N, b, a; int move = 0;int max = 0; 
  scanf("%d %d",&N, &b); 
	for (int i = 1; i < N; i++){
		scanf("%d",&a); 
    if(b >= a) move++;
    else{
      if(move > max) max = move;
      move = 0;
    }
    b = a;
	}
  if(move > max) max = move; // N番目の要素の後にも処理が必要
  printf("%d", max);
}


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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    string s; cin >> s; int cnt = 0;

    for(char c : s) if(c == 'p') cnt++;

    cout << (int)s.length() / 2 - cnt;
}

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

#define all(n) n.begin(),n.end()
#define ll long long

#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll maxn=3e6+120;
const ll maxx=1e16;
const ll mod1=1e9+7;
const ll mod=998244353;
vector<ll> adj[maxn];
ll h1[maxn] ;
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("TEAMS.INP","r"))
    {
        freopen("TEAMS.INP", "r", stdin);
        freopen("TEAMS.OUT", "w", stdout);
    }
  ll n, k;
  cin>> n>>k ;
  for (int i=1;i<=n;i++)
  {
      cin>>a[i];
  }
  sort(a+1,a+n+1);
  ll ans=0;
  for (int i=1;i<=min(n,k);i++)
  {
      ans+=a[i];
  }
  cout <<ans;



}


Measured memory_bytes: 73948
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int n, k;
	cin >> n >> k;
	vi heights(n), costs(n);
	for(auto& e : heights) {
		cin >> e;
	}

	costs[n - 1] = 0;

	for(int i = n - 2; i >= 0; --i) {
		costs[i] = costs[i + 1] + abs(heights[i] - heights[i + 1]);
		for(int j = 2; j <= k && i + j < n; ++j) {
			costs[i] = min(costs[i], costs[i + j] + abs(heights[i] - heights[i + j]));
		}
	}
	cout << costs[0] << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


Measured memory_bytes: 1024
import java.io.*;

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

        while(true){
            String[] str = br.readLine().split(" ");
            int m = Integer.parseInt(str[0]);
            int f = Integer.parseInt(str[1]);
            int r = Integer.parseInt(str[2]);

            int sum = m+f;

            if(m==-1 && f==-1 && r ==-1)break;
            if(sum<30 || m==-1 || f==-1){
                System.out.println("F");
            }else if(sum>=80){
                System.out.println("A");
            }else if(sum>=65 && sum<80){
                System.out.println("B");
            }else if(sum>=50 && sum<65 || r>=50){
                System.out.println("C");
            }else if(sum>=30 && sum<50){
                System.out.println("D");
            }
        }
    }
}

Measured memory_bytes: 24292
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;


int main()
{
    string s;
    char a[26] = {0};
    cin >> s;
    rep(i, s.size())
    {
        a[s[i] - 'a']++;
    }
    int res = -1;
    rep(i, 26)
    {
        if(a[i] == 0)
        {
            res = i;
            break;
        }
    }
    if (res == -1) printf("None\n");
    else printf("%c\n", res + 'a');
}

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

int main() {
  int N;
  string S;
  cin>>N;
  //if(A%3==0||B%3==0||(A+B)%3==0) S="Possible";
  //else S="Impossible";
  
  cout<<"ABC"<<N<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Feb  8 15:39:57 2017

@author: kes31
"""

#dicstra
import numpy as np

N = int(input())

orig = np.arange(1,N+1)
data = np.arange(1,N+1)
cont = np.zeros_like(data)
for m in range(2,N+1):
    while(True):
        ct = 0
        mask = (data%m)==0
        data[mask]=data[mask]//m
        ct = np.sum(mask)
        cont[m-1]+=ct
        if ct == 0:
            break
#print (data)
alcount = 1
for c in cont:
    alcount = alcount*int(c+1)
alcount = np.mod(alcount,1000000007)
print (alcount)
    


Measured memory_bytes: 12500
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

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

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
  ll n, k;
  cin >> n >> k;
  if(k==0){
      cout << n * n << endl;
      return 0;
  }
  ll ans = 0;
  lrep(i, 1, n+1){
    if(i-1>=k){
      ans += (n/i)*(i-k);
      ans += max(0ll, (n%i)-k+1);
    }
  }
  cout << ans << endl;
}

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

string U = "UNRESTORABLE";

int main() {
    string s, t;
    cin >> s >> t;
    string ans = "X";
    rep(i, s.size()) {
        if ((s[i] == t[0] or s[i] == '?') and s.size() - i >= t.size()) {
            bool flag = true;
            for (int j=i; j<i+t.size(); ++j) {
                if (s[j] != '?' and s[j] != t[j-i]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                string tmp = "";
                rep(j, s.size()) {
                    if (i == j) {
                        tmp += t;
                        j += t.size() - 1;
                    }
                    else if (s[j] == '?') {
                        tmp += 'a';
                    }
                    else {
                        tmp += s[j];
                    }
                }
                if (ans == "X") {
                    ans = tmp;
                }
                else {
                    ans = min(ans, tmp);
                }
            }
        }
    }

    cout << (ans == "X" ? U : ans) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<math.h>
using namespace std;

int main(){
    
    int W, H, N;
    cin >> W >> H >> N;
    vector<int> x(N+1, 0), y(N+1, 0), a(N+1, 0);
    for(int i=1; i<=N; i++){
        cin >> x.at(i) >> y.at(i) >> a.at(i);
    }
    int xI=0, xF=W, yI=0, yF=H;
    for(int i=1; i<=N; i++){
        if(a.at(i)==1){
            xI=max(xI, x.at(i));
        }
        if(a.at(i)==2){
            xF=min(xF, x.at(i));
        }
        if(a.at(i)==3){
            yI=max(yI, y.at(i));
        }
        if(a.at(i)==4){
            yF=min(yF, y.at(i));
        }
    }
    if(xI>=xF || yI>=yF){
        cout << 0 << endl;
    }else{
        cout << (xF-xI)*(yF-yI) << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
using namespace std;

long long memo[10001][101],w[101],v[101],n;

/*long long solve(int a,int b){
    if(b==n)return 0;
    if(memo[a][b]!=0)return memo[a][b];
    if(a-w[b]<0){memo[a][b]=solve(a,b+1);return memo[a][b];}
    else{
        memo[a][b]=max(solve(a-w[b],b+1)+v[b],solve(a,b+1));
        return memo[a][b];
    }
}*/

int main(void){
    int W;
    cin>>n>>W;
    for(int i=0;i<n;i++){
        cin>>v[i]>>w[i];
    }
    long long dp[101][10001];
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            if(i==0||j==0)dp[i][j]=0;
            if(j-w[i]<0){
                dp[i+1][j]=dp[i][j];
                continue;
            }
            dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
            
        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}

Measured memory_bytes: 10996
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main(){
	int h,x;
	vector<int> a;
	cin>>h;
	a.pb(0);
	for (int i=1; i<=h; i++){
		cin>>x;
		a.pb(x);
	}
	for (int i=1; i<=h; i++){
		cout<<"node "<<i<<": key = "<<a[i]<<",";
		if (i/2!=0)
		   cout<<" parent key = "<<a[i/2]<<",";
		if (2*i>0 && 2*i<=h)
		   cout<<" left key = "<<a[2*i]<<",";
		if ((2*i+1)>0 && (2*i+1)<=h)
		   cout<<" right key = "<<a[2*i+1]<<",";
		cout<<' '<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3152
/*
 * FileName:     count
 * CreatedDate:  2020-05-24 15:37:38 +0900
 * LastModified: 2020-05-24 15:43:45 +0900
 */

#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n;
    scanf("%d",&n);
    long int *a = malloc(n*sizeof(long int));
    for(int i=0;i<n;i++){
        scanf("%ld",a+i);
    }
    int q;
    int count;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        int b,e,k;
        count=0;
        scanf("%d %d %d",&b,&e,&k);
        for(int j=b;j<e;j++){
            if(a[j]==k){
                count++;
            }
        }
        printf("%d\n",count);
    }
    free(a);
    return 0;
}



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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
const ll INF = LLONG_MAX / 2;

signed main() {
    int x;
    cin >> x;
    cout << (x == 3 || x == 5 || x == 7 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string a[8];
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(h, w);
    rep(i, h)cin >> a[i];
    int cnt = 0;
    rep(i, h)rep(j, w)if(a[i][j] == '#')++cnt;
    if(cnt == (h + w - 1))puts("Possible");
    else puts("Impossible");


/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

ll bit[200010];
//ll kai[3010];
ll Cnt[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	//i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	//i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

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

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			Cnt[j] = max(Cnt[j], cnt);
		}
	}
	if (X != 1) Cnt[X] = max(Cnt[X], 1LL);
}

ll N;
string S, T;

void solve() {
	cin >> N >> S >> T;
	rep(i, N) {
		cout << S[i] << T[i];
	}
	cout << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

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

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e6 + 5;
int n = 0, m = 0;
int a[MAXN];
int b[MAXN];


int main() {
	string s;
	cin >> s;
	int size = s.length();
	if(s[size-1] == '2' or s[size-1] == '4' or s[size-1] == '5' or s[size-1] == '7' or s[size-1] == '9'){
		cout << "hon" << endl;
	}
	else if(s[size-1] == '0' or s[size-1] == '1' or s[size-1] == '6' or s[size-1] == '8'){
		cout << "pon" << endl;
	}
	else{
		cout << "bon" << endl;
	}

    return 0;
} 

Measured memory_bytes: 2968
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let n: i64 = read();
    let k: i64 = read();

    let mut cnt = 0;
    let mut v = 1;

    while v <= n {
        v = v * k;
        cnt += 1;
    }

    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<iostream>
#include <malloc.h>
#include <vector>
using namespace std;

void search(int i,int j,int **c,int h,int w){
  c[i][j] = 0;
  if(j<w-1 && c[i][j+1]==1) search(i,j+1,c,h,w);
  if(i<h-1 && c[i+1][j]==1) search(i+1,j,c,h,w);

  if(j>0 && i<h-1 && c[i+1][j-1]==1) search(i+1,j-1,c,h,w);
  if(j<w-1 && i>0 && c[i-1][j+1]==1) search(i-1,j+1,c,h,w);
  if(j>0 && i>0 && c[i-1][j-1]==1) search(i-1,j-1,c,h,w);
  if(j<w-1 && i<h-1 && c[i+1][j+1]==1) search(i+1,j+1,c,h,w);
  if(i>0 && c[i-1][j]==1) search(i-1,j,c,h,w);
  if(j>0 && c[i][j-1]==1) search(i,j-1,c,h,w);
}

int main(){
  vector<int> vec;
  while(1){
    int w,h;
    cin >> w >> h;
    if(w==0 && h==0) break;
    int **c = (int**)malloc(sizeof(int*)*h);
    for(int i=0;i<h;i++){
        c[i] = (int*)malloc(sizeof(int*)*w);
        for(int j=0;j<w;j++) cin >> c[i][j];
    }
    int count = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(c[i][j]==1){
          count += 1;
          search(i,j,c,h,w);
        }
      }
    }
    //cout << count << endl;
    vec.push_back(count);
    for(int i=0;i<h;i++){
        free(c[i]);
    }
    free(c);
  }
  int n = vec.size();
  for(int i=0;i<n;i++) cout << vec[i] << endl;
  return 0;
}





Measured memory_bytes: 3392
// Problem : B - An Odd Problem
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub uppper_bound
using namespace std;
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin >> x;
		if(i%2 and x%2)
		cnt++;
	}	
	cout << cnt;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <array>
#include <vector>
#include <ios>
#include <iomanip>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    struct data {
        int pref;
        int year;
        int num;
    };
    vector<data> dataList;
    for (int i = 0; i < m; i++) {
        data d;
        cin >> d.pref >> d.year;
        d.num = i;
        dataList.push_back(d);
    }
    
    sort(dataList.begin(), dataList.end(), [](const data &a, const data &b) {
        return a.year < b.year;
    });
    
    vector<data> outList;
    vector<int> pn;
    pn.resize(n);
    for (auto&& it: dataList) {
        data d;
        d.year = pn[it.pref-1];
        d.pref = it.pref;
        d.num = it.num;
        outList.push_back(d);
        pn[it.pref-1]++;
    }
    
    sort(outList.begin(), outList.end(), [](const data &a, const data &b) {
        return a.num < b.num;
    });
    
    for (auto&& it : outList) {
        cout << setfill('0') << right << setw(6) << it.pref << setfill('0') << right << setw(6) << it.year+1 << endl;
    }

    return 0;
}

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

int main(){
        int n;cin>>n;
        int x[n];
        int p=0;

        for(int i=0;i<n;i++)cin >> x[i];
        sort(x,x+n);
        int sum;

        while(true){
                sum=0;
                for(int i=0;i<n;i++)sum+=2*(p-x[i])+1;
                if(sum<0)p++;
                else break;
        }
        sum=0;
        for(int i=0;i<n;i++)sum+=(p-x[i])*(p-x[i]);
        cout << sum;
}

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

using namespace std;
typedef long long lint;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int g = 0, maxi = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        g = __gcd(g, A[i]);
        maxi = max(maxi, A[i]);
    }
    if (K <= maxi && K % g == 0) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec_start(n), vec_end(n);
  
  for(int i= 0; i< n; i++){
    cin >> vec_start.at(i) >> vec_end.at(i);
  }
  
  int sum= 0;
  for(int i= 0; i< n; i++){
    sum += vec_end.at(i) - vec_start.at(i) + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

void solve() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	int ans = 1e9;
	for (int i = 0; i < n - m + 1; i++) {
		int cur = 0;
		for (int j = 0; j < m; j++) {
			if (s[i + j] != t[j])
				cur++;
		}
		ans = min(ans, cur);
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}

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

int main() {
    int n,k,x,y;
    cin>>n>>k>>x>>y;

    if(n<=k){
        cout<<n*x<<endl;
    }
    else {
        cout<<k*x+(n-k)*y<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111



	void solve(){


		ini(n);
		ini(n1);
		vi morty(n);
		FOR(i,0,n)in(morty[i]);
		FOR(i,1,n){
			morty[i]+=morty[i-1];
		}
		map<int,int> map1;
		map1[0]++;
		int tmp = 0;
		FOR(i,0,n){
			tmp+=map1[morty[i]%n1];
			map1[morty[i]%n1]++;
		}
		out(tmp);









	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int g[2002][2002];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,x,y;
    cin >> n >> x >> y;
    rep(i,n+1)rep(j,n+1)g[i][j] = 1e9+7;

    g[x][y] = 1;
    g[y][x] = 1;

    for(int i=1;i<=n;i++){
        g[i][i] = 0;
        g[i][i+1] = 1;
        g[i+1][i] = 1;
    }
    vector<int> ans(n+1);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            // 点(i,j)について考える
            // 何事もなければ距離は j-iだが、その間に辺があると距離はj-i-1になる
            int dis = j-i;
            chmin(dis,abs(i-x) + abs(j-y) + 1);
            ans[dis]++;
        }
    }
    for(int k=1;k<=n-1;k++){
        cout << ans[k] << endl;
    }
}

Measured memory_bytes: 15872
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

int a[8];
int b[8];
int main() {
	cin >> N;
	string s;
	cin >> s;
	int wrong_cnt = 0;
	rep(i, N-1){
		if(s[i+1] == 'E') wrong_cnt++;
	}
	int ans = wrong_cnt;
	rep(i, N-1){
		if(s[i] == 'W') wrong_cnt++;
		if(s[i+1] == 'E') wrong_cnt--;
		ans = min(ans, wrong_cnt); 
	}
	cout << ans;
}



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

int main(void){
    int N;cin >> N;
    bool flag  = false;
    for(int i = 0; i < N;i++){
        int A;cin >> A;
        if(A%2!=0)flag = true;
    }
    if(flag)cout << "first"<<endl;
    else cout << "second" << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            int n = in.nextInt();
            if (n == 0) {
                out.println(0);
            } else {
                StringBuilder ans = new StringBuilder();
                while (n != 0) {
                    int remainder = Math.abs(n % 2);
                    ans.insert(0, remainder);
                    n = (n - remainder) / (-2);
                }
                out.println(ans.toString());
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

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

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

const int N = 202020;

inline char get(void) {
	static char buf[100000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
template<typename T>
inline void read(T &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

int a[N];
int n, l, r;
struct Seg {
	int c[N];
	int mn[N << 2];
	inline int MinPos(int a, int b) {
		return c[a] < c[b] ? a : b;
	}
	inline void Build(int o, int l, int r) {
		if (l == r) return (void)(mn[o] = l);
		int mid = (l + r) >> 1;
		Build(o << 1, l, mid);
		Build(o << 1 | 1, mid + 1, r);
		mn[o] = MinPos(mn[o << 1], mn[o << 1 | 1]);
	}
	inline void Init(int fl) {
		for (int i = 0; i <= n; i++) c[i] = N;
		for (int i = fl; i <= n; i += 2)
			c[i] = a[i];
		Build(1, 1, n);
	}
	inline int MinPos(int o, int l, int r, int L, int R) {
		if (l >= L && r <= R) return mn[o];
		int mid = (l + r) >> 1, res = 0;
		if (L <= mid) res = MinPos(res, MinPos(o << 1, l, mid, L, R));
		if (R > mid) res = MinPos(res, MinPos(o << 1 | 1, mid + 1, r, L, R));
		return res;
	}
};
Seg S[2];
struct cpp {
	int l, r, s, t, fl;
	cpp(void) {}
	cpp(int _l, int _r, int f) {
		l = _l; r = _r; fl = f;
		s = S[fl].MinPos(1, 1, n, l, r);
		t = S[fl ^ 1].MinPos(1, 1, n, s, r);
	}
	inline bool operator <(const cpp &x) const{
		return a[s] > a[x.s];
	}
};
cpp x;
priority_queue<cpp> Q;

int main(void) {
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	S[1].Init(1); S[0].Init(2);
	Q.push(cpp(1, n, 1));
	while (!Q.empty()) {
		x = Q.top(); Q.pop();
		printf("%d %d ", a[x.s], a[x.t]);
		if (x.l < x.s) Q.push(cpp(x.l, x.s - 1, x.fl));
		if (x.t < x.r) Q.push(cpp(x.t + 1, x.r, x.fl));
		if (x.s + 1 < x.t) Q.push(cpp(x.s + 1, x.t - 1, x.fl ^ 1));
	}
	return 0;
}

Measured memory_bytes: 11252
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define make make_pair
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
        ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll total=b-a+1;
	ll onlyc=b/c -(a-1)/c;
	ll onlyd=b/d -(a-1)/d;
	ll lcm=__gcd(c,d);
	lcm=(c*d)/lcm;
	ll both=b/(lcm) -(a-1)/(lcm);
	cout<<total-(onlyc+onlyd-both)<<endl;
}
	

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
long long n,xx,yy;
long long x,y;
long long ans;
int main()
{
	scanf("%lld%lld%lld",&n,&xx,&yy);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&y);
		if(x>=xx&&y>=yy)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 998244353
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    dat = [LI() for _ in range(N)]
    dat.sort()
    yo = [y for _,y in dat]
    yo.sort()

    up = [0] * N
    dw = [0] * N

    bit = [0] * (N+1)

    def bit_add(i):
        while i <= N:
            bit[i] += 1
            i += i & -i

    def bit_sum(i):
        ret = 0
        while i > 0:
            ret += bit[i]
            i -= i & -i
        return ret

    for i in range(N):
        x,y = dat[i]
        y = bisect.bisect_left(yo,y) + 1
        up[i] = bit_sum(y)
        bit_add(y)

    bit = [0] * (N+1)
    for i in range(N-1,-1,-1):
        x,y = dat[i]
        y = bisect.bisect_left(yo,y) + 1
        dw[i] = bit_sum(y)
        bit_add(y)

    ans = N * pow(2,N-1,MOD)
    for i in range(N):
        a = i - up[i]
        b = up[i]
        c = N-(i+1) - dw[i]
        d = dw[i]
        pa = pow(2,a,MOD)
        pb = pow(2,b,MOD)
        pc = pow(2,c,MOD)
        pd = pow(2,d,MOD)
        pad = pow(2,a+d,MOD)
        pbc = pow(2,b+c,MOD)
        p = (pad-1) - (pa-1) - (pd-1)
        q = (pbc-1) - (pb-1) - (pc-1)
        x = p * pbc
        y = q * pad
        z = p * q
        ans = (ans + x + y - z) % MOD
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 124040