akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second

int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

signed main(){
	int n;
	cin>>n;
	int a[n];
	r(i,n)cin>>a[i];

	multiset<int>st;

	for(int i=n-1;i>=0;i--){
		set<int>::iterator it = st.upper_bound(a[i]);
		if(it==st.end()) st.insert(a[i]);
		else{
			st.erase(it);
			st.insert(a[i]);
		}
		//cout<<st.size()<<endl;
	}

	cout<<st.size()<<endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 998244353
#define N 200005
int main()
{
    int i,n,t;
    in2(n,t);
    vi v(n);
    read(v,i,n);
    ll ans=t;
    rep(i,n-1)
    {
        if(v[i+1]-v[i]<t)
            ans+=(v[i+1]-v[i]);
        else
            ans+=t;
    }
    llout(ans);
}








Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

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

  int n;
  string s;

  cin >> s;

  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  } else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
using namespace std;
int n, *h, *mem;
int jump(int i = 0)
{
    if(~mem[i])
        return mem[i];
    int ret1 = jump(i + 1) + abs(h[i] - h[i + 1]);
    int ret2 = INT_MAX;
    if(i + 2 < n)
        ret2 = jump(i + 2) + abs(h[i] - h[i + 2]);
    return mem[i] = min(ret1, ret2);
}
int main()
{
    //cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #endif
    scanf("%d", &n);
    h = new int[n];
    mem = new int[n];
    memset(mem, -1, n * sizeof(mem));
    mem[n - 1] = 0;
    for(int i = 0; i < n; i++)
        scanf("%d", h + i);
    printf("%d", jump());
}


Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 136
	// https://atcoder.jp/contests/abc136/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		
		int count = 1;
		
		for (int i = n - 1 ; i >= 1; i--) {    
			if (nums[i - 1] - 1 == nums[i] ) {
				nums[i-1]--;
				count++;
			} else if (nums[i - 1] <= nums[i]) {
				count++;
			} else {
				break;
			}
		}
		
		if (count == n) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 41256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int H, N; std::cin >> H >> N;
  std::vector<int> A(N), B(N); rep(i,N) std::cin >> A[i] >> B[i];

  const ll INF = 1LL<<60;;
  std::vector<std::vector<ll>> dp(N+1, std::vector<ll>(H+1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for(int j=0; j<=H; j++) {
      dp[i+1][j] = std::min(dp[i+1][j], dp[i][j]);

      int next = std::min(j+A[i], H);
      dp[i+1][next] = std::min( dp[i+1][next], dp[i+1][j]+B[i] );
    }
  }

  std::cout << dp[N][H] << std::endl;
  return 0;
}


Measured memory_bytes: 78592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int H, W; cin >> H >> W;
	vector<string>vec(H);
	rep(i, 0, H)cin >> vec[i];
	string s = string(W + 2, '#');
	cout << s << "\n";
	rep(i, 0, H) {
		cout << '#' << vec[i] << '#' << "\n";
	}
	cout << s << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000+5;
int a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int n,m;
    ll sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	double k=1.0*sum*1/(4*m);
	int f=0;
	for(int i=n-1;i>=n-m;i--){
		if(a[i]<k){
			f=1;break;
		}
	}
	if(f)puts("No");
	else puts("Yes");
	return 0; 
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())

	count := 0
	coins := []int{25, 10, 5, 1}

	for _, v := range coins {
		countTmp := num / v
		count = count + countTmp
		num = num - countTmp*v

		if num == 0 {
			break
		}
	}

	fmt.Println(count)

}



Measured memory_bytes: 1088
n, k, c = map(int, input().split())
s = input()

max_ = 0
dp = [0] * (n + 1)
cnt = {0: 0}
for i in range(n)[::-1]:
    max_ = max(dp[min(i + c + 1, n)] + 1, max_)
    if s[i] == "o":
        dp[i] = max_
        if dp[i] not in cnt:
            cnt[dp[i]] = 1
        else:
            cnt[dp[i]] += 1

if max_ > k:
    exit()
  
i = 0
ans = []
while True:
    if i >= n:
        break
        
    if s[i] == "x":
        i += 1
        continue
        
    if k == dp[i]:
        if cnt[k] == 1:
            ans.append(i)
        for j in range(c + 1):
            cnt[dp[min(i + j, n)]] -= 1
        i = i + c + 1
        k -= 1
        continue
    else:
        cnt[dp[i]] -= 1
        i += 1
