akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    vector<char> x;
    int len = S.length();
    int cnt = 0;
    while(cnt < len){
        dump(cnt)
        if(cnt != len-1){
            if(S[cnt] == 'B' && S[cnt+1] == 'C'){
                x.pb('D');
                cnt += 2;
            }
            else{
                x.pb(S[cnt]);
                cnt++;
            }
        }
        else{
            x.pb(S[cnt]);
            cnt++;
        }
    }
    //cout << printVector(x) << endl;
    LL acnt = 0;
    LL ans = 0;
    for(auto p : x){
        if(p == 'A') acnt++;
        else if(p == 'D') ans += acnt;
        else acnt = 0;
    }
    cout << ans << endl;

}


Measured memory_bytes: 916
import java.util.*;

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

	int mod = 1_000_000_007;

	class P{
		int v;
		int p;
		P(int v, int p){
			this.v=v;
			this.p=p;
		}
	}
	private long pow(long a, int k) {
		if(k==0) return 1;
		if(k%2==0) {
			long tmp = pow(a, k/2);
			tmp *= tmp;
			tmp %= mod;
			return tmp;
		}else {
			long tmp = pow(a, k-1);
			tmp *= a;
			tmp %= mod;
			return tmp;
		}
	}

	private long inv(long a) {
		return pow(a, mod-2);
	}


	long fact[];
	long ifact[];

	private void init(int n) {
		fact = new long[n+1];
		ifact = new long[n+1];
		fact[0]=1;
		for(int i=1; i<=n; i++) {
			fact[i] = fact[i-1]*i;
			fact[i] %= mod;
		}
		ifact[n] = inv(fact[n]);
		for(int i=n-1; i>=0; i--) {
			ifact[i] = ifact[i+1] * (i+1);
			ifact[i] %= mod;
		}
	}

	private long perm(int a, int k) {
		if(a<k) return 0;
		long ret = fact[a] * ifact[a-k];
		ret %= mod;
		return ret;
	}


	ArrayList<ArrayList<Integer>> g = new ArrayList<>();
	long ans = 1;
	int n;
	int k;
	private void dfs(int r) {
		ArrayDeque<P> stack = new ArrayDeque<>();
		stack.push(new P(r,-1));
		while(!stack.isEmpty()) {
			P p = stack.pop();
			int v =p.v;
			if(v==r) {
				ans *= perm(k, g.get(v).size()+1);
				ans %= mod;
			}else {
				ans *= perm(k-2, g.get(v).size()-1);
				ans %= mod;
			}
			for(int u : g.get(v)) {
				if(u==p.p) continue;
				stack.push(new P(u,v));
			}
		}
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		n=sc.nextInt();
		k=sc.nextInt();
		for(int i=0; i<n; i++) {
			g.add(new ArrayList<>());
		}
		init(100005);
		for(int i=0; i<n-1; i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			a--;b--;
			g.get(a).add(b);
			g.get(b).add(a);
		}
		dfs(0);
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 75624
import java.util.*;



public class Main {
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       
       
      int a,b,cnt=0;
      for(;;){
          
       a= sc.nextInt();
       b= sc.nextInt();
       if(a==0&&b==0){break;}
       
       for(int i=1;i<a;i++){
           for(int x=i+1;x<a;x++){
               for(int y=x+1;y<=a;y++){
                   if(i+x+y==b){
                       cnt++; }
                  
                   
               }
               
           }
       }System.out.println(cnt);
       cnt=0;
      }
    } 
     
}




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

int n, m;
vector<int>E[200005];
bool vis[200005];

void dfs(int Now,int dep){
    if(Now == n){
        puts("POSSIBLE");
        exit(0);
    }
    else if(dep > 1) return;
    for(auto Nex : E[Now]){
        if( !vis[Nex] ){
            vis[Nex] = true;
            dfs(Nex, dep + 1);
            //vis[Nex] = false;
        }
    }
}

int main(){
    scanf("%d%d",&n,&m);
    while(m--){
        int x,y;
        scanf("%d%d",&x,&y);
        E[x].push_back(y);
        E[y].push_back(x);
    }
    dfs(1, 0);
    printf("IMPOSSIBLE");
    return 0;

}


