akhauriyash/Code-Regression huggingface dataset:
num = list(str(input()))
n = len(num)
for i in range(1 << 3):
    li = [int(num[0])]
    pri = [num[0]]
    for j in range(n - 1):
        if (i >> j) & 1:
            li.append(int(num[j + 1]))
            pri.append("+"+num[j + 1])
        else:
            li.append(-1 * int(num[j + 1]))
            pri.append("-"+num[j + 1])
    if sum(li) == 7:
        print("{}{}{}{}=7".format(pri[0], pri[1], pri[2], pri[3]))
        quit()


Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)<sum(b):
  print(-1)
  exit()
ans=0
ab=[]
cd=[]
for i in range(n):
  m=a[i]-b[i]
  if m<0:
    ab.append(m)
  else:
    cd.append(m)
res=sum(ab)
cd.sort(reverse=True)
t=0
if len(ab)>0:
  while t<len(cd):
    res+=cd[t]
    t+=1
    if res>0:
      print(len(ab)+t)
      exit()
else:
  print(0)

Measured memory_bytes: 24172
// https://atcoder.jp/contests/abc155/tasks/abc155_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "unordered_map"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  unordered_map<string, ll> ct_map;

  rep(i, N) {
    string s;
    cin >> s;
    ct_map[s]++;
  }

  ll max_ct = 0;
  for (auto e : ct_map) {
    chmax(max_ct, e.se);
  }

  V<string> res(0);

  for (auto e : ct_map) {
    if (e.se == max_ct) res.emplace_back(e.fi);
  }

  sort(all(res));

  for (auto s : res) {
    cout << s << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int N, M;
int a[(int)2e5], b[(int)2e5];

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

    map<int, int> part1, part2;

    rep(i, M) {
        if (b[i] == N) {
            // part2 -> N となる便
            part2[a[i]]++;
        }
        if (a[i] == 1) {
            // 1 -> part2 となる便
            part1[b[i]]++;
        }
    }

    string ans = "IMPOSSIBLE";
    for (auto iter = part2.begin(); iter != part2.end(); iter++) {
        if (part1.count(iter->first)) {
            ans = "POSSIBLE";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	string s;
        cin>>s;
       for(int i=0;i<3;i++)
       {
              if(s[i]=='1')
             cout<<9;
              else
              cout<<1;  
       }
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vi vec;
    REP(i,n){
        int t;
        cin>>t;
        vec.pb(t);
    }
    sort(all(vec));
    int ans=0;
    int now=0;
    while(now<n){
        int j=0;
        while(j+1<m&&now+j<n&&vec[now+j+1]<=vec[now]+k){
            j++;
        }
        now+=j+1;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 892
import bisect

n = int(input())
l = list(map(int, input().split()))

ans = 0

l.sort()

for i in range(n):
    for j in range(i+1, n):
        gap = l[i] + l[j]
        index = bisect.bisect_left(l, gap)

        ans += max(0, index-j-1)

print(ans)

Measured memory_bytes: 3188
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;
long long stint(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve() {
	string s;
	cin >> s;
	map<char, int> m;

	rep(i, s.length()-1) {
		if(s[i] == s[i+1]){
			cout << i+1 << " " << i + 2 << endl;
			return;
		}
	}
	rep(i, s.length()-2) {
		if (s[i] == s[i + 2]) {
			cout << i+1 << " " << i+3 << endl;
			return;
		}
	}
	P("-1 -1");
}

int main() {
	solve();
	return 0;
}


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

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++)  cin >> b.at(i);
  int count = 0;
  for (int j = 0; j < n; j++) {
    int val = 0;
    for (int i = 0; i < m; i++)  {
      int a;
      cin >> a;
      val += b.at(i) * a;
    }
    val += c;
    if (val > 0)  count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
# B
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
 
a = (10 - A) % 10
b = (10 - B) % 10
c = (10 - C) % 10
d = (10 - D) % 10
e = (10 - E) % 10
 
print(A+B+C+D+E+a+b+c+d+e-max([a,b,c,d,e]))

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

int main()
{
	int N;
	cin >> N;
	cout << N * N*N << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int off=100000;
	vector<vector<int>> g(3*off);
	vector<bool> used(3*off,false);
	rep(i,n){
		int x,y;
		cin>>x>>y;
		x--,y--;
		y+=off;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	ll cnt1=0,cnt2=0;
	auto dfs=[&](auto &dfs,int v)->void{
		if(used[v]) return ;
		used[v]=true;
		if(v<off) cnt1++;
		else cnt2++;
		for(auto to:g[v]) dfs(dfs,to);
	};
	ll ans=0;
	rep(i,3*off){
		if(!used[i]){
			cnt1=cnt2=0;
			dfs(dfs,i);
			ans+=cnt1*cnt2;
		}
	}
	cout<<ans-n<<endl;
}

Measured memory_bytes: 11648
let id x = x

let () =
  let solve h w k =
    let calc_score (i,j) =
      List.fold_left min i [h-1-i; j; w-1-j]
    in
    let calc_ans score =
      (score + k - 1) / k + 1
    in
    let delta = [0,1; 1,0; 0,-1; -1,0] in
    let a = Array.init h (fun _ -> Scanf.scanf "%s " id) in
    let rec loop i j =
      if j = w then loop (i+1) 0
      else if a.(i).[j] = 'S' then i,j
      else loop i (j+1)
    in
    let start = loop 0 0 in
    let q = Queue.create () in
    Queue.add (start, 0) q;
    let ans = ref (calc_ans (calc_score start)) in
    let rec bfs () =
      if Queue.is_empty q then !ans
      else
        let (i,j), k' = Queue.pop q in
        let score = calc_score (i,j) in
        ans := min !ans (calc_ans score);
        if score = 0 then !ans else
        if k' = k then bfs () else (
          delta
          |> List.iter (fun (dx, dy) ->
            let x, y = i+dx, j+dy in
            if a.(x).[y] = '.' then (
              a.(x).[y] <- '#';
              Queue.add ((x,y),k'+1) q
            )
          );
          bfs ()
        )
    in
    bfs ()
  in
  Scanf.scanf "%d %d %d " solve
  |> Printf.printf "%d\n"


Measured memory_bytes: 6528
#include<iostream>

using namespace std;
int main(){
  int k;
  int gusu,kisu;
  cin >> k;
  if(k%2==0){
    gusu=k/2;
    kisu=k/2;
  }
  else{
    gusu=(k-1)/2;
    kisu=(k+1)/2;
  }
  cout << gusu*kisu << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2000

int n;
int N[MAX];

int fanc(int, int);

int main(){
  int i,judge;
  int q;
  int Q[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&N[i]);
  }
   scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&Q[i]);
  } 

  for(i=0;i<q;i++){
    judge = fanc(0,Q[i]);

    if(judge == 1){
      printf("yes\n");
    }
    else printf("no\n");
  }

  return 0;
}
int fanc(int i, int m){
  int res;
  
  if(m==0) return 1;
  if(i>=n) return 0;

  res = fanc(i+1, m) || fanc(i+1, m-N[i]);

  return res;
}

Measured memory_bytes: 592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner sc = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    int max = (int)Math.max(A, Math.max(B, C));
	out.println(A + B + C + max * ((1 << K) - 1));
    out.close();
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int n1=(a*c),n2=(a*d);
	int n3=(b*c),n4=(b*d);
	int ans=max(max(n1,n2),max(n3,n4));
	cout<<ans;
    
    
    
    
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll x, ans = 0;
    cin >> x;
    for(ll i = 1; i < 100000; ++i){
        ll sum = i*(i+1)/2;
        if(sum >= x){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int N, M;
	cin >> N >> M;

	ll X[M];
	rep(i, M) cin >> X[i];

	if(N >= M){
		cout << 0 << endl;
		return 0;
	}

	sort(X, X + M);

	vector<ll> v;
	rep(i, M-1){
		v.push_back(X[i+1] - X[i]);
	}

	sort(v.begin(), v.end(), greater<ll>() );

	ll ans = 0;
	for(int i = N-1; i < M-1 ; i++) ans += v[i];

	cout << ans << endl;	
}


Measured memory_bytes: 2168
/*    Mohammed Sami Khan
                       মোহাম্মদ সামী খান
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define endl "\n"
#define mp(a,b) make_pair(a,b)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;

bool sortbysecc(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}

int main()
{
    fastio;
    //freopen("alchemy_input.txt", "r", stdin);
    //freopen("output2.txt", "w", stdout);
    ll tc, t, n, m, p, q, r, i, j, k, x, d, f=0, ac=0, wa=0, tle=0, re=0;
    //cin>>tc;
    tc=1;
    while(tc--){
        cin>>n;
        string verdict;
        while(n--){
            cin>>verdict;
            if(verdict=="AC") ac++;
            if(verdict=="TLE") tle++;
            if(verdict=="WA") wa++;
            if(verdict=="RE") re++;
        }
        cout<<"AC x "<<ac<<endl;
        cout<<"WA x "<<wa<<endl;
        cout<<"TLE x "<<tle<<endl;
        cout<<"RE x "<<re<<endl;

    }
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
long mod=1e9+7,dp[51][51][2505];
int N,K;
main()
{
	cin>>N>>K;
    if (K%2==1) {
      cout << 0 << '\n';
      return 0;
    }
	dp[0][0][0]=1;
	for(int i=0;i<N;i++)for(int j=0;j<=i;j++)
	{
		for(int k=0;k<=K-2*j+2;k++)
		{
			if(dp[i][j][k]==0)continue;
			(dp[i+1][j][k+2*j]+=dp[i][j][k]*(2*j+1)%mod)%=mod;
			if(j>0)(dp[i+1][j-1][k+2*(j-1)]+=dp[i][j][k]*j*j%mod)%=mod;
			(dp[i+1][j+1][k+2*(j+1)]+=dp[i][j][k])%=mod;
		}
	}
	cout<<dp[N][0][K]<<endl;
}

Measured memory_bytes: 15208
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, ans = 0; cin >> n;
    vi a(n+1, 10001);
    repf(i, n){
        cin >> a[i];
        if(a[i] == a[i-1]){
            ans++;
            a[i] = 10001;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long a[3];
    cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[2]%2==0)
	 cout<<"0"<<endl;
	else
	 cout<<a[0]*a[1]<<endl;
	return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

int main(){

	bool dp[1000001];
	int a,b,n;
	while(cin>>n>>a>>b&&!(n==0&&a==0&&b==0)){
		memset(dp,0,sizeof(dp));
		dp[0]=dp[a]=dp[b]=true;
		int cnt=0;
		for(int i = 1; i <= n; i++){
			if(i==a||i==b){
				cnt++;
				continue;
			}
			if(i-a>=0){
				dp[i]=dp[i-a];
				if(dp[i])
					cnt++;
			}
			if(!dp[i]&&i-b>=0){
				dp[i]=dp[i-b];
				if(dp[i])
					cnt++;
			}
		}
		cout<<n-cnt<<endl;
	}

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;

int main() {
    ll n, k;
    cin >> n >> k;
    vll nums(n);
    vll v(40);
    ll mask = 0;
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
        for (int j = 39; j >= 0; --j) {
            mask = 1ll << j;
            if (mask & nums[i]) {
                ++v[j];
            }
        }
    }
    ll cur = 0;
    ll curX = k;
    for (int i = 39; i >= 0; --i) {
        mask = 1ll << i;
        if (mask & curX) {
            cur += (n - v[i]) * mask;
        } else {
            cur += v[i] * mask;
        }
    }
    ll ans = cur;
    ll X = curX;
    for (int i = 39; i >= 0; --i) {
        curX = k;
        cur = 0;
        mask = 1ll << i;
        curX = curX & ~(mask);
        if (curX < k) {
            for (int j = 39; j >= 0; --j) {
                mask = 1ll << j;
                if (j >= i) {
                    if (mask & curX) {
                        cur += (n - v[j]) * mask;
                    } else {
                        cur += v[j] * mask;
                    }
                } else {
                    if (v[j] > n - v[j]) {
                        curX = curX & ~(mask);
                        cur += v[j] * mask;
                    } else {
                        curX = curX | mask;
                        cur += (n - v[j]) * mask;
                    }
                }
            }
            if (cur > ans) {
                ans = cur;
                X = curX;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=350;
//↑templete
#define int long long
signed main(){
	int N, T;
	cin>>N>>T;
	vll A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}

	int mini=INF, ans=0;
	for(int i=0;i<N;i++){
		ans=max(ans, A[i]-mini);
		mini=min(mini, A[i]);
	}

	mini=INF;
	int cost=0;
	for(int i=0;i<N;i++){
		int temp=A[i]-mini;
		if(temp>=ans){
			cost+=temp-ans+1;
			A[i]-=temp-ans+1;
		}
		mini=min(mini, A[i]);
	}
	cout<<cost<<endl;
	return 0;
}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string str;
  cin>>str;
  if(str.size()>=6){
  	if(str[2]==str[3] && str[4]==str[5])
    	cout<<"Yes";
  	else cout<<"No";
  }
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
n=int(input())
h=[]
for i in range(n):
    x,l=map(int,input().split())
    h.append([x-l,x+l])
h.sort(key=lambda x: x[1])
xl=-10**9
c=0
for i in range(n):
    if xl<=h[i][0]:
        c+=1
        xl=h[i][1]
print(c)

Measured memory_bytes: 21336
#include<iostream>
#include<stack>
#define int long long
#define pii pair<int, int>
#define mp make_pair
using namespace std;

const int N=2e5+5;
int n, k, arr[N], fin[N], fo[N];
pii f[N];
stack<int> S;
bool instk[N];
signed main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	for(int i = 0; i < N; i++)
	{
		fo[i]=-1;
	}
	f[n]=mp(0, n);
	for(int i = n-1; i >= 0; i--)
	{
		if(fo[arr[i]]==-1)
		{
			f[i]=mp(arr[i], i);
		}
		else
		{
			f[i]=f[fo[arr[i]]+1];
		}
		fo[arr[i]]=i;
	}
	int cnt=1, curr=0;
	while(f[curr].first!=0)
	{
	//	cout << curr << " - " << f[curr].first << endl;
		curr=fo[f[curr].first]+1;
		cnt++;
	//	cout << curr << "lol" << endl;
	}
	int it=k%cnt;
	curr=0;
	for(int i = 1; i < it; i++)
	{
		curr=fo[f[curr].first]+1;
	}
	//cout << cnt << " - " << curr << endl;
	for(int i = curr; i < n; i++)
	{
		if(!instk[arr[i]])
		{
			S.push(arr[i]);
			instk[arr[i]]=true;
		}
		else
		{
//			cout << i << " " << S.top() << " " << " - ";
			while(S.top()!=arr[i])
			{
//				cout << S.top() << endl;
				instk[S.top()]=false;
				S.pop();
			}
//			cout << S.top() << endl;
			instk[S.top()]=false;
			S.pop();
		}
	}
	int l = S.size();
	for(int i = l-1; i >= 0; i--)
	{
		fin[i]=S.top();
		S.pop();
	}
	for(int i = 0; i < l; i++)
	{
		cout << fin[i] << " ";
	}
}

Measured memory_bytes: 10552
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
struct edge
{
    int to, dist, cnt;
    edge(int to, int dist, int cnt) : to(to), dist(dist), cnt(cnt) {}
    bool operator<(const edge &e) const { return cnt > e.cnt; }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, l;
    while(cin >> n >> m >> l, n | m | l)
    {
        vector<edge> G[n];
        for(int i = 0; i < m; i++)
        {
            int a, b, d, e; cin >> a >> b >> d >> e;
            a--, b--;
            G[a].push_back(edge(b, d, e));
            G[b].push_back(edge(a, d, e));
        }
        vector<vector<int>> cost(n, vector<int>(l + 1, INF));
        priority_queue<edge> que;
        que.push(edge(0, l, 0));
        cost[0][l] = 0;
        while(que.size())
        {
            edge p = que.top(); que.pop();
            int money = p.dist;
            //cout << p.to << " " << p.dist << " " << p.cnt << endl;
            for(int u = 0; u < G[p.to].size(); u++)
            {
                edge e = G[p.to][u];
                if(money - e.dist >= 0)
                {
                    if(cost[p.to][money] < cost[e.to][money - e.dist])
                    {
                        cost[e.to][money - e.dist] = cost[p.to][money];
                        que.push(edge(e.to, money - e.dist, p.cnt));
                    }
                }
                if(cost[p.to][money] + e.cnt < cost[e.to][money])
                {
                    cost[e.to][money] = cost[p.to][money] + e.cnt;
                    que.push(edge(e.to, money, p.cnt + e.cnt));
                }
            }
        }
        int ans = INF;
        for(int i = 0; i <= l; i++) ans = min(ans, cost[n - 1][i]);
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3480
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;

typedef struct {
    int dice[6];

    void north() {
        swap(dice[0], dice[4]);
        swap(dice[0], dice[5]);
        swap(dice[0], dice[1]);
    }

    void east() {
        swap(dice[0], dice[2]);
        swap(dice[0], dice[5]);
        swap(dice[0], dice[3]);
    }

    void south() {
        swap(dice[0], dice[1]);
        swap(dice[0], dice[5]);
        swap(dice[0], dice[4]);
    }

    void west() {
        swap(dice[0], dice[3]);
        swap(dice[0], dice[5]);
        swap(dice[0], dice[2]);
    }

} DICE;


int main()
{
    DICE a;
    string s;

    for (int i = 0; i < 6; i++) {
        int tmp;
        cin >> tmp;
        a.dice[i] = tmp;
    }
    
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'N') {
            a.north();
        }
        else if (s[i] == 'E') {
            a.east();
        }
        else if (s[i] == 'S') {
            a.south();
        }
        else {
            a.west();
        }
    }

    cout << a.dice[0] << endl;

}



Measured memory_bytes: 3212
N = gets.to_i

dp = Array.new(N + 10)
dp[0] = 0
# 1
N.times do |i|
  dp[i + 1] = dp[i] + 1
end
N.times do |i|
  c = dp[i]
  n = 6
  while i + n <= N
    dp[i + n] = c + 1 if c + 1 < dp[i + n]
    n *= 6
  end
  n = 9
  while i + n <= N
    dp[i + n] = c + 1 if c + 1 < dp[i + n]
    n *= 9
  end
end
puts dp[N]


Measured memory_bytes: 2556
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nk = br.readLine().split(" ");
        int n = Integer.parseInt(nk[0]);
        int k = Integer.parseInt(nk[1]);
        String[] str_l = br.readLine().split(" ");
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = Integer.parseInt(str_l[i]); 
        }
        Arrays.sort(l);
        
        int ans = 0;
        for (int i = n - k; i < n; i++) {
            ans += l[i];
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
#include<stdio.h>
int main()
{
  unsigned long N;
  scanf("%lu",&N);
  unsigned long hun,one,tmp,sum;
  hun=N/500;
  tmp=N%500;
  one=tmp/5;
  sum=1000*hun+5*one;
  printf("%lu",sum);
  return 0;
}
  

Measured memory_bytes: 128
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if n == 1:
        print(1)
        exit()

    # Only when there is no bit duplication in a group,
    # it always meets the condition.
    # l <= true_l < true_r < r
    ans = n
    l = 0
    now = a[0]
    for r in range(1, n):
        if now & a[r] == 0:
            now = now ^ a[r]
            continue

        now = now ^ a[r]
        for new_l in range(r-1, l-1, -1):
            if a[new_l] & a[r] != 0:
                break
        # else:
            # print('Error')
            # exit()
        new_l += 1

        for i in range(l, new_l):
            now = now ^ a[i]

        ans += (r-l) * (r-l-1) // 2 - (r-new_l) * (r-new_l-1) // 2

        l = new_l

    r += 1
    ans += (r-l) * (r-l-1) // 2

    print(ans)

main()

Measured memory_bytes: 32236
const fs = require('fs')

const input = fs.readFileSync('/dev/stdin', 'utf8')

const S = input.trim()

const counter = {}

for (let i=0; i<4; i++) {
  const c = S.substr(i, 1)
  if (c in counter) {
    counter[c] = counter[c] + 1
  } else {
    counter[c] = 1    
  }
}

if (Object.keys(counter).length === 2) {
  console.log('Yes')
} else {
  console.log('No')
}




Measured memory_bytes: 29520
#https://atcoder.jp/contests/abc127/tasks/abc127_c

NM = [int(i) for i in input().split()]
LR = []
for i in range(NM[1]):
    LR.append([int(i) for i in input().split()])

mi = LR[0][0]
ma = LR[0][1]
for i in range(NM[1]):
    if LR[i][0] > mi:
        mi = LR[i][0]
    if LR[i][1] < ma:
        ma = LR[i][1]

'''
if ma > NM[0]:
    ma = NM[0]
if mi > NM[0]:
    mi = ma + 1
print(ma - mi + 1)
'''
if ma < mi:
    print(0)
elif NM[0] >= ma:
    print(ma-mi+1)
elif NM[0] < ma and NM[0] > mi:
    print(NM[0]-mi+1)
elif NM[0] <= mi:
    print(0)

Measured memory_bytes: 21156
using System;
using System.Linq;

namespace A.Something_on_It
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            int ans = 700 + S.Count(x => x == 'o') * 100;

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

vector<vector<int>> graph;

void solution(){

	int n; cin >> n;
	vector<int> h(n); for(auto& x : h) cin >> x;

	vector<int> dp(n);

	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);

	for(int i = 2; i < n; i++)
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1])
			       ,dp[i-2] + abs(h[i] - h[i-2]));

	cout << dp[n-1] << endl;




	
}	

int main(){ 

	fio; // fast input output
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// GOOGLE //
		// cout << "Case #" << i << ": ";

		solution();
	} 
	return 0;
}

Measured memory_bytes: 3964
package main

import (
	"fmt"
	"strconv"
)

func solve(s string) int {
	sum := 0
	l := len(s) - 1
	for bit := 0; bit < (1 << uint(l)); bit++ {
		lasti := 0
		for i := 0; i < l; i++ {
			if bit&(1<<uint(i)) != 0 {
				n, _ := strconv.Atoi(s[lasti : i+1])
				sum += n
				lasti = i + 1
			}
		}
		last, _ := strconv.Atoi(s[lasti:])
		sum += last
	}
	return sum
}

func main() {
	var s string
	fmt.Scan(&s)

	sum := solve(s)
	fmt.Println(sum)
}


Measured memory_bytes: 512
S = input()
Q = int(input())
rev = 0
top = []
bot = []

for _ in range(Q):
  a = list(input().split())
  if a[0] == "1":
    rev += 1
  else:
    if rev%2 == 0:
      if a[1] == "1":
        top.append(a[2])
      else:
        bot.append(a[2])
    else:
      if a[1] == "2":
        top.append(a[2])
      else:
        bot.append(a[2])
      
t = "".join(top)[::-1]
b = "".join(bot)
S = "".join([t,S,b])
if rev%2 == 1:
  S = S[::-1]
print(S)

Measured memory_bytes: 5832
import Data.List

go :: (Ord a, Num a) => [a] -> Int
go = sum . map (\g -> length g * (length g - 1) `div` 2) . group . sort . scanl (+) 0

main = do
    getLine
    l <- map read . words <$> getLine :: IO [Integer]
    print $ go l


Measured memory_bytes: 114044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll H;cin>>H;
    ll ans=0,cnt=1;
    
    while(H){
        ans+=cnt;
        H/=2;
        cnt*=2;
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define MAX_N 200000
 
vector<int> G[MAX_N];
int cnt[MAX_N];
int ans[MAX_N];
 
void DFS(int v, int pre){
    ans[v] = pre + cnt[v];
    REP(i,G[v].size()){
        DFS(G[v][i], ans[v]);
    }
    return;
}
 
signed main(){
    int n,q;
    cin >> n >> q;
    int a,b;
    REP(i,n - 1){
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
    }
    int p,x;
    REP(i,q){
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    DFS(0, 0);
    REP(i,n){
        cout << ans[i] << " ";
    }
    cout << endl;
}

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

using namespace std;

int main(){
    int a, b, c, k, sum = 0;

    cin >> a >> b >> c >> k;

    while (k > 0 )
    {
    	if (k >= a && a > 0)
    	{
    		sum = sum + a;
    		k = k - a;
    		a = 0;
    	}
    	else if (k < a && a > 0)
    	{
    		sum = sum + k;
    		k = 0;
    		a = a - k;
    	}
    	else if (k < b && a == 0 && b > 0)
    	{
    		k = 0;
 			b = b -k;
    	}
    	else if (k >= b && a == 0 && b > 0)
    	{
    		k = k - b;
    		b = 0;
    	}
    	else if (k >= c && a == 0 && b == 0 && c > 0)
    	{
    		sum = sum - c;
    		c = 0;
    		k = 0;
    	}
    	else if (k < c && a == 0 && b == 0 && c > 0)
    	{
    		sum = sum - k;
    		c = c - k;
    		k = 0;
    	}
    }

    cout << sum;
	
	return 0;
}

Measured memory_bytes: 3620
/// time is tough.....so don't stop ...keep learning ...keep growing :)

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
const int N = 1e5+5 ;
const int K = 50 ;
const ll mod =  1e9+7 ;
#define pb push_back
#define ft first 
#define sd second 
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll mod){ll res=1;while(b){if(b&1){res*=a;res%=mod;}a=a*a;a%=mod;b>>=1;}return res;}
const ll INF = 2e18 ;
int h[N], k ;
int dp[N];
int solve(int n) {
	if(n <= 1) return dp[n];
	int &res = dp[n];
	if(~res) return res;
	res = 2e9;
	for(int i=1;i<=min(n-1,k);i++) {
		res = min(res, solve(n-i)+(int)abs(h[n]-h[n-i])) ;
	}
	return res ;
}
int main() {
    IOS;
    int n;
    cin >> n >> k;
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++) {
    	cin >> h[i];
    }
    dp[1] = 0;
    cout << solve(n) << '\n';
	return 0 ;
}

// https://atcoder.jp/contests/dp/tasks






// // // https://codeforces.com/problemset/problem/474/E
// // // https://www.hackerrank.com/contests/codeagon/challenges/number-of-ways-1/problem
// // // https://codeforces.com/contest/475/problem/D


// https://www.spoj.com/problems/INS17M/
// https://www.codechef.com/SEPT18B/problems/ANDSQR
// 


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();

        int[] nums = new int[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

        System.out.println(nums[k-1]);
    }
}

Measured memory_bytes: 35620
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	vector<int>v(3);
	rep(i, 3)cin >> v[i];
	sort(v.begin(), v.end());
	int ans = v[2] - v[1];
	if ((v[1] - v[0]) % 2 == 0)ans += (v[1] - v[0]) / 2;
	else ans += (v[1] - 1 - v[0]) / 2 + 2;
	cout << ans;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
grid = [list(input()) for _ in range(H)]

cnt_1 = 0
for n_h in range(1 << H):
    idx_h = set()
    cnt_h = 0
    while n_h > 0:
        if n_h & 1:
            idx_h.add(cnt_h)

        cnt_h += 1
        n_h >>= 1

    for n_w in range(1 << W):
        idx_w = set()
        cnt_w = 0
        while n_w > 0:
            if n_w & 1:
                idx_w.add(cnt_w)

            cnt_w += 1
            n_w >>= 1

        cnt_bkl = 0
        for h in range(H):
            if h in idx_h:
                continue

            for w in range(W):
                if w in idx_w:
                    continue

                if grid[h][w] == '#':
                    cnt_bkl += 1

        if cnt_bkl == K:
            cnt_1 += 1


print(cnt_1)


Measured memory_bytes: 9216
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const lint inf=1e18+1e7;
const int MAXN=1e5+1e1;

map <lint,bool> m;

lint n,k,minn=inf;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%lld%lld",&n,&k);

	n-=(n/k)*k;

	while(!m[n])
	{
		m[n]=true;
		n-=k;
		if(n<0) n=-n;
		minn=min(minn,n);
	}

	printf("%lld\n",minn);

	return 0;

}

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

int main(){
  int K;cin >> K;
  ll sum = 0;
  for(int a=1;a<=K;a++){
    for(int b=1;b<=K;b++){
      for(int c=1;c<=K;c++){
        sum += gcd(gcd(a,b),c);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	char s[100];
	
	scanf("%s",s);
	
	int i=0;
	int min=1000;
	int x;
	
	while(s[i+2]!='\0'){
		
		x=(int)((s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0');
		
		if(x>753){
			x=x-753;
		}else{
			x=753-x;
		}
			
		if(min>x){
			min=x;
		}
		
		i++;
		
	}
	
	printf("%d\n",min);
	
	return 0;
}

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

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

    if (n % 500 <= a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;



int main() {
    bool flg = true;
    int n; cin >> n;
    string s; cin >> s;
    if (n%2 == 1){
        cout << "No" << endl;
    }
    else{ 
        rep(i, n/2){
            if(s[i] != s[i+n/2]){
                flg = false;
                break;
            }
        }
        if (flg){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }

    }
}



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

int main() {
    int a, b, out = 0;
    cin >> a >> b;
    out += a > b ? a-- : b--;
    out += a > b ? a-- : b--;
    cout << out << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int n, k;
  cin >> n>>k;
  
  vector <int> p(n);
  for (int i=0; i<n; i++){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  
  int sum=0;
  for (int i=0; i<k; i++) {
    sum += p.at(i);
  }    
  cout << sum << endl;
}


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

r = []
g = []
b = []
for i in range(len(s)):
    t = s[i]
    if t == 'R':
        r.append(i+1)
    elif t == 'G':
        g.append(i+1)
    else:
        b.append(i+1)

ans = len(r) * len(g) * len(b)

for i in range(1, int((n-1)/2)+1):
    for j in range(n-i-i, 0, -1):
        if s[j-1] != s[j+i-1] and s[j+i-1] != s[j+i+i-1] and s[j+i+i-1] != s[j-1]:
            ans -= 1

print(ans)

Measured memory_bytes: 68208
n=int(input())
#n,p=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

dic={}
for a in al:
    dic[a]=dic.get(a,0)+1
total=0
for v in dic.values():
    total+=v*(v-1)//2

for k in range(n):
    res=total-(dic[al[k]]-1)
    print(res)



Measured memory_bytes: 26268
#include <stdio.h>
#include <math.h>
//#include <algorithm>

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    if(n==3 || n==5 || n==7) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }

    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	if(!k){printf("%lld",1ll*n*n);return 0;}
	ll ans=0;
	for(int i=k+1;i<=n;i++)
	{
	   ans+=(ll)(n/i)*(i-k);
	   ans+=max((ll)(n%i-k+1),0ll);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    it.next();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    it.next();
    for k in it {
        let k: usize = k.parse().unwrap();
        let mut d = 0u64;
        let mut m = 0;
        let mut dm = 0;
        let mut dmc = 0;
        for &c in s[..k].iter() {
            match c {
                'D' => {
                    d += 1;
                },
                'M' => {
                    m += 1;
                    dm += d;
                },
                'C' => {
                    dmc += dm;
                },
                _ => (),
            }
        }
        for (&f, &t) in s.iter().zip(s[k..].iter()) {
            match f {
                'D' => {
                    dm -= m;
                    d -= 1;
                },
                'M' => {
                    m -= 1;
                },
                _ => (),
            }
            match t {
                'D' => {
                    d += 1;
                },
                'M' => {
                    m += 1;
                    dm += d;
                },
                'C' => {
                    dmc += dm;
                },
                _ => (),
            }
        }
        writeln!(out, "{}", dmc).ok();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 11512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp  make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf1(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
int inf = (1e9) + 7;


int tabela[100005][3];

int main(){

	int n;
	cin >> n;


	int aux;
	int occ[100005];
	memset(occ,0,sizeof(occ));
	for (int i = 0; i < n; ++i)
	{
		sf1(aux);
		occ[aux]++;
		occ[aux+1]++;
		occ[aux-1]++;
	}

	int mx = 0;

	for (int i = 0; i < 100004; ++i)
	{
		mx = max(mx,occ[i]);
	}

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

Measured memory_bytes: 640
import scala.io.StdIn._

object Main extends App {
  val nk = readLine.split(" ").map(_.toInt)
  val n = nk(0)
  val k = nk(1)

  val numList = readLine.split(" ").map(_.toInt)
  val kitaiList = numList.map(n => n + 1) // 期待値(n+1/2)の2倍

  var max = kitaiList.slice(0, k).sum
  var sum = max
  for (i <- k until kitaiList.length) {
    sum = sum - kitaiList(i - k) + kitaiList(i)
    if (sum > max) {
      max = sum
    }
  }

  println(max.toDouble / 2)
}


Measured memory_bytes: 71104
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n,m;
  cin >> n >> m;
  vector<pii> r(m);
  for(int i=0;i<m;i++)cin >> r[i].first >> r[i].second;
  sort(r.begin(),r.end());

  int s=-1,t=-1,sum=0;
  for(int i=0;i<m;i++){
    if(r[i].first<=t){
      t = max(t, r[i].second);
    }else{
      sum += t-s;
      s = r[i].first, t = r[i].second;
    }
  }
  sum += t-s;

  cout << n+1 + 2*sum << endl;
}

Measured memory_bytes: 1204
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	vll v(n);
	read(v);
	ll ans=1;
	ll mi[n+10];
	mi[0]=v[0];
	for(int i=1;i<n;i++)
	{
	    mi[i]=min(mi[i-1],v[i]);
	    if(mi[i]==v[i])
	    ans++;
	}
	cout<<ans;
	
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i, j, k) for(register ll i = j; i <= k; ++i)
#define D(i, j, k) for(register ll i = j; i >= k; --i)
#define random(x) (rand() % (x)) + 1
#define pb push_back
#define fi first
#define se second
#define pp pair<ll, ll>
#define mp make_pair
#define error(x) cerr << #x << "=" << x << endl
//***********var defination*********
const ll maxn = 2e5+5;
ll n, m, x, y, z;
ll a[maxn], b[maxn], c[maxn];
int main() {
#ifdef orz
    freopen("input", "r", stdin);
#endif
    cin >> n;
    F(i, 1, n) cin >> a[i];
    F(i, 1, n) cin >> b[i];
    F(i, 1, n) cin >> c[i];
    sort(a+1, a+1+n);
    sort(b+1, b+1+n);
    sort(c+1, c+1+n);
    ll bb = n, cc = n;
    ll tmp = 0, tmp2 = 0, ans = 0;
    D(aa, n, 1) {
	while(b[bb] > a[aa]) {
	    while(c[cc] > b[bb]) cc--, tmp++;
	    bb--;
	    tmp2 += tmp;
	}
	ans += tmp2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3584
#include <math.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	int N, M;
	cin >> N;
	vs s(N);
	rep(i, N) cin >> s[i];
	cin >> M;
	vs t(M);
	rep(i, M) cin >> t[i];

	int ans = 0;
	rep(i, N) {

		string tmp = s[i];
		int buf = 0;

		rep(j, N) {
			if (tmp == s[j]) buf++;
		}

		rep(j, M) {
			if (tmp == t[j]) buf--;
		}

		if (ans < buf) ans = buf;
	}


	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		scan.close();
		int cnt[]=new int[26];
		for(int i=0;i<26;i++) {
			cnt[i]=0;
		}
		for(int i=0;i<w.length();i++) {
			int suffix=w.charAt(i)-(int)'a';
			cnt[suffix]+=1;
		}
		int check=1;
		for(int i=0;i<26;i++) {
			if(cnt[i]%2!=0) {
				check=0;
				break;
			}
		}
		System.out.println((check==1)? "Yes":"No");
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		if(a<b)
		{
			System.out.println("a < b");
		}
		else if(a>b)
		{
			System.out.println("a > b");
		}
		else
		{
			System.out.println("a == b");
		}
	}

}

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

int main () {

	string s;
	cin >> s;

	int ans1 = 0;
	for (int i = 0; i < s.size(); ++i) if (s[i] - '0' != (i & 1)) ++ans1;

	int ans2 = 0;
	for (int i = 0; i < s.size(); ++i) if (s[i] - '0' != !(i & 1)) ++ans2;

	cout << min (ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 512