for i in ans:
    print(i + 1)


Measured memory_bytes: 73428
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

// void yes(){
//   cout << "Yay!" << endl;
//   return;
// }

// void no(){
//   cout << ":(" << endl;
//   return;
// }

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

  int n,k;
  cin >> n >> k;

  if(k != 1) cout << n-k << endl;
  else cout << 0 << endl;

  return 0;
}

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

void Main() {
    int a, b;
    cin >> a >> b;
    if (a * b % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int i,j,k;
char a[1002];

int main(){
	scanf("%s",a);
	for(i=0;i<strlen(a);i++){
		if(a[i]<=67){
			a[i]=a[i]+23;
		}else{
			a[i]=a[i]-3;
		}
	}
	printf("%s\n",a);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(),a.end());
    ll num1 = 0,num2 = 0;
    for(int i = n-1; i >= 0; i--){
        if(a[i] == a[i-1]){
            if(num1){
                num2 = a[i];
                break;
            }
            num1 = a[i];
            i--;
        }
    }
    cout << num1*num2 << endl;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static long R { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            R = CR.GetLong();
            return 2 * Math.PI * R;
        }
    }
}


Measured memory_bytes: 27572
<?php
    /*
        Problem URL : http://abc042.contest.atcoder.jp/tasks/abc042_b
 
        Score  :
        Result :
        Time   : ms
        Memory : KB
     */
 
    ini_set('error_reporting', E_ALL & ~E_NOTICE);
    // define('DEBUG', true);
    define('DEBUG', false);
 
    fscanf(STDIN, "%d %d", $N, $L);

    for ($i = 0; $i < $N; $i++) {
        fscanf(STDIN, "%s", $S[$i]);
    }
    sort($S);

    for ($i = 0; $i < $N; $i++) {
        echo $S[$i];
    }
    echo PHP_EOL;


Measured memory_bytes: 3576
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

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

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

// ref. arihon 3-3
// E: type of data, R: type of query result
template<typename E, typename R>
class SegmentTree {
    public:
        SegmentTree(const int _n, const E inf, R (*f)(E, E)): f(f), inf(inf) {
            n = 1;
            while (n < _n) n *= 2;
            data.resize(2 * n, inf);
        }

        // update data[k] with a
        // time complexity: O(n)
        void update(int k, E a) {
            k += n - 1;
            data[k] = a;
            while (k > 0) {
                k = (k - 1) / 2;
                data[k] = (*f)(data[k * 2 + 1], data[k * 2 + 2]);
            }
        }

        // query value from [a, b)
        // // time complexity: O(n)
        R query(int a, int b) {
            return query(a, b, 0, 0, n);
        }

    private:
        int n;
        R (*f)(E, E);
        const E inf;
        vector<E> data;

        R query(int a, int b, int k, int l, int r) {
            // if [a, b) intersect [l, r) = empty
            if (r <= a || b <= l) {
                return inf;
            }

            // if [a, b) includes [l, r)
            if (a <= l && r <= b) {
                return data[k];
            } else {
                R vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
                R vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
                return (*f)(vl, vr);
            }
        }
};

// {position, hp}
vector<pair<int, int>> enemies;

ll solve(SegmentTree<ll, ll> * const st, const int N, const int D, const int A) {
    ll count = 0LL;
    for (int i = 0; i < N; i++) {
        pair<int, int> enemy = enemies[i];
        const pair<int, int> target = {enemy.first - 2 * D, -1};
        auto p = lower_bound(enemies.begin(), enemies.begin() + i, target,
                [](const pair<int, int> &x, const pair<int, int> &y) {
                    return x.first < y.first;
                });
        // printf("query(%d, %d)\n", p->first, enemy.first);
        ll sum = st->query(p - enemies.begin(), i);
        ll hp = enemy.second;
        hp -= sum * A;
        if (hp > 0) {
            ll k = (hp - 1 + A) / A;
            // printf("i: %d, sum: %lld, k: %lld\n", i, sum, k);
            count += k;
            // printf("update(%d, %d)\n", enemy.first, k);
            st->update(i, k);
        }
    }
    return count;
}

