akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll k, x;
    cin >> k >> x;
    vll ans;
    repr(i, -1000000, 1000001){
        if(abs(i-x) <= k-1){
            ans.emplace_back(i);
        }
    }
    rep(i, SZ(ans)){
        cout << ans[i] << (i+1==SZ(ans)?"\n":" ");
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100000
typedef struct P{
  char name[100];
  int time;
}P;
void enqueue(P);
P dequeue(void);
int head=0,tail=0,n;
P Q[N];

int main()
{
  int i,q,b,c,sum;
  P a;
  scanf("%d %d",&n,&q);

  for(i=1;i<=n;i++)
    {
      scanf("%s",Q[i].name);
      scanf("%d",&Q[i].time);
    }
  tail=n+1; head=1;

  while(head != tail)
    {
      a=dequeue();
      if(q<a.time) b=q;    
      else b=a.time;
      a.time -=b;
      sum+=b;
      if(a.time>0) enqueue(a);
      else printf("%s %d\n",a.name,sum);
    }	   

  return 0;
}

void enqueue(P x)
{
  Q[tail] =x;
  tail=(tail+1)%N;
}

P dequeue(void)
{
   P x=Q[head];
  head=(head+1)%N;
  return  x;
}





Measured memory_bytes: 11860
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define lli long long int
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    for(int i = 0; i < s.size(); i = i + 2){
      if(s[i] == '1'){
        a++;
      }
    }
    for(int i = 1; i < s.size(); i = i + 2){
      if(s[i] == '0'){
        b++;
      }
    }
    for(int i = 0; i < s.size(); i = i + 2){
      if(s[i] == '0'){
        c++;
      }
    }
    for(int i = 1; i < s.size(); i = i + 2){
      if(s[i] == '1'){
        d++;
      }
    }
    int ans = 0;
    if(a + b > c + d){
      ans = c + d;
    }
    else{
      ans = a + b; 
    }
    cout << ans;
    return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

    int k, x;
    cin >> k >> x;

    for(int i = x - k + 1; i < x + k; i++) cout << i << " ";
}









Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
double EPS=1e-10;
double add(double a, double b) {
    if (abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
    return a+b;
}
struct P {
    double x, y;
    P() {}
    P(double x, double y) : x(x), y(y) {}
    P operator - (P p) {
        return P(add(x,-p.x),add(y,-p.y));
    }
    double dot(P p) {
        return add(x*p.x,y*p.y);
    }
    double det(P p) {
        return add(x*p.y,-y*p.x);
    }
};
bool comp(const P& p, const P& q) {
    if (p.x!=q.x) return p.x<q.x;
    return p.y<q.y;
}
vector<P> grahamscan(P* ps, int n) {
    sort(ps, ps+n, comp);
    int k=0;
    vector<P> qs(n*2);
    for (int i=0; i<n; i++) {
        while (k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
        qs[k++]=ps[i];
    }
    for (int i=n-2, t=k; i>=0; i--) {
        while (k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
        qs[k++]=ps[i];
    }
    qs.resize(k-1);
    return qs;
}
P ps[100];
int main() {
    int n;
    while (scanf("%d",&n)) {
        if (!n) break;
        for (int i=0; i<n; i++) {
            double x, y; scanf("%lf%*c%lf",&x,&y);
            ps[i]=P(x,y);
        }
        vector<P> qs=grahamscan(ps,n);
        printf("%d\n",n-qs.size());
    }
}

Measured memory_bytes: 0
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

char s[100005];

pii solve(){
    int n = strlen(s+1);
    REP(pos,1,n-1){
        if(s[pos] == s[pos+1]) return mp(pos,pos+1);
        if(s[pos] == s[pos+2]) return mp(pos,pos+2);
    }
    return mp(-1,-1);
}

int main(){
    scanf("%s", s+1);
    pii res = solve();
    printf("%d %d\n", res.fi, res.se);
    return 0;
}


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

using namespace std;

int main()
{
	int n, m,ans=0,min=0,max;
	cin >> n >> m;
	vector<int>l(m), r(m);
	for (int i = 0 ; i < m; i++) {
		cin >> l[i] >> r[i];
	}
	max = r[0];
	for (int j = 0; j < m; j++) {
		if (min < l[j]) min = l[j];
		if (max > r[j]) max = r[j];
	}
	if(max>=min) ans = 1 + max - min;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
fn main() {
    let r = std::io::stdin();
    let mut sc = Scanner::new(r.lock());

    let v = sc.read_line();
    let n : usize = v[0].parse().unwrap();

    let v = sc.read_line();

    let ans: bool = solve(n, v);

    if ans { 
        println!("APPROVED", );
    } else {
        println!("DENIED", );
    }
}
 
fn solve(n: usize, v: Vec<String>) -> bool {
    for i in 0..n {
        let x: usize = v[i].parse().unwrap();
        if x % 2 == 0 { // 偶数
            if x % 3 != 0 && x % 5 != 0 { // 3 でも 5 でも割れない
                return false;
            }
        }
    }

    true
}

pub struct Scanner<R: std::io::Read> (std::io::BufReader<R>);
 
impl<R: std::io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner (std::io::BufReader::new(r))
    }
 
    pub fn read_line(&mut self) -> Vec<String> {
        use std::io::BufRead;
        let mut line = String::new();
        self.0
            .read_line(&mut line)
            .unwrap();
 
        line.split_whitespace()
            .map(|b| b.to_string())
            .collect::<Vec<String>>()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b,c;
 cin >> a >> b>> c;
 if(a+b==c||b+c==a||a+c==b){
   cout << "Yes" << endl;
 }else{
   cout << "No" << endl;
 }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100003;
ll w,h,x,y,n,w0=0,h0=0,a;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>w>>h>>n;

	FOR(i,0,n){
		cin>>x>>y>>a;
		if(a==1){
			if(w0<x)w0=x;
		}else if(a==2){
			if(w>x)w=x;
		}else if(a==3){
			if(h0<y)h0=y;
		}else if(a==4){
			if(h>y)h=y;
		}
	}
	ll ans=(w-w0)*(h-h0);
	if(w-w0<0)ans=0;
	if(ans<0)ans=0;
	pri(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const int MAX_W = 8;
const int MAX_H = 8;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    cin >> h >> w;
    string a[MAX_H];
    rep(i, h) cin >> a[i];
    int x = 0, y = 0;
    bool ans = true;
    h--; w--;
    a[0][0] = '*';
    
    while ((x != w) || (y != h)) {
        if (
            ((x > 0) && (a[y][x - 1] == '#')) ||
            ((y > 0) && (a[y - 1][x] == '#'))
        ) {
            ans = false;
            break;
        }
        
        if ((x < w) && (y < h) && (a[y][x + 1] == '#') && (a[y + 1][x] == '#')) {
            ans = false;
            break;
        }
        
        a[y][x] = '*';
        
        if ((x < w) && (a[y][x + 1] == '#')) {
            x++;
        }
        else if ((y < h) && (a[y + 1][x] == '#')) {
            y++;
        }
        else {
            ans = false;
            break;
        }
    }
    
    if (
        ((x > 0) && (a[y][x - 1] == '#')) ||
        ((y > 0) && (a[y - 1][x] == '#'))
    ) {
        ans = false;
    }
    
    cout << (ans ? "Possible" : "Impossible") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const 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 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;
}


// ----------------------------------------------------------------------------
int main(){
  while(1){
    string S;
    cin >> S;
    if(S == "0"){
      break;
    }
    int sum=0;
    for(int i=0; i<S.size(); i++){
      sum += S[i] - '0';
    }
    cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
n, m = map(int, input().split())
ab = set([i for i in range(1, n+1)])
a = []
b = []
for _ in range(m):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)

for i in ab:
    print(a.count(i) + b.count(i))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    for(;;){
        int H,W; cin >> H >> W;
        if(H==0 && W==0) break;
        rep(i,H){
            rep(j,W){
                if((i+j)%2==0) cout << '#';
                else cout << '.'; 
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

ll power(ll a, ll b) {
  if(b==0) return 1;
  ll res = power(a, b/2);
  res *= res;
  res %= mod;
  if(b&1) {
    res *= a;
    res %= mod;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  if(n==1) n=0;
  else n=1;
  cout<<n;
  return 0;
}


Measured memory_bytes: 3636
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

ll digi_sum(ll x){
	ll ret = 0;
	while(x){
		ret += x%10;
		x /= 10;
	}
	return ret;
}

int main(){
	std::string s;
	std::cin >> s;
	int c1 = 0, c2 = 0;
	REP(i, 0, s.size()){
		c1 += s[i]-'0';
		if(i==0) c2 += s[i]-'1';
		else c2 += 9;
	}
	printf("%d\n", std::max(c1, c2));
	return 0;
}



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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

template<typename T> struct Dinic{
	struct edge{
		int to,rev;
		T cap;
	};
	vector< vector<edge> > G;
	vector<int> level,iter;
	void init(int n){
		G.assign(n,vector<edge>());
		level.assign(n,0);
		iter.assign(n,0);
	}
	void add_edge(int from,int to,T cap){
		G [from].push_back(edge{to,int(G [to].size()),cap});
		G [to].push_back(edge{from,int(G [from].size()) - 1,0});
	}
	void bfs(int s){
		fill(level.begin(),level.end(),-1);
		queue<int> q;
		level [s] = 0;
		q.push(s);
		while(q.empty() == false){
			int curr = q.front();
			q.pop();
			for(int i = 0;i < int(G [curr].size());i++){
				edge& e = G [curr] [i];
				if(e.cap > 0 && level [e.to] < 0){
					level [e.to] = level [curr] + 1;
					q.push(e.to);
				}
			}
		}
	}
	T dfs(int curr,int t,T f){
		if(curr == t) return f;
		for(int& i = iter [curr];i < int(G [curr].size());i++){
			edge& e = G [curr] [i];
			if(e.cap > 0 && level [e.to] > level [curr]){
				T d = dfs(e.to,t,min<T>(f,e.cap));
				if(d == 0) continue;
				e.cap -= d;
				G [e.to] [e.rev].cap += d;
				return d;
			}
		}
		return 0;
	}
	T max_flow(int s,int t){
		T flow = 0,d;
		while(true){
			bfs(s);
			if(level [t] < 0) break;
			fill(iter.begin(),iter.end(),0);
			while((d = dfs(s,t,numeric_limits<T>::max())) > 0) flow += d;
		}
		return flow;
	}
};

int N,M;

int main()
{
	scanf("%d%d",&N,&M);
	Dinic<int> din;
	din.init(N);
	FOR(i,0,M){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		din.add_edge(u,v,c);
	}

	printf("%d\n",din.max_flow(0,N - 1));

	return 0;
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll; 

ll inf =1e9+7;

#define pi 3.14159265358979323846L
bool isprime(ll a)
{
	
	ll cnt=0;	
	for(ll i=1;i*i<a;i++)
	{
		
	 	if(a%i==0)
	 	{
	 		cnt+=2;
		 }
		
		
	}
	
		if(cnt==2)
		return true;
		else
		return false;
		
}
ll mod(ll a)
{
	if(a<inf)return a;
	else
	return a%inf;
}
void solve()
{
	ll s,w;
	cin>>s>>w;
	if(w>=s)cout<<"unsafe";
	else
	cout<<"safe";
}
int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


Measured memory_bytes: 3564
#include <stdio.h>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> pii;
vector<vector<pii> > v;
int visit[100001];
int N;
void BFS(int sx){
	queue<int> q;
	visit[sx]=1;
	q.push(sx);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto it : v[x]){
			int nx=it.first, c=it.second;
			if(visit[nx]==0){
				q.push(nx);
				if(c%2) visit[nx]=3-visit[x];
				else visit[nx]=visit[x];
			}
		}
	}
}
int main(){
	scanf("%d",&N);
	v.resize(N+1);
	for(int i=0;i<N-1;i++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		v[a].push_back({b,c});
		v[b].push_back({a,c});
	}
	for(int i=1;i<=N;i++){
		if(visit[i]==0) BFS(i);
	}
	for(int i=1;i<=N;i++){
		if(visit[i]==0) printf("1\n");
		else printf("%d\n",visit[i]-1);
	}
}

Measured memory_bytes: 6784
gets.to_i.times{
  train = gets.chomp
  ans=[]
  train.gsub!(/-/,"")
  hash = Hash.new
  flag = false
  train.each_char{|c|
    if c==">"
      flag = false
    elsif c=="<"
      flag = true
    elsif hash.include?(c)
      next
    else
      flag ? ans.unshift(c) : ans<<c
      hash[c]=true
    end
  }
  puts ans.join
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  int ans = max(0LL, a-2*b);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
main = do
    fs <- getLine
    ss <- getContents
    let ls = map (map (\x -> read x :: Int)) $ map words $ lines ss
    let tbl = (map showCalcedRow ls) ++ [showCalcedCol ls]
    mapM_ putStrLn tbl

showCalcedRow :: [Int] -> String
showCalcedRow l = unwords $ map show $ l ++ [sum l]

showCalcedCol :: [[Int]] -> String
showCalcedCol ls = unwords $ map show total
  where
    total = subtotal ++ [sum subtotal]
    subtotal = map (sumCol ls) [0..((length $ ls!!0)-1)]
    sumCol ls idx = sum $ map (\line -> line!!idx) ls


Measured memory_bytes: 5400
#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
using namespace std;


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  
  int A,D;
  string B,C;
  cin >> A >> B;
  C = "Yes";
  
  if(A%2==1){
    C = "No";
  }
  else{
    D = A/2;
    for (int i = 0; i<D;i++){
      if(B.at(i) != B.at(i+D)){
       C = "No";
      }
    }
  }
  cout << C << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main (String[] args) {

//	パターン1（Aから順番に使って足していく）
//	変数を読み込む
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int total = 0;  //合計を入れる変数

//	Aから順に、合計K枚になるまで足していく
		if(A >= K) {  //A>KならKの数を表示で終了
			total = K;
			System.out.println(total);
			return;
		}
		else {  //A＜Kの場合は続く
			total = A;
		}
      
//	BがK-A枚より多いか少ないかで判断
		if(B < K-A) {  //B<=K-AならK-A-Bの数分-1をする
			total -= K-A-B;
			System.out.println(total);
		}
		else {  //B>K-Aならそのまま表示
			System.out.println(total);
		}
	}
}

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

int main(int argc, char const *argv[])
{
	int t,d,l;
	while(cin>>t>>d>>l,t)
	{
		int x,ans=0,w=0;
		for (int i = 0; i < t; ++i)
		{
			cin>>x;
			if(i==t-1);
			else if(x>=l) ++ans,w=d-1;
			else if(w>0) ++ans,--w;
			else w=0;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  string s,ans;cin >> s;
  for(auto &i:s){
    if(i=='B'&&!(ans.empty())) ans.pop_back();
    else if(i!='B') ans.push_back(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  ll K;
  cin >> N >> K;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vi bp(50,0);
  rep(i,N) {
    rep(j,50) {
      if((A[i]>>j)&1) {
        bp[j]++;
      }
    }
  }
  ll ans = 0;
  drep(j,50) {
    if(bp[j] <= (N-bp[j])) {
      ll num = (1ll<<j);
      if(num+ans <= K) {
        ans += num;
      }
    }
  }
  ll sum = 0;
  rep(i,N) {
    sum += A[i] ^ ans;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String altar = sc.nextLine();
		
		int left = 0;
		int right = altar.length() -1;
		int out = 0;
		while(left < right) {
			char leftcolor = altar.charAt(left);
			char rightcolor = altar.charAt(right);
			if(leftcolor == 'W' && rightcolor == 'R') {
				out++;
				right--;
				left++;
			}
			else {
				if(rightcolor == 'W') right--;
				if(leftcolor == 'R') left++;
			}
		}
		
		System.out.println(out);
	}
}


Measured memory_bytes: 41648
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int a, b;
	a = N / 100;
	b = N % 10;

	if (a == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, H;
    cin >> N >> H;
    vector<int> b(N, 0);
    int a = 0;
    for(int i=0; i<N; i++){
        int x, y;
        cin >> x >> y;
        a = max(a, x);
        if(b[i] != a)
            b[i] = y;
    }
    sort(b.begin(), b.end(), greater<int>());
    for(int i=1; i<N; i++)
        b[i] += b[i-1];
    int ans = H / a;
    if(H % a != 0) ans++;
    for(int i=0; i<N; i++){
        int rm = H-b[i];
        if(rm <= 0){
            ans = min(ans, i + 1);
            continue;
        }
        int cnt = rm / a;
        if(rm % a != 0) cnt++;
        cnt += i + 1;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            
            while((line = stdReader.readLine()) != null) {
                int n = Integer.parseInt(line);
                
                System.out.println((int)Math.pow(n, 3));
            }
            stdReader.close();
        } catch(Exception e) {
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 24212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)(1e18)
#define mod 1000000007

int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        ll a,b,c,k;
        cin>>a>>b>>c>>k;

        if( k<=a )
            cout<<k;
        else if( k<=a+b )
            cout<<a;
        else
        {
            ll ans=a-(k-(a+b));
            cout<<ans;
        }
    }
    return 0;
}












Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
bool seive[100005];
void SieveOfEratosthenes(ll n)
{ memset(seive, true, sizeof(seive)); for (ll p=2; p*p<=n; p++) if (seive[p] == true) for (ll i=p*p; i<=n; i += p) seive[i] = false; }
// ll a[11*LIM]={0},b[11*LIM]={0};
// vp64 v[LIM];
typedef struct 
{
	ll one,two,three;
}data;






int main()
{
	fast;
	ll n,m;
	cin>>n>>m;
	ll a[n];
	ll sum=0;
	for (ll i=0;i<n;i++)
	{
		
		cin>>a[i];
		sum+=a[i];
	}
	ll f=0;
	for (ll i=0;i<n;i++)
	{
		if (a[i]>=(sum+4*m-1)/(4*m))
		{
			f++;
		}
	}
	if (f>=m)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <complex>
#include <cmath>

using namespace std;

typedef complex<double> Point;

bool eqv(double d1, double d2) {
    return abs(d1-d2) < 1e-10;
}

double r_(double x) {
    if(abs(x) < 0.001) return 0;
    return x;
}

int main() {
    int N;

    cin >> N;
    while(N--) {
        double x1, x2, x3, y1, y2, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Point p1(x1, y1), p2(x2, y2), p3(x3, y3);

        //³·è
        double R = abs(abs(p3-p2) / sin(arg(p2-p1) - arg(p3-p1))) / 2;

        Point vb = p3-p2;
        double len = sqrt(R*R - norm(vb)/4.0);
        Point vbh = vb * Point(0, 1);
        Point center = p2 + vb/2.0 + vbh*len/abs(vbh);
        if(eqv(abs(center-p1), R) && eqv(abs(center-p2), R) && eqv(abs(center-p3), R)) {}
        else center = p2 + vb/2.0 - vbh*len/abs(vbh);
        printf("%.3f %.3f %.3f\n", center.real(), center.imag(), R);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

ll A, B, C, X, Y;

int main()
{
        cin >> A >> B >> C >> X >> Y;
        if (A + B <= 2 * C) {
                cout << A * X + B * Y << endl;
                return 0;
        }
        ll Z = 2 * min(X, Y);
        X -= Z/2;
        Y -= Z/2;
        if (A > 2 * C) {
                Z += 2 * X;
                X = 0;
        }
        if (B > 2 * C) {
                Z += 2 * Y;
                Y = 0;
        }
        cout << A * X + B * Y + C * Z << endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
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;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  ll K;
  cin >> N >> M >> K;
  vector<ll> A(N),B(M);
  for(int i=0;i<N;i++)  cin >> A.at(i);
  for(int i=0;i<M;i++)  cin >> B.at(i);

  vector<ll> sumA(N+1,0);
  for(int i=0;i<N;i++)  sumA.at(i+1)=sumA.at(i)+A.at(i);
  vector<ll> sumB(M+1,0);
  for(int i=0;i<M;i++)  sumB.at(i+1)=sumB.at(i)+B.at(i);

  int ans=0;
  for(int i=0;i<N+1;i++){
    ll T=K-sumA.at(i);
    if(T<0) break;

    int tmp=upper_bound(sumB.begin(),sumB.end(),T)-sumB.begin();
    chmax(ans,i+tmp-1);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9528
N = int(input())
D = [[] for _ in range(N)]
for i in range(N):
    D[i] = tuple(map(int, input().split()))

INIT = -1
dp = [[INIT, INIT, INIT] for _ in range(N)]
dp[0][0] = D[0][0]
dp[0][1] = D[0][1]
dp[0][2] = D[0][2]

for i in range(1, N):
    for j in range(3):
        tmp = INIT
        for k in range(3):
            if k == j:
                continue
            tmp = max(tmp, dp[i-1][k] + D[i][j])
        dp[i][j] = tmp

print(max(dp[N-1]))


Measured memory_bytes: 40212
#include<cstdio>

int main() {
	char s[5];
	scanf("%s", &s);
	if (s[0] == s[1]&&s[1]== s[2] || s[3] == s[2]&&s[2] == s[1]) {
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
#define print_no_indention(n) std::cout << n
using namespace std;


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

    if(k - a >= 0){
        k = k - a;
        a = 0;
    }
    else if(k - a < 0){
        a = a - k;
        k = 0;
    }
    if(k - b >= 0){
        k = k - b;
        b = 0;
    }
    else if(k - b < 0){
        b = b - k;
        k = 0;
    }

    print(a);
    print(b);
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a,b;
  cin>>a>>b;
  int cnt=0;
  for(int i=0;i<3;i++)
  {if(a[i]==b[i])
    cnt++;
  }
  cout<<cnt<<endl;
  
  
return 0;  
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))

    amax = max(a)

    from collections import Counter

    counter = Counter(a)

    ans = 0
    for i in range(amax + 1):
        cnt = 0
        cnt = counter[i - 1] + counter[i] + counter[i + 1]
        ans = max(ans, cnt)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14312
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] s = scanner.nextLine().toCharArray();
        char[] t = scanner.nextLine().toCharArray();
        int count = 0;
        for(int i=0; i <=2 ; i++) {
            if(s[i]==t[i]) {
                count++;
            }
        }
        System.out.println(count);
    }
}


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

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= 9; i++) {
		for(int j = 1; j <= 9; j++) {
			if(i * j == n)  {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

// GCC __gcd(long long A, long long B)

ll gcd(ll a, ll b){
  if(a == 0) return b;
  return gcd(b%a, a);
}

ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


int main() {
  int A, B;

  cin >> A >> B;

  cout << lcm(A, B) << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	reverse(a.begin(), a.end());
	int l = 2;
	int r = 2;
	for (auto t : a) {
		int up = (r / t) * t;
		if (l <= up) {
			//
		} else {
			cout << -1 << endl;
			return 0;
		}
		int nl = ((l + t - 1) / t) * t;
		int nr = up + t - 1;
		l = nl;
		r = nr;
	}
	cout << l << ' ' << r << endl;
}

Measured memory_bytes: 4000
#include<stdio.h>
int main(){
  int a = 0, b = 0, c = 0;
  scanf("%d %d %d", &a, &b, &c);
  if (a < b && b < c) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    
    int n;
    cin >> n;
    
    rep(i,n){
        string t;
        cin >> t;
        
        if(t == "print"){
            int a,b;
            cin >> a >> b;
            cout << s.substr(a,b-a+1) << endl;
        }
        else if(t == "reverse"){
            int a,b;
            cin >> a >> b;
            reverse(s.begin()+a, s.begin()+b+1);
        }
        else if(t == "replace"){
            int a,b;
            string str;
            cin >> a >> b >> str;
            
            s = s.replace(a, b-a+1, str);
        }
    }
}



Measured memory_bytes: 3208
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
prev = -1
ans = 0

for i,dish in enumerate(A):
    if prev+1 == dish:
        ans += C[prev-1]
    prev = A[i]
    ans += B[i-1]

print(ans)

Measured memory_bytes: 3064
/**** 
     Author: Moudud Ahmed
****/
#include <bits/stdc++.h>
#define MOD 1000000007
#define Long long long int
#define pii pair<int,int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb(x) push_back(x)
#define pi acos(-1)
#define mp(x, y) make_pair(x, y)
#define rep(a) sort(a.begin(),a.end())
#define rrep(a) sort(a.rbegin(), a.rend())
#define gap                        " "
#define FOR(start, end)            for(int i=start; i<end; i++)
#define FORR(start, end)           for(int j=start; j<end; j++)
#define RFOR(start, end)           for(int k=start-1; k>=end; k--)
using namespace std;
class ANewYearandtheChristmasOrnament
{
	public:
		void solve(std::istream& in, std::ostream& out)
		{
			Long x, y, ans=0;
			cin>>x>>y;
			ans+=(x*(x-1))/2;
			ans+=(y*(y-1))/2;
			cout<<ans<<endl;
		}
};
int main()
{
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(0);
	ANewYearandtheChristmasOrnament Solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	int t=1;
 //   cin>>t;
	while(t--)
	{
		Solver.solve(in, out);
	}
	return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

ll dp[220000];

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

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

    for(int i = 0; i < 220000; i++) dp[i] = INF;

    dp[0] = 0;

    for(int i = 0; i < n; i++){
        dp[i + 1] = min(dp[i] + abs(x[i + 1] - x[i]) * a, dp[i] + b);
    }

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


}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, m;
	cin >>n >>m;

	vector<ll> a(n), b(n+1);
	rep(i, n) cin >>a[i];
	map<ll, ll> mp;
	rep(i, n) b[i+1] = (b[i] + a[i]) % m;
	rep(i, n+1) mp[b[i]]++;
	ll ans =0;
	for(auto x: mp){
		ans += x.second * (x.second -1) /2;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 5760
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

lim = 2*(10**6)  # 必要そうな階乗の限界を入れる
fact = [1] * (lim+1)
fact_inv = [1] * (lim+1)
for n in range(1, lim+1):
    fact[n] = (fact[n-1] * n) % mod
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
    fact_inv[n-1] = (n * fact_inv[n]) % mod
def C(n, r):
    return (((fact[n] * fact_inv[r]) % mod) * fact_inv[n-r]) % mod

K = INT()
S = input()
L = len(S)

ans = 0
for i in range(K+1):
    ans += pow(26, K-i, mod)*pow(25, i, mod)*C(i+L-1, i)
    ans %= mod
print(ans)


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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}


int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> cnt(n+1), depth(n+1);
    vector<int> defeated(n+1);
    for(int i = 2; i <= n; i++) {
        cin >> defeated[i];
        cnt[defeated[i]]++;
    }
    set<pair<int,int>> leafs;
    for(int i = 1; i <= n; i++) {
        if(cnt[i] == 0) {
            leafs.insert({depth[i], i});
        }
    }
    int itr = n-1;
    while(itr--) {
        auto t = *leafs.begin();
        leafs.erase(t);
        int x = t.second;
        cnt[defeated[x]]--;
        depth[defeated[x]] = 1+max(depth[defeated[x]], depth[x]);
        if(cnt[defeated[x]] == 0) {
            leafs.insert({depth[defeated[x]], defeated[x]});
        }
    }
    cout << depth[1] << endl;
}





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

using namespace std;
int main() {
    int n;
    int a;
    int b;
    int c;
    int d;
    int sum = 0;
    int max_v = 0;

    cin >> n;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    int x = (n-1)/a + 1;
    int y = (n-1)/c + 1;


    cout << min(x*b, y*d) <<endl;

    return 0;
}


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

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> x(n);
	for(int i = 0;i<n;i++)cin >> x[i];
	int a = 1e9;
	for(int i = 0;i<n-k+1;i++)
	{
		if(x[i]<0&&x[i+k-1]<0)
		{
			a = min(a,abs(x[i]));
		}
		else if(x[i]>=0&&x[i+k-1]>=0)
		{
			a = min(a,x[i+k-1]);
		}
		else
		{
			a = min(a,min(abs(x[i]),abs(x[i+k-1]))+x[i+k-1]-x[i]);
		}
		//cout<<a<<endl;
	}
	cout<<a<<endl;

	return 0;
}

Measured memory_bytes: 640
import copy

N = int(input())

S = []
P = []
for i in range(N):
	s, p = input().split()
	S.insert(i, s)
	P.insert(i, p)

list = []
for i in range(N):
	temp = [S[i], int(P[i])]
	list.append(temp)

clone = copy.copy(list)

clone.sort(key=lambda x:x[1], reverse=True)
clone.sort(key=lambda x:x[0], reverse=False)

for i in range(N):
	print(list.index(clone[i])+1)


Measured memory_bytes: 3444
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			System.out.println(new StringBuilder(sc.next()).reverse().toString());
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

Measured memory_bytes: 11000
def main():
    import sys
    N=int(sys.stdin.readline())
    if N==1:
        print(0)
        return
    m=10**9+7
    res=pow(10,N,m)-(2*pow(9,N,m)-pow(8,N,m))%m
    if res<0:
        print(res+m)
    else:
        print(res%m)

main()

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,p,ct=0; cin>>n;
for(int i=1; i<=n && ct<3; i++) { cin>>p; if (p!=i) ct++; }  
if(ct<=2) cout<<"YES"; else cout<<"NO";
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define False false
#define True true
const ll mod = 10000000007;
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(void){
    int N, Y;
    cin >> N >> Y;
    int ans_1, ans_5, ans_10;
    ans_1 = -1, ans_5 = -1; ans_10 = -1;

    for (int x = 0; x <= N; x++){
        for (int y = 0; y <= N-x; y++){
            int z = N - x - y;
            if (Y == 1000 * x + 5000 * y + 10000 * z){
                ans_1 = x;
                ans_5 = y;
                ans_10 = z;
            }
        }
    }
    cout << ans_10 << " "<< ans_5 << " " << ans_1 << endl;

    return 0;
}

Measured memory_bytes: 256