Measured memory_bytes: 12144
## coding: UTF-8


s = input()

large = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
small = 'abcdefghijklmnopqrstuvwxyz'

ans = 'no'
for i in range(26):
    if(s == large[i]):
        ans = 'A'
    elif(s == small[i]):
        ans = 'a'

print(ans)

Measured memory_bytes: 61624
#include<iostream>
using namespace std;
	void judge(int a, int b);
	
	int main(void){
		int a, b;
		cin >> a >> b;
		if(a != 0 && b != 0){
			judge(a, b);
		}
		while(1){

			cin >> a >> b;
			if(a == 0 && b == 0){
				break;
			}
			cout << endl;
			judge(a, b);
		}
		return 0;	
	}
	void judge(int a, int b){
		int ans[1000] = {0};
		int j = 0;
		for(int i = a; i <= b; i++){
			if(i%400 == 0){
				ans[j] = i;
				j++;
			}else if(i%4 == 0 && i%100 != 0){
				ans[j] = i;
				j++;
			}
		}
		if(j == 0){
			cout << "NA" << endl;
 		}else{
 			int i;
 			for(i = 0; i < j ; i++){
 				cout << ans[i] << endl;
 			}
 		}
	}

Measured memory_bytes: 2988
#include <stdio.h>

int partition(int *,int ,int );

int main()
{
  int n,c,k, p=0,r;
  int A[100000];
  
  scanf("%d", &n);

  r=n-1;
  
  for(c=0;c<n;c++)
    {
      scanf("%d",&A[c]);
    }
  k=partition(&A[0],p,r);
  
  for(c=0;c<k;c++)
    {
      printf("%d ",A[c]);
    }

  printf("[%d] ",A[k]);

  for(c=k+1;c<n-1;c++)
    {
      printf("%d ",A[c]);
    }
  printf("%d\n",A[n-1]);

  return 0;
}

int partition(int *A,int p,int r){
  int x,y,i,j;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      y=A[i];
      A[i]=A[j];
      A[j]=y;
    }
  }
  y=A[i+1];
  A[i+1]=A[r];
  A[r]=y;
  return i+1;
}
      






Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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(int argc, char const *argv[]) {
  int n;
  cin >> n;
  ll sum = 0;
  rep(i, n+1) {
    if (i % 15 != 0 && i % 3 != 0 && i % 5 != 0) sum += i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(readline())
A = list(map(int, readline().split()))

from collections import defaultdict
d = defaultdict(int)

s = set()
extra = 0
for a in A:
    if a >= 3200:
        extra += 1
    else:
        div = a // 400
        s.add(div)

min_ans = max(1, len(s))
max_ans = len(s) + extra
print(min_ans, max_ans)

Measured memory_bytes: 3316
//FIRST THINK, THEN CODE.


#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}
 
const ll mxn=1e6+5;





int main()
{ 
IOS;


ll n;

cin>>n;

ll tot=0;

unordered_map<ll,ll>m;

vl a(n);

for(int i=0;i<n;i++){
  cin>>a[i];
  m[a[i]]++;
  tot+=a[i];
}

ll q;cin>>q;

while(q--){
  ll b,c;
  cin>>b>>c;
  ll d=m[b];
  tot+=d*(c-b);
  cout<<tot<<endl;
  m[c]+=m[b];
  m[b]=0;
}


 return 0;
 
 
 
}

Measured memory_bytes: 7892
#include<iostream>
#include<string>
#include<set>
#include<cmath>
#include<cctype>
#include<vector>
#include<sstream>

using namespace std;

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

  int count = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '+'){
      count++;
    }else{
      count--;
    }
  }

  cout << count << endl;

  return 0;
}



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


bool dx[MAX_D][MAX_D];

void resetDx();
void makeDx();
void dispDx();
bool checkField(int n);
void make2();
int d;