int main(void) {
    int N, D, A;
    cin >> N >> D >> A;

    enemies.resize(N);
    for (int i = 0; i < N; i++) {
        int x, h;
        cin >> x >> h;
        enemies[i] = {x, h};
    }
    sort(enemies.begin(), enemies.end());

    auto f = [](ll x, ll y) {
        return x + y;
    };
    SegmentTree<ll, ll> *st = new SegmentTree<ll, ll>(N + 1, 0LL, f);

    cout << solve(st, N, D, A) << endl;

    delete st;
    return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    vector<int> x(5);
    for (auto &e : x) cin >> e;
    for (int i = 0; i < 5; ++i) if (x[i] == 0) cout << i + 1;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3584
#1は一意
#2は小さい番号の石の数が大きくなるように、大きい番号の石を除きたい

#個数が同順のものを、番号小以外が個数が時点になるまで除いてから、番号少を除く
n = int(input())
a = list(map(int, input().split( )))

cnt = {}#keyは個数、要素は最小番号

for i in range(n):
    if a[i] in cnt:
        cnt[a[i]][0] = min(cnt[a[i]][0],i)
        cnt[a[i]][1]+=1
    else:
        cnt[a[i]] = [i,1]

#個数、最小番号、番号の数    
mins = [[k,cnt[k][0],cnt[k][1]] for k in cnt]
mins.append([0,0,0])
#末端処理になっていない
mins.sort(reverse = True)
#print(mins)
ans = [0]*n

for i in range(len(mins)-1):
    k,cntk,l = mins[i][0],mins[i][1],mins[i][2]
    ans[cntk] += (k-mins[i+1][0])*l
    mins[i+1][2]+=l###=じゃおかしい
    if mins[i+1][1]>mins[i][1]:##追加
        mins[i+1][1] = mins[i][1]
#ans[mins[-1][1]]=n*mins[-1][0]

for ai in ans:
    print(ai)
    





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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

//a,b x
int main(){
	ll A,B; cin>>A>>B;
    if((A+B)%2==0) cout<<(A+B)/2;
	else cout<<"IMPOSSIBLE";
}

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

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

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

  sort(x.begin(), x.end());
  int ans=1e9;
  for(int i=x[0];i<=x[n-1];i++){
int sum=0;
    for(int j=0;j<n;j++){
      sum +=pow(x[j]-i,2);
    }
    ans =min(ans,sum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
typedef struct LIST{
	struct LIST *next;
	struct LIST *prev;
	int value;
}NODE,*PNODE;

PNODE list;
void Add(int);
void Del(int);
void DelFirst();
void DelLast();
void DelNode(PNODE);
void Display();
void Release();

int main() {
	list = (NODE*)malloc(sizeof(NODE));
	list->next = list;
	list->prev = list;
	int fig,n,f;
	char op[13];
	fscanf(stdin, "%d", &n),getchar();
	while (n--) {
		fscanf(stdin, "%[^\n]*s", op),getchar();
		f == 0;
		if (op[0] == 'i') { f = 1; }
		else if (op[0] == 'd') {
			switch (op[6]) {
			case 'F':
				DelFirst();
				f = 0;
				break;
			case 'L':
				DelLast();
				f = 0;
				break;
			default:
				f = 2;
				break;
			}
		}
		if (f) {
			fig = atoi(&op[7]);
			if (f == 1) Add(fig);
			else if (f == 2) Del(fig);
		}
		//Display();
	}
	Display();
	Release();
	return 0;
}

void Add(int tmp){
	PNODE p = (NODE*)malloc(sizeof(NODE));
	p->value = tmp;
	p->next = list->next;
	p->prev = list;
	list->next->prev = p;
	list->next = p;
}

void Del(int tmp){
	PNODE cur = list->next;
	while (cur != list) {
		if (cur->value == tmp) {
			DelNode(cur);
			return;
		}
		cur = cur->next;
	}
}

void DelFirst(){
	DelNode(list->next);
}

void DelLast(){
	DelNode(list->prev);
}

void DelNode(PNODE node){
	if (node == list) return;
	node->next->prev = node->prev;
	node->prev->next = node->next;
}

void Display() {
	if (list->next == list) { puts("list is empty"); return; }
	NODE *p= list->next;
	fprintf(stdout, "%d", p->value);
	p = p->next;
	for (; p != list; p = p->next) fprintf(stdout, " %d", p->value);
	puts("");
}

void Release(){
	NODE *next, *del;
	next = list->next;
	while (next != list){
		del = next;
		next = next->next;
		free(del);
	}
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   string S;
   cin >> S;
   bool n = false, s = false, w = false, e = false;
   rep (i, S.size()) {
      char c = S[i];
      if (c == 'N') n = true;
      if (c == 'W') w = true;
      if (c == 'S') s = true;
      if (c == 'E') e= true;
   }
   if (n == s && w==e) {
      puts("Yes");
   } else {
      puts("No");
   }

   return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b + c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 3540
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, H);
    IN(ll, W);
    IN(ll, M);
    A2IN(ll, h, ll, w, M);
    vi X(W + 1), Y(H + 1);
    ll u = 0;
    ll v = 0;
    set<ii> S;
    REP(i, M)
    {
        S.insert({w[i], h[i]});
        ++X[w[i]];
        ++Y[h[i]];
        if (X[u] < X[w[i]])
        {
            u = w[i];
        }
        if (Y[v] < Y[h[i]])
        {
            v = h[i];
        }
    }
    ll ans = 0;
    REP1(i, H)
    {
        CH(max, ans, X[u] + Y[i] - (ll)S.count({u, i}));
    }
    REP1(j, W)
    {
        CH(max, ans, Y[v] + X[j] - (ll)S.count({j, v}));
    }
    OUT(ans);
}

Measured memory_bytes: 31504
#include <stdio.h>

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

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

  int B[N],mCon = 0;
  long ans = 0,min = 1000000000;
  for (int j=0; j<N; j++) {
    if (A[j] < 0) {
      B[j] = A[j]*(-1);
      mCon++;
    } else {
      B[j] = A[j];
    }
    ans += B[j];
    if (min > B[j]) {
      min = B[j];
    }
  }

  if (mCon%2 == 1) {
    ans = ans - min*2;
  }

printf("%ld\n",ans);
return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>

using namespace std;

int main(void)
{
	int ans;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			ans = i * j;
			printf("%dx%d=%d\n", i, j, ans);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1092
#include <stdio.h>
int main(void){
  char s[100010];
  int n;
  scanf("%d %s",&n,s);
  long long int i,cnt[100]={0},sum=1;
  for(i=0;i<n;i++) {
    int num=s[i]-'a';
    cnt[num]++;
  }
  for(i=0;i<26;i++) sum=(sum*(cnt[i]+1))%1000000007;
  printf("%lld\n",sum-1);
  return 0;
}

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

d = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(d)]
# T = [int(input()) for i in range(d)]
c = 26
# m = int(input())
# Q = [list(map(int,input().split())) for i in range(m)]

ans = 0
L = [[-1] * c for i in range(d)]
T = [-1] * d  # この中には0-25を入れる

for i in range(d):
    ANS = [0] * c
    L[i] = L[i-1][:]
    for k in range(c):
        ANS[k] = S[i][k] + C[k] * (i - L[i][k])
    ind = ANS.index(max(ANS))
    ans += S[i][ind]
    L[i][ind] = i
    for j in range(c):
        ans -= C[j] * (i - L[i][j])
    # print(ans)
    # print(ind + 1)
    T[i] = ind


# print("fans",ans)
# print(L)
# print(T)

K = [[] for i in range(d)]

cp = 5
dp = 5

CC = [[C[i], i] for i in range(c)]
CC.sort(reverse=True)
for i in range(d):
    for k in range(cp):
        K[i].append(CC[k][1])

for i in range(d):
    DD = [[S[i][j], j] for j in range(c)]
    DD.sort(reverse=True)
    for k in range(dp):
        K[i].append(DD[k][1])

# print("K",K)
    
from random import randint

m = 10**5

Q = [[0] * 2 for i in range(m)]
for i in range(m):
    dd = randint(0, d-1)
    # print("dd",dd)
    # print(dd-1,randint(0, len(K[dd-1])-1))
    q = K[dd][randint(0, len(K[dd])-1)]
    Q[i][0] = dd
    Q[i][1] = q

# print(Q)

for i in range(m):
    # print(*T)
    # print(Q)
    dd = Q[i][0]
    q = Q[i][1]
    nans = ans
    # print("dd",dd)
    nans -= S[dd][T[dd]]
    nans += S[dd][q]
    for j in range(dd, d):
        # print("j",j)
        if T[j] == q:
            # print("break")
            break
        nans += C[q] * (j - L[j][q])
        nans -= C[q] * (j - dd)
        L[j][q] = dd
    
    old = T[dd]
    T[dd] = q

    for j in range(dd, d):
        # print("j",j)
        if T[j] == old:
            # print("break")
            break
        oldl = L[j-1][old] if j > 0 else -1
        nans += C[old] * (j - dd)
        nans -= C[old] * (j - oldl)
        L[j][old] = oldl

    # print(nans, ans)

    if nans < ans:
        if i != m-1:
            Q[i+1] = [dd, old]
        else:
            T[dd] = old
    
    ans = nans

# print(max(ans,nans))
for i in T:
    print(i+1)

Measured memory_bytes: 93396
#include "bits/stdc++.h"
using namespace std;

typedef pair<int,int> P;
int N;
int Max;
int Min=12345678;
int a[55];
int s,t;
vector<P> v;

int main() {
	
	cin>>N;
	
	for(int i=0; i<N; i++){
	    cin>>a[i];
	    if(a[i]<Min){
	    	Min=a[i]; s=i;
	    }
	    if(a[i]>Max){
	    	Max=a[i]; t=i;
	    }
	}
	
	for(int i=0; i<N; i++){
		if(-Min>Max) a[i]=a[i]+Min;
		else if(-Min<=Max) a[i]=a[i]+Max;
	}
	
	if(-Min>Max){
		for(int i=N-1; i>=1; i--){
			if(a[i]<a[i-1]){
				a[i-1]=a[i-1]+a[i];
				v.push_back(P(i+1,i));
			}
		}
	}
	else if(-Min<=Max){
		for(int i=0; i<N-1; i++){
			if(a[i]>a[i+1]){
				a[i+1]=a[i+1]+a[i];
				v.push_back(P(i+1,i+2));
			}
		}
	}
	
	int cnt=v.size()+N;
	
	cout<<cnt<<endl;
	
	if(-Min>Max){
		for(int i=0; i<N; i++){
			if(i==s) continue;
			cout<<s+1<<" "<<i+1<<endl;
		}
		cout<<s+1<<" "<<s+1<<endl;
	}
	
	if(-Min<=Max){
		for(int i=0; i<N; i++){
			if(i==t) continue;
			cout<<t+1<<" "<<i+1<<endl;
		}
		cout<<t+1<<" "<<t+1<<endl;
	}
	
	for(P p:v){
		cout<<p.first<<" "<<p.second<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
L,R=map(int,input().split())
# L <= i < j <= R
# (i*j)%2019 の最小値
M=[]
for i in range(L, R):
    for j in range(i+1, R+1):
        #print(i,j)
        M.append((i*j)%2019)
        if M[-1]==0:
            print(0)
            exit()
print(min(M))


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}


int main() {
char c;
cin>>c;
cout<<char(c+1)<<endl;
return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def Z_algo(S):
    n = len(S)
    LCP = [0] * n
    c = 0  # 最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        # i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i + LCP[i - c] < c + LCP[c]:
            LCP[i] = LCP[i - c]
        else:
            j = max(0, c + LCP[c] - i)
            while i + j < n and S[j] == S[i + j]:
                j += 1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP


n = int(readline())
s = read().rstrip().decode()
ans = 0
for i in range(n):
    for j, m in enumerate(Z_algo(s[i:])):
        ans = max(ans, min(j, m))
print(ans)


Measured memory_bytes: 50524
from itertools import *
def g(a,x,b):return a+b if x=='+'else a-b if x=='-'else a*b
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   if g(g(a,x,b),y,g(c,z,d))==10:return f"(({a} {x} {b}) {y} ({c} {z} {d}))"
   if g(g(a,x,g(b,y,c)),z,d)==10:return f"(({a} {x} ({b} {y} {c})) {z} {d})"
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5656
-- capture
local h, w = io.read("*n", "*n", "*l")
local s = h * w
local str = ""
local t = {}
local white = 0
for i = 1, h do
  str = io.read()
  for j = 1, w do
    if(string.sub(str, j, j) == ".") then
      t[(i - 1) * w + j] = 0
      white = white + 1
    else
      t[(i - 1) * w + j] = -1
    end
  end
end
t[1] = 1
local check_pos = {1}
local rem_count, task_idx, step = 1, 1, 1
while(0 < rem_count) do
  local idx = check_pos[task_idx]
  rem_count, task_idx = rem_count - 1, task_idx + 1
  -- left
  if(idx % w ~= 1) then
    if(t[idx - 1] == 0) then t[idx - 1] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx - 1) end
  end
  -- right
  if(idx % w ~= 0) then
    if(t[idx + 1] == 0) then t[idx + 1] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx + 1) end
  end
  -- up
  if(w < idx) then
    if(t[idx - w] == 0) then t[idx - w] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx - w) end
  end
  -- down
  if(idx <= s - w) then
    if(t[idx + w] == 0) then t[idx + w] = t[idx] + 1; rem_count = rem_count + 1; table.insert(check_pos, idx + w) end
  end
end
if(0 < t[s]) then print(white - t[s]) else print(-1) end



Measured memory_bytes: 384
S = [0 for i in range(300000)]
S2 = []
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S2.append(da)
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1
while 1:
    n = int(input())
    if n == 1:break
    #res = [str(n) + ':']
    #res += [x for x in S2 if int(x) <= n and n % int(x) == 0]
    print(str(n) + ':',' '.join([str(x) for x in S2 if n % x == 0 and x <= n]))

Measured memory_bytes: 11016
#include<bits/stdc++.h>
using namespace std;
#define MN 200005
#define LL long long
#define mp make_pair
#define fir first
#define sec second
#define pii pair<int,int>
inline void chkmax(int &a,int b){if(a<b)a=b;}
inline void chkmin(int &a,int b){if(a>b)a=b;}
inline int read(){
	   int a=0,fh=1;char c=getchar();
	   while(c>'9'||c<'0'){if(c=='-')fh=-1;c=getchar();}
	   while('0'<=c&&c<='9'){
		   a=a*10+c-48;
		   c=getchar();
	   }
	   return a*fh;
}
map<string,int>vis;
int Max;
vector<string>Q;
int main(){
	int a,n;
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;++i){
		string S;cin>>S;
		vis[S]++;
		if(Max<vis[S])Max=vis[S],Q.clear(),Q.push_back(S);
		else if(Max==vis[S])Q.push_back(S);
	}
	sort(Q.begin(),Q.end());
	for(int i=0;i<Q.size();++i)cout<<Q[i]<<"\n";
	return 0;
}


