akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,q; cin>>a>>b>>q;
  vll s,t;
  s.push_back(-LINF);
  t.push_back(-LINF);
  rep(i,a){
    ll x; cin>>x;
    s.push_back(x);
  }
  rep(i,b){
    ll x; cin>>x;
    t.push_back(x);
  }
  s.push_back(LINF);
  t.push_back(LINF);
  
  rep(i,q){
    ll x; cin>>x;
    ll si=lower_bound(all(s),x)-s.begin();
    ll ti=lower_bound(all(t),x)-t.begin();
    ll ans=LINF;
    chmin(ans,max(s[si]-x,t[ti]-x));
    chmin(ans,max(x-s[si-1],x-t[ti-1]));
    chmin(ans,(s[si]-x)*2+x-t[ti-1]);
    chmin(ans,(t[ti]-x)*2+x-s[si-1]);
    chmin(ans,(x-s[si-1])*2+t[ti]-x);
    chmin(ans,(x-t[ti-1])*2+s[si]-x);
    cout<<ans<<endl;
  }
  
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


using zahyou = pair<ld,ld>;
//相異なる３座標に対して外心の座標を返す、存在しなければ(INF,INF)を返す
zahyou gaisin(ld x1,ld y1,ld x2,ld y2,ld x3,ld y3){
    ld &a=x1,&b=y1,&c=x2,&d=y2,&e=x3,&f=y3;
    if((e-a)*(b-d)-(c-a)*(b-f)==0)return zahyou(INF,INF);
    ld aa,bb,cc,dd,ee,ff,px,py;
    aa=a*a;
    bb=b*b;
    cc=c*c;
    dd=d*d;
    ee=e*e;
    ff=f*f;
    py=((e-a)*(aa+bb-cc-dd)-(c-a)*(aa+bb-ee-ff))/(2*(e-a)*(b-d)-2*(c-a)*(b-f));
    if (c==a)px=(2*(b-f)*py-aa-bb+ee+ff)/(2*(e-a));
    else px=(2*(b-d)*py-aa-bb+cc+dd)/(2*(c-a));
    return zahyou(px,py);
}

ld dist(ld x1,ld y1,ld x2,ld y2){
    return (ld)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ld ans=INF;
    vector<ld> x(N);
    vector<ld> y(N);
    for(ll i=0;i<N;++i)cin>>x[i]>>y[i];
    cout << fixed << setprecision(18);
    for(ll i=0;i<N;++i)
        for(ll j=i+1;j<N;++j){
            ld &a=x[i],&b=y[i],&c=x[j],&d=y[j];
            zahyou E=zahyou((a+c)/2,(b+d)/2);
            ld R=dist(E.first,E.second,x[i],y[i]);
            bool ok=1;
            for(ll l=0;l<N;++l){
                if(dist(E.first,E.second,x[l],y[l])>R+0.00000001){
                    ok=0;break;
                }
            }
            if(ok)chmin(ans,R);
        }
    for(ll i=0;i<N;++i)
            for(ll j=i+1;j<N;++j)
                for(ll k=j+1;k<N;++k){
                    ld &a=x[i],&b=y[i],&c=x[j],&d=y[j],&e=x[k],&f=y[k];
                    zahyou E=gaisin(a,b,c,d,e,f);
                    if(E==zahyou(INF,INF))continue;
                    ld R=dist(E.first,E.second,x[i],y[i]);
                    bool ok=1;
                    for(ll l=0;l<N;++l){
                        if(dist(E.first,E.second,x[l],y[l])>R+0.00000001){
                            ok=0;break;
                        }
                    }
                    if(ok)chmin(ans,R);
                }

    prt(ans)
    return 0;
}


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

int main(){
	int e;
	cin >> e;
	while(e!=0){
		int Min = 1000000;
		for(int i=0; i<e+1; i++){
			int z = i;
			if(z*z*z > e){
				break;
			}
			int y = 0;
			int x = 0;
			while( (y+1)*(y+1) <= e-z*z*z ){
				y++;
			}
			x = e-z*z*z-y*y;
			if(Min > x+y+z){
				Min = x+y+z;
			}
		}
		cout << Min << endl;
		cin >> e;
	}
}

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

int n,m;
bool g[8][8];

int dfs(int v,int mask){
    if((1<<n)-1 == mask){
        return 1;
    }
    int sum = 0;
    rep(u,n){
        if(!g[v][u] || mask&(1<<u))continue;
        sum += dfs(u,mask|(1<<u));
    }
    return sum;
}

