akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ii          int int
#define ll       	long long
#define pi       	pair<int,int>
#define pl       	pair<ll,ll>
#define ps       	pair<string,string>
#define mod      	1000000007
#define INF      	1e18
#define PI       	acos(-1)
#define si(a)    	scanf("%d",&a)
#define ss(a)           scanf("%s",a);
#define sii(a,b)  	scanf("%d%d",&a,&b)
#define siii(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define sl(a)    	scanf("%lld",&a)
#define sL(a)    	scanf("%I64d",&a)
#define sll(a,b) 	scanf("%lld%lld",&a,&b)
#define sLL(a,b)        scanf("%I64d%I64d",&a,&b)
#define slll(a,b,c)     scanf("%lld%lld%lld",&a,&b,&c)
#define sLLL(a,b,c)    scanf("%I64d%I64d%I64d",&a,&b,&c)

//geometry
#define EPS 1e-12
#define _abs(x)    (((x)>0)?(x):-(x))
#define _max(x,y)  ( ((x)>(y))?(x):(y))
#define _min(x,y)  ( ((x)<(y))?(x):(y))

#define E(x,y)	(_abs((x)-(y)) < EPS)
#define Z(x)	(_abs(x) < EPS)
#define ZN(x)	(x < 0 || Z(x))
#define ZP(x)	(x > 0 || Z(x))

//END
#define FR(i,a,b) 	for(ll i=(a);i<(b);i++)
#define F       	first
#define S        	second
#define pb       	push_back

#define mp       	make_pair
#define bg       	begin()
#define en       	end()
#define mem(a,b) 	memset(a,b,sizeof(a))
#define vsort(v)        sort(v.begin(),v.end())
#define REV(v)         reverse(v.begin(),v.end())
#define RET            return(0)
#define  _               ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    string s;
    s=a[0]-32;
    s+=b[0]-32;
    s+=c[0]-32;
    cout<<s;
    RET;
}


Measured memory_bytes: 256
#include <stdio.h>