Measured memory_bytes: 25456
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
using namespace std;

int main(){
    int N,M;
    while(cin >> N >> M && N){
        vector<int> A(N),W(M);
        for(int i=0;i<N;i++) cin >> A[i];
        for(int i=0;i<M;i++) cin >> W[i];
        set<int> s;
        for(int S=0;S<(1<<M);S++){
            for(int T=S;T>=0;T=(T-1)&S){
                int x = 0,y = 0;
                for(int i=0;i<M;i++){
                    if((S&(1<<i)) && (T&(1<<i))) x += W[i];
                    else if((S&(1<<i)) && !(T&(1<<i))) y += W[i];
                }
                s.insert(x-y);
                if(T==0) break;
            }
        }
        vector<int> unable;
        for(int i=0;i<N;i++){
            if(s.count(A[i])==0 && s.count(-A[i])==0) unable.push_back(A[i]);
        }
        if(unable.empty()){
            cout << 0 << endl;
            continue;
        }
        set<int> kouho;
        for(auto a:s){
            kouho.insert(abs(a-unable[0]));
            kouho.insert(abs(a+unable[0]));
        }
        for(auto u:unable){//O(N)
            if(kouho.empty()) break;
            set<int> nkouho;
            for(auto k:kouho){//O(3^M)
                if(s.count(u-k)!=0 || s.count(u+k)!=0 || s.count(-u-k)!=0 || s.count(-u+k)!=0) nkouho.insert(k);
            }
            kouho = nkouho;
        }
        cout << (!kouho.empty()? *kouho.begin():-1) << endl;
    }
}