int main(void){
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a][b] = true;
        g[b][a] = true;
    }
    cout<<dfs(0,1)<<endl;
    return 0;
}


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

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  
  if(n%x==0)
    cout << t * n/x;
  else
    cout << t * (n/x + 1);
  
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int x, y;
    cin >> x >> y;

    int ans = numeric_limits<int>::max();
    for (int bit = 0; bit < 1 << 2; ++bit) {
        int tx = x, ty = y, cnt = 0;
        if (bit & 1){
            tx *= -1;
            ++cnt;
        }
        if (bit >> 1 & 1){
            ty *= -1;
            ++cnt;
        }

        if (ty - tx >= 0){
            cnt += ty - tx;
            ans = min(ans, cnt);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
    a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    ans = 1
    if b == 1:
        print(0)
    else:
        while(True):
            if a < b:
                b = b - a + 1
                ans += 1
            else:
                print(ans)
                break     

if __name__ == '__main__':
    main()

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

	int main(){
		int n;
		cin >>n;
	 	 int k;
	 	 cin >>k;
		int arr[n+1];

		for(int i=1;i<=n;i++)	
			cin >>arr[i];

		int dp[n+1];

		dp[1]=0;
		dp[2] = abs(arr[2]-arr[1]);

		for(int i=3;i<=n;i++){
			int res=INT_MAX;
			for(int j=1;j<=k;j++){
	         
	        if(i-j>=1)
			res = min(dp[i-j]+abs(arr[i]-arr[i-j]),res);
			
	        }
          
          dp[i]=res;
		}

		cout << dp[n] << endl;
	}


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

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

  int count=0;
  for(int s=0;pow(10,s)<=N;++s){
    if(s%2==0 && pow(10,s+1)<=N){
    count=count+(pow(10,s+1)-pow(10,s));
    }
    else if(s%2==0){
      count=count+(N-pow(10,s)+1);
    }
  }

  cout<<count<<endl;
}

Measured memory_bytes: 384
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    ll S; cin >> S;

    vl x(3), y(3);
    const ll M = 1e9;

    x[0] = y[0] = 0;
    x[1] = M; x[2] = 1;

    y[2] = (S + M - 1) / M;
    y[1] = x[1]*y[2] - S;
    
    REP(i,3){
        assert(0 <= x[i] && x[i] <= M);
        assert(0 <= y[i] && y[i] <= M);
    }

    cout << x[0] << " " << y[0] << " "
         << x[1] << " " << y[1] << " "
         << x[2] << " " << y[2] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define MOD2 1000000009
#define sp fixed<<setprecision
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll add(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD + b%MOD + MOD)%MOD;}
ll sub(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD - b%MOD + MOD)%MOD;}
ll mul(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return ((a%MOD)*(b%MOD) + MOD)%MOD;}
void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (sz(name)) {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}
int main(){
    setIO();
    ll x;
    cin>>x;
    cout<<(x^1LL);
}


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

using namespace std;

