akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>
#include <utility>

using namespace std;

#include <vector>
#include <limits>
#include <utility>
#include <queue>
#include <functional>

using namespace std;

struct Dijkstra {
  typedef long long dist_t;

  vector<dist_t> distance;
  vector<int> parent;

  template<typename TEdge> /* member: target, dist */
  void solve(const vector<vector<TEdge>> &graph, int start) {
    int n = graph.size();
    distance.assign(n, numeric_limits<dist_t>::max());
    parent.assign(n, -1);
    typedef pair<dist_t, int> queue_t;
    priority_queue<queue_t, vector<queue_t>, greater<queue_t>> pq;
    distance[start] = 0;
    parent[start] = -1;
    pq.push(make_pair(0, start));
    while (!pq.empty()) {
      int cur;
      dist_t cur_dist;
      tie(cur_dist, cur) = pq.top(); pq.pop();
      if (cur_dist != distance[cur]) continue;
      for (const auto &edge : graph[cur]) {
        int next = edge.target;
        dist_t new_dist = cur_dist + edge.dist;
        if (distance[next] <= new_dist) continue;
        distance[next] = new_dist;
        parent[next] = cur;
        pq.push(make_pair(new_dist, next));
      }
    }
  }

  vector<int> getPath(int v) {
    vector<int> ans;
    if (distance[v] == numeric_limits<dist_t>::max()) {
      return ans;
    }
    do {
      ans.push_back(v);
      v = parent[v];
    } while (v >= 0);
    reverse(ans.begin(), ans.end());
    return ans;
  }
};


struct dedge_t {
  int target;
  int dist;
};