int main(){
    int n;
    cin >>n;
    for(int i = 0; i < n; i++){
        if(i != 0) cout <<endl;
        resetDx();
        cin >>d;
        if(d == 2){
            make2();
        } else{
        makeDx();
        }
        /*for(int i = 0; i < d; i++){
            for(int j = 0; j < d; j++){
                cout <<dx[i][j];
            }
            cout <<endl;
        }*/
    }
    return 0;
}

void resetDx(){
    for(int i = 0; i < MAX_D; i++){
        for(int j = 0; j < MAX_D; j++){
            dx[i][j] = false;
        }
    }
}

void dispDx(){
    for(int i = 0; i < d; i++){
        for(int j = 0; j < d; j++){
            if(dx[i][j] == true) cout <<'#';
            else cout <<' ';
        }
        cout <<endl;
    }
}

void makeDx(){
    for(int i = 0; i < d; i++){
        dx[i][0] = true;
        dx[0][i] = true;
        dx[i][d - 1] = true;
    }
    int x = d - 1, y = d - 1, mx[4] = {-1, 0, 1, 0}, my[4] = {0, -1, 0, 1}, i = 0;
    bool moveFlg = false;
    while(true){
        while(checkField(x + mx[i]) && checkField(y + my[i]) && !dx[y + my[i] + my[i]][x + mx[i] + mx[i]]){
            if(!moveFlg) moveFlg = true;
            dx[y + my[i]][x + mx[i]] = true;
            x += mx[i]; y += my[i];
        }
        if(!moveFlg) break;
        //cout <<"now = " <<y <<", " <<x <<" iBefore = " <<i <<endl;
        i = (i + 1) % 4;
        int conti = (i + 2) % 4;
        int ny = y + my[i], nx = x + mx[i];
        bool endFlg = false;
        //cout <<"ny = " <<y <<"+" <<my[i] <<"=" <<ny <<", nx = " <<x <<"+" <<mx[i] <<"=" <<nx <<endl;
        for(int j = 0; j < 4; j++){
            if(j == conti) continue;
            else{
                if(checkField(ny + my[j]) && checkField(nx + mx[j])){
                    //cout <<"j = " <<j <<" ny + my[j] = " <<ny + my[j] <<", nx + mx[j] = " <<nx + mx[j];
                    if(dx[ny + my[j]][nx + mx[j]]){
                        //cout <<" true" <<endl;
                        endFlg = true;
                        break;
                    } else{
                        //cout <<" false" <<endl;
                    }
                }
            }
        }
        if(endFlg){
            break;
        }
        //dispDx();
    }
    dispDx();
}

bool checkField(int n){
    bool ret = true;
    if(n < 0 || n >= d) ret = false;
    return ret;
}

void make2(){
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            if(i == 1 && j == 1){
                dx[i][j] = false;
            } else{
                dx[i][j] = true;
            }
        }
    }
    dispDx();
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

//========================================================================//