main(){

   

  int a,b,c,x,y,z;

   

  scanf("%d%d%d",&a,&b,&c);

   

  if(a > b){ 

    x = a;

    a = b;

    b = x;

  }

   

  if(b > c){

    y = b;

    b = c;

    c = y;

  }

   

  if(a > b){

    z = a;

    a = b;

    b = z;

  }

   

  printf("%d %d %d\n",a,b,c);

   

  return 0;

}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int a, b, c; std::cin >> a >> b >> c;
    int x, y; std::cin >> x >> y;
    int ans = inf, ma = max(x, y)+1;
    rep(i, ma) {
        int tmp = i*c*2 + max(0, x-i)*a + max(0, y-i)*b;
        chmin(ans, tmp);
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;

int n,m,X,Y;
bool work(){
    cin>>n>>m>>X>>Y;
    for (int i=1,x;i<=n;i++){
        cin>>x;
        X = max(X, x);
    }
    for (int i=1,y;i<=m;i++){
        cin>>y;
        Y = min(Y, y);
    }
    return X < Y;
}
int main(){
//    freopen("in.txt","r",stdin);
    if (work()) puts("No War");else puts("War");
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define s(x) #x<<" "<<x<<" | "<<
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
#define endl "\n"
const int MSIZE = 1e5+5;;
const int MOD = 1e9+7;
 
 
int main(){
 
    FIO
    int x,y; cin>>x>>y;
    int a = 4*x-y, b = y-2*x; 
    if(a>=0 and b>=0 and a%2==0 and b%2==0 ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 
 
} 

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N;
int ans = 0;

signed main(void) {
    cin >> N;

    int i = 1;
    while(N-i > i*i){
        if((N-i)%i == 0){
            ans += (N-i)/i;
        }
        i++;
    }

    cout << ans << endl;

    return 0;
}


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

void SOLVE(int* dice, int u, int f) {
    int around[4];
    switch(u) {
        case 0 : {
            around[0] = 1;   around[1] = 2;   around[2] = 4;   around[3] = 3;
            break;
        }
        case 1 : {
            around[0] = 0;   around[1] = 3;   around[2] = 5;   around[3] = 2;
            break;
        }
        case 2 : {
            around[0] = 0;   around[1] = 1;   around[2] = 5;   around[3] = 4;
            break;
        }
        case 3 : {
            around[0] = 0;   around[1] = 4;   around[2] = 5;   around[3] = 1;
            break;
        }
        case 4 : {
            around[0] = 0;   around[1] = 2;   around[2] = 5;   around[3] = 3;
            break;
        }
        case 5 : {
            around[0] = 1;   around[1] = 3;   around[2] = 4;   around[3] = 2;
            break;
        }
    }
    int index = 0;
    while(dice[f] != dice[around[index]])   ++index;
    index += 1;
    if(index < 4)   cout << dice[around[index]] << endl;
    else            cout << dice[around[0]] << endl;
}

int main(void) {
    int dice [6];
    int n;
    int u, f;
    int u_index, f_index;
    
    for(int i = 0; i < 6; ++i) {
        cin >> dice[i];
    }
    cin >> n;
    
    for(int i = 0; i < n; ++i) {
        cin >> u >> f;
        u_index = 0;
        f_index = 0;
        while(dice[u_index] != u)   ++u_index;
        while(dice[f_index] != f)   ++f_index;
        SOLVE(dice, u_index, f_index);
    }
    return 0;
}




Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> x >> y;
	int cnt=0;
	rep(i, x+1){
		rep(j, x+1){
			k = y - i - j;
			if(0 <= k && k <= x) ++cnt;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void){
  int n,k,x,y,i,sum=0;
  scanf("%d%d%d%d",&n,&k,&x,&y);
  for(i=1;i<=n;i++){
    if(i>k) sum+=y;
    else sum+=x;
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
#include <math.h>
	using namespace std;
#define lol long long

int N, A, B, C, D;
string S;

bool pos(int a, int b) {
	
	if (b - 2 <= a) {
		return true;
	}
	else if (S[a + 1] == '.') {
		return pos(a + 2, b);
	}
	else if (S[a] == '.') {
		return pos(a + 1, b);
	}
	else {
		return false;
	}
}
	int main()
	{
		cin >> N >> A >> B >> C >> D;
		cin >> S;
		S = S + "l";
		bool can = false;
		
		if (C < D) {
			if (pos(A, C) && pos(B, D)) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			for (int i = B - 2; i < D - 1; i++) {
				if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
					can = true;
				}
			}
			if (can && pos(A, C) && pos(B, D)) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
	}

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

using namespace std;

void dfs(int src, vector<int>& dist, vector<vector<int>>& graph){
  stack<int> s;
  s.push(src);
  vector<bool> used(graph.size(), false);
  used[src] = true;
  
  while(s.size()){
    int node = s.top();
    s.pop();
    
    for(int next : graph[node]){
      if(used[next]) continue;
      
      dist[next] = dist[node] + 1;
      used[next] = true;
      s.push(next);
    }
  }
}

int main(){
  int N;
  cin >> N;
  
  vector<vector<int>> graph(N);
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    --a; --b;
    
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  
  vector<int> dist(N, -1);
  dist[0] = 0;
  dfs(0, dist, graph);
  
  int furthest = -1;
  int max_dist = 0;
  for(int i = 0; i < N; i++){
    if(dist[i] >= max_dist){
      furthest = i;
      max_dist = dist[i];
    }
  }
  
  dist[furthest] = 0;
  dfs(furthest, dist, graph);
  
  max_dist = 0;
  for(int i = 0; i < N; i++) max_dist = max(dist[i], max_dist);
  
  puts(max_dist % 3 == 1 ? "Second" : "First");
  
  return 0;
}

Measured memory_bytes: 16432
/**
 *    author:  tourist
 *    created: 04.01.2020 02:49:37       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 5010;

bitset<N> pref[N];
bitset<N> suf[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = min(a[i], k);
  }
  sort(a.begin(), a.end());
  pref[0][0] = 1;
  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] | (pref[i] << a[i]);
  }
  suf[0][0] = 1;
  for (int i = 0; i < n; i++) {
    suf[i + 1] = suf[i] | (suf[i] << a[n - 1 - i]);
  }
  int low = 0, high = n;
  while (low < high) {
    int mid = (low + high) >> 1;
    int y = k - 1;
    bool has = false;
    if (pref[mid].count() > suf[n - 1 - mid].count()) {
      for (int x = 0; x <= k - 1; x++) {
        if (suf[n - 1 - mid][x]) {
          y = max(y, k - 1 - x);
          while (!pref[mid][y]) {
            --y;
          }
          if (x + y >= k - a[mid]) {
            has = true;
            break;
          }
        }
      }
    } else {
      for (int x = 0; x <= k - 1; x++) {
        if (pref[mid][x]) {
          y = max(y, k - 1 - x);
          while (!suf[n - 1 - mid][y]) {
            --y;
          }
          if (x + y >= k - a[mid]) {
            has = true;
            break;
          }
        }
      }
    }
    if (!has) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  cout << low << '\n';
  return 0;
}


Measured memory_bytes: 6400
//hail to jwalaji
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli h,w,a,b,f,t,e;
set<pair<lli,lli>> st;
multiset<lli> ms;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w;
    for(lli i=0;i<w;i++){
        st.insert({i,i});
        ms.insert(0);
    }
    for(lli i=0;i<h;i++){
        cin>>a>>b;
        auto tl=st.lower_bound({a-1,0}),el=st.lower_bound({b,0});
       e=tl!=el;
       for(;tl!=el;tl=st.erase(tl)){
        tie(t,f)=*tl;
        ms.erase(ms.find(t-f));
       }
       if(e&&b!=w){
        st.insert({b,f});
        ms.insert(b-f);
       }
       if(ms.empty()){cout<<-1<<endl;}
       else{
        cout<<*ms.begin()+i+1<<endl;
       }
    }
}


Measured memory_bytes: 25492
#include <iostream>
#include <cmath>
#include <utility>
#include <algorithm>
#include <cstring>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
#define mp make_pair
#define x first
#define y second

pll sor[2003];
ll arr[2003],dp[2003][2003];

ll rek(int x,int y){
	if(x>y) return 0ll;
	if(dp[x][y]!=-1ll) return dp[x][y];
	int k=y-x+1;
	dp[x][y]=0ll;
	dp[x][y]=max(sor[k].x*(abs(sor[k].y-x))+rek(x+1,y),sor[k].x*(abs(sor[k].y-y))+rek(x,y-1));
	return dp[x][y];
}

int main () {
	ll n;
	cin>>n;
	memset(dp,-1ll,sizeof dp);
	for(ll i=1ll;i<=n;i++){
		cin>>arr[i];
		sor[i]=mp(arr[i],i);
	}
	sort(sor+1,sor+n+1);
	cout<<rek(1,n);



return 0;
}



Measured memory_bytes: 35180
#include <algorithm>
#include <iostream>

using namespace std;

const long long INF = 1e17;

long long dp[200200][3][2];

int main() {
  int n; cin >> n;
  int a[200000]; for (int i = 0; i < n; ++i) cin >> a[i];
  
  if (n % 2 == 0) {
    long long mx = 0, sum = 0;
    for (int i = 0; i < n; ++i) if (i % 2 == 0) sum += a[i];
    mx = sum;
    for (int i = n-2; i >= 0; --i) if (i % 2 == 0) {
      sum += a[i+1] - a[i];
      mx = max(mx, sum);
    }
    cout << mx << endl;
    return 0;
  }
  
  for (int i = 0; i < n; ++i) for (int j = 0; j < 3; ++j)
    for (int k = 0; k < 2; ++k) dp[i][j][k] = -INF;
  
  dp[0][0][0] = 0;
  
  for (int i = 0; i < n-1; ++i) for (int j = 0; j < 3; ++j) {
    dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][1]);
    dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][0] + a[i]);
    if (j > 0) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j-1][0]);
  }
  
  long long ans = dp[n-1][2][0] + a[n-1];
  for (int j = 0; j < 2; ++j) for (int k = 0; k < 2; ++k)
    ans = max(ans, dp[n-1][j][k]);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13712
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef unsigned long lli;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    lli n, k, t, f;
    char ch;
    string z="";
    cin >> n;
    while(n!=0){
        n--;
        k = n % 26;
        ch = (char)(k+97);
        z += ch;
        n /= 26;
    }
    reverse(z.begin(), z.end());
    cout << z << endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 1005

int main()
{
    int n ;

    scanf("%d",&n) ;

    map<int,int> M ;

    for(int i=1; i<=n ; i++)
    {
        int a ;
        scanf("%d",&a) ;
        if( M.find(a) == M.end() ) M[a] = 0 ;
        M[a] = M[a] + 1 ;
    }

    int ans = 0 ;

    for( auto p:M )
    {
        if( p.yy >= p.xx ) ans += (p.yy-p.xx) ;
        else ans += p.yy ;
    }

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

    return 0 ;
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    int c=0;
    int n;
    cin>>n;
    ll ar[n+2];
    for(int i=0; i<n; i++)
    {
        cin>>ar[i];
    }
    int f=1;
    while(f)
    {
        for(int i=0; i<n; i++)
        {
            if(ar[i]%2==1)
            {
                f=0;
                //break;
            }
            ar[i]=ar[i]/2;
        }
        c++;
    }
    cout<<c-1<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
    public static void Main()
    {
        int[] n = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int ans = n[0] + n[1];
        if (23 < ans) ans -= 24;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
 
long long dp[100005],valor[105],peso[105],n;
 
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    long long m,p=0,i,j;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++){
        cin>>peso[i]>>valor[i];
    }
    dp[0]=0;
    for(i=0;i<n;i++){
        for(j=100000;j>=valor[i];j--){
            if(dp[j-valor[i]]>-1) {
                if(dp[j]==-1) dp[j]=peso[i]+dp[j-valor[i]];
                else dp[j]=min(dp[j],dp[j-valor[i]]+peso[i]);
            }
        }
    }
    for(i=100000;i>=0;i--){
        if(dp[i]<=m and dp[i]!=-1){
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 4448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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(){
  string S;
  cin >> S;
  if(S.size()%2){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<S.size(); i+=2){
    if(S.substr(i,2) != "hi"){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n,m;
   cin>>n>>m;
   char a[n][n];
   char b[m][m];

   rep(i,n){
      rep(j,n){
         cin>>a[i][j];
      }
   }
   rep(i,m){
      rep(j,m){
         cin>>b[i][j];
      }
   }
   bool flag=false;
   rep(i,n){
      rep(j,n){
         if(i+m-1>=n || j+m-1>=n) continue;
         bool kari=true;
         rep(k,m){
            rep(l,m){
               if(a[i+k][j+l]!=b[k][l]) kari=false;
            }
         }
         if(kari==true) flag=true;
      }
   }
   flag? cout<<"Yes":cout<<"No";

   






return 0;
}

Measured memory_bytes: 256
for i in range(4):
    t1,n1=map(int,input().split())
    if t1==1:
       print(n1*6000)
    elif t1==2:
        print(n1*4000)
    elif t1==3:
        print(n1*3000)
    elif t1==4:
        print(n1*2000)
        


Measured memory_bytes: 5596
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();

    let mut input: Vec<_> = input.trim().chars().collect();


    if input[0] != 'A' {
        println!("WA");
        return;
    } else {
        input.remove(0);
    }

    if input[1..input.len()-1].iter().filter(|&&c| c == 'C').count() != 1 {
        println!("WA");
        return;
    } else {
        let pos = input[1..input.len()-1].iter().position(|&c| c == 'C').unwrap() + 1;
        input.remove(pos);
    }

    if input.iter().filter(|c| c.is_uppercase()).count() != 0 {
        println!("WA");
        return;
    }

    println!("AC");
}


Measured memory_bytes: 4352
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <ll, ll> pll;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
#define int ll

const int N = 2e5 + 5;
const int INF = 1e10 + 5;

int n, d, a, cur, no[N];
pll p[N];
int ans;

main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> d >> a;
	for(int i = 1; i <= n; ++i) {
		int x, h;
		cin >> x >> h;
		p[i] = mkp(x, h);
	}
	sort(p + 1, p + n + 1);
	
	int cur = 0ll;
	p[n + 1] = mkp(INF, INF);
	
	for(int i = 1; i <= n; ++i) {
		
		int x = p[i].F, h = p[i].S;
		
		cur -= no[i];
		h -= (a * cur);
		
		if(h <= 0) continue;
		
		int cnt = (h / a) + (h % a > 0);
		ans += cnt;	
		cur += cnt;
		
		// x[j] > x + d + d
		int l = i, r = n + 1;
		while(l < r) {
			int mid = (l + r) / 2;
			if(p[mid].F > x + d + d) r = mid;
			else l = mid + 1;
		}
		no[r] += cnt;
	
	}
	cout << ans;
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
	String[] inputS = scan.nextLine().split(" ");
	int q = Integer.parseInt(scan.nextLine());
	String[] inputT = scan.nextLine().split(" ");
	int[] s = new int[n];
	int[] t = new int[q];
	for (int i = 0; i < n; i++) {
	    s[i] = Integer.parseInt(inputS[i]);
	}
	for (int i = 0; i < q; i++) {
	    t[i] = Integer.parseInt(inputT[i]);
	}

	int cnt = 0;
	int high, low, j;
	for (int i = 0; i < q; i++) {
	    int key = t[i];
	    high = n - 1;
	    low = 0;
	    while (true) {
		if (high < low) {
		    break;
		}
		j = (high + low) / 2;
		if (s[j] == key) {
		    cnt++;
		    break;
		} else if (s[j] < key) {
		    low = j + 1;
		} else if (s[j] > key) {
		    high = j - 1;
		}
	    }
	}
	System.out.println(cnt);
    }
}

Measured memory_bytes: 55876
a=input()
b=map(int,raw_input().split())
b.sort()
c=[]
d=0
for i in b:
	if d==i:
		c[-1]+=1
	else:
		c.append(1)
		d=i
ans=0
for i in c:
	ans+=i-1
if ans%2==0:
	print a-ans
else:
	print a-ans-1       

Measured memory_bytes: 11328
/*alurquiza*/
#include <bits/stdc++.h>

using namespace::std;

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

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

	int N;
	cin >> N;

	map<string,int> F;
	pair<int,std::vector<string>> sol;
	for(int i = 1;i <= N;i++){
		string S;
		cin >> S;

		int aux = ++F[S];

		if(aux > sol.first){
			std::vector<string> v = {S};
			sol = make_pair(aux,v);
		}
		else if(aux == sol.first){
			sol.second.push_back(S);
		}
	}

	stable_sort(sol.second.begin(), sol.second.end());

	for(string s : sol.second)
		cout << s << '\n';

	return 0;
}

//g++ -std=c++11 -Wall DS.cpp -o main

Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

int n,k,r,s,p,ans=0;
string t;

void solve() 
{   
    cin>>n>>k>>r>>s>>p>>t;
    REP(i,n){
        if(i>=k&&t[i]==t[i-k])t[i]=0;
        if(t[i]=='s')ans+=r;
        if(t[i]=='p')ans+=s;
        if(t[i]=='r')ans+=p;
    }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 512
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

const ll MAX = 1e9+5;


int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    ll n;
    cin>>n;

    ll arr[n+1];
    for(ll i=1; i<=n; i++){
        cin>>arr[i];
    }

    pair<ll, ll> dp[n+1][n+1];

    for(ll i=0; i<=n; i++){
        for(ll j=0; j<=n; j++){
            dp[i][j] = mp(0, 0);
        }
    }

    for(ll i=1; i<=n; i++){
        dp[i][i] = mp(arr[i], 0);
    }

    for(ll l=2; l<=n; l++){
        for(ll i=1; i<=n-l+1; i++){
            ll s = i, e = i+l-1;

            ll a1, a2;
            a1 = arr[s] + dp[s+1][e].ss;
            a2 = dp[s+1][e].ff;

            pair<ll, ll> p1 = mp(a1, a2);

            a1 = arr[e] + dp[s][e-1].ss;
            a2 = dp[s][e-1].ff;

            pair<ll, ll> p2 = mp(a1, a2);

            dp[s][e] = max(p1, p2);
        }
    }

    cout<<(dp[1][n].ff - dp[1][n].ss)<<endl;

    return 0;
}


Measured memory_bytes: 140928
#include<iostream>
using namespace std;
int main() {
  string A = "abcdefghijklmnopqrstuvwxyz";
  A.size() == 26;
  
  char C;
  cin >> C;
  
  for (int i = 0; i < A.size(); i++) {
     if (C == A.at(i)) {
       cout << A.at(i + 1) << endl;
       break;
     }
  }


}



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

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

	if (a < b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 2616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

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

	cout << (a*b)/2 << endl;

	return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> s;
    int n;
    cin >> n;
    s.resize(n);
    rep(i,n)cin>>s[i];
    rep(i,n-1){
        if(s[i].back()!=s[i+1][0])return no,0;
    }
    map<string,int>m;
    rep(i,n){
        m[s[i]]++;
        if(m[s[i]]==2)return no,0;
    }
    yes;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }


const long long INF = 1LL<<60;
int main() {
    long long N, A, B; cin >> N >> A >> B;
    vector<int> p(N);
    for (int i = 0; i < N; ++i) cin >> p[i];

    // dp[i][j] := i 個まで見て、右にうごさないことを確定した最大の値が j
    vector<vector<long long> > dp(N+1, vector<long long>(N+1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= N; ++j) {
            if (dp[i][j] >= INF) continue;
            if (p[i] > j) {
                // p[i] は右にずらさない
                chmin(dp[i+1][p[i]], dp[i][j]);

                // p[i] を右にずらすことにする
                chmin(dp[i+1][j], dp[i][j] + A);
            }
            else {
                // p[i] を左にずらすしかない
                chmin(dp[i+1][j], dp[i][j] + B);
            }
        }
    }

    // 集計
    long long res = INF;
    for (int j = 0; j <= N; ++j) chmin(res, dp[N][j]);
    cout << res << endl;
}


Measured memory_bytes: 195840
A, B, C, X, Y = map(int, input().split())

ab = min(C * 2, A + B) #A, B1枚ずつ用意するのにかかるお金の最小値
a = min(C * 2, A)
b = min(C * 2, B)
if X >= Y:
    print(ab * Y + a * (X - Y))
else:
    print(ab * X + b * (Y - X))

Measured memory_bytes: 3060
#include <stdio.h>


int main() {
    int n, m;

    while ((scanf("%d%d", &n, &m)) != EOF && (n || m)) {
        int player[1000] = {};
        int i = 0, count = 0, p = n;
        while (p) {
            count += player[i] == 0;
            if (count == m) {
                p--;
                player[i] = 1;
                if (p == 0) {
                    printf("%d\n", i + 1);
                    break;
                }
                count = 0;
            }
            i = (i + 1) % n;
        }
        
    }

    return 0;
}

Measured memory_bytes: 604
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
	int N, K;
	cin >> N >> K;

	int ans = 1;
	for (int i = 0; i < N; i++) {
		if (ans < K) ans *= 2;
		else ans += K;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
                int a = sc.nextInt();
                int b = sc.nextInt();

                if(a ==0 && b == 0){
                    break;
                }
                for(int u = 0;u < a;u++){
                    if(u == 0|| u == a-1){
                        for(int e = 0;e < b;e++){
                            System.out.print("#");
                        }
                    }
                    else
                        for(int e = 0; e < b;e++){
                            if(e == 0||e ==b-1){
                                System.out.print("#");
                            }
                        else{
                            System.out.print(".");
                        }
                    }
                    System.out.println("");
                }                   
                System.out.println("");
        }

    }
}


Measured memory_bytes: 32524
#include<stdio.h>

int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	long long ans=0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++){
		long long t;
		scanf("%lld",&t);
		ans+=t*(i+1)*(h-i)*(j+1)*(w-j);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 2088
import java.math.BigInteger;
import java.util.*;

public class Main {
	double EPS = 10.e-08;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int a = sc.nextInt();
			int [] data = new int[n];
			long sum = 0;
			for(int i = 0; i < n; i++){
				data[i] = i + a;
				sum += data[i];
			}
			int min = Integer.MAX_VALUE;
			int value = 0;
			for(int i = 0; i < n; i++){
				if(min > Math.abs(data[i])){
					min = Math.abs(data[i]);
					value = data[i];
				}
			}
			System.out.println(sum - value);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


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

string s, t;
vector<int> harf_indexs[26];
void cons() {
  for(int i = 0; i< s.size(); i++) {
    int m_harf = s[i] - 'a';
    harf_indexs[m_harf].push_back(i);
  }
}

int bin_search(int m_harf, int k) {
  int l = 0, r = harf_indexs[m_harf].size()-1;
  while(l < r) {
    int mid = (l+r)/2;
    if(harf_indexs[m_harf][mid] > k){
      r = mid;
    }
    else{
      l = mid+1;
    }
  }
  return harf_indexs[m_harf][l];
}

int main() {
  cin >> s >> t;
  cons();
  int k = -1; int s_sayisi = 0;
  for(int i = 0; i < t.size(); i++) {
    int m_harf = t[i]-'a';
    if(harf_indexs[m_harf].empty()) {
      cout << -1 << endl; return 0;
    }
    if(harf_indexs[m_harf].back()<=k){s_sayisi++; k = harf_indexs[m_harf][0];continue;}
    k = bin_search(m_harf, k);
  }
  cout << s_sayisi * s.size() + k+1 << endl;
  return 0;
}


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

long long mod=2019;
struct mint{
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-() const{return mint(-x);}
    mint& operator+=(const mint a){
        if((x+=a.x)>=mod)x-=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x+=mod-a.x)>=mod)x-=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a)const{return mint(*this)+=a;}
    mint operator-(const mint a)const{return mint(*this)-=a;}
    mint operator*(const mint a)const{return mint(*this)*=a;}
    mint pow(long long t)const{
        if(!t)return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1)a*=*this;
        return a;
    }
    mint inv()const{return pow(mod-2);}
    mint& operator/=(const mint a){return *this*=a.inv();}
    mint operator/(const mint a)const{return mint(*this)/=a;}
};
istream& operator>>(istream& is,mint& a){return is>>a.x;}
ostream& operator<<(ostream& os,const mint& a){return os<<a.x;}

int main() {
    string s;
    cin>>s;
    mint n=0;
    V mods(2019,0);
    mint ex=1;
    mods[0]+=1;
    rep(i,s.size()){
        n+=(mint)(s[s.size()-i-1]-'0')*ex;
        mods[n.x]+=1;
        ex*=10;
    }
    ll ans=0;
    rep(i,2019){
        ans+=mods[i]*(mods[i]-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	long long n,m;
	string s,t;
	cin>>n>>m>>s>>t;
	long long gcd=__gcd(n,m),lcm=n*m/gcd,len=n;
	n/=gcd,m/=gcd;
	int a=0,b=0;
	while(a<len)
	{
		if(s[a]!=t[b])
		{
			cout<<-1<<endl;
			return 0;
		}
		a+=n,b+=m;
	}
	cout<<lcm<<endl; 
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
// #define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;

struct _in {
	const _in operator,(int&a)const {
		a = 0; char k = getchar(); int f = 1;
		for(;!isdigit(k); k = getchar()) if (k == '-') f = -1;
		for(; isdigit(k); k = getchar()) a = a * 10 + k - '0';
		a *= f; return*this;
	}
}in;

int mod;
int fpow (int base, int v, int mm = mod) {
	int tot = 1;
	while (v) {
		if (v & 1) tot = 1LL * tot * base % mm;
		base = 1LL * base * base % mm;
		v >>= 1;
	}
	return tot;
}
const int N = 3000 + 5;
int n, S[N][N], C[N][N], powmod[N];

signed main ()
{
	in, n, mod;
	powmod[0] = 1;
	rep (i, 1, n) powmod[i] = (long long)powmod[i - 1] * 2 % (mod - 1);
	S[0][0] = 1;
	rep (i, 1, n + 1) rep (j, 1, i) S[i][j] = (S[i - 1][j - 1] + (long long)j * S[i - 1][j] % mod) % mod;
	rep (i, 0, n) C[i][0] = 1;
	rep (i, 1, n) rep (j, 1, n) C[i][j] = (C[i - 1][j - 1] + (long long)C[i - 1][j]) % mod;
	int ans = 0;
	rep (i, 0, n) {
		int ret = i % 2 ? mod - 1 : 1;
		ret = 1LL * ret * C[n][i] % mod;
		int dl1 = fpow (2, powmod[n - i]), dl3 = fpow (2, n - i), dl2 = 1;
		rep (j, 0, i) {
			int tmp = S[i + 1][j + 1];
			tmp = (long long) tmp * dl1 % mod;
			tmp = (long long) tmp * dl2 % mod;
			ans = (ans + (long long)tmp * ret % mod) % mod;
			dl2 = (long long)dl2 * dl3 % mod;
		}
	}
	printf ("%d\n", ans);
	return 0;
}

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

typedef long long ll;
typedef pair<int,int>P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while (b != 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/
/*--------------------------------------------*/

const int MAX_N = 110000;

int memo[MAX_N]; // memo[i] が i についての答え
int rec(int n) {
    //printf("n=%d\n",n);
    if (n == 0) return 0; // 終端条件
    if (memo[n] != -1) return memo[n]; // すでに探索済みならリターン

    int res = n; // INF の気持ち
    int pow6,pow9;
    // 1, 6, 6^2, ..., を試す (n を超えない範囲で)
    for (pow6 = 1; pow6 <= n; pow6 *= 6) {//printf("6for=%d,nextn=%d\n",pow6/6+1,n-pow6);
res = min(res, rec(n - pow6) + 1);}
    // 1, 9, 9^2, ..., を試す (n を超えない範囲で)
    for (pow9 = 1; pow9 <= n; pow9 *= 9) {//printf("9for=%d,nextn=%d\n",pow9/9+1,n-pow9);
res = min(res, rec(n - pow9) + 1);}

    // メモしながらリターン
    //printf("memo[%d]=%d\n",n,res);
    return memo[n] = res;
}

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

    // テーブルを -1 で初期化
    for (int i = 0; i < MAX_N; ++i) memo[i] = -1;
    cout << rec(N) << endl;
}





Measured memory_bytes: 3840
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, X, Y;
    cin >> N >> X >> Y;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    if(N==1){
        // とるしかない
        p(abs(A[0]-Y));
        return 0;
    }


    ll candidate0 = abs(A[N-1] - Y);
    ll candidate1 = abs(A[N-2] - A[N-1]);

    p(max(candidate0, candidate1));
    
    return 0;
}

Measured memory_bytes: 256
import numpy as np
 
H, W=map(int, input().split())
matrix=np.zeros((H, W))
 
for i in range(H):
  s=input()
  for j in range(W):
    if s[j]=='#':
      matrix[i, j]=1
      
for i in range(H):
  if np.sum(matrix[i, :]==0)==W:
    matrix[i, :]=-1
    
for i in range(W):
  if np.sum(matrix[:, i]<=0)==H:
    matrix[:, i]=-1
    
i=0
for i in range(H):
  if np.sum(matrix[i, :]==-1)==W:
    pass
  else:
    for j in range(W):
      if matrix[i, j]==0:
        print('.', end='')
      elif matrix[i, j]==1:
        print('#', end='')
      else:
        pass
    print()

Measured memory_bytes: 21432
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vl A(N + 1, 0);
  vl DP(N + 3, 0);
  REP(i, M) {
    ll a;
    cin >> a;
    A[a] = 1;
  }
  DP[0] = 1;
  REP(i, N) {
    if (A[i + 1] == 0) {
      DP[i + 1] += DP[i];
      DP[i + 1] %= MOD;
    }
    if (A[i + 2] == 0) {
      DP[i + 2] += DP[i];
      DP[i + 2] %= MOD;
    }
  }
  // REP(i, N + 1)
  cout << DP[N] << endl;
  return 0;
}


Measured memory_bytes: 1792
import string


def main(S):
    if not S[0] == 'A' or S[1] == 'C':
        return 'WA'
    if S.endswith('C'):
        return 'WA'

    count_upper = 0
    for upper in string.ascii_uppercase:
        count_upper += S.count(upper)

    if count_upper != 2:
        return 'WA'

    count_C = 0

    for s in S[2:]:
        if s == 'C':
            if count_C == 1:
                return 'WA'
            else:
                count_C += 1
                continue
        elif not s.islower():
            return 'WA'

    if count_C == 0:
        return 'WA'

    return 'AC'


if __name__ == '__main__':
    S = input()
    print(main(S))


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

struct Chess
{
    vector<vector<bool>> hit;
    vector<vector<bool>> queen;
    
    Chess()
    {
        hit = vector<vector<bool>>(8, vector<bool>(8, false));
        queen = vector<vector<bool>>(8, vector<bool>(8, false));
    }

    void locate(int x, int y)
    {
        queen[x][y] = true;
        
        for (int i=0; i<8; i++)
        {
            hit[x][i]=true;
        }

        for (int i=-7; i<=7; i++)
        {
            if (x+i>=0 && x+i<8)
            {
                hit[x+i][y] = true;
                if (y+i>=0 && y+i<8)
                {
                    hit[x+i][y+i]=true;
                }
                if (y-i>=0 && y-i<8)
                {
                    hit[x+i][y-i]=true;
                }
            }
        }
    }

    bool pos(int x, int y)
    {
        bool ans = true;
        if (hit[x][y] || queen[x][y]) ans=false;
        return ans;
    }

    void test()
    {
        for (int i=0; i<8; i++)
        {
            for (int j=0; j<8; j++)
            {
                if (hit[i][j]) cout<<"o";
                else cout<<"x";
            }
            cout << endl;
        }
    }
};


int main()
{
    int k;
    cin >> k;
    vector<int> X(k);
    vector<int> Y(k);
    vector<vector<int>> kizon(k, vector<int>(2));
    for (int i=0; i<k; i++) cin >> X[i] >> Y[i];
    for (int i=0; i<k; i++) kizon[i][0]=X[i], kizon[i][1]=Y[i];
    sort(kizon.begin(), kizon.end());
    vector<int> tmp_y = Y;
    sort(tmp_y.begin(), tmp_y.end());
    //for (int i=0; i<k; i++) cout << tmp_y[i];
    //cout<< endl;

    vector<int> permutation(8); // 各xにおけるクイーンのy座標を探索 (既存のものを除く)
    for (int i=0; i<8; i++) permutation[i] = i;
    for (int i=k-1; i>=0; i--) permutation.erase(permutation.begin() + tmp_y[i]); //既存のものと同じy座標には置けない
    vector<vector<char>> ans(8, vector<char>(8, '.'));
    do
    {
        bool ok=true;
        //全コマの配置を決定する
        vector<int> haichi = permutation;
        for (int i=0; i<k; i++)
        {
            haichi.insert(haichi.begin() + kizon[i][0], kizon[i][1]);
        }
        //for (int i=0; i<8; i++) cout<<haichi[i];
        //cout<<endl;
        Chess chess;
        //各コマを配置していき不可能なら次の配置を試す
        for (int i=0; i<8; i++)
        {
            if (chess.pos(i, haichi[i]))
            {
                chess.locate(i, haichi[i]);
            }
            else
            {
                ok=false;
                break;
            } 
        }
        
        if (ok)
        {
            for (int i=0; i<8; i++) ans[i][haichi[i]]='Q';
            break;
        }

    } while (next_permutation(permutation.begin(), permutation.end()));

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


Measured memory_bytes: 3164
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define mod 1000000007
#define ll long long
#define mp make_pair
int main()
{
	int n,a[105];
	cin>>n;
	memset(a,0,sizeof(a));
	for(int i=0;i<=25;i++)
	{
		for(int j=0;;j++)
		{
			if((4*i+7*j)>100)break;
			else a[4*i+7*j]=1;
		}
	}
	if(a[n])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256