int main(){
    
    int n;
    cin >> n;
    
    vector<int> ps(n);
    vector<int> qs(n);
    vector<int> check(n);
    for(int i = 0; i < n; i++){
        cin >> ps[i];
        check[i] = ps[i];
    }
    for(int i = 0; i < n; i++){
        cin >> qs[i];
    }
    
    sort(check.begin(), check.end());
    
    int p_num = 0;
    int q_num = 0;
    int num = 1;
    do{
        bool p_flag = true;
        for(int i = 0; i < n; i++){
            if(ps[i] != check[i]){
                p_flag = false;
                break;
            }
        }
        if(p_flag){
            p_num = num;
        }
        bool q_flag = true;
        for(int i = 0; i < n; i++){
            if(qs[i] != check[i]){
                q_flag = false;
                break;
            }
        }
        if(q_flag){
            q_num = num;
        }
        num++;
    }while(next_permutation(check.begin(), check.end()));
    
    cout << abs(p_num - q_num) << endl;
    
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

string s;

int calc(string t) {
	if (t.back() == '+') {
		return 0;
	}

	vec<int> v;
	string tmp = "";
	t += "+";
	rep (i, t.size()) {
		if (isdigit(t[i])) {
			tmp += t[i];
		} else {
			v.push_back(stoll(tmp));
			tmp = "";
		}
	}

	return accumulate(all(v), 0ll);
}

int rec(int idx, string shiki) {
	if (idx >= s.size()) {
		return calc(shiki);
	}

	int ret = 0;

	// no
	ret += rec(idx + 1, shiki + s[idx]);

	// yes
	ret += rec(idx + 1, shiki + s[idx] + "+");

	return ret;
}

signed main() {
	cin >> s;

	int ans = rec(0, "");

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll n; cin>>n;
	ll cnt=0;
	ll ans=0,m=MOD;
	rep(i,0,n){
		ll a; cin>>a;
		chmin(m,abs(a));
		if(a<0)cnt++;
		ans+=abs(a);	
	}
	if(cnt%2==1)ans-=(m*2);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
vector<int> tonari[100010];
vector<int> group(100010,-1);

void dfs(int node){
  for(int i=0;i<tonari[node].size();i++){
    if(group[tonari[node][i]]>=0) continue;
    group[tonari[node][i]]=group[node];
    dfs(tonari[node][i]);

  }
}

int main(){
  int N,M;
  cin>>N>>M;
  int x,y,z;
  
  for(int i=0;i<M;i++){
    cin>>x>>y>>z;
    tonari[x-1].push_back(y-1);
    tonari[y-1].push_back(x-1);
  }
  int groupno=0;
  for(int i=0;i<N;i++){
    if(group[i]!=-1) continue;
    group[i]=groupno;
    
    dfs(i);

    groupno++;
  }

  cout<<groupno<<endl;

  return 0;
}



Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1e18 : 1e9;
const int MOD = 1000000007;
const long double EPS = 1e-8;

int main() {
	int n, m, p, va = 0;
	while (cin >> n >> m >> p, n) {
		int x[n], sum = 0;
		rep (i, n) {
			cin >> x[i];
			sum += x[i];
		}
		if (x[m - 1] == 0) {
			cout << 0 << endl;
		} else {
			long long ans = sum * 100.0L * (1.0L - (p / 100.0L)) / x[m - 1] + EPS;
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3072
a,b=(int(x) for x in input().split())
if int(25*(a+1)/2)<int(10*b):
  print(-1)
elif int(25*(a+1)/2)==int(10*b):
  if a%2==1:
    print(-1)
  else:
    print(int(10*b))
elif int(10*(b+1))<=int(25*a/2):
  print(-1)
elif int(10*(b+1)-1)==int(25*a/2):
  if a%2==1:
    print(-1)
  else:
    print(int(25*a/2))  
else:
  if a%2==1:
    print(max([int(25*a/2+1),int(10*b)]))
  else:
    print(max([int(25*a/2),int(10*b)]))

Measured memory_bytes: 3192
#include <stdio.h>

int main(void){
    int page = 0, print = 0;
    scanf("%d", &page);
    if(page % 2 == 1){
        page = page / 2;
        print = page + 1;
    }else{
        print = page / 2;
    }
    printf("%d", print);

    return 0;
}

Measured memory_bytes: 128
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    println!("{}", lucas(n));
}

fn lucas(n: i32) -> u64 {
    if n == 1 {
        1
    } else {
        let mut n_i = 3;
        let mut n_i_1 = 1;
        let mut n_i_2 = 2;

        for _ in 0..n - 1 {
            n_i = n_i_1 + n_i_2;
            n_i_2 = n_i_1;
            n_i_1 = n_i;
        }
        n_i
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll>> key;
    rep(i, m){
        ll a, b, s = 0; cin >> a >> b;
        rep(j, b){
            ll c; cin >> c; c--;
            s |= (1ll<<c);
        }
        key.emplace_back(s, a);
    }

    // bitDP
    vector<ll> dp(1ll<<n, 10e9+7); dp[0] = 0;
    rep(s, 1ll<<n){
        rep(i, m){
            ll t = s | key[i].first;
            ll cost = dp[s] + key[i].second;
            chmin(dp[t], cost);
        }
    }
    ll ans = dp.back();
    if(ans == 10e9+7) ans = -1;
    cout << ans << endl;
}

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

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

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


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

int n;
int a[SIZE], b[SIZE];

int solve1(){
  int right[SIZE] = {};
  int left[SIZE] = {};

  for(int i=0;i<n;i++){
    right[b[i]]++;
    left[a[i]]++;
  }

  for(int i=0;i<SIZE/2;i++){
    right[i+1] += right[i];
    left[SIZE/2 - i] += left[SIZE/2 - i + 1];
  }

  int ans = 0;
  
  for(int i=0;i<n;i++){
    ans = max(ans, n - right[a[i]] - left[b[i]]);
  }

  return ans;
}


int solve2(){
  int sum[SIZE] = {};
  int ans = 0;
  
  for(int i=0;i<n;i++){
    sum[a[i]]++;
    sum[b[i]]--;
  }

  for(int i=0;i<SIZE/2;i++){
    sum[i+1] += sum[i];
    ans = max(sum[i], ans);
  }

  return ans;
}


int main(){

  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%d%d",a+i, b+i);
  }

  printf("%d %d\n",solve1(), solve2());
  
  return 0;
}



Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()






int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w, 0));
    queue<P> Q;
    rep (i, h) {
        string s;
        cin >> s;
        rep (j, w) {
            if (s[j] == '#') {
                a[i][j] = 1;
                Q.push(make_pair(i, j));
            }
        }
    }
    int ans = 0;
    vector<int> dx = {0, 0, 1, -1};
    vector<int> dy = {1, -1, 0, 0};
    while (!Q.empty()) {
        ans++;
        vector<P> next;
        while (Q.size()) {
            P f = Q.front();
            Q.pop();
            int y = f.first;
            int x = f.second;
            rep (i, 4) {
                int newy = y + dy[i];
                int newx = x + dx[i];
                if (newy < 0 || h <= newy) continue;
                if (newx < 0 || w <= newx) continue;
                if (a[newy][newx] == 1) continue;
                next.push_back(make_pair(newy, newx));
                a[newy][newx] = 1;
            }
        }
        rep (i, next.size()) {
            Q.push(next[i]);
        }
    }
    cout << ans - 1 << endl;
}



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

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(br.readLine());
		ArrayList<Integer> pos = new ArrayList<>();
		ArrayList<Integer> neg = new ArrayList<>();
		StringTokenizer st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; i++){
			int a = Integer.parseInt(st.nextToken());
			if(a > 0) pos.add(a);
			else neg.add(a);
		}
		if(pos.isEmpty()){
			Collections.sort(neg);
			Collections.reverse(neg);
			pos.add(neg.remove(0));
		}
		else if(neg.isEmpty()){
			Collections.sort(pos);
			neg.add(pos.remove(0));
		}
		int x = neg.remove(0);
		int y = pos.remove(0);
		StringBuilder sb = new StringBuilder();
		while(!pos.isEmpty()){
			int a = pos.remove(0);
			sb.append(String.format("%d %d\n", x, a));
			x = x-a;
		}
		while(!neg.isEmpty()){
			int b = neg.remove(0);
			sb.append(String.format("%d %d\n", y, b));
			y = y-b;
		}
		sb.append(String.format("%d %d\n", y, x));
		bw.write(y-x+"\n");
		bw.write(sb.toString());
		bw.flush(); bw.close();
	}

}


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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vector<int>h(n), dp(n, (int)2e9);
    for(int i=0; i<n; i++) cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2; i<n; i++)
    {
        dp[i]=min(dp[i], min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])));
    }
    cout<<dp[n-1]<<endl;
    return 0;

}


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


