akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

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

	int ans=0;
	REP(i, b - a) {
		ans += i;
	}
	ans -= a;
	cout << ans;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <map>
#define MOD 1000000007

using namespace std;

int n;
map<int,int> dat;
int main(){
    cin >> n;
    //vector<int> A(n,0);
    int x,ans=1;
    for(int d = 0; d < n; d++){
        cin >> x;
        if(dat[x] == 0) dat[x] = 1;
        else dat[x]++;
    }
    for(auto e : dat){
        if(n % 2 == 0){
            if(e.second != 2){
                cout << 0 << endl;
                return 0;
            }
        }else {
            if(e.second != 2 && e.first != 0){//0でない要素が2以外ならありえない
                cout << 0 << endl;
                return 0;
            }
        }
    }

    if(n % 2==1){
       // cout << (n-1)/2 << endl;
        for(int s = (n-1)/2; s > 0; s--){
            ans = ((ans % MOD) *(2 %MOD)) % MOD;
        }
    }else{
      //  cout << (n)/2 << endl;
        for(int s = (n)/2; s > 0; s--){
            ans = ((ans % MOD) *(2 %MOD)) % MOD;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <deque>
using namespace std;
int main() {
  int n;
  int w_count = 0,r_count = 0, cost = 0;
  string c;
  cin >> n >> c;
  for (int i=0; i<n; i++) if (c[i] == 'R') r_count++;
  cost = r_count;
  for (int i=0; i<n; i++) {
    if (c[i] == 'W') w_count++;
    else r_count--;
    cost = min(max(r_count, w_count), cost);
  }
  cout << cost << endl;
}

Measured memory_bytes: 3464
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	std::ios::sync_with_stdio(false);
	
	ll s,w;

	cin >> s >> w;

	if (w >= s)
	{
		cout << "unsafe" << endl;
	}
	else
	{
		cout << "safe" << endl;
	}

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
using namespace std;

int main()
{
    long long a[1000002], num, cnt;

    cin >> num;
    for (long long i = 0; i < num; i++)
    {
        cin >> cnt;
        a[cnt] = i+1;
    }

    for (long long i = 1; i <= num; i++)
    {
        if (i == num)
        {
            cout << a[i] << endl;
        }
        else
        {
            cout << a[i] << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 3200
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string w;
  cin >> w;
  const int32_t char_number = static_cast<int32_t>('z' - 'a' + 1);
  vector<int32_t> counts(char_number, 0);
  const int32_t length = static_cast<int32_t>(w.length());
  for (int32_t i = 0; i < length; ++i) {
    counts[w.c_str()[i] - 'a']++;
  }
  bool is_beautiful = true;
  for (const int32_t count : counts) {
    if (count % 2 != 0) {
      is_beautiful = false;
      break;
    }
  }
  if (is_beautiful) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
typedef long long int LL;
typedef pair<int,int> P;

int main() {
	string s;
	cin >> s;
	int zero = 0,one = 0;
	for(int i = 0;i < s.size();i++) {
		if(s[i]=='0') zero++;
		else one++;
	}
	cout << min(zero,one)*2 << endl;
	return 0;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<string> s(N + 1);
    cout << "0\n";
    cin >> s[0];
    s[N] = s[0];
    int m = 0, l = 0, r = N;
    while (s[m] != "Vacant") {
        m = (l + r) / 2;
        cout << m << endl;
        cin >> s[m];
        if ((m - l) % 2 ^ s[m] == s[l]) {
            l = m;
        } else {
            r = m;
        }
    }
}

Measured memory_bytes: 1620
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
int n,k;
int a[300000];
vector <int> v;
int ans;

int main(){
  cin >> n >> k;
  REP(i,n){
    int t;
    cin >> t;
    a[t]++;
  }
  FOR(i,n){
    if(a[i]>0){
      int t = a[i];
      v.pb(t);
    }
  }

  sort(v.begin(),v.end());
  //dump(v.size());
  if(v.size()<k){
    cout << 0 << endl;
    return 0;
  }
  for(int i=0;i<v.size()-k;i++) ans += v[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans;
	if (a <= c) {
		if (b <= d) {
			ans = b - c;
		}
		else {
			ans = d - c;
		}
	}
	else {
		if (b >= d) {
			ans = d - a;
		}
		else {
			ans = b - a;
		}
	}
	if(ans>0){
		cout << ans << endl;
	}
	else {
		cout << "0" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int m, f, r;
	cin >> m >> f >> r;
	while (m!=-1||f!=-1||r!=-1)

	{
		if (m == -1)
		{
			cout << "F" << endl;
		}
		else if (f == -1)
		{
			cout << "F" << endl;
		}
	    else if (m + f >= 80)
		{
			cout << "A"<< endl;
		}
		else if (m + f >= 65 && m + f < 80)
		{
			cout << "B" << endl;
		}
		else if (m + f >= 50 && m + f < 65)
		{
			cout << "C" << endl;
		}
		else if (m + f >= 30 && m + f < 50&&r<50)
		{
			cout << "D"<<endl;
		}
		else if (m + f >= 30 && m + f < 50 && r >= 50)
		{
			cout << "C" << endl;
		}
		else if (m == -1 || f == -1)
		{
			cout << "F" << endl;
		}
		else if (m + f < 30)
		{
			cout << "F" << endl;
		}
		cin >> m >> f >> r;
	}
	return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
typedef long long ll;
typedef unsigned long long ull;
class solution{
public:
	void solve(){
		int n;
		cin>>n;
		int a;
		cin>>a;
		if(n%a == 0){
			cout<<n/a;
		}
		else{
			cout<<n/a+1;
			
		}
	}

};

int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}



Measured memory_bytes: 256
import sys
# sys.stdin = open('input.txt')

n, k = map(int, input().split())
a = list(map(int, input().split()))

s = []  #　頂点を訪れた順番に持つ数列
ord = [-1 for i in range(n+1)]  # 訪問済みの頂点の index. 未訪問のときは -1
c = 1  # 周期
l = 0  # 例外部分の長さ

v = 1  # 現在の頂点
while ord[v] == -1:
    ord[v] = len(s)
    s.append(v)
    v = a[v-1]

l = ord[v]
c = len(s) - l

if k < l:
    print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])

Measured memory_bytes: 32380
#include<stdio.h>
int main()
{
    long long a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    long long d;
    d=a+b+c;
    if(d>=22)
    {
        printf("bust\n");
    }
    else
        printf("win\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll inf  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}
/*
const int MAX=510000;
ll fact[MAX], fact_inv[MAX];

//繰り返し二乗法
ll power(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

ll comb(ll n, ll r){
    return (fact[n] * fact_inv[r]) % MOD * fact_inv[n-r] % MOD;
}*/

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}//mod mでの逆元aを計算

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 510000;
//const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    //cout << fac[n] << "  "<< " " <<  finv[k] << "  " << finv[n - k] << endl;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    ll N;
    ll A, B ,C, res = 0;
    cin >> N >> A >> B >> C ;
    COMinit();
    /*fact[0] = 1;
    //階乗計算(O(n))

    REP(i, 2*N) fact[i+1] = fact[i] * (i+1)%MOD;
    fact_inv[2*N] = power(fact[2*N], MOD - 2);
    FORR(i, 0, 2*N) fact_inv[i] = fact_inv[i+1]*(i+1)%MOD;*/
    for(int i = N; i < 2 * N; i++){
        res += COM(i-1,N-1) % MOD * (modpow(A,N,MOD)%MOD * modpow(B,i-N,MOD) % MOD + modpow(A,i-N,MOD)%MOD * modpow(B, N, MOD)%MOD)%MOD * modinv(modpow(A+B,i,MOD),MOD)%MOD* 100 * i %MOD * modinv(100-C, MOD)%MOD;
        res %= MOD; 
        //cout << res << endl;
    }
   // cout << comb(2 * N - 2,N-1) << endl;
    /*for(int i = N; i < 2 * N; i++){
        res += i * 100 * modinv(100-C, MOD) % MOD * COM(i-1,N-1) % MOD * modpow(B,N,MOD) * modpow(A,i-N,MOD) % MOD * modinv(modpow(100,i,MOD),MOD) % MOD; 
    }*/
    res %= MOD;
 //   cout << res <<endl;
    cout << res << endl;
}

Measured memory_bytes: 12288
N = int(input())
nums = list(map(int,input().split()))

count = 0
current_max = nums[0]
for i in range(len(nums)-1):
    nv = nums[i+1]
    if nv > current_max:
        current_max = nv
    else:
        count += (current_max - nv)

print(count)

Measured memory_bytes: 32328
n,k = map(int,input().split())
cnt = 0
count = 0
if k % 2 == 1:
    for i in range(1,n+1):
        if i % k == 0:
            cnt += 1
    print(cnt**3)
else:
    for i in range(1,n+1):
        if i % k == 0:
            cnt += 1
        if i % k == (k//2):
            count += 1
    print((count**3) + (cnt**3) )

Measured memory_bytes: 3064
#include<stdio.h>
#define min(a,b) (a)<(b)?(a):(b)
int main(void)
{
  int n,h[110]={},min,ans=0,i=0,j=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  i=0;
  while(i<n){
    while(h[i]){
      j=i;
      min=h[j];
      while(h[j]){
        min=min(min,h[j]);
        j++;
      }
      j=i;
      while(h[j]){
        h[j]-=min;
        j++;
      }
      ans+=min;
    }
    i++;
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#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 <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9

int main() {
	string s;
	cin >> s;
	string f = s.substr(0,2);
	string b = s.substr(2);
	if ("00" < f && f <= "12") {
		if("00" <b && b <= "12") cout << "AMBIGUOUS" << endl;
		else cout << "MMYY" << endl;
	}
	else {
		if ("00" < b && b <= "12") cout << "YYMM" << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]
for i in range(1,N+1):
  k = 0
  for j in range(M):
    if (L[j][0] == i):
      k += 1
    elif (L[j][1] == i):
      k += 1
    else:
      k += 0
  print(k)        

Measured memory_bytes: 3064
import std.stdio;
import std.array;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.bigint;

alias Tuple!(int, int, int) Couple;

void main()
{
	int[] results;
	while (true) {
		auto strs = readln.split;
		int n = to!int(strs[0]);
		int m = to!int(strs[1]);
		int a = to!int(strs[2]);
		if (n == m && m == a && a == 0) break;
		Couple[] t;
		foreach (i; 0..m) {
			strs = readln.split;
			int h = to!int(strs[0]);
			int p = to!int(strs[1]);
			int q = to!int(strs[2]);
			t ~= tuple(h, p, q);
		}
		sort!((Couple c1, Couple c2){return c1[0] > c2[0];})(t);
		int y = t[0][0]+1;
		foreach (i; 0..m) {
			int h = t[i][0];
			if (h > y) continue;
			y = h;
			if (a == t[i][1]) a = t[i][2];
			else if (a == t[i][2]) a = t[i][1];
		}
		results ~= a;
	}
	foreach (r; results)
		r.writeln;
}

Measured memory_bytes: 3444
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
//#include <math.h>
#include <cmath>
//#include <bits/stdc++.h>
//#define M_PI=3.1415926535;
using namespace std;

int main(){
    int A,B,H,M;
    double a,b,d,D,p,q;
    cin >> A >> B >> H >> M;
    p=3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628;
    a=H*p/6+M*p/360;
    b=M*p/30;
    q=abs(a-b);
    D=A*A+B*B-2*A*B*cos(q);
    d=sqrt(D);
    cout << fixed << setprecision(20) << d << endl;
    return 0;
}

Measured memory_bytes: 4124
n, a, b = map(int, input().split())
s = input()
ca, cb = 0, 0
for i in s:
    if i == 'c':
        print('No')
    elif i == 'a' and (ca+cb) < (a+b):
        ca += 1
        print('Yes')
    elif (i == 'b' and (ca+cb) < (a+b) and cb < b):
        cb += 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9140
N = gets.to_i
alist = gets.split(" ").map{|item| item.to_i}.sort.unshift(0)
blist = gets.split(" ").map{|item| item.to_i}.sort
clist = gets.split(" ").map{|item| item.to_i}.sort{|a,b| b<=>a}.unshift(-1)
#p alist
#p blist
#p clist
sum = 0
a = 0
c = clist.length - 1
N.times do |i|
  b = blist[i]
  #p b < alist[a]
  while b > alist[a] and a+1 != alist.length
    #p "#{a+1} #{alist[a+1]}"
    a += 1
    if b <= alist[a]
      a -= 1
      break
    elsif a+1 >= alist.length
      break
    end
  end
  while b >= clist[c]
    break if clist[c] == -1
    c -= 1
    break if c <= 0
  end
  sum += a * c
  ##p "#{a} #{b} #{c}"
  #p "#{a} * #{c} = #{a * c}"
end
puts sum

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

int main() {
    int total = 0;
    int maxAdd = 0;
    for (int i = 0; i < 5; i++)
    {
        int time = 0;
        cin >> time;

        int rem = time % 10;

        if (rem == 0)
        {
            total += time;
        }
        else
        {
            int add = 10 - rem;
            total += time + add;
            maxAdd = max(maxAdd,add);
        }        
    }

    cout << (total - maxAdd) << endl;
}

Measured memory_bytes: 256
N = gets.to_i 
A = gets.split.map(&:to_i)

def calc(sign)
  tot = 0 
  cost = 0
  (0...A.size).each do |i|
    tot += A[i]
    if tot * sign < 0 
      cost += 1 - tot * sign 
      tot = sign
    elsif tot == 0 
      cost += 1 
      tot = sign 
    end
    sign *= -1
  end
  cost
end

puts [calc(1), calc(-1)].min

Measured memory_bytes: 8580
def resolve():
    N, Q = list(map(int, input().split()))
    adjs = [set() for _ in range(N)]
    for _ in range(N-1):
        src, dst = list(map(int, input().split()))
        adjs[src-1].add(dst-1)
        adjs[dst-1].add(src-1)
    costs = [0 for _ in range(N)]
    for i in range(Q):
        idx, cost = list(map(int, input().split()))
        idx = idx - 1
        costs[idx] += cost
    
    q = [0]
    visited = set()
    while q:
        node = q.pop()
        for nxt in adjs[node]:
            if nxt in visited:
                continue
            costs[nxt] += costs[node]
            q.append(nxt)
        visited.add(node)
    print(*costs)


if '__main__' == __name__:
    resolve()


Measured memory_bytes: 193336
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=9000000009;

signed main(){
  string s;
  int f=0;
  while(getline(cin,s)){
    string t;
    REP(i,s.size()){
      if(s[i]==','||s[i]==' '||s[i]=='.'){
        if(2<t.size()&&t.size()<7){
          if(f)cout<<' ';
          cout<<t;
          f=1;
        }
        t="";
      }else{
        t+=s[i];
      }
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;


int main(){
	int n,m,a;
	while(cin>>n>>m>>a&&n&&m&&a){
		vector<int> vt[1001];
		int h,p,q;
		REP(i,0,m){
			cin>>h>>p>>q;
			vt[h].push_back(p);
		}
		for(int i=1000;i>0;i--){
			for(unsigned int j=0;j<vt[i].size();j++){
				if(vt[i][j]==a){
					a++;
					break;
				}else if(vt[i][j]==a-1){
					a--;
					break;
				}
			}
		}

		p(a);
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main(void){
    std::string S,T;
    std::cin >> S >> T;
    long count=0;
    for(long i=0; i<S.length(); i++){
        if(S[i]!=T[i]){
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 3916
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  if(a+5*b+10*c+50*d+100*e+500*f>=1000){
    cout<<1<<endl;
  }
  else{
    cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define N 200010
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;  

int main(){
  int n,m;
  cin>>n>>m;
  P A[N];
  for(int i=0,x,y;i<m;i++)cin>>x>>y,A[i]=P(x,y-1);
  sort(A,A+m);

  int u[N],d[N];
  for(int i=0;i<n;i++) u[i]=d[i]=i;

  for(int i=0;i<m;i++){
    int y=A[i].s;
    u[y]=max(u[y],u[y+1]);
    d[y+1]=min(d[y+1],d[y]);
  }

  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<(u[i]-i)+(i-d[i])+1;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 6196
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    n = int(input())
    s = input()
    cnt = 0
    ans = 0
    for e in s:
        if e == 'I':
            cnt += 1
        else:
            cnt -= 1
        ans = max(ans, cnt)
    print(ans)
        
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()



"""

1 4
7
RRRR
1 1 0 1
----
4

1 4
47
RCRR
1 1 0 1
----
-1

2 2
10
RR
RR
1 7
4 1
----
4

2 2
10
RR
RR
7 4
7 4
----
-1

3 3
8
RCR
RRC
RRR
1 1 1
1 1 1
1 3 1


3 3
1
RCR
RRC
RRR
1 1 1
1 1 1
1 3 1


"""





Measured memory_bytes: 3444
n = int(input())
p = [int(i) - 1 for i in input().split()]
count = 0
for i in range(n-1):
    if p[i] == i:
        count += 1
        p[i+1] = p[i]
if p[n-1] == n-1:
    count += 1
print(count)


Measured memory_bytes: 13880
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    a: [usize; n]
    }
    let mut m = 1000000000;
    let mut ans = 1000;
    for i in 0..n {
        if a[i] < m {
            m = a[i];
        } else {
            ans = a[i] * (ans / m) + ans % m;
            m = a[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2200
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}

signed main () {
	int n; cin >> n;
	vel d(n);
	vel inv(n + 1, 0);
	rep(i, n) { cin >> d[i]; inv[d[i]]++; }
	if (d[0] != 0||inv[0]!=1) { cout << 0 << endl; return 0; }
	int ans = 1;
	rep(i, n) {
		int count = inv[i+1];
		int val = inv[i];
		rep(j, count) { ans *= val; ans %= 998244353; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

bool isprime(int n)
{
	if(n == 1) return false;
	if(n == 2) return true;
	else {
		for(int i = 2; i * i < n + 1; i++){
			if(n % i == 0) return false;
		}
	}
	return true;
}

int main()
{
	int m;
	int a, b;
	int prime[2000];
	int cnt = 0;
	for(int i = 1; i < 10001; i++){
		if(isprime(i)){
			// cout << i << " ";
			prime[cnt] = i;
			cnt++;
		}
	}
	while(1){
		cin >> m >> a >> b;
		if(m == 0 && a == 0 && b == 0) break;
		int p, q;
		int ans_p = 0, ans_q = 0;
		for(int i = 0; i < cnt; i++){
			for(int j = i; j < cnt; j++){
				p = prime[i];
				q = prime[j];
				if(p * q > m || b * p < a * q) break;
				else {
					if(ans_p * ans_q < p * q){
						ans_p = p;
						ans_q = q;
					}
				}
			}
		}
		cout << ans_p << " " << ans_q << endl; 
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<long>h(n);
  int i;
  for(i=0;i<n;i++){
    cin >> h[i];
  }
  sort(h.begin(),h.end(),greater<long>());
  long cnt = 0;
  for(i=0;i<n;i++){
    if(k>0){
      k--;
    }else{
      cnt += h[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c;
  cin>>a;
  b=1,c=0;
  vector<long long>vec1(a);
  for(long long i=0;i<a;i++){
    cin>>vec1.at(i);
  }
  sort(vec1.begin(),vec1.end());
  for(long long j=a-1;j>0;j--){
    if(vec1.at(j)==vec1.at(j-1)){
      b*=vec1.at(j);
      c++;
       if(c==2){
      break;
    }
      vec1.at(j-1)=0;
    }
  }

  if(c==2){
    cout<<b<<endl;
  }
    else{
    cout<<0<<endl;
  }
}

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

int main()
{
    ios_base::sync_with_stdio(0);

    string s;
    cin >> s;
    reverse(s.begin(),s.end());

    int n=s.length(),idx=0;

    while(idx<n){
        if(idx+5<=n && s.substr(idx,5)=="maerd")
            idx+=5;
        else if(idx+7<=n && s.substr(idx,7)=="remaerd")
            idx+=7;
        else if(idx+5<=n && s.substr(idx,5)=="esare")
            idx+=5;
        else if(idx+6<=n && s.substr(idx,6)=="resare")
            idx+=6;
        else break;
    }

    if(n==idx) puts("YES");
    else puts("NO");

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<long long>;
using vvi=vector<vector<long long>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int ans=0;
int n,m;
void dfs(int i,vvi v,int c,vi on){
  if(c==2){
    bool b=true;
    rep(j,m){
      if(on[j]%2==1){
        b=false;
        break;
      }
    }
    if(b)ans++;
  }
  if(c==1){
    rep(j,v[i].size()){
      on[v[i][j]]++;
    }
  }
  if(i==n-1)dfs(i+1,v,2,on);
  if(i<n-1){
    dfs(i+1,v,1,on);
    dfs(i+1,v,0,on);
  }
}
int main(){
  cin>>n>>m;
  vvi v(n);
  vi on(11);
  rep(i,m){
    int k;
    cin>>k;
    rep(j,k){
      int a;cin>>a;
      v[a-1].push_back(i);
    }
  }
  rep(i,m){
    cin>>on[i];
  }
  dfs(-1,v,0,on);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
	int n,m,masu[1001],furu[1001],i=0,j=0,k=1,h=0,kai[1001]={0};
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0){
			break;
		}
		h=h+1;
		for(i=1;i<=n;i++){
			scanf("%d",&masu[i]);
		}
		for(j=1;j<=m;j++){
			scanf("%d",&furu[j]);
		}
		i=0,j=0,k=1;
		while(1){
			if(k>=n){
				break;
			}
			j++;
			k=k+furu[j];
			i=k;
			if(masu[i]>=0){
				k=k+abs(masu[i]);
			}
			else if(masu[i]<0){
				k=k-abs(masu[i]);
			}
		}
		kai[h]=j;
	}
	for(i=1;i<=h;i++){
	printf("%d\n",kai[i]);
	}
	return 0;
}



Measured memory_bytes: 2032
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();

        int i = 0;
        while (true) {
            if (i % 2 == 0) {
                C -= B;
                if (C <= 0) {
                    System.out.println("Yes");
                    break;
                }
            } else {
                A -= D;
                if (A <= 0) {
                    System.out.println("No");
                    break;
                }
            }
            i++;
        }
        scan.close();
    }

}

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

typedef long long ll;
typedef long long ld;
typedef vector<int> vi;
typedef priority_queue<int> pq;
typedef pair<ll, ll> pii;

struct Node
{
    int node, len;
    Node() {node = len = 0;}
    Node(int node, int len) {this -> node = node, this -> len = len;}
};
typedef vector<Node> vg;

#define MAX 1000001
#define NON 0
#define MOD 1000000007

#define FOR(type, i, a, b) for(type i = a; i <= b; i++)
#define FORR(type, i, b, a) for(type i = b; i >= a; i--)

#define testBit(n, bit) ((n >> bit) & 1)
#define flipBit(n, bit) (n ^ (1ll << bit))
#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, c, k; cin >> a >> b >> c >> k;
    int sum = 0;
    if (a >= k){cout << k; return 0;}
    sum += a, k -= a;
    if (b >= k){cout << sum; return 0;}
    k -= b;
    sum -= min(k, c);
    cout << sum;
}

Measured memory_bytes: 3644
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpii = vector<pii>;
using vpll = vector<pll>;

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

  vector<string> days(7);
  days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  rep(i, 7){
    if(days[i] == S){
      cout << 7 - i << endl;
    }
  }
  
  return 0;
}

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

int main() {
	int N, T;
	int minC=1001;

	cin >> N >> T;

	vector<int> c(N), t(N);

	for (int i = 0; i < N; i++) {
		cin >> c[i] >> t[i];
		if (t[i] <= T) {
			minC = min(minC, c[i]);
		}
	}

	if (minC == 1001) {
		cout << "TLE";
	}
	else {
		cout << minC;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;

ll dist[300][300];
ll need[300][300];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n,m,l;
  cin >> n >> m >> l;
  
  rep(i,n)rep(j,n){
    dist[i][j]=INF;
    need[i][j]=INF;
  }
 
  while(m--){
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b]=c;
    dist[b][a]=c;
  }
  rep(k,n)rep(i,n)rep(j,n){
    dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
  }
  rep(i,n)rep(j,n){
    if(dist[i][j]<=l)need[i][j]=1;
  }
  rep(k,n)rep(i,n)rep(j,n) {
    need[i][j]=min(need[i][j],need[i][k]+need[k][j]);
  }
  
  int q;
  cin >> q;
  while(q--){
    int s,t;
    cin >> s >> t;
    s--;
    t--;
    if(need[s][t] == INF)cout << -1 << endl;
    else cout << need[s][t]-1 << endl;
  }
  return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s, t;
  std::cin >> s >> t;
  std::cout << t << s << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define ld long double
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 5e5+1;
int a[N];
int n,q;
int blocks = 1000;
int ans[N];
int cnt[N] = {};
int dis = 0;
struct Query
{
    int l,r,idx;
}Q[N];
bool cmp (Query q1 ,Query q2){
    int b1 = q1.l/blocks;
    int b2 = q2.l/blocks;
    if(b1!=b2)
        return b1<b2;
    return (b1%2)?q1.r<q2.r:q1.r>q2.r;
}
void add (int idx){
    cnt[a[idx]]++;
    if(cnt[a[idx]] == 1)
    	dis++;
}
void remove (int idx){
    cnt[a[idx]]--;
    if(cnt[a[idx]] == 0)
    	dis--;
}
signed main(){
    fast;
    cin>>n>>q;
    for(int i = 1;i<=n;i++){
        cin>>a[i];
    }
    //blocks = ceil(sqrt(n));
    for(int i = 1;i<=q;i++){
        int l,r;
        cin>>l>>r;
        Q[i].l = l;
        Q[i].r = r;
        Q[i].idx = i;
    }
    sort(Q+1,Q+q+1,cmp);
    int start = 0,end = 0;
    for(int i = 1;i<=q;i++){
        int l = Q[i].l;
        int r = Q[i].r;
        int idx = Q[i].idx;
        while(start<l){
            if(start!=0)
                remove(start);
            start++;
        }
        while(start>l){
            start--;
            if(start!=0)
                add(start);
        }
        while(end<r){
            end++;
            if(end!=0)
                add(end);
        }
        while(end>r){
            if(end!=0)
                remove(end);
            end--;
        }
        ans[idx] = dis;
    }
    for(int i = 1;i<=q;i++){
        cout<<ans[i]<<"\n";
    }
}

Measured memory_bytes: 27216
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 5100000;
const int MOD = 1000000007;


//エラトステネスの篩
int prime[MAX]; //i番目の素数
bool is_prime[MAX+1]; //素数かどうか

int sieve(int n) {
    int p = 0;
    for (int i = 0; i <= n; i++) {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return p;
}


int main(){
  sieve(1000000);
  ll a;cin>>a;
  while(1){
    if(is_prime[a]){
      cout<<a<<endl;
      return 0;
    }
    a++;
  }
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				        3.14159265358979
#define 	mod 			        1000000007
#define 	ll  			        long long
#define 	rep(i, a, b) 	        for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)           for(ll i = a ; i > b ; i--)
#define 	mod1 			        1000003
#define     mod2                    998244353
#define 	hi   			        "hello"
#define 	nl 				        "\n"
#define 	ws 				        " "
#define 	ff 				        first
#define 	ss 				        second
#define 	pb 				        push_back
#define 	B 				        begin()
#define     RB                      rbegin()
#define 	E 				        end()
#define     UB                      upper_bound
#define     LB                      lower_bound
#define 	all(v) 			        v.begin(), v.end()
#define 	reset(a, val) 	        memset(a, val, sizeof(a))
#define     pll                     pair<ll, ll>
#define     vll                     vector<ll>
#define     vpll                    vector<pll>
#define 	vs 				        vector<string>
#define     vc                      vector<char>
#define     sqr(a)                  ((a)*(a))
#define 	print1(a) 		        for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		        for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		        for(auto i : a)cout<<i<<nl;
#define 	boost 			        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(10);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 10)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve() {
    ll s;
    cin >> s;
    
    if(s <= 2) {
        cout << 0 << nl; return;
    }

    if(s < 6) {
        cout << 1 << nl; return ;
    }

    vll dp(s+1, 0);
    dp[0] = 1;

    rep(i, 3, s+1) {
        for(ll j = 3 ; j <= s ; j++){
            if(i-j < 0)continue;
            dp[i] += dp[i-j];
            dp[i] %= mod;

        }
    }

    cout << dp[s] << nl;
}

int main(){
    boost;
    // cal(3);

    // // For getting input from input.txt file 
    // freopen("alchemy_input.txt", "r", stdin); 
  
    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout);

    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 3648
import fractions
def gcd(x,y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x

    return fractions.gcd(x%y, y)

n = int(input())
a = list(map(int, input().split()))
L = [0]
R = [0]
now1 = 0
now2 = 0
ans = 0

for i in range(n-1):
    now1 = gcd(now1,a[i])
    L.append(now1)

    now2 = gcd(now2,a[-i-1])
    R.append(now2)

for i in range(n):
    ans = max(ans, gcd(L[i], R[n-i-1]))

print(ans)

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

#define reg register

using namespace std;

typedef long long ll;

const int MAXN=12500;

int a,b;
bool ans=0;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0); 
	cin>>a>>b;
	for(int i=0; i<=MAXN; ++i)
		if(static_cast<int>(i*0.08)==a && static_cast<int>(i*0.1)==b) {
			cout<<i<<endl;
			ans=1;
			break;
		}
	if(!ans) puts("-1");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int r,l;
	l=a+b;r=c+d;
	if(l>r) cout<<"Left"<<endl;
	else if(l==r) cout<<"Balanced"<<endl;
	else cout<<"Right"<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n, k ;
    cin >> n >> k ;

    if(k==0){
        cout << n*n <<endl;
        return 0 ;
    }

    ll ans = 0 ;

    FOR(b,k+1,n+1){
        ans += n/b * (b-k) + max((ll)0,n%b-k+1) ;
    }

    cout << ans <<endl;

    






    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 3564
#include<iostream>

using namespace std;

int main(){
    int w,h;
    while(true){
        cin>>h>>w;
        if((h|w) != 0){
            for(int i =0;i<h;i++){
                for(int j =0;j<w;j++){
                    if(i>0 && i<h-1 && j>0 && j<w-1){
                        cout <<".";
                    }else{
                        cout<<"#";
                    }
                }
                cout<<endl;
                
            }
            cout<<endl;
            
        }else{
            break;
        }
   }
   return 0;
}


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

using namespace std;
#define IOS cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;

#define pb push_back
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int mod = 1e9+7;

const int hax = 1005;
char a[hax][hax];
int dp[hax][hax];

void add_self(int & a, int b){
    a += b;
    if(a >= mod)
         a-=mod;
}



int main(){
    IOS

    int h, w; cin>>h>>w;

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin>>a[i][j];
        }
    }

    for(int i = 1; i <= h; i++){
        if(a[i][1] != '#')
            dp[i][1] = 1;
        else break;
    }

    for(int i = 2; i <= w; i++){
        if(a[1][i] != '#')
            dp[1][i] = 1;
        else break;
    }

    for(int i = 2; i <= h; i++){
        for(int j = 2; j <= w; j++){
            if(a[i][j] != '#'){
                if(a[i][j-1] != '#')
                    add_self(dp[i][j], dp[i][j-1]);
                if(a[i-1][j] != '#')
                    add_self(dp[i][j], dp[i-1][j]);
            }else{
                dp[i][j] = 0;
            }
        }
    }

    // for(int i = 1; i <= h; i++){
    //     for(int j =1; j <= w; j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    

    
    cout<<dp[h][w]<<"\n";


    


    
}


Measured memory_bytes: 5248
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int m; CI m;
	vector<int> a(m),b(m); CI a;
	b = a;
	sort(all(a));

	REP(i, m) {
		if (b[i] <= a[m / 2 - 1]) CO a[m / 2] EN;
		else CO a[m / 2 - 1] EN;
	}

	return 0;
}

Measured memory_bytes: 3712
#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>
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)
#define toupper(S) transform(S.begin(),S.end(),S.begin(),toupper)
#define tolower(S) transform(S.begin(),S.end(),S.begin(),tolower)
const lint MOD = pow(10, 9) + 7;


int main() {
	int N, K;
	cin >> N >> K;
	vector<int>A;
	while (1) {
		A.push_back(N % K);
		N /= K;
		if (N == 0)break;
	}
	cout << A.size() << endl;
}

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

void solve(int n, int s, int sum, int x){
	//cout << "t " << n << ' ' << s << ' ' << sum << ' ' << x << endl;
	if(n == 0){
		if(sum == s) ans++;
		return;
	}
	if(sum > s) return;

	for(int i = 0; i < x; i++){
		solve(n - 1, s, sum+i, i);
	}
}

int main(void){
	int n, s;
	while(1){
		cin >> n >> s;
		if(n == 0 && s == 0) break;
		ans = 0;
		solve(n, s, 0, 10);

		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int N;cin >> N;
    vector<vector<int>> dp(N, vector<int>(3,0));
    vector<vector<int>> vec;
    for(int a = 0;a < N;a++){
        int b,c,d;cin >> b >> c >> d;
        vec.push_back({b,c,d});
    }
    dp[0] = vec.at(0);
    for(int a = 1;a < N;a++){
        for(int idx = 0;idx < 3;idx++){
            dp[a][idx] = max(dp[a-1][(idx+1)%3] + vec.at(a).at(idx),dp[a-1][(idx+2)%3] + vec.at(a).at(idx));
        }
    }
    cout<<*max_element(ALL(dp.back()))<<endl;
    return 0;
}


Measured memory_bytes: 12340
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int ax,ay,bx,by,x,y;
	cin>>ax>>ay>>bx>>by;
	x=bx-ax;
	y=by-ay;
	cout<<bx-y<<" "<<by+x<<" "<<ax-y<<" "<<ay+x<<endl;
return 0;
}

Measured memory_bytes: 256