int main() {
	int n; cin >> n;
	vi p(n);
	Loop(i, n) {
		cin >> p[i];
	}
	int ans = 0;
	Loop(i, n - 2) {
		vi a = { p[i], p[i + 1], p[i + 2] };
		sort(a.begin(), a.end());
		if (a[1] == p[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> B(n+1);
    rep(i,n-1) cin >> B[i+1];
    B[0] = B[n] = INF;
    ll ans = 0;
    rep(i,n){
        ans += min(B[i], B[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

using namespace std;

int main() {
    nl // 163 braces

    int y,d,m;
    char c1, c2;
    cin >> y >> c1 >> d >> c2 >> m;
    cout << (d <= 4 ? "Heisei" : "TBD");

    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; int K;
    cin >> s >> K;
    int N = s.size();
    
    vector<string> substrings;
    for(int i = 0; i < N; i++) {
        for(int j = i; j < min(N, i+K); j++) {
            string now;
            for(int k = i; k <= j; k++) now += s.at(k);
            substrings.push_back(now);
        }
    }
    sort(substrings.begin(), substrings.end());
    unique(substrings.begin(), substrings.end());
  
    cout << substrings.at(K-1) << endl;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  string a;
  ci(a);
  ll b=0,c=0;
  wFor(i,0,a.size()){
    if(a[i]=='0')
      b++;
    else
      c++;
  }
  wFor(i,1,a.size()){
    if(a[i]=='1')
      b++;
    else
      c++;
  }
  co(min(b,c));
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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;}

void solve(){
    ll n,k;cin>>n>>k;
    vec h(n);
    rep(i,n)cin>>h[i];
    vec dp(n+5,LINF);
    dp[0]=0;
    rep(i,n){
        rep(j,1,k+1){
            chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<(s.size()+1)/2;i++){
		if(s[i]!=s[s.size()-i-1])sum++;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS
#define MAX 100000;	//マクロは条件式内では使えない？
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct process {
	char name[10];
	int time;
};


int max = MAX
struct process Q[100000];
int head, tail;

void initialize() {
	head = tail = 0;
}

int isEmpty() {
	return head == tail;
}
int isFull() {
	return head == (tail + 1) % MAX;	//MAX = 7のときhead =4、tail=3となる。head = tailではないのは、配列の要素を全て使うわけではないことが原因。
}										//（入る容量は要素-1。つまりMAX）

void enqueue(struct process x) {
	if (isFull()) {
		printf("これ以上入りません\n");
		return;
	}
	
	Q[tail] = x;
	if (tail + 1 == max) {
		tail = 0;
	}
	else {
		tail++;
	}
}

struct process dequeue() {
	struct process x;
	if (isEmpty()) {
		printf("これ以上取り除けません\n");

	}
	x = Q[head];
	if (head + 1 == max) {
		head = 0;
	}
	else {
		head++;
	}
	return x;
}


int main() {
	int i, n, q, total = 0;
	char nameAndTime[20], nq[15], *cn;
	struct process p[100000];

	initialize();

	fgets(nq, sizeof(nq), stdin);
	cn = strtok(nq, " ");
	n = atoi(cn);
	cn = strtok(NULL, " ");
	q = atoi(cn);

	for (i = 0; i < n; i++) {
		fgets(nameAndTime, sizeof(nameAndTime), stdin);
		cn = strtok(nameAndTime, " ");
		strcpy(p[i].name, cn);
		cn = strtok(NULL, " ");
		p[i].time = atoi(cn);
		total += p[i].time;
		if (total > 1000000) {
			return 0;
		}
		enqueue(p[i]);
	}

	struct process x;
	int	cnt = 0, k = 0, sec = 0;

	while (cnt < n) {
		x = dequeue();
		if (x.time <= 0) {
			enqueue(x);
		}
		else {
			if (x.time - q <= 0) {
				sec += x.time;
				printf("%s %d\n", x.name, sec);
				x.time -= q;
				cnt++;
			}
			else {
				x.time -= q;
				sec += q;
				enqueue(x);
			}
			
		}
	}

}

//


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

using namespace std;

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

  string s; 
  cin >> s;
  string res = "Yes";
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if (i%2 == 0 && s[i] == 'L') {
      res = "No";
      break;
    }
    if (i%2 == 1 && s[i] == 'R') {
      res = "No";
      break;
    }
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200500;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

void discretize(int A[], int n){
    int Acopy[n];
    copy(A,A+n,Acopy);
    sort(Acopy, Acopy+n);
    for (int i=0; i<n; i++){
        A[i] = lower_bound(Acopy, Acopy+n, A[i])-Acopy+1;
    }
}

int N, A[MAXN], B[MAXN], LIS[MAXN], t[4*MAXN], ans[MAXN];
vector<int> adjList[MAXN];
int query(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return -1e9;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(query(v*2, tl, tm, l, min(r, tm)),query(v*2+1, tm+1, tr, max(l, tm+1), r));
}


void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) t[v] = new_val;
    else {
        int tm = (tl + tr) / 2;
        if (pos <= tm) update(v*2, tl, tm, pos, new_val);
        else update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2], t[v*2+1]);
    }
}

void dfs(int u, int p){
	LIS[u]=max(LIS[u], query(1,1,N,1,B[u]-1)+1);
	ans[u]=max(LIS[u],ans[p]);
	int prev=query(1,1,N,B[u],B[u]);
	update(1,1,N,B[u],LIS[u]);
	for (auto v:adjList[u]){
		if(v==p)continue;
		dfs(v,u);
	}
	update(1,1,N,B[u],prev);
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	FOR(i,0,N-1) cin>>A[i];
	discretize(A,N);
	FOR(i,1,N-1){
		int u,v;cin>>u>>v;
		adjList[u].pb(v);
		adjList[v].pb(u);
	}
	FOR(i,1,N) {
		B[i]=A[i-1];
	}
	FOR(i,1,N) LIS[i]=1;
	dfs(1,0);
	FOR(i,1,N)cout<<ans[i]<<"\n";
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
ll W;
ll w[120], v[120];

ll dp[120][100010];

ll rec(int i, int j) {
	if (dp[i][j] >= 0) return dp[i][j];

	ll res;
	if (i == n) res = 0;
	else if (j < w[i]) res = rec(i + 1, j);
	else res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]);

	return dp[i][j] = res;
}

int main(void){
	cin>>n>>W;
	for (int i = 0; i < n; i++) cin>>w[i]>>v[i];

	memset(dp, -1, sizeof(dp));
	printf("%lld\n", rec(0, W));
	
	return 0;
}

Measured memory_bytes: 93952
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int ai[10005];
#define N 1000000
int main()
{
    int a,b,c,x,y;
    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
    int r;
    long long e,s;
    if(x>y)
    {
        r=y;
        e=r*c*2+(x-y)*a;
        s=c*x*2;
    }
    else
    {
        r=x;
        e=r*c*2+(y-x)*b;
        s=y*c*2;
    }
    long long q=x*a,w=b*y;
    if((q+w)>=e&&e<=s)
        printf("%lld\n",e);
    else if((q+w)<e&&(q+w)<s)
        printf("%lld\n",q+w);
    else if(s<(q+w)&&s<e)
        printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sf sacnf
#define pf printf
#define ll long long
#define ull unsigned long long
#define ii pair <int,int>
#define iii pair <int,ii>
#define pll pair <ll,ll>
#define plll pair <ll,pll>
#define Ziru 0
using namespace std;

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

    if(a<b && b<c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return Ziru;
}





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

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

    long long block = a+b;
    long long block_n = n/block;
    long long amari = n%block;
    long long ans = 0;

    if (amari >= a) {
        ans = (block_n+1) * a;
    } else {
        ans = block_n * a + amari;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
d,x = map(int,input().split())
a = [int(input()) for i in range(n)]

cnt = 0
day = 1
for i in range(n):
	while day <= d:
		day += a[i]
		cnt += 1
	x += cnt
	cnt = 0
	day = 1

print(x)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

ull gcd(ull a, ull b)
{
	while (b)
	{
		a %= b;
		swap(a, b);
	}
	return a;
}

void solve()
{
	int n;
	cin >> n;
	ull M;
	cin >> M;

	vector<ull> a(n);
	input(a);

	set<ull> st;

	for (auto to : a)
		st.insert(to/2);

	bool cnt_even = 0;
	bool cnt_odd = 0;

	for (auto to : st)
		if (to % 2 == 0)
			cnt_even = true;
		else
			cnt_odd = true;

	if (cnt_even && cnt_odd)
	{
		cout << 0;
		return;
	}

	ull lcm = 1;
	
	for (auto to : st)
	{
		if (lcm > M)
		{
			cout << 0;
			return;
		}
		lcm = lcm * to / gcd(lcm, to);
		
		if (lcm > M)
		{
			cout << 0;
			return;
		}
	}
	
	for (auto to:st)
		if (lcm / to % 2 == 0)
		{
			cout << 0;
			return;
		}

	cout << (M / lcm) / 2 + M / lcm % 2;

}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

Measured memory_bytes: 5760
#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 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<<25;
const ll INFL = 1223372036854775807;
const ll mod = 1000000007;





int main() {

	int a, b, q;
	cin >> a >> b >> q;

	VLL s(a), t(b);

	sort(ALL(s));
	sort(ALL(t));

	REP(i, a)cin >> s[i];
	REP(i, b)cin >> t[i];
	REP(i, q) {
		ll x;
		cin >> x;
		auto Iter1 = lower_bound(ALL(s), x);
		auto Iter2 = lower_bound(ALL(t), x);
		int j = Iter1 - s.begin();
		int k = Iter2 - t.begin();

		int l, m;

		l = j - 1;
		m = k - 1;

		ll ans = INFL;

		if (l != -1 && m != -1)ans = min(ans, abs(x - min(s[l], t[m])));

		if (j != a && k != b)ans = min(ans, abs(max(s[j], t[k]) - x));
		
		if (m != -1 && j != a)ans = min(ans, abs(s[j] - t[m] + min(s[j] - x, x - t[m])));
		
		if (k != b && l != -1)ans = min(ans, abs(t[k] - s[l] + min(t[k] - x, x - s[l])));

		cout << ans << endl;

	}
	
	return 0;


}


Measured memory_bytes: 2944
import math

A,B=map(int,input().split())

Min=math.ceil(100*A/8)
Max=math.ceil(100*(A+1)/8)-1
P={i for i in range(Min,Max+1)}

MIN=math.ceil(100*B/10)
MAX=math.ceil(100*(B+1)/10)-1
Q={j for j in range(MIN,MAX+1)}

R=P&Q
if len(R)>=1:
    print(min(R))
else:
    print('-1')







    




Measured memory_bytes: 3064
#include <iostream>
#include <map>

using namespace std;

int main(){

  map<string,int> mp;

  int loop,ans=0;
  string str;
  
  cin >> loop;

  for(int i = 0; i < loop; i++){
    cin >> str;

    if(mp[str] != 0){
      mp[str] += 1;
    }
    else{
      mp[str] = 1;
    }
  }

  cin >> loop;

  for(int i = 0; i < loop; i++){
    cin >> str;

    if(mp[str] != 0){
      mp[str] -= 1;
    }
    else{
      mp[str] = -1;
    }
  }

  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    if(ans < itr->second){
      ans = itr->second;
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,head[MAXN],sumE;
int a[MAXN];
int deg[MAXN],line[MAXN];
bool vis[MAXN],mark[MAXN];
int cnt[MAXN],dp[MAXN],f[MAXN];
vector<int> v;
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
queue<int> Q;
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
        read(a[i]);
        ++deg[a[i]];
    }
    for(int i = 1 ; i <= N ; ++i) {
        if(!deg[i]) Q.push(i);
    }
    while(!Q.empty()) {
        int u = Q.front();Q.pop();
        vis[u] = 1;
        if(line[a[u]]) {puts("0");return;}
        line[a[u]] = line[u] + 1;
        if(!(--deg[a[u]])) Q.push(a[u]);
    }
    int ans = 1;
    for(int i = 1 ; i <= N ; ++i) {
        if(!vis[i]) {
            v.clear();
            int p = i;v.pb(i);vis[p] = 1;p = a[p];
            while(p != i) {
                vis[p] = 1;
                v.pb(p);
                p = a[p];

            }
            int n = v.size();
            bool no = 1;
            for(int j = 0 ; j < n ; ++j) {
                mark[j] = 0;
                if(line[v[j]]) no = 0;
            }
            if(no) {cnt[n]++;continue;}
            for(int j = 0 ; j < n ; ++j) {
                for(int k = 0 ; k < line[v[j]] ; ++k) {
                    int t = ((j - k) % n + n) % n;
                    if(mark[t]) {puts("0");return;}
                    mark[t] = 1;
                }
            }
            for(int j = 0 ; j < n ; ++j) {
                if(!line[v[j]]) continue;
                int t = ((j - line[v[j]]) % n + n) % n;
                if(!mark[t]) ans = mul(ans,2);
            }
        }
    }
    for(int i = 1 ; i <= N ; ++i) {
        if(cnt[i]) {
            for(int j = 1 ; j <= cnt[i] ; ++j) dp[j] = 0;
            dp[0] = 1;
            for(int j = 1 ; j <= cnt[i] ; ++j) {
                dp[j] = dp[j - 1];
                if((i & 1) && i != 1) update(dp[j],dp[j - 1]);
                if(j >= 2) {
                    update(dp[j],mul(j - 1,mul(i,dp[j - 2])));
                }
            }
            ans = mul(ans,dp[cnt[i]]);
        }
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 2208
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse = True)

tmp = sum(a) * (1 / (4 * m))
ans = 0

for i in a:
    if i >= tmp:
        ans += 1

    if i < tmp:
        break

print("Yes" if ans >= m else "No")


Measured memory_bytes: 2940
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        System.out.print((x2+y1-y2) + " ");
        System.out.print((y2+x2-x1) + " ");
        System.out.print((x1+y1-y2) + " ");
        System.out.print((y1+x2-x1) + " ");
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
//#define ls x<<1
//#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=11092019;
const int maxn=1e5+100;

void solve(){
	int n;scd(n);
	int x=n%10;
	if(x==3)printf("bon");
	else if(x==0||x==1||x==8||x==6)printf("pon");
	else printf("hon");
}
int main(){
    //IOS;
    //freopen("D:\\data.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
    solve();

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
#include <cctype>
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i==a){
            if(s[i]=='-'){
                continue;
            }else{
                cout<<"No"<<endl;
                return 0;
            }
        }else{
            if(s[i]=='-'){
                cout<<"No"<<endl;
                return 0;
            }else{
                continue;
            }
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
# ABC  104 B, accepted
from collections import Counter

S = input()
if S[0] == 'A':
    t = Counter(S[2:-1])
    if t['C'] == 1:
        S=S.replace('A', '')
        S=S.replace('C', '')
        if S.islower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')



Measured memory_bytes: 3316
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;


int main()
{
	int area[10001];
	area[0] = 1;
	for (int i = 1; i <= 10000; ++i)
		area[i] = area[i-1] + i;

	int n;
	while (scanf("%d\n", &n) != EOF)
		printf("%d\n", area[n]);

	return 0;
}

Measured memory_bytes: 0
#! ruby -Ks

INF = 100000000000000000

class Mqueue
	def initialize
		@d = Array.new(0)
		@s = 0
		@e = 0
	end
	
	def push(num,ind)
		while @s < @e
			if @d[@e - 1][0] < num
				@d[@e - 1].pop
				@e -= 1
			else
				break
			end
		end
		@d[@e] = [num,ind]
		@e += 1
	end
	
	def del(ind)
		if @s < @e
			if @d[@s][1] == ind
				@s += 1
			end
		end
	end
	
	def top
		return -INF if @s == @e
		return @d[@s][0]
	end
end

def make(d,k,a)
	w = Array.new(k * 3)
	n1 = 0
	n2 = 0
	n3 = 0
	(k * 3).times do |i|
		w1 = n1 < k ? d[n1][0] - a[0] : INF
		w2 = n2 < k ? d[n2][0] : INF
		w3 = n3 < k ? d[n3][0] + a[0] : INF
		if w1 < w2
			if w1 < w3
				w[i] = [d[n1][0] - a[0],d[n1][1] - a[1]]
				n1 += 1
			else
				w[i] = [d[n3][0] + a[0],d[n3][1] + a[1]]
				n3 += 1
			end
		else
			if w2 < w3
				w[i] = [d[n2][0],d[n2][1]]
				n2 += 1
			else
				w[i] = [d[n3][0] + a[0],d[n3][1] + a[1]]
				n3 += 1
			end
		end
	end
	return w
end

n,d = gets.split(" ").map{|s| s.to_i}
x = Array.new(n)
y = Array.new(n)
n.times do |i|
	x[i],y[i] = gets.split(" ").map{|s| s.to_i}
end
a1 = Array.new(1){[0,0]}
a2 = Array.new(1){[0,0]}
n1 = n / 2
k1 = 1
k2 = 1
for i in 0...n1
	a1 = make(a1,k1,[x[i],y[i]])
	k1 *= 3
end
for i in n1...n
	a2 = make(a2,k2,[x[i],y[i]])
	k2 *= 3
end
mae = k2 - 1
ato = k2 - 1
qu = Mqueue.new
res = 0
k1.times do |i|
	while ato >= 0
		if -d <= a2[ato][0] + a1[i][0]
			qu.push(a2[ato][1],ato)
			ato -= 1
		else
			break
		end
	end
	while mae >= 0
		if d < a2[mae][0] + a1[i][0]
			qu.del(mae)
			mae -= 1
		else
			break
		end
	end
	res = [res,qu.top + a1[i][1]].max
end
print(res,"\n")

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

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


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

using namespace std;

int main() {
  string S, S1, S2;

  cin >> S;

  if(S.size() % 2 == 0) S.pop_back();
  for(int i = 1;i < S.size();i+=2){
      S1 = S.substr(0, (S.size()-i)/2);
      S2 = S.substr((S.size()-i)/2, (S.size()-i)/2);

      if(S1 == S2){
        cout << S.size() - i << endl;
        return 0;
      }
  }

}



Measured memory_bytes: 256
import math
N = int(input())

cnt = 0
for i in range(1, int(math.sqrt(N)+1)):
    sub = N//i
    cnt += (sub-i+1)*(sub+i)*i - i**2  # 約数の対となるペアも考慮するが平方根だけ別なので除外
cnt = int(cnt)
print(cnt)


Measured memory_bytes: 9160
N, M = gets.split.map(&:to_i)
As = readlines.map(&:to_i)
MOD = 1_000_000_007

def fib(n)
  return 1 if n < 2
  a, b = 1, 1
  n.times{a, b = b, a + b}
  a
end

puts ([0] + As.flat_map{|a| [a - 1, a + 1]} + [N]).each_slice(2).map{|a, b| a > b ? 0 : fib(b - a)}.inject(1){|r, x| r * x % MOD}

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans = 0;
    if (K < A) ans = K;
    else if (K <= A + B) ans = A;
    else ans = A - (K - A - B);
    cout << ans << endl;
}

Measured memory_bytes: 3636
readline = open(0).readline
writelines = open(1, 'w').writelines
Q = int(readline())
ans = []
A = []
def access(p):
    ans.append("%d\n" % A[p])


C = [A.append, access, A.pop].__getitem__
for i in range(Q):
    t, *a=map(int, readline().split())
    C(t)(*a)
writelines(ans)



Measured memory_bytes: 16836
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))
 
#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("WA.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
using namespace std;
LL ac,wa,tle,re;
string s;
int main(){
	
	LL N;
	SL(N);
	while(N--){
		cin>>s;
		if(s=="AC") ac++;
		if(s=="WA") wa++;
		if(s=="TLE") tle++;
		if(s=="RE") re++;
	}	
	
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	
return 0;}




Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cstring>
#include <iomanip>
#include <queue>
#include <deque>
#include <cmath>
using namespace std;
#define inf 280201280201280201
#define mn 100005
#define FLN "test"
#define int long long
typedef pair<int, int> ii;
//constance

//common data structures and templates
template<typename T>
struct SegmentTree{
};
//gb
int n;
string s;
//functions here
void input(){
}
void solve(){
}

//#define LOCAL 1

signed main(signed argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifdef LOCAL
	   freopen(FLN".inp", "r", stdin);
	   freopen(FLN".out", "w", stdout);
#endif
  cin >> s; n = s.length();
  int cur = 0;
  int ans = 0;
  for(int i=0; i< n; ++i){
    if(s[i] == 'W'){
      ++cur;
      ans += (i+1-cur);
    }
  }
  cout << ans;
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
  
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x, a; cin >> x >> a;
	if (x < a)cout << "0" << endl;
	else cout << 10 << endl;
	return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn get_vec_by_lines<T : FromStr>(n : usize) -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for _i in 0..n {
        let x : T = get_one();
        v.push(x);
    }
    return v;
}

fn main() {
    let mut v : Vec<i32> = get_vec();

    println!("{}", v[1] + std::cmp::max(0,(100 * (10 - v[0]))));
}


Measured memory_bytes: 4352