int main() {
  int n; cin >> n;
  string S[n];
  for(int i = 0; i < n; i++) cin >> S[i];
  char s = S[0][0];
  for(int i = 0; i < n; i++)
    for(int j = i+1; j < n; j++){
      if(S[i] == S[j]){
        cout << "No" << endl;
        return 0;
      }
    } 
  for(int i = 0; i < n; i++){
    if(S[i][0] != s){
      cout << "No" << endl;
      return 0;
    }
    s = S[i][S[i].size()-1];
  }
  cout << "Yes" << endl;
}


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

double sq_dist(const vector<double>& as, const vector<double>& bs) {
  double d = 0;
  for(int i = 0; i < as.size(); ++i) {
    double t = as[i] - bs[i];
    d += t * t;
  }
  return d;
}

bool is_ans(double sq_d) {
  double d = sqrt(sq_d);
  int di = (int)d;
  return d == di;
}

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<double>> xs(N);
  for(int i = 0; i < N; ++i) {
    double x;
    for(int j = 0; j < D; ++j) {
      cin >> x;
      xs[i].push_back(x);
    }
  }
  int ans = 0;
  for(int i = 0; i < N - 1; ++i) {
    for(int j = i + 1; j < N; ++j) {
      auto sd = sq_dist(xs[i], xs[j]);
      if(is_ans(sd)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<ll, ll>;
#define INF 10000000;

ll MOD = 1e9 + 7;

int gcd(int x, int y)
{
    return y != 0 ? gcd(y, x % y) : x;
}

int lcm(int x, int y)
{
    return x * y / gcd(x, y);
}

int main()
{

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N)
    cin >> A[i];

    ll ans = gcd(A[0], A[1]);

    for (int i = 2; i < N; i++)
    {
        ll fact = gcd(ans, A[i]);
        ans = min(fact, ans);
    }
    Cout(ans);

    return 0;
}


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

int main() {
  vector<int> vec = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  int k;
  cin >> k;
  cout << vec.at(k-1) << endl; 
}

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

using namespace std;
int main(){
    string s,t; cin >> s >> t;
    int i,j,n = s.size(),m = t.size(),ans = 100000;;
    for(i=0;i<=n - m;i++){
        int res = 0;
        for(j=0;j<m;j++){
            if(s[i + j]!=t[j]) res++;
        }
        ans = min(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)
	if A > C {
		A, C = C, A
	}

	if B > D {
		B, D = D, B
	}

	ans := B - C
	if ans < 0 {
		fmt.Println(0)
	} else {
		fmt.Println(ans)
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int d;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d);
		if(d>=k)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if(a <= 9 && b <= 9){
    ans = a*b;
  }
  else{
    ans = (-1);
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int n;cin>>n;
  if(n<1200)cout <<"ABC"<<endl;
  else if(n<2800) cout<<"ARC"<<endl;
  else cout << "AGC" <<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [S() for i in range(N)]
print(len(set(a)))

Measured memory_bytes: 111056
N,K,S = map(int,input().split())
X = [0]*N
if S < 10**9:
    for i in range(K):
        X[i] = S
    for i in range(K,N):
        X[i] = S+1
else:
    for i in range(K):
        X[i] = S
    for i in range(K,N):
        X[i] = S-1
for x in X:
    print(x,end = " ")

Measured memory_bytes: 8136
# -*- coding: utf-8 -*-

# 入力
X = int(input())
A = [list(map(int, input().split())) for i in range(2)]

# 処理
ans = []
for i in range(X):
    cnt = 0
    x = 0
    y = 0
    for j in range(X):
        if i == j:
            x += 1
        else:
            y += 1
        cnt += A[x][y]        
    ans.append(cnt+A[0][0])
print(max(ans))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if((a < b) && (b < c)){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

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

int main()
{
    
    ios_base::sync_with_stdio(false), cin.tie(nullptr);

    int n;
    cin >> n;
    vl a[4];
    fori(i,n){
        int x, y;
        cin >> x >> y;
        int c = 0;
        for (int j : {-1, +1})
        {
            for(int k:{-1,+1}){
                a[c++].pb(j * x + k * y);
            }
        }
    }
    ll ans = 0;
    fori(i, 4)
    {
        sort(all(a[i]));
        ans = max(ans, a[i].back() - a[i].front());
    }
    cout << ans << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 9752
from collections import defaultdict
import bisect

N = int(input())
S = input()
dst = [[] for i in range(10)]
for i,x in enumerate(S):
    y = int(x)
    dst[y].append(i)

bs = bisect.bisect_right
ans = 0

for k in range(10):
    for j in range(10):
        for i in range(10):
            if dst[i] == [] or dst[j] == [] or dst[k] == []:
                continue
            else:
                A = dst[i][0]
                if A >= dst[j][-1]:
                    continue
                else:
                    b = bs(dst[j],A)
                    B = dst[j][b]
                    if B >= dst[k][-1]:
                        continue
                    else:
                        ans += 1            
            
print(ans)

Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int X;cin>>X;
    X/=200;
    X=10-X;
    cout<<X<<endl;
}


Measured memory_bytes: 3576
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.WriteLine("! "+sb.ToString());
    }
    void Calc(){
        long count = 10000000000;
        int digit = 0;
        while(true){
            Console.WriteLine("? "+ count);
            string s = Console.ReadLine();
            if(s[0] == 'Y'){
                break;
            }
            else{
                count /= 10;
            }
            digit++;
        }
        string ans = "";
        if(digit == 0){
            long C = 9;
            ans += "1";
            while(true){
                Console.WriteLine("? "+C);
                C = C*10+9;
                string s = Console.ReadLine();
                if(s[0] == 'Y'){
                    break;
                }
                ans += "0";
            }
        }
        else{
            long bf = count+1;
            long bl = count*10-1;
            while(bf != bl){
                long bc = (bf+bl)/2;
                Console.WriteLine("? "+ bc*10);
                string s = Console.ReadLine();
                if(s[0] == 'Y'){
                    bl = bc;
                }
                else{
                    bf = bc+1;
                }
            }
            ans += bf;
        }
        sb.Append(ans);
    }
}

Measured memory_bytes: 13600
S = input()
if len(S) < 26:
    for i in range(26):
        if chr(ord('a')+i) not in S:
            print(S + chr(ord('a')+i))
            exit()
for i in range(len(S)-1, -1, -1):
    minC = ord('z')+1
    for j in range(len(S)-1, i, -1):
        if ord(S[j]) > ord(S[i]):
            minC = min(minC, ord(S[j]))
    if minC < ord('z')+1:
        print(S[:i] + chr(minC))
        exit()
print(-1)

Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
X = int(input())

n = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      x = 500 * a + 100 * b + 50 * c
      if X == x:
        n += 1
print(n)

Measured memory_bytes: 2940
anss = []
flag = False
def main():
    N, K = [int(i) for i in input().split()]
    if N == K == 0:
        global flag
        flag = True
        return
    A = [int(input()) for _ in range(K)]
    A.sort()
    zero = False
    if A[0] == 0:
        zero = True
    prev = -1
    last_island = -1
    current_streak = 0
    ans = 0
    for a in A:
        if prev == -1 or a == prev + 1:
            current_streak += 1
        elif zero == True and a == prev + 2:
            last_island = current_streak
            current_streak = 1
        else:
            last_island = -1
            current_streak = 1
        ans = max(current_streak + last_island + 1, ans)
        prev = a
    global anss
    anss.append(ans)
while not flag:
    main()
for a in anss:
    print(a)


Measured memory_bytes: 9128
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 300001
#define E 12000001
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;void re(int& x)
{
	while(ch=getchar(),ch<33);x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
}
using namespace std;
int n,m,last[N];
int siz,root[N],ls[E],rs[E],sum[E];
struct node
{
	int a,b;
	bool operator < (const node& i)const{return a<i.a;}
}w[N];
void build(int &x,int y,int l,int r,int a)
{
	x=++siz;
	ls[x]=ls[y];
	rs[x]=rs[y];
	sum[x]=sum[y]+1;
	if(l==r)return;
	int mid=l+r>>1;
	if(a<=mid)build(ls[x],ls[y],l,mid,a);
	else build(rs[x],rs[y],mid+1,r,a);
}
int query(int x,int l,int r,int a)
{
	if(!x)return 0;
	if(a<=l)return sum[x];
	int mid=l+r>>1;
	if(a>mid)return query(rs[x],mid+1,r,a);
	else return query(ls[x],l,mid,a)+query(rs[x],mid+1,r,a);
}
int main()
{
	re(n),re(m);
	for(int i=1;i<=n;++i)
		re(w[i].a),re(w[i].b);
	sort(w+1,w+n+1);
	for(int i=1;i<=n;++i)
	{
		build(root[i],root[i-1],1,m,w[i].b);
		last[w[i].a]=root[i];
	}
	for(int i=1;i<=m;++i)
		if(!last[i])
			last[i]=last[i-1];
	for(int i=1;i<=m;++i)
	{
		int ans=0;
		for(int j=i;j<=m;j+=i)
			ans+=query(last[j],1,m,j)-query(last[j-i],1,m,j);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 75776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;cin>>s;ll n=s.size();
  vector<char> cv={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  if(s=="zyxwvutsrqponmlkjihgfedcba") print(-1);
  else {
    if(n<26) {
      rep(i,26) { if (find(s.begin(),s.end(),cv[i])==s.end()) {s+=cv[i];break;}}
    }
    else {
      ll l=1;
      for(ll i=n-1;i>=1;--i) {
        if (s[i]-'a' < s[i-1]-'a') l+=1;
        else break;
      }
      string s_ = s.substr(0,n-l),ss=s.substr(n-l,l);
      sort(ss.begin(),ss.end());
      rep(i,ss.size()) if(ss[i]-'a' > s[n-l-1]-'a') {s_[n-l-1]=ss[i];break;}
      s=s_;
    }
    print(s);
  }
  return 0;
}


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

long long H, W, K, dp[109][9], mod = 1000000007;

int main() {
	cin >> H >> W >> K; K--;
	dp[0][0] = 1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (dp[i][j] == 0) continue;
			for (int k = 0; k < (1 << (W - 1)); k++) {
				int bit[7]; for (int l = 0; l < W - 1; l++) bit[l] = (k / (1 << l)) % 2;
				bool flag = true; for (int l = 0; l < W - 2; l++) { if (bit[l] == 1 && bit[l + 1] == 1) flag = false; }

				if (flag == false) continue;
				if (j < W - 1 && bit[j] == 1) { dp[i + 1][j + 1] += dp[i][j]; dp[i + 1][j + 1] %= mod; }
				else if (j >= 1 && bit[j - 1] == 1) { dp[i + 1][j - 1] += dp[i][j]; dp[i + 1][j - 1] %= mod; }
				else { dp[i + 1][j] += dp[i][j]; dp[i + 1][j] %= mod; }
			}
		}
	}
	cout << dp[H][K] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    
 using namespace std; int main(void){
    int a,b;
    cin>>a>>b;
    int n=0;
    for(int i=0;i<1000000;i++){
    if(a>b){
        a=a-b;
        n++;
    }else{
        cout<<n+1;
        return 0;
    }
}
     return 0;
   
    }


Measured memory_bytes: 256
import java.util
object Main extends App {
  import scala.io.StdIn._
  val goal = new Square(Array(Array(1,2,3), Array(4,5,6), Array(7,8,0)))
  val goalHash = goal.hashCode()
  val start = new Square((0 until 3).map{_ => readLine().trim().split(' ').map(_.toInt).toArray}.toArray)
  println(search(start))
  def search(start:Square):Int = {
    val memo = Array.tabulate(362880){_ => -1}
    var count = 0
    val queue:util.Deque[Square] = new util.LinkedList()
    memo(start.hashCode()) = 0
    queue.addLast(start)
    while (memo(goalHash) < 0){
      count += 1
      for (i <- 0 until queue.size()){
        for (s <- queue.peek().nextCases){
          if (memo(s.hashCode()) < 0){
            memo(s.hashCode()) = count
            queue.addLast(s)
          }
        }
        queue.pop()
      }
    }
    memo(goalHash)
  }
  class Square(private val array:Array[Array[Int]]){
    override def hashCode(): Int = Square.factorial.foldLeft((0, (0 until 3).flatMap{a => (0 until 3).map{b => array(a)(b)}}.toList)){
      case ((s, h::t), f) => (s + f * h, t.map{n => if (n > h) n - 1 else n})
      case (s, f) => s
    }._1
    lazy val zeroPoint:Point = (0 until 3).flatMap{x => (0 until 3).map{y => Point(x, y)}}.filter{case Point(x, y) => array(x)(y) == 0}.head
    def copy:Square = new Square(array.map(_.clone()))
    def nextCases:List[Square] = zeroPoint.neighbors.filter(Square.isValidPoint(_)).map{
      case Point(x, y) =>
        val r = copy
        r.array(zeroPoint.x)(zeroPoint.y) = array(x)(y)
        r.array(x)(y) = 0
        r
    }
  }
  case class Point(x:Int, y:Int){
    def neighbors:List[Point] = List(Point(x - 1, y), Point(x + 1, y), Point(x, y - 1), Point(x, y + 1))
  }
  object Square{
    val factorial = List(40320, 5040, 720, 120, 24, 6, 2, 1, 1)
    def isValidPoint(other:Point):Boolean = (0 until 3).contains(other.x) && (0 until 3).contains(other.y)
  }
}



Measured memory_bytes: 483560
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a="abcdefghijklmnopqrstuvwxyz.?! ";
	string b;
	char ans[100];
	while(cin>>b){
	int top=0;
	bool na=false;
	if(b.size()%2==1)
		na=true;
	for(int i=0;i<b.size()-1;i+=2){
		ans[top]=a[(b[i]-'1')*5+b[i+1]-'1'];
		top++;
		if(b[i]<'1'||b[i]>'6'||b[i+1]<'1'||b[i+1]>'5')
			na=true;
	}
	if(na==true)
		cout<<"NA"<<endl;
	else{
	for(int i=0;i<top;i++)
		cout<<ans[i];
	cout<<endl;
	}
	}
	return 0;
}

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

public class Main
{
    public static void main(String[] args)
    {
        CP sc =new CP();
        int n = sc.nextInt();
        Pair[] p = new Pair[n];
        for(int i=0;i<n;i++){
            p[i] = new Pair(sc.nextInt(), sc.nextInt());
        }
        boolean flag = true;
        for(int i=0;i<n-2;i++){
            if(p[i].x==p[i].y && p[i+1].x==p[i+1].y && p[i+2].x==p[i+2].y){
                flag = false;
                break;
            }
        }
        if(!flag)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
    static class Pair{
        int x,y;
        Pair(int a, int b){
            x=a;
            y=b;
        }
    }
    /*****************************************************************************/
    static class CP
    {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;
        public CP() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }
        int nextInt() {
            return Integer.parseInt(NNNN());
        }
        long nextLong() {
            return Long.parseLong(NNNN());
        }
        double nextDouble() {
            return Double.parseDouble(NNNN());
        }
        String NNNN() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }
        String nextLine() {
            String spl = "";
            try {
                spl = bufferedReader.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return spl;
        }
    }
    /*****************************************************************************/
}

Measured memory_bytes: 32888
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n; cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
    }
    ll ans = 0;
    for(int i = 1; i < n; ++i){
        if(arr[i] < arr[i - 1]){
            ans += arr[i - 1] - arr[i];
            arr[i] = arr[i - 1];
        }

    }
    cout << ans << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


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

int main(void) {
    string s, ans = "yes";
    cin >> s;
    vector<char> c;
    for (int i = 0; i < s.size(); i++) {
        for (char& cc: c) {
            if (cc == s.at(i)) {
                ans = "no";
                break;
            }
        }
        c.push_back(s.at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n, A, B, C, D;
int p[maxn], t;
char s[maxn];

bool check() {
	int pos = 1, l, r;
	while(p[pos] < A) ++pos;
	while(p[pos] < C) {
		if(p[pos] - 1 == p[pos - 1]) return 0;
		++pos;
	}
	pos = 1;
	while(p[pos] < B) ++pos;
	l = pos - 1;
	while(p[pos] < D) {
		if(p[pos] - 1 == p[pos - 1]) return 0;
		++pos;
	}
	r = pos;
	if(C > D) {
		if(p[l + 1] - p[l] > 3 && p[l + 1] - B > 1) return 1;
		if(p[r] - p[r - 1] > 3 && D - p[r - 1] > 1) return 1;
		for (int i = l + 2; i < r; ++i) if(p[i] - p[i - 1] > 3) return 1;
		return 0;
	}
	return 1;
}

int main() {
	scanf("%d%d%d%d%d", &n, &A, &B, &C, &D);
	scanf("%s", s + 1);
	++t;
	for (int i = 1; i <= n; ++i) if(s[i] == '#') p[++t] = i;
	p[++t] = n + 1;
	if(check()) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 4296
def takeSecond(elem):
    return elem[1]

n,k = map(int,input().split())

sushi = [list(map(int,input().split())) for i in range(n)]

sushi.sort(key=takeSecond,reverse=True)
'''
selected = sushi[:k]
kindset = set([item[0] for item in selected])

startKindNum = len(kindset)

score = startKindNum*startKindNum + sum([item[1] for item in selected])
maxscore = score
front_pointer = k - 1
pointer = k
for i in range(startKindNum+1,min([k+1,n+1])):
    #remove the smallest one that does not decrease kind
    for p in range(front_pointer,-1,-1):
        item = selected[p]
        flag = False
        for idx in range(p):
            if(selected[idx][0]==item[0]):
                score -= item[1]
                selected.remove(item)
                front_pointer = p - 1
                flag = True
                break
        if(flag):
            break

    #add the largest one that add kind
    for j in range(pointer,n):
        if(sushi[j][0] not in kindset):
            selected.append(sushi[j])
            kindset.add(sushi[j][0])
            k += 1
            pointer = j + 1            
            score += 2*startKindNum + 1 + sushi[j][1]
            if(score>maxscore):
                maxscore = score
            startKindNum += 1
            break
'''
kindset = set([])
score = 0
extras = []
for item in sushi[:k]:
    if item[0] in kindset:
        extras.append(item[1])
    else:
        kindset.add(item[0])
    score += item[1]
score += len(kindset)**2
maxscore = score
for item in sushi[k:]:
    if not  extras:
        break
    if item[0] in kindset:
        continue
    score += (item[1] - extras.pop()) + 2*len(kindset) + 1
    kindset.add(item[0])
    #print(score)
    if score > maxscore:
        maxscore = score


print(maxscore)


Measured memory_bytes: 30792
#include <iostream>

using namespace std;

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

    if (a > b && a > c) {
        cout << b + c << endl;;
    }
    else if (b > a && b > c) {
        cout << a + c << endl;
    }
    else {
        cout << a + b << endl;
    }
}



Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

const int INF = 1e9;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    vector<int> DP(N, INF);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    DP[0] = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = 1; j <= min(K, N - i); j++) {
            DP[i + j] = min(DP[i + j], DP[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << DP[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
from sys import stdin
def main():
	inp=stdin.readline
	a,b,c,d=map(int, inp().split())
	f=False
	while a>0 and c>0:
		if f:
			a-=d
		else:
			c-=b
		f=not(f)
	if a>0:
		print("Yes")
	else:
		print("No")

main()

Measured memory_bytes: 9180