int main() {
  int n, m, s, t;
  scanf("%d%d%d%d", &n, &m, &s, &t);
  s--, t--;
  vector<vector<dedge_t>> graphyen(n), graphsnu(n);
  for (int i = 0; i < m; i++) {
    int u, v, a, b;
    scanf("%d%d%d%d", &u, &v, &a, &b);
    u--, v--;
    dedge_t e1, e2;
    e1.dist = a;
    e1.target = v;
    graphyen[u].push_back(e1);
    e1.target = u;
    graphyen[v].push_back(e1);
    e2.dist = b;
    e2.target = u;
    graphsnu[v].push_back(e2);
    e2.target = v;
    graphsnu[u].push_back(e2);
  }
  vector<long long> dist_yen(n, LLONG_MAX), dist_snuke(n, LLONG_MAX);
  Dijkstra dijkstra;
  dijkstra.solve(graphyen, s);
  dist_yen = dijkstra.distance;
  dijkstra.solve(graphsnu, t);
  dist_snuke = dijkstra.distance;

  vector<long long> ans(n);
  for (int i = 0; i < n; i++) {
    long long cur = 1000000000000000ll;
    cur -= dist_yen[i];
    cur -= dist_snuke[i];
    ans[i] = cur;
  }
  for (int i = n - 2; i >= 0; i--) {
    ans[i] = max(ans[i], ans[i + 1]);
  }
  for (int i = 0; i < n; i++) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 17220
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back



int main(void){
  int n;
  while(cin >> n ){
    if(!n)break;
    int m, x, y;
    pii pos = pii(10,10);
    string S;
    int cell[32][32] = {0};
    rep(i,n){
      cin >> x >> y;
      cell[x][y] = 1;
    }
    cin >> m; 
    rep(i,m){
      cin >> S >> x;
      if(S[0] == 'N'){
        while(x--){
          pos.Y++;
          cell[pos.X][pos.Y] = 0;
        }
      }else if(S[0]=='E'){
        while(x--){
          pos.X++;
          cell[pos.X][pos.Y] = 0;
        }
      }else if(S[0] == 'S'){
        while(x--){
          pos.Y--;
          cell[pos.X][pos.Y] = 0;
        }
      }else if(S[0] == 'W'){
        while(x--){
          pos.X--;
          cell[pos.X][pos.Y] = 0;
        }
      }
    }
    bool flag = false;
    rep(i,32)rep(j,32)
      if(cell[i][j] != 0)
        flag |=true;

    if(flag) cout << "No" << endl;
    else cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

int main() {

  double Ans = 0;
  int N;

  cin >> N;

  vector< map<string, double> > mati(N);
  double x, y;


  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    mati[i]["x"] = x;
    mati[i]["y"] = y;
  }


  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      Ans += sqrt( pow( (mati[i]["x"] - mati[j]["x"]), 2.0) +  pow( (mati[i]["y"] - mati[j]["y"]), 2.0) );


  cout << fixed << setprecision(10) << Ans / N << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

template <int MD>
struct ModInt {
    typedef ModInt M;
    int v;
    ModInt(int _v = 0) : v(_v) {}
    M& operator += (const M &r) {
        if ((v += r.v) >= MD) v -= MD;
        return *this;
    }
    M& operator -= (const M &r) {
        if ((v -= r.v) < 0) v += MD;
        return *this;
    }
    M& operator *= (const M &r) {
        v = ll(v) * r.v % MD;
        return *this;
    }
    M operator + (const M &r) const { return M(*this) += r; }
    M operator - (const M &r) const { return M(*this) -= r; }
    M operator * (const M &r) const { return M(*this) *= r; }
    M pow(int n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return this->pow(MD - 2); }
};
typedef ModInt<1000000007> Mint;

const int MN = 100010;
int n;
int last[MN];
Mint fac[MN], ifac[MN];

void first() {
    fac[0] = 1;
    for (int i = 1; i < MN; i++) {
        fac[i] = fac[i - 1] * Mint(i);
    }
    ifac[MN - 1] = fac[MN - 1].inv();
    for (int i = MN - 2; i >= 0; i--) {
        ifac[i] = ifac[i + 1] * Mint(i + 1);
    }
}

Mint C(int x, int y) {
    if (x < y) return Mint(0);
    return fac[x] * ifac[y] * ifac[x - y];
}

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

    first();
    cin >> n;
    fill(last, last + n, -1);
    int m = -1;
    for (int i = 0; i <= n; i++) {
        int x;
        cin >> x; x--;
        if (last[x] >= 0) {
            m = n - i + last[x];
        }
        last[x] = i;
    }
    assert(m >= 0);

    for (int k = 1; k <= n + 1; k++) {
        Mint ans = C(n + 1, k) - C(m, k - 1);
        cout << ans.v << "\n";
    }
    return 0;
}

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

int main() {
	int h = 1,w = 1;
	cin >> h >> w;
	vector<string> s;
	vector<string> ans;
	for (int i = 0; i < h; i++) {
		string sin;
		cin >> sin;
		s.push_back(sin);
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++){
			if (s[i][j] == '.') {
				int count = 0;
				for (int k = i-1; k < i+2; k++) {
					if (k < 0 || k >= h) continue;
					for (int l = j-1; l < j+2; l++) {
						if (l < 0 || l >= w) continue;
						if (s[k][l] == '#') {
							count++;
						}
					} 
				}
				s[i][j] = char(count+'0');
			}
		}
	}

	for (int i = 0; i < h; i++) {
		cout << s[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
int N,tmp,tmp1,tmp2,tmp3;
string s;
int step1()
{
  cin>>N;
  cin>>s;
return 0;
}

int tansaku(string q,int start,int key )
{
  FOR(i,start+1,N-1)
  {
    if(s[i]==key+48)
    {
      tmp=i;
      return 0;
    }
  }
  tmp=-1;
  return 0;
}

int main()
{
  step1();
  vector<vector<vector<int>>> data(10,vector<vector<int>>(10,vector<int>(10)));
  REP(i,10)
  {
    REP(j,10)
    {
      REP(r,10)
      {
        data[i][j][r]=0;
      }
    }
  }

  REP(i,10)
  {
    REP(j,10)
    {
      REP(r,10)
      {
        tansaku(s,-1,i);tmp1=tmp;
        tansaku(s,tmp1,j);tmp2=tmp;
        tansaku(s,tmp2,r);tmp3=tmp;
        if(tmp1==-1){continue;}
        if(tmp2==-1){continue;}
        if(tmp3==-1){continue;}
        if(tmp1<tmp2&&tmp2<tmp3)
        {
          data[i][j][r]=1;
        }

      }
    }
  }
  int ans=0;
  REP(i,10)
  {
    REP(j,10)
    {
      REP(r,10)
      {
        if(data[i][j][r]==1)
        {
          ans=ans+1;
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
print(n * 2 - 1)
ma, mi = max(a), min(a)
ima, imi = a.index(ma), a.index(mi)
if abs(ma) >= abs(mi):
    for i in range(1, n + 1):
        print(ima + 1, i)
    for i in range(1, n):
        print(i, i + 1)
else:
    for i in range(1, n + 1):
        print(imi + 1, i)
    for i in range(1, n)[::-1]:
        print(i + 1, i)

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

using namespace std;
typedef long long ll;

ll mod = 998244353;

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % mod;
    if (pow % 2 == 1) a *= x;
    return a % mod;
}

template<typename T>
struct BinaryIndexedTree {
    vector<T> data;

    BinaryIndexedTree(int sz) {
        data.assign(++sz, 0);
    }

    T sum(int k) {
        T ret = 0;
        for (++k; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    void add(int k, T x) {
        for (++k; k < data.size(); k += k & -k) data[k] += x;
    }
};

int main() {
    int n;
    cin >> n;
    vector<vector<int>> point(n);
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        point[i] = {x, y};
        v[i] = y;
    }
    sort(point.begin(), point.end());
    sort(v.begin(), v.end());

    vector<int> y_axis(n);
    for (int i = 0; i < n; i++) {
        y_axis[i] = lower_bound(v.begin(), v.end(), point[i][1]) - v.begin();
    }

    vector<int> left_up(n);
    vector<int> left_down(n);
    auto u_bit = BinaryIndexedTree<int>(n);
    auto d_bit = BinaryIndexedTree<int>(n);
    for (int i = 0; i < n; i++) {
        int tmp = n - 1 - y_axis[i];
        left_up[i] = u_bit.sum(tmp);
        u_bit.add(tmp, 1);
        left_down[i] = d_bit.sum(y_axis[i]);
        d_bit.add(y_axis[i], 1);
    }
    vector<int> right_up(n);
    vector<int> right_down(n);
    u_bit = BinaryIndexedTree<int>(n);
    d_bit = BinaryIndexedTree<int>(n);
    for (int i = n - 1; i >= 0; i--) {
        int tmp = n - 1 - y_axis[i];
        right_up[i] = u_bit.sum(tmp);
        u_bit.add(tmp, 1);
        right_down[i] = d_bit.sum(y_axis[i]);
        d_bit.add(y_axis[i], 1);
    }

    ll ret = n * calc_pow(2, n - 1) % mod;
    for (int i = 0; i < n; i++) {
        ll a = (calc_pow(2, left_up[i]) - 1) * (calc_pow(2, right_down[i]) - 1);
        a %= mod;
        a *= calc_pow(2, left_down[i] + right_up[i]);
        a %= mod;

        ll b = (calc_pow(2, left_down[i]) - 1) * (calc_pow(2, right_up[i]) - 1);
        b %= mod;
        b *= calc_pow(2, left_up[i]) + calc_pow(2, right_down[i]) - 1;
        b %= mod;

        ret += a + b;
        ret %= mod;
    }
    cout << ret << endl;
}

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

int main() {
  string s;
  cin >> s;
  int a_i, z_i = -1;
  for (int i = 0; i < s.size(); ++i) {
    char c = s[i];
    if (c == 'A') {
      a_i = i;
      break;
    }
  }
  for (int i = a_i + 1; i < s.size(); ++i) {
    char c = s[i];
    if (c == 'Z') {
      z_i = max(z_i, i);
    }
  }
  cout << z_i - a_i + 1 << endl;
}

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

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 ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    int N;
    cin>>N;
    vector<int> ans(4);
    rep(i,N){
        string S;
        cin>>S;
        if(S=="AC") ans[0]++;
        if(S=="WA") ans[1]++;
        if(S=="TLE") ans[2]++;
        if(S=="RE") ans[3]++;
    }
    rep(i,4){
        if(i==0) cout<<"AC x "<<ans[0]<<endl;
        if(i==1) cout<<"WA x "<<ans[1]<<endl;
        if(i==2) cout<<"TLE x "<<ans[2]<<endl;
        if(i==3) cout<<"RE x "<<ans[3]<<endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a*b, c) << endl;
}

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

using namespace std;

const int INF = 1e9 ;

int n , k , s ;
vector <int> ans ;

int main()
{
    cin >> n >> k >> s ;
    if( s < INF ) {
        for (int i = 0; i < k; i++)
            ans.push_back(s);
        int t = n-k ;
        for(int i = 0 ; i < t ; i++ )
            ans.push_back( INF ) ;

    }else{
        for (int i = 0; i < k; i++)
            ans.push_back(s);
        int t = n-k ;
        for(int i = 0 ; i < t ; i++ )
            ans.push_back( 1 ) ;
    }

    for(auto x : ans)
        cout << x << " " ;
    cout << endl;

    return 0;

}


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

int main()
{
  int setcount;
  float x1, y1, x2, y2, x3, y3;
  float nx1, ny1, nx2, ny2;
  float nr1, nr2;
  float xp, yp, r;
  float tmp;
  int i;

  scanf("%d", &setcount);
  for(i=0; i<setcount; i++){
    scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3);
    nx1=x2-x1; ny1=y2-y1;
    nx2=x3-x1; ny2=y3-y1;
    nr1=nx1*nx1+ny1*ny1; nr2=nx2*nx2+ny2*ny2;
    nr1*=0.5f; nr2*=0.5f;

    if(nx1==0.0f){
      nr1/=ny1; ny1=1.0f;
      nr2-=nr1*ny2; ny2=0.0f;
      nr2/=nx2; nx2=1.0f;
      tmp=nr1; nr1=nr2; nr2=tmp;
    }
    else {
      //normalize
      ny1/=nx1; nr1/=nx1; nx1=1.0f;
      //subtraction
      ny2-=ny1*nx2; nr2-=nr1*nx2; nx2=0.0f;
      //normalize
      nr2/=ny2; ny2=1.0f;
      //subtraction
      nr1-=nr2*ny1; ny1=0.0f;
    }

    xp=nr1+x1; yp=nr2+y1;
    r=sqrt(nr1*nr1+nr2*nr2);
    printf("%.3f %.3f %.3f\n", xp, yp, r);
  }

  return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; string s;
    cin >> n >> s;

    for(int i = 0; i < s.length(); i++){
        int l = int(s[i] - 'A') + n;
        l%=26;
        s[i] = char('A' + l);
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())
if X == 0 and K%2 == 0:
  print(0)
elif X == 0 and K%2 == 1:
  print(abs(D))
elif X > 0 and X - D*K >= 0:
  print(X - D*K)
elif X < 0 and X + D*K <= 0:
  print(abs(X + D*K))
else:
  i = abs(X)//D
  if (K - i) % 2 == 0:
    print(abs(X)%D)
  else:
    print(abs(abs(X)%D-D))

Measured memory_bytes: 61904
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 300005;
const int mod = 998244353;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    vector<string>ans;
    int ptr = 1;
    ans.pb(s.substr(0,1));
    while(ptr < s.size()) {
        int cur = 1;
        while(ptr + cur <= s.size() && s.substr(ptr,cur) == ans.back()) {
            cur++;
        }
        if (ptr + cur > s.size())break;
        ans.pb(s.substr(ptr,cur));
        ptr += cur;
    }
    cout << ans.size() << '\n';
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,v,a[101],b[101];
long long d[101][100001];

void nhap()
{
    scanf("%d %d",&n,&v);
    for (int i=1;i<=n;++i)
    {
        scanf("%d %d",&a[i],&b[i]);
    }
}

void process()
{
    for (int j=0;j<=v;++j)
    {
        for (int i=1;i<=n;++i)
        {
            d[i][j]=d[i-1][j];
            if (j>=a[i])
                d[i][j]=max(d[i][j],d[i-1][j-a[i]]+b[i]);
        }
    }
    cout<<d[n][v];
}

int main()
{
    nhap();
    process();
    return 0;
}


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

int h, w, K;


int main(void){
    cin >> h >> w >> K;
    vector<vector<int>> c(h, vector<int>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char ch;
            cin >> ch;
            if(ch == '.') c[i][j] = 0;
            else c[i][j] = 1;
        }
    }
    int res = 0;
    for(int k = 0; k < (1<<(h+w)); k++){
        vector<vector<int>> sk = c;
        int sum = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if((k>>i&1) || (k>>(h+j)&1)) sk[i][j] = 0;
            }
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                sum+=sk[i][j];
            }
        }
        if(sum == K) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3604
from sys import stdin
from fractions import gcd
def main():
    #入力
    readline=stdin.readline
    a,b,c,d=map(int,readline().split())
    a-=1
    l=c*d//gcd(c,d)
    print((b-(b//c+b//d-b//l))-(a-(a//c+a//d-a//l)))
if __name__=="__main__":
    main()

Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;


ll powmod(ll x, ll y){
    ll res = 1;
    for(ll i=0; i<y; i++){
        res = (res * x)%mod;
    }
    return res;
}

int main(){

    int N;
    cin >> N;

    long long ans;
    ans = powmod(10,N)-2*powmod(9,N)+powmod(8,N);
    ans %= mod;
    ans=(ans+mod)%mod;
    cout << ans << endl;

}

Measured memory_bytes: 3496
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    bool f = false;
    int diff = b - a;
    rep(i, 0, n){
        int r = - i * c + (n - 1 - i) * d;
        int l = (n - 1 - i) * c - i * d;
        if(l <= diff && diff <= r) f = true;
    }
    cout << (f ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#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, K;
int x[100];

int main() {
    cin >> N >> K;
    rep(i, N) cin >> x[i];

    int ans = 0;
    rep(i, N) {
        int left = abs(x[i]);
        int right = abs(x[i] - K);
        ans += min(left, right);
    }

    cout << ans * 2 << endl;
}

Measured memory_bytes: 256
list = list(map(int, input().split()))
N=list[0]+1
X=list[1]
Y=list[2]
l=[0]*N
c=0
# i<j
for i in range(1,N):
    for j in range(i+1, N):
        if i<=X and Y<=j:
            l[j-i-(Y-X)+1]+=1
        else:
            if j-i>abs(X-i)+1+abs(j-Y):
                l[abs(X-i)+1+abs(j-Y)]+=1
            else:
                l[j-i]+=1
for i in range(1,N-1):
    print(l[i])

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int P[10010];

// グラフの初期化
void init(int n) {
    for (int i = 0; i < n; i++) P[i] = i;
}

int root(int a) {
    if (P[a] == a) {
        return a;
    } else {
        return root(P[a]);
    }
}

void unite(int x, int y) {
    P[root(x)] = root(y);
}

bool is_same_root(int a, int b) {
    return root(a) == root(b);
}

int main() {
    int n, q; // n個の要素, q個のクエリ
    cin >> n >> q;
    init(n);
    for (int i = 0; i < q; i++) {
        int com; // 命令、０の時unite、１の時same
        cin >> com;
        int x, y;
        cin >> x >> y;
        if (com == 0) {
            unite(x, y);
        } else if (is_same_root(x, y)) {
        cout << 1 << endl;
        } else {
        cout << 0 << endl;
        }
    }
}


Measured memory_bytes: 3128
#include <complex>
#include <stdio.h>
#include <math.h>
using namespace std;

// _ÀWð^Æ·é
typedef complex<double> P;
// ÎÌè`
#define PI 3.1415926535898

// e·éë·Ã
#define EPS (1e-10)
//XYÀW
#define X real()
#define Y imag()

//QÂÌdouble^Ìlªµ¢©Ç¤©
bool equal(double a, double b){
	return (fabs( a-b ) < EPS)? true : false ;
}
	
// Op`NX
class Triangle{

private:
	//Op`ÌR_ÌÀW
	P a, b, c;
	//Op`ÌRÓÌ·³
	double edgeA,edgeB,edgeC;
	//Op`ÌRpÌå«³(WA)
	double angleA,angleB,angleC;
	//]·è©çRÂÌpxðßéÖ
	double LawOfCosines(double a,double b, double c){
		return acos( (b*b+c*c-a*a) / (2.0*b*c) );
	}
	

public:
	//RXgN^(RÂÌ_ÆÓÆpxðú»)
	Triangle(P p1, P p2, P p3){
		a = p1;
		b = p2;
		c = p3;
		edgeB = abs(c-a);
		edgeA = abs(b-c);
		edgeC = abs(a-b);
		angleA = LawOfCosines(edgeA,edgeB,edgeC);
		angleB = LawOfCosines(edgeB,edgeC,edgeA);
		angleC = LawOfCosines(edgeC,edgeA,edgeB);
	}
	double getAngleC(){//pCÌpxðÏ¦·
		return angleC;
	}
};

int main(){
	double x1, x2, x3, y1, y2, y3, xp, yp, angle;

	while( scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF ){
		P a( x1 , y1 );
		P b( x2 , y2 );
		P c( x3 , y3 );
		P p( xp , yp );
		Triangle Tr1(a,b,p);
		Triangle Tr2(b,c,p);
		Triangle Tr3(c,a,p);
		angle = Tr1.getAngleC() + Tr2.getAngleC() + Tr3.getAngleC();
		if ( equal( 2.0*PI , angle) ){
			printf("YES\n");
		}else {
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 2e5; // CAMBIAR ESTE

// GJNM
ll cnt[60][60];//?

int main() {
	int n;
	ri(n);
	ll DEN = 1e9;
	FOR(i, 0, n) {
		long double aux;
		scanf("%Lf", &aux);
		ll val = round(DEN * aux);
		int five = 0, two = 0;
		while ( val % 2 == 0 ) {
			two++;
			val /= 2;
		}
		while ( val % 5 == 0 ) {
			five++;
			val /= 5;
		}
		cnt[two][five]++;
	}
	ll ans = 0;
	FOR(i, 0, 60) {
		FOR(j, 0, 60) {
			FOR(ii, 0, 60) {
				FOR(jj, 0, 60) {
					if ( make_pair(i, j) > make_pair(ii, jj) )
						continue;
					if ( i + ii >= 18 && j + jj >= 18 ) {
						if ( i == ii && j == jj ) {
							ans += (cnt[i][j] * (cnt[ii][jj] - 1ll)) / 2ll;
						}
						else {
							ans += (cnt[i][j] * cnt[ii][jj]) ;
						}
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3864
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  (n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    normalForms :: [String]
    normalForms = unfoldr next . Just . zeroes $ n
      where
        next :: Maybe Digits -> Maybe (String, Maybe Digits)
        next = fmap next'
          where
            next' :: Digits -> (String, Maybe Digits)
            next' = (,) <$> showDs <*> succDs
  mapM_ putStrLn normalForms

type Digits = [(Int, Int)]

extend :: Digits -> Digits
extend [] = (1, 0) : []
extend ds@((m, k) : _) = (max m (succ k), 0) : ds

zeroes :: Int -> Digits
zeroes 1 = []
zeroes l  = extend . zeroes . pred $ l

succDs :: Digits -> Maybe Digits
succDs [] = Nothing
succDs ((m, k) : ds) | k < m = Just ((m, succ k) : ds)
succDs (_ : ds) = extend <$> succDs ds

showDs :: Digits -> String
showDs = ('a' :) . map (toLEL . snd) . reverse

toLEL :: Int -> Char
toLEL = toEnum . (fromEnum 'a' +)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 2172
N, K = map(int, input().split())
H = []
for _ in range(N):
    H.append(int(input()))
H = list(sorted(H))
r_min = 10 ** 10
for i in range(N-K+1):
    n_min = H[i]
    n_max = H[i+K-1]
    r_min = min(r_min, n_max-n_min)
print(r_min)


Measured memory_bytes: 14292
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[105];

void solve()
{
    int n;
    scanf("%d%s", &n, str);
    int i,j;
    int ans = 0;
    for (i = 1; i < n-1; i++) {
        set<char> z0, z1;
        for (j = 0; j < i; j++) {
            z0.insert(str[j]);
        }

        for (j = i; j < n; j++) {
            z1.insert(str[j]);
        }
        vector<char> v;
        set_intersection(z0.begin(), z0.end(), z1.begin(), z1.end(), back_inserter(v));

        int tmp = (int)v.size();
        ans = MAX(ans, tmp);
    }
    printf("%d\n", ans);
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 200000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

ll a[MAX + 5], b[MAX + 5];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n, m, i, j, ans;
    ll k, curr;
    cin >> n >> m >> k;
    for (i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (i = 1; i <= m; ++i) {
        cin >> b[i];
        b[i] += b[i - 1];
    }
    j = m;
    ans = 0;
    for (i = 0; i <= n and a[i] <= k; ++i) {
        curr = k;
        curr -= a[i];
        while (j >= 1 and b[j] > curr) {
            j--;
        }
        ans = max(ans, i + j);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 6240
#include <limits.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

#include <bits/stdc++.h>

namespace test {
std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
}
}  // namespace test

using namespace std;

int maxtime(int x){
    return (x + 9)/10 * 10;
}

int retime(int x){
    return maxtime(x) -x;
}

int main(void) {
   int a,b,c,d,e;
   cin >> a >> b >> c >> d >> e;
   int sum = maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e);
   sum -= max({retime(a), retime(b),retime(c),retime(d),retime(e)});
   cout << sum << endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))

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

const int N = 1e5 + 5;
int n, a[N], ans[N], deg[N];

main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	set<int> s;
	for(int i=1; i<=n; ++i) s.insert(i);
	for(int i = 1; i <= n; ++i) cin >> a[i];
	for(int i = 1; i <= n; ++i) deg[a[i]]++;
	set<ii> p;
	for(int i = 1; i <= n; ++i) p.insert(make_pair(deg[i],i));
	for(int i=1; i<=n; ++i){
		if(n-i+1<=10){
			//brute;
			vector<int> c;
			for(auto v:s) c.pb(v);
			do{
				bool ok=1;
				for(int j=0; j<(int)c.size()-1; ++j){
					if(a[c[j]]==c[j+1]){
						ok=0;
						break;
					}
				}
				if(a[ans[i-1]]==c[0]) ok=0;
				if(ok){
					for(int j=0; j<c.size(); ++j){
						ans[i+j]=c[j];
					}
					break;
				}
			}while(next_permutation(all(c)));
			if(ans[n]==0) return cout<<-1,0;
			for(int i=1; i<=n; ++i) cout<<ans[i]<<' ';
			return 0;
		}
		set<ii>::iterator u=p.end(); u--;
		if((*u).fi==n-i){
			ans[i]=(*u).se;
			if(a[ans[i-1]]==ans[i]) return cout<<-1,0;
		}
		else{
			set<int>::iterator u=s.begin();
			if(*u==a[ans[i-1]]){
				u++;
				if(u==s.end()) return cout<<-1,0;
			}
			ans[i]=*u;
		}
		s.erase(ans[i]);
		p.erase(make_pair(deg[ans[i]],ans[i]));
		int v=a[ans[i]];
		if(s.find(v) != s.end()){
			p.erase(make_pair(deg[v],v));
			p.insert(make_pair(deg[v]-1,v));
			deg[v]--;
		}
	}
	for(int i=1; i<=n; ++i) cout<<ans[i]<<' ';
}

Measured memory_bytes: 11392
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__;
const ll MOD = 1000000007;
const int MAX = 200000;

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;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
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;
}
// a^n mod を計算する
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;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int a,b; cin >> a >> b;
    int c=10;
    if(b>10)c=100;
    if(b==100) c=1000;
    int x=a*c+b;
    cerr << x << endl;
    c=1;
    bool f=false;
    while(c<=1000){
        if(x==c*c){
            f=true;
            break;
        }
        c++;
    }
    
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

void main() {
    int a, b;
    scan(a, b);
    int n = b - a;
    int ans = n * (n - 1) / 2 - a;
    writeln(ans);
}










































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        s: [Chars; n],
    }

    let mut counter = vec![0; 5];
    for ns in &s {
        match ns[0] {
            'M' => counter[0] += 1,
            'A' => counter[1] += 1,
            'R' => counter[2] += 1,
            'C' => counter[3] += 1,
            'H' => counter[4] += 1,
            _ => {}
        }
    }

    let mut ans: u64 = 0;
    for bit in 0u64..1 << 5 {
        if bit.count_ones() == 3 {
            let mut sub_ans = 1;
            for i in 0..5 {
                if (bit >> i & 1) != 0 {
                    sub_ans *= counter[i];
                }
            }
            ans += sub_ans;
        }
    }

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


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

int main() {
  int n;
  cin >> n;
  int l = 10000 - n;
  
  cout << l%1000 << endl;
 
  return 0;
}

Measured memory_bytes: 3632
class Room:
    def __init__(self, prev=-1, dist=1 << 64):
        self.prev = prev
        self.dist = dist


n, m = map(int, input().split())
passages = [set() for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    passages[a].add(b)
    passages[b].add(a)

opening = {0}
closing = {0}
guide_points = [-1] * n
while opening:
    next_opening = set()

    for curr_room in opening:
        for next_room in passages[curr_room]:
            if next_room in closing:
                continue

            guide_points[next_room] = curr_room
            next_opening.add(next_room)
            closing.add(next_room)

    opening = next_opening

print('Yes')
print('\n'.join(map(lambda x: str(x + 1), guide_points[1:])))


Measured memory_bytes: 75148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  	int n;
  	cin >> n;
  
  	int m = n % 1000;
  
  	if (m == 0) {
      cout<< 0 << endl; 
    } else {
      cout<< 1000-m << endl; 
    }
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
// g++ -std=c++14 -O3 -fsyntax-only -o main main.cpp

using ll = long long int;

const int MOD = 1e9 + 7;

#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

template <class T>
class my_array{
  private:
    int n;
    vector<T> A;
  public:
    my_array(int k){n = k; A.resize(n);}
    ~my_array(void){};
    // input a_0, a_1, ..., a_(n-1)
    void get(void){
      for(int i = 0; i < n; i++) cin >> A.at(i);
    }
    // sort A
    void sorted(bool flag = true){
      if(flag) sort(A.begin(), A.end());
      else sort(A.begin(), A.end(), greater<T>());
    }
    // print : a_0, a_1, ... a_(n-1)
    void show(void){
      for(int i = 0; i < n - 1; i++) cout << A.at(i) << " ";
      cout << A.at(n - 1) << "\n";
    }
    int solve(int a, int b){
      if(a >= b) return 0;
      int mn_idx = 0, min = 1e9;
      for(int i = a; i < b; i++) if(min > A.at(i)){
        min = A.at(i);
        mn_idx = i;
      }
      for(int i = a; i < b; i++) A.at(i) -= min;
      return solve(a, mn_idx) + min + solve(mn_idx + 1, b);
    }
};

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

int main(void){
  int n; cin >> n;
  my_array<int> a(n);
  a.get();
  cout << a.solve(0, n) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007


    
int main()
{
    
 ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,k;
    cin>>n>>k;
    ll h[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
   ll dp[n];
   for(i=0;i<n;i++)
   {
       dp[i]=INT_MAX;
   }
   dp[0]=0;
   dp[1]=abs(h[1]-h[0]);
   for(i=2;i<n;i++)
   {
       for(j=1;j<=k;j++)
       {
        if(i-j>=0)   
       dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
       }
   //cout<<dp[i]<<endl;
   }
    cout<<dp[n-1]<<endl;
    return 0;
   
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,n;
	string s1,s2;
	cin>>n;
	cin>>s1>>s2;
	for(i=0;i<n;i++) cout<<s1[i]<<s2[i]; 
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	//key:値		最小index,要素数
	map< int, vector<LL> > numMap;
	int N;
	cin >> N;
	vector<LL> temp(2);
	for(int i=0;i<N;++i){
		int a;
		cin >> a;
		if( numMap.find( a ) != numMap.end() ){
			//indexがあるなら、それはより小さいi
			temp = numMap[ a ];
			temp[1]++;
			numMap[a] = temp;
			
		}else{
			temp[0] = i;
			temp[1] = 1;
			numMap[ a ] = temp;
		}
	}
	map<int,vector<LL> >::iterator itr,begin,next;
	itr = numMap.end();
	--itr;
	begin = numMap.begin();
	vector<LL> ans(N,0);
	while(1){
		if( itr == begin ){
			//LL Aval = 0;
			LL Bval = itr->first;
			int index = (itr->second)[0];
			LL num = (itr->second)[1];
			ans[ index ] += Bval*num;
			break;
		}
		next = itr;
		next--;
		LL Aval = next->first;
		LL Bval = itr->first;
		int index = (itr->second)[0];
		LL num = (itr->second)[1];
		
		//indexが呼び出される回数。
		ans[index] += (Bval-Aval)*num;
		
		(next->second)[0] = min((next->second)[0],(LL)index);
		(next->second)[1] += num;

		--itr;
	}

	for(int i=0;i<N;++i){
		cout << ans[i] << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 12800
#include<stdio.h>
  
int main(void)
{
int h,m,s;
int S,a,b;
  
scanf("%d",&S);
  
h=S/3600;
a=S%3600;
m=a/60;
s=a%60;
  
printf("%d:%d:%d\n",h,m,s);
  
return 0;
}

Measured memory_bytes: 592
import sys
input = sys.stdin.buffer.readline

def main():
    H,W = map(int,input().split())
    if (H%3 != 0 and W%3 != 0):
        ans = min(H,W)
        a = H//3
        b = (H-a)*(W//2)
        c = (H-a)*(-(-W//2))
        d = max(a*W,b,c)-min(a*W,b,c)
        a1 = a+1
        b1 = (H-a1)*(W//2)
        c1 = (H-a1)*(-(-W//2))
        d1 = max(a1*W,b1,c1)-min(a1*W,b1,c1)
        s = W//3
        t = (W-s)*(H//2)
        u = (W-s)*(-(-H//2))
        v = max(s*H,t,u)-min(s*H,t,u)
        s1 = s+1
        t1 = (W-s1)*(H//2)
        u1 = (W-s1)*(-(-H//2))
        v1 = max(s1*H,t1,u1)-min(s1*H,t1,u1)
        ans = min(ans,d,d1,v,v1)
        print(ans)
    else:
        print(0)

if __name__ == "__main__":
    main()

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

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


    if(a==b && b==c)
        cout<<"1";
    else if(a==b || b==c || a==c)
        cout<<"2";
    else
        cout<<"3";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int a,b,c,d;
    int i;
    scanf("%d %d %d",&a,&b,&c);
    for(i=0;i<3;i++){
    if(a>b)
    {     
        d = b;
        b = a;
        a = d;
    }else if(b>c){
        d = c;
        c = b;
        b = d;
    }
}
    printf("%d %d %d\n",a,b,c);
    return 0;
}        


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int h,w;
    cin>>h>>w;
    vector<string> vs(h);
    REP(i,h){
        cin>>vs[i];
    }
    bool f;
    REP(i,h){
        REP(j,w){
            f=false;
            if(vs[i][j]=='#'){
                
                if(i-1>=0){
                    if(vs[i-1][j]=='#'){
                        f=true;
                    }
                }
                if(i+1<h){
                    if(vs[i+1][j]=='#'){
                        f=true;
                    }
                }
                if(j-1>=0){
                    if(vs[i][j-1]=='#'){
                        f=true;
                    }
                }
                if(j+1<w){
                    if(vs[i][j+1]=='#'){
                        f=true;
                    }
                }
                if(f==false){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
x = int(input())
base = 100
year = 0
while True:
    year +=  1
    base = int(base * 1.01)
    if(x <= base):
        print(year)
        break

#結果：
#コード長:206 Byte 	
#処理速度：21 ms	
#メモリ： 9096 KB

Measured memory_bytes: 9116
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	ll ans = 0, cnt = 0;
	for(int i = n-1; i >= 0; --i){
		if(s[i] == 'A'){
			ans += cnt;
		}
		else if(i > 0 && s[i] == 'C' && s[i-1] == 'B'){
			++cnt;
			--i;
		}
		else{
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>

using namespace std;

int status[4]={};

int main(void){
  int N;
  cin >> N;
  for(int n=0;n<N;n++){
    string str;
    cin >> str;
    if(str == "AC"){
      status[0]++;
    }else if(str == "WA"){
      status[1]++;
    }else if(str == "TLE"){
      status[2]++;
    }else{
      status[3]++;
    }
  }
  cout << "AC x " << status[0] << endl;
  cout << "WA x " << status[1] << endl;
  cout << "TLE x " << status[2] << endl;
  cout << "RE x " << status[3] << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N =  1e5 + 10;
 
struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(8);
  }
}IO;

int32_t main(){
 string s;
 cin >> s;
 deque<char> a(s.begin(), s.end());
 int Q; cin >> Q;
 bool rev = false;
 while (Q--){
  int cmd;
  cin >> cmd;
  if (cmd == 1){
    rev ^= 1;
  }
  else{
   int curr; char c;
   cin >> curr >> c;
   if (rev){
    if (curr == 1) a.push_back(c);
    else a.push_front(c);
   }
   else{
    if (curr == 1) a.push_front(c);
    else a.push_back(c);
   }
  }
 }
 if (rev)
  reverse(a.begin(), a.end());
 for (auto& it : a)
  cout << it;
 cout << endl;
}



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

int main() {
    for(int i=0; i<3; i++){
        char a;
        cin >>a;
        if(a=='1'){
            cout << "9";;
        }
        else{
            cout << "1";
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(0);cin.tie(0)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define slld(t) scanf("%lld",&t)
#define plld(t) printf("%lld\n",t)
#define sc(t) scanf("%c",&t)
#define pb(x) push_back(x)
#define ii pair<int,int>
#define vi vector<int>
#define vvi vector<vi >
#define vii vector<ii >
#define vvii vector<vii >
#define clr(x) memset(x,0,sizeof(x))
#define rep(i,begin,end) for(__typeof(end) i=begin-(begin>end);i!=end-(begin>end);i+=1-2*(begin>end))
#define M_PI 3.14159265358979323846
#define MOD 1000000007
#define MAX 100005
#define EPS 1e-12
using namespace std;

int main()
{
	int a,b,c,d;
	sd(a); sd(b); sd(c); sd(d);

	int a1 = a*b;
	int a2 = c*d;
	pd(max(a1,a2));
	return 0;
}


Measured memory_bytes: 256