Measured memory_bytes: 11420
N, Y = map(int, input().split())
#print(N)
for x in range(N+1)[::-1]:
  for y in range(N+1-x)[::-1]:
    #print(x,y,N-x-y)
    if x*10000+y*5000+(N-x-y)*1000 == Y:
      print(x,y,N-x-y)
      exit(0)
print(-1,-1,-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using M = map<string,ll>;


int main(){
    string S;
    cin >> S;
    ll T=S.size();
    vector<char> vec(T);
    vector<char> vec2(T);
    for(int i=0;i<T;i++){
        vec[i]=S.at(i);
        vec2[i]=S.at(i)
    ;}
    reverse(vec2.begin(), vec2.end());
    ll counter=0;
    for(int i=0;i<T;i++){
        if(vec[i]!=vec2[i]){counter++;}
    ;}
    cout<<counter/2<<endl;

}  



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a < 0 && -a == b){
    cout<<0<<'\n';
  }
  else if(a >= 0){
    cout<<1<<'\n';
  }
  else{
    cout<<-1<<'\n';
  }
  return 0;
}



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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {


	int a;
	string s;
	cin >> a >> s;

	if (a < 3200) {
		cout << "red" << endl;
	}
	else cout << s << endl;
}

Measured memory_bytes: 256
# import math
# import statistics
# import itertools
a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
# H,W,K= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input().split for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

lis=[str(i) for i in range(1,a+1)]

count=0
for i in lis:
    if int(len(i))%2!=0:
        count+=1
print(count)

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

#define int long long

main()
{
  string s;
  
  char val[] = {'N', 'W', 'S', 'E'};
  bool flag[4] = {};
  
  cin >> s;
  for(int i = 0; i < s.size(); i++) {
    for(int j = 0; j < 4; j++) {
      if(val[j] == s[i]) {
	flag[j] = true;
      }
    }
  }

  if(flag[0] == flag[2] && flag[1] == flag[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return (0);
}
  
    


Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
#import itertools
#import heapq
#from collections import deque
#d = deque()

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    mod=998244353
    dp=[0]*(2*(10**5)+10)
    dp[0]=1
    n,k=map(int, readline().rstrip().split())
    #s=set()
    #lr=[0]*(2*(10**5)+10)
    ll=[0]*(2*(10**5)+10)
    rr=[0]*(2*(10**5)+10)
    for i in range(k):
        ll[i],rr[i]=map(int, readline().rstrip().split())
    for i in range(n-1):
        if i > 0:
            dp[i]+=dp[i-1]

        if dp[i] == 0:
            continue

        for j in range(k):
            if i+ll[j] <= n:
                dp[i+ll[j]] += dp[i]
                dp[i+ll[j]]%=mod
            if i+rr[j]+1 <= n:
                dp[i+rr[j]+1] -= dp[i]
                dp[i+rr[j]+1]%=mod
    print(dp[n-1])
    #for i in range(n):
    #    if i > 0:
    #        lr[i]+=lr[i-1]
    #    if lr[i] > 0:
    #        s.add(i)

    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 31232
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();
 
    
    let n: i64 = iter.next().unwrap().parse().unwrap();
    let d: i64 = iter.next().unwrap().parse().unwrap();
    
    // 2d + 1見れる
    let mut man = 0;
    loop {
        if (man * (2 * d + 1) >= n) {break;}
        man += 1;
    }
    
    println!("{}", man);
    
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
using namespace std;
int ren[101];
int main()
{
    int n,p;
    cin >> n;
    for (int i = 0; i < n;i++)
        cin >> ren[i];
    for (int i = 0; i < n;i++)
    {
        if(ren[i]%2==0)
        {
            if(ren[i]%3==0||ren[i]%5==0)
                continue;
            else
            {
                cout << "DENIED" << endl;
                //system("pause");
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 2;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    deque<int> a;
    rep(i, 0, n)
    {
        int x;
        cin >> x;
        if (i % 2 == 0)
            a.push_back(x);
        else
            a.push_front(x);
    }
    if (n % 2 == 1)
        reverse(a.begin(), a.end());
    for (int i : a)
        cout << i << " ";
    cout << "\n";
    return 0;
}

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

//Compiler version g++ 6.3.0

int main()
{
  string s;
   cin>>s;
   for(int i=0;i<s.size();i++){
     if(s[i]==','){
       s[i]=' ';
     }
   }
   cout<<s;
   return 0;
}

Measured memory_bytes: 256