akhauriyash/Code-Regression huggingface dataset:
from collections import deque

h,w = map(int,input().split())
s = ["#"*(w+1)] + ["#" + input() + "#" for _ in range(h)] + ["#"*(w+1)]

shortest_path = [[float('inf')] * (w+1) for _ in range(h+1)]

shortest_path[1][1] = 1
q = deque([(1,1)])

while q:
    x,y = q.popleft()
    cost = shortest_path[y][x]
    for j,i in [(x-1,y),(x+1,y),(x,y-1),(x,y+1)]:
        if s[i][j] == "#":
            continue
        else:
            if shortest_path[i][j] > cost+1:
                q.append((j,i))
                shortest_path[i][j] = cost+1

if shortest_path[h][w] == float('inf'):
    print(-1)
else:
    print(sum( st.count(".") for st in s) - shortest_path[h][w])

Measured memory_bytes: 3316
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , x;
    cin >> a >> b >> x;
	if ( a <= x && x - a <= b ) cout << "YES";
	else cout << "NO";
} 

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

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

void Main()
{
	string S; cin >> S;
	int N = S.size() - 1;
	for (int bit = 0; bit < (1 << N); ++bit) {
		int sum = S[0] - '0';
		string expr = ""s + S[0];
		for (int i = 0; i < N; ++i) {
			if (bit & (1 << i)) {
				sum += S[i + 1] - '0';
				expr += "+"s + S[i + 1];
			} else {
				sum -= S[i + 1] - '0';
				expr += "-"s + S[i + 1];
			}
		}
		if (sum == 7) {
			cout << expr << "=7" << endl;
			return;
		}
	}
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String in =scan.next();
		char[] data=in.toCharArray();
		int ans=0;
		int n =data.length;
		for(int i=0;i<n/2;i++)
		{
			if(data[i]==data[n-1-i])
			{
				
			}
			else
			{
				ans=1;
			}
		}
		if(ans==1)
		{
			System.out.println("No");
		}
		else
		{
			for(int i =0;i<((n-1)/2)/2;i++)
			{
				if(data[i]==data[(n-1)/2-1-i])
				{
					
				}
				else
				{
					ans=1;
				}
			}
			if(ans==1)
			{
				System.out.println("No");
			}
			else
			{
				for(int i =(n+3)/2-1;i<(n-((n+3)/2-1))/2;i++)
				{
					if(data[i]==data[n-i])
					{
						
					}
					else
					{
						ans=1;
					}
				}
				if(ans==1)
				{
					System.out.println("No");
				}
				else
				{
					System.out.println("Yes");
				}
			}
		}
	}
}


Measured memory_bytes: 23124
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp

//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=1e5+10;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}

char a[MAX];
int main()
{
    scanf("%s",a);
    int len=strlen(a);
    for(int i=0;i<len-1;i++)
    {
        if(a[i]=='A'&&a[i+1]=='C')
            return 0*printf("Yes\n");
    }
    return 0*printf("No\n");
    return 0;
}
/*
5
5 6
1 2 1
2 3 2
2 4 3
3 4 4
3 5 3
4 5 2
*/


Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
using namespace std;

#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vector<int>>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define fir(i,a,b)      for(int i=a;i<b;i++)
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);
#define MAXZ            200005
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

bool cmp(int a,int b) {return a>b;}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

int a[200001],b[200001];

int32_t main()
{
    FIO
    int n,m,x; cin>>n>>m>>x;
    int arr[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<=m;j++){
            if(j){
                 
                cin>>arr[i][j-1];
                // if(i) arr[i][j-1]+=arr[i-1][j-1];
            }
            else cin>>a[i];
        }
    }
    int p=0;
    int minz=INT_MAX;
    for(int i=0;i<pow(2,n);i++){
        int chk[m]={0};
        int cost=0;
        for(int j=0;j<n;j++){
            if((i & (1<<j))!=0){
                for(int k=0;k<m;k++) chk[k]+=arr[j][k];
                cost+=a[j];
            }
        }
        int p=1;
        for(int j=0;j<m;j++){
            if(chk[j]<x) p=0; 
        }
        if(p==1) minz=min(minz,cost);
    }
    if(minz!=INT_MAX) cout<<minz<<"\n";
    else cout<<-1<<"\n";
    return 0;

}

Measured memory_bytes: 4128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)

const int inf=1<<29;
int n;
vector<vector<int>> d(110, vector<int>(110, inf));

void floyd(){
    rep(i, n) d[i][i]=0;
    rep(k, n){
        rep(i, n){
            if(d[i][k]==inf) continue;
            rep(j, n){
                if(d[k][j]==inf) continue;
                chmin(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

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

    int m; cin >> n >> m;
    vector<int> a(m), b(m), c(m);
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
        d[a[i]][b[i]]=d[b[i]][a[i]]=c[i];
    }

    floyd();

    int ans=0;
    rep(i, m){
        bool shortest=false;
        rep(s, n){
            if(shortest) break;
            if(d[s][a[i]]+c[i] == d[s][b[i]]) { shortest=true; break; }
        }
        if(!shortest) ++ans;
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
using namespace std;


long long x[1002];
long long y[1002];
long long r[1002];

double c[1002][1002];
double dists[1002];
bool done[1002];

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

void dijikstra(int N){
    for(int i = 0; i < N; i++){
        dists[i] = LLONG_MAX;
        done[i] = false;
    }
    dists[0] = 0;
    for(int i = 0; i < N; i++){
        bool updated = false;
        int closest;
        long long min_dist = LLONG_MAX;
        for(int j = 0; j < N; j++){
            if(!done[j] && dists[j] < min_dist){
                closest = j;
                min_dist = dists[j];
                updated = true;
            }
        }
        if(!updated){
            break;
        }
        done[closest] = true;
        for(int j = 0; j < N; j++){
            dists[j] = min(dists[j], dists[closest] + c[closest][j]);
        }
    }
}

int main(){
    int N;
    for(int i = 0; i < 2; i++){
        cin >> x[i] >> y[i];
        r[i] = 0;
    }
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x[2 + i] >> y[2 + i] >> r[2 + i];
    }

    for(int i = 0; i < N + 2; i++){
        for(int j = 0; j < N + 2; j++){
            c[i][j] = max(0.0, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j]);
            //printf("%f ", c[i][j]);
        }
        //cout << endl;
    }

    dijikstra(N + 2);
    printf("%.10f\n", dists[1]);
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
int cnt[1000009];
int ka[214514],inv[214514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int p2[55],res=1;
	p2[0]=1;p2[1]=x%inf;
	for(int i=2;i<=50;i++){
		p2[i]=p2[i-1]*p2[i-1];
		p2[i] %= inf;
	}
	for(int i=1;i<=50;i++){
		if(k%2==1){
			res *= p2[i];
			res %= inf;
		}
		k /= 2;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if(n<0)return 0;
	if(k<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
signed main(){
	int n; cin>>n;
	vector<int> a;
	for(int i=0;i<=n;i++){
		int x;
		cin>>x;
		a.pb(x);
		cnt[x]++;
	}
	setkaijo(114514);
	setinv(114514);
	int db = -1;
	for(int i=1;i<=n;i++){
		if(cnt[i] == 2)db=i;
	}
	vector<int> pos;
	for(int i=0;i<=n;i++){
		if(a[i] == db)pos.pb(i);
	}
	vector<ll> ans;
	ans.pb(n);
	for(int k=2;k<=n;k++){
		ll tmp = 0;
		tmp += comb(n-1,k);
		tmp += 2 * comb(n-1,k-1);
		tmp += comb(n-1,k-2);
		tmp -= comb( pos[0]+n-pos[1], k-1 );
		tmp += inf;
		tmp %= inf;
		ans.pb(tmp);
	}
	ans.pb(1);
	for(int i=1;i<=n+1;i++){
		cout<<ans[i-1]<<endl;
	}
	return 0;
}

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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
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; }

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;

//const ll M=1000000007ll;
//const ll MOD=1000000007ll;
const ll MOD=2019ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

//const int mod = 1000000007;
const int mod = 2019;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
   return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint g(ll n, ll x){
  if(x==0) return 1;
  mint ans = g(n, x/2);
  ans *= ans;
  if(x%2==1) ans*= n;
  return ans;  
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
ll fff(ll n, vector<ll>& v, ll i, ll j, ll rl){
  ll can = 0;
  ll can_i = 0;

  cout << v[0]<<endl;
  
  // right
  if(rl == 0){
    rep(k, n){
      if(v[k]*(j-k)>can){
	can = v[k]*(j-k);
	can_i = k;
      }
      //cout << can<<endl;
    }
    v[can_i] = 0;
    return can;
  }
  // left
  else{
    rep(k, n){
      if(v[k]*(k-i)>can){
	can = v[k]*(k-i);
	can_i = k;
      }
      //cout << can<<endl;

    }
    v[can_i] = 0;
    return can;
  }
  
}

ll ff(ll x){
  return x * (x+1) / 2;
}

void dfs(string s, ll ma, ll n){
  //cout << ma<<endl;
  if(s.size()==n){
    cout << s <<endl;
    return;
  }
  rep(i, ma+1){
    dfs(s + char('a'+i), max(ma, i+1), n);
  }
}

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

  string s = "a";
  //cout << s + char('a'+1)<<endl;
  
  dfs(s, 1, n);
    
    
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
  vector<ll> v;
  REP(i, 4) {
    ll p;
    cin >> p;
    v.pb(p);
  }

  sort(v.begin(), v.end());
  if (v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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 = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  int ans;
  int mx=0;
  for(int i = 0; i < n; i++) {
    cin>>a[i];
    mx = max(a[i],mx);
  }
  for(int i = 0; i < n; i++){
    if(i == 0) ans = a[0];
    ans = gcd(a[i],ans);
  }
  bool ansflg;
  if(k>mx) ansflg = false;
  else{
    if(k%ans==0) ansflg = true;
    else ansflg = false;
  }
  // cout<<ans<<endl;
  if(ansflg) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}



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

using namespace std;
typedef long long ll;

int main(){
    int n;
    string S;
    cin >> n;
    cin >> S;
    if(n<3)
    {
        cout << 0 << endl;
        return 0;
    }
    ll r, g, b;
    r = b = g = 0;
    for (int i = 0; i < n; i++)
    {
        if(S[i]=='R')
        {
            r++;    
        }
        else if (S[i]=='G')
        {
            g++;
        }
        else if (S[i]=='B')
        {
            b++;
        }
    }
    ll all = r * g * b;

    for (int i = 0; i < n - 2; i++)
    {
        for (int j = i+1; j < n - 1; j++)
        {
            if (S[i] != S[j])
            {
                int a = j - i;
                int k = i + 2 * a;
                if (k >= n)
                {
                    continue;
                }

                if (S[j] != S[k] && S[k] != S[i])
                {
                        all--;
                }
                
                
            }
        }
        
    }
    cout << all << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t=1,i,j,k,n,m,x,y,z,a,b;
    // cin>>t;
    while(t--)
    {
        cin>>n;
        if(n>=400&&n<=599)
            cout<<8<<endl;
        else if(n>=600&&n<=799)
            cout<<7<<endl;
        else if(n>=800&&n<=999)
            cout<<6<<endl;
        else if(n>=1000&&n<=1199)
            cout<<5<<endl;

        else if(n>=1200&&n<=1399)
            cout<<4<<endl;
        else if(n>=1400&&n<=1599)
            cout<<3<<endl;
        else if(n>=1600&&n<=1799)
            cout<<2<<endl;
        else if(n>=1800&&n<=1999)
            cout<<1<<endl;


    }
    return 0;
}


Measured memory_bytes: 3640
n=int(input())
alist=list(map(int,input().split()))

answer_list=[]
for i in range(n-1,-1,-2):
  answer_list.append(alist[i])
if n%2==0:
  for i in range(0,n,2):
    answer_list.append(alist[i])
else:
  for i in range(1,n,2):
    answer_list.append(alist[i])
    
print(*answer_list)

Measured memory_bytes: 26020
#include <iostream>
int main()
{
   int a, b;
   std::cin >> a >> b;
   for (int c = 1; c <= 3; c++)
   {
      if ((a * b * c % 2)!= 0)
      {
         std::cout << "Yes" << std::endl;
         return 0;
      }
   }
   std::cout << "No" << std::endl;
   return 0;
}

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

using namespace std;

int main()
{
  string S; cin >> S;
  sort(S.begin(), S.end());
  for (int i = 1; i < S.size(); ++i) {
    if (S[i] == S[i-1]) {
      cout << "no";
      return 0;
    }
  }

  cout << "yes";
}

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

const int dx[] = {0,  -1, 0, 1, 0,  -1, 1, 1, -1,  -2, 0, 2, 0};
const int dy[] = {0,  0, -1, 0, 1,  -1, -1, 1, 1,  0, -2, 0, 2};
const int sz[] = {5, 9, 13};

struct Ink {
	int x, y, val;
	Ink(int x = 0, int y = 0, int val = 0) : x(x), y(y), val(val) {}
	bool operator < (const Ink &t) const {
		if (x != t.x) return x < t.x;
		if (y != t.y) return y < t.y;
		return val < t.val;
	}
};

set<int> done;
int grid[10][10];

inline int hash_(vector<Ink> &c, int n, int nx, int ny)
{
	typedef unsigned int uint;
	uint p = 1e9 + 7;
	uint mod = 1e9 + 9;
	uint h = 0;
	for (int i = 0; i < c.size(); i++){
		h = (h * p + c[i].x) % mod;
		h = (h * p + c[i].y) % mod;
		h = (h * p + c[i].val) % mod;
	}
	h = (h * p + n) % mod;
	h = (h * p + nx) % mod;
	h = (h * p + ny) % mod;
	return h;
}

inline bool ingrid(int x, int y)
{
	return x >= 0 && y >= 0 && x < 10 && y < 10;
}

vector<Ink> search(int n, vector<Ink> c, int nx, int ny)
{
	if (n == 0){
		if (c.size() == 0) return vector<Ink>(1);
		else return vector<Ink>(0);
	}
	if (c.size() == 0) return vector<Ink>(0);
	
	
	for (int i = 0; i < c.size(); i++){
		if (nx - 2 > c[i].x) return vector<Ink>(0);
		else if (nx - 2 == c[i].x){
			if (ny > c[i].y) return vector<Ink>(0);
		}
	}
	
	
	memset(grid, 0, sizeof(grid));
	for (int i = 0; i < c.size(); i++){
		grid[c[i].x][c[i].y] = c[i].val;
	}
	
	for (; nx < 10; nx++){
		for (; ny < 10; ny++){
			for (int s = 0; s < 3; s++){
				bool f = true;
				for (int dir = 0; dir < sz[s]; dir++){
					int tx = nx + dx[dir];
					int ty = ny + dy[dir];
					//if (!ingrid(tx, ty)) continue;
					if (!ingrid(tx, ty) || grid[tx][ty] == 0){
						for (int dir2 = 0; dir2 < dir; dir2++){
							int tx2 = nx + dx[dir2];
							int ty2 = ny + dy[dir2];
							grid[tx2][ty2]++;
						}
						f = false;
						break;
					}
					grid[tx][ty]--;
				}
				if (!f) continue;
				vector<Ink> v;
				for (int i = 0; i < c.size(); i++){
					if (grid[c[i].x][c[i].y]){
						v.push_back(Ink(c[i].x, c[i].y, grid[c[i].x][c[i].y]));
					}
				}
				vector<Ink> t = search(n - 1, v, nx, ny);
				if (t.size()){
					t.push_back(Ink(nx, ny, s));
					return t;
				}
				for (int dir = 0; dir < sz[s]; dir++){
					int tx = nx + dx[dir];
					int ty = ny + dy[dir];
					//if (!ingrid(tx, ty)) continue;
					grid[tx][ty]++;
				}
			}
		}
		ny = 0;
	}
	
	int h = hash_(c, n, nx, ny);
	if (done.count(h)) return vector<Ink>(0);
	done.insert(h);
	
	return vector<Ink>(0);
}

int main()
{
	int n;
	scanf("%d", &n);
	vector<Ink> c;
	for (int i = 0; i < 10; i++){
		for (int j = 0; j < 10; j++){
			int x;
			scanf("%d", &x);
			if (x) c.push_back(Ink(i, j, x));
		}
	}
	
	vector<Ink> res = search(n, c, 0, 0);
	for (int i = 1; i < res.size(); i++){
		printf("%d %d %d\n", res[i].y, res[i].x, ++res[i].val);
	}
}

Measured memory_bytes: 5884
using System;
public class App
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine();
        var count = 0;
        var a = 0;
        for(int i = 0; i < input.Length; i++)
        {
            if(input[i] == 'R') a++; 
            else if(input[i] == 'S') a=0;
            
            count = Math.Max(count,a);
        }
        
        Console.WriteLine(count);
 }
}

Measured memory_bytes: 25896
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {

			int n = sc.nextInt();

			if (n == 0) {
				break;
			}
			HashMap<String, Integer> value = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				value.put(sc.next(), sc.nextInt());
			}
			int m = sc.nextInt();
			String[][] memo = new String[m][];
			for (int i = 0; i < m; i++) {
				String S = sc.next();
				int l = sc.nextInt();
				memo[i] = new String[l + 1];
				for (int j = 1; j <= l; j++) {
					memo[i][j] = sc.next();
				}
				memo[i][0] = S;
			}
			String t = sc.next();
			boolean f = true;
			while (f) {
				f = false;
				for (int i = 0; i < m; i++) {
					int num = 0;
					for (int j = 1; j < memo[i].length; j++) {
						num += value.get(memo[i][j]);
					}
					if (num < value.get(memo[i][0])) {
						f = true;
						value.put(memo[i][0], num);
					}
				}
			}
			ans = value.get(t);
			System.out.println(ans);
		}

	}
}


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

INF = 10**18

N = int(input())
D = []
U = []
L = []
R = []
UD = []
LR = []
for _ in range(N):
    str_x, str_y, d = map(str, input().rstrip().split())
    x = int(str_x)
    y = int(str_y)
    if d == "U":
        U.append(y)
        UD.append(x)
    elif d == "D":
        D.append(y)
        UD.append(x)
    elif d == "L":
        L.append(x)
        LR.append(y)
    else:
        R.append(x)
        LR.append(y)

UD.sort()
LR.sort()
U.sort()
D.sort()
L.sort()
R.sort()

T = [0]
if L and R:
    T.append((L[0]-R[0])/2)
    T.append((L[-1]-R[-1])/2)
if L and UD:
    T.append(L[0]-UD[0])
    T.append(L[-1]-UD[-1])
if R and UD:
    T.append(UD[0]-R[0])
    T.append(UD[-1]-R[-1])
if U and D:
    T.append((D[0]-U[0])/2)
    T.append((D[-1]-U[-1])/2)
if U and LR:
    T.append(-U[0]+LR[0])
    T.append(-U[-1]+LR[-1])
if D and LR:
    T.append(-LR[0]+D[0])
    T.append(-LR[-1]+D[-1])

ans = INF
for t in T:
    if t < 0: continue
    l = INF
    r = -INF
    d = INF
    u = -INF
    if L:
        l = min(l, L[0]-t)
        r = max(r, L[-1]-t)
    if R:
        l = min(l, R[0]+t)
        r = max(r, R[-1]+t)
    if U:
        d = min(d, U[0]+t)
        u = max(u, U[-1]+t)
    if D:
        d = min(d, D[0]-t)
        u = max(u, D[-1]-t)
    if LR:
        d = min(d, LR[0])
        u = max(u, LR[-1])
    if UD:
        l = min(l, UD[0])
        r = max(r, UD[-1])
    ans = min(ans, (r-l)*(u-d))

print(ans)

Measured memory_bytes: 11380
/*#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<long long, long long>
#define ff first
#define ss second
#define ld long double
 
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
}
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<long long, long long>
#define ff first
#define ss second
#define ld long double
 
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int M, D; cin >> M >> D;
    int ans = 0, cnt = 0;
    for(int i = 2; i <= 9; i++){
        for(int j = 2; j <= 9; j++){
            if(i*10+j > D || i*j > M) continue;
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3568
N,L = map(int,input().split())
aji = []
for i in range(1,N+1):
    aji.append(L+i-1)

aji_sort = sorted(aji)
min_aji = -10000
for j in range(N):
    if aji_sort[j] >= 0:
        min_aji = aji_sort[j]
        break

if min_aji == -10000:
    min_aji = aji_sort[-1]

print(sum(aji)-min_aji)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string.h>
#include<cstdio>
#include<map>
using namespace std;
typedef long long ll;
const int MAX=200000+10; 
int n,k;
ll a[MAX];
ll b[MAX];
ll s[MAX];
map<ll, int>mp;
int lowbit(int x)
{
    return (x&-x);
}
 
void modify(int x,int num)
{
    while(x<=n+1){
        a[x]+=(long long)num;
        x+=lowbit(x);
    }
}
 
long long sum(int x)
{
    long long ans=0;
    while(x>0){
        ans+=a[x];
        x-=lowbit(x);
    }
    return ans;
}
 
int main()
{
    scanf("%d %d",&n,&k);
    s[0]=0;b[0]=0;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        s[i]=s[i-1]+(long long)(x-k);
        b[i]=s[i];
    }
    sort(b,b+1+n);
    int tot=0;
    for(int i=0;i<=n;i++)
        if(!mp.count(b[i]))mp[b[i]]=++tot; 
    long long cnt=0;
    memset(a,0,sizeof(a));
    for(int i=0;i<=n;i++){
        cnt+=sum(mp[s[i]]);
        modify(mp[s[i]],1);
    }
    printf("%lld\n",cnt);
    return 0;
} 

Measured memory_bytes: 21020
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int i,j,k,n;
 map<int,int> m;
 for(i=1;i<=100;i++)
 {
  for(j=1;j<=100;j++)
  {
   for(k=1;k<=100;k++)
   m[(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i)]++;
  }
 }
 cin >> n;
 for(i=1;i<=n;i++)
 cout << m[i] << '\n';
 return 0;
}

Measured memory_bytes: 5428
package main

import (
	"fmt"
	"math"
)

var N, K int
var ans int = 1

func main() {
	fmt.Scan(&N, &K)

	ans *= K
	for i := 1; i < N; i++ {
		ans *= (K - 1)
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


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

int main(){
    int n,c,k;
    string s;
    cin >> n >> k >> c;
    cin >> s;
    //cout << "c = " << c << endl;
    //cout << s << endl;

    vector<int> a(n,0),b(n,0);
    int idx=0;
    while(idx<n){
        if(s[idx]=='o'){
            a[idx] = 1;
            idx += c;
        }
        idx++;
    }
    idx=n-1;
    while(idx>=0){
        if(s[idx]=='o'){
            b[idx] = 1;
            idx -= c;
        }
        idx--;
    }
    vector<int> suma(n,0),sumb(n,0);
    suma[0] = a[0];
    for(int i=1;i<n;i++){
        suma[i] = suma[i-1] + a[i];
    }
    sumb[n-1] = b[n-1];
    for(int i=n-2;i>=0;i--){
        sumb[i] = sumb[i+1] + b[i];
    }
    int ver=-1;
    vector<int> last(n,0);
    for(int i=0;i<n;i++){
        last[i] = ver;
        if(a[i] == 1){
            ver = i;
        }
    }

    vector<int> ans;
    for(int i=0;i<n;i++){
        if(s[i]!='o') continue;
        bool ok = false;
        int left = (i-c-1>=0) ? suma[i-c-1] : 0;
        int right = (i+c+1<n) ? sumb[i+c+1] : 0;
        if(left + 1 + right >= k) ok = true;
        //cout << i << " " << left << " " << right << " " << i-c-1 << endl;

        if(!ok) continue;

        left = (i-1>=0) ? suma[i-1] : 0;
        if(last[i]==-1){
            //cout << "right A" << endl;
            right= (i+1<n) ? sumb[i+1] : 0;
        }else{
            //cout << "right B " << last[i] << " " << last[i]+c+1 << endl;
            right = (max(last[i]+c+1,i+1)<n) ? sumb[max(last[i]+c+1,i+1)] : 0;
        }

        //cout << i << " " << left << " " << right << endl;
        if(left+right<k){
            ans.emplace_back(i);
        }
    }
    for(auto v : ans){
        cout << v+1 << endl;
    }

    /*
    cout << "a : ";
    for(auto v : a) cout << v << " ";
    cout << endl;
    cout << "suma : ";
    for(auto v : suma) cout << v << " ";
    cout << endl;
    cout << "b : ";
    for(auto v : b) cout << v << " ";
    cout << endl;
    cout << "sumb : ";
    for(auto v : sumb) cout << v << " ";
    cout << endl;
    */
}

Measured memory_bytes: 6520
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n,m,i,j;
    cin>>n>>m;
    vector<ll> h(n);
    for(i=0;i<n;i++) cin>>h[i];
    ll a,b;
    set<ll> e[n];
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        a--;b--;
        e[a].insert(b);
        e[b].insert(a);
    }
    ll ans = 0 ;
    for(i=0;i<n;i++)
    {
        if(e[i].empty()) {ans++;continue;}
        ll f = 0;
        ll cur = h[i];
        for(auto v : e[i])
        {
            if(cur<=h[v]) {f=1;break;}
        }
        if(!f) ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 17960
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;

	int d[N+5];
	int num[N+5];
	for(int k=0;k<N;++k){
		cin >> d[k];
	}

	sort(d, d + N);
	int jiten = 1;
	for(int i=0;i<N-1;++i){
		if(d[i] != d[i+1]){
			++jiten;
		}
	}
	cout << jiten << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, x;
    cin >> n >> x;
    vector<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    lint ret = inf;
    vector<lint> b(n, inf);
    for (int i = 0; i < n; ++i) { // i: magic
        lint temp = i * x;
        for (int j = 0; j < n; ++j) {
            chmin(b[j], a[(j - i + n) % n]);
            temp += b[j];
        }
        chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
vector<vector<int>> v(201);

int arr[201];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int A = 0, B = 0, C = 0;

    int N;
    cin >> N;

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            int a;
            cin >> a;
            v[i].push_back(a);
        }
    }

    for (int i = 0; i < 3; ++i)
    {
        map<int, int> mp;
        for (int j = 0; j < N; ++j)
        {
            mp[v[j][i]]++;
        }

        for (int j = 0; j < N; ++j)
        {
            if (mp[v[j][i]] == 1)
            {
                arr[j] += v[j][i];
            }
        }
    }

    REP(i, N)
    cout << arr[i] << endl;
    return 0;
}



Measured memory_bytes: 3232
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input {(source=$s:expr,$($r:tt)*) => {let mut iter=$s.split_whitespace(); let mut next=||{iter.next().unwrap()}; input_inner! {next,$($r)*}};($($r:tt)*) => {let stdin=std::io::stdin();let mut bytes=std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next=move||->String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()}; input_inner! {next,$($r)*}};}
#[allow(unused_macros)]
macro_rules! input_inner {($next:expr) => {}; ($next:expr,) => {}; ($next:expr,$var:ident:$t:tt$($r:tt)*) => {let $var=read_value!($next,$t); input_inner! {$next$($r)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($next:expr,($($t:tt),*)) => {($(read_value! ($next,$t)),*)}; ($next:expr, [$t:tt; $len:expr]) => {(0..$len).map(|_|read_value! ($next,$t)).collect::<Vec<_>>()}; ($next:expr,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{n:usize, k:i64, a:[i64;n]};
    let mut map = HashMap::new();
    for el in a {
        let count = map.entry(el).or_insert(0i64);
        *count += 1;
    }
    let mut ans = 0i64;
    let mut vect:Vec<i64> = map.into_iter().map(|(_,v)| v).collect();
    vect.sort();
    if vect.len() <= k as usize {
        println!("0");
        return();
    }
    for (i,v) in vect.iter().enumerate() {
        if i == vect.len() - k as usize {break;}
        ans += *v;
    }

    println!("{}", ans);


}


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

# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define p(s) std::cout << s << endl;

int main()
{
    int a,b;cin >> a >> b; ;
    int ret=0;
    for(int i=a;i<=b;i++){
        string tmp=to_string(i);
        if(tmp.substr(0,2)==(tmp.substr(4,1)+tmp.substr(3,1))) ret++;
    }
    p(ret)
}

Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
	long int a=0,b=0,c=0,d=0,e=0;
	scanf("%ld %ld",&a,&b);
	c=a+b;
	d=a-b;
	e=a*b;
	
	if(c>=d&&c>=e)
	{
		printf("%ld\n",c);
	}
	else if(d>=c&&d>=e)
	{
		printf("%ld\n",d);
	}
	else if(e>=c&&e>=d)
	{
		printf("%ld\n",e);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  int N;
  scanf("%d",&N);
  N=N%10;
  if(N==3){
    printf("bon");
  }else if(N==0||N==1||N==6||N==8){
    printf("pon");
  }else{
    printf("hon");
  }
  return 0;
}

Measured memory_bytes: 1732
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
a_half = A[-1] / 2
def binsearch(upper, lower):
  if upper - lower == 1:
    if A[upper] == A[-1] or abs(A[upper] - a_half) > abs(a_half - A[lower]):
      return lower
    else:
      return upper
  med = (upper + lower) // 2
  if A[med] == a_half:
    return med
  elif A[med] > a_half:
    return binsearch(med, lower)
  else:
    return binsearch(upper, med)
print(A[-1], A[binsearch(N - 1, 0)])

Measured memory_bytes: 14052
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> C(H);
  for(int i=0;i<H;i++){
    cin >> C.at(i);
  }
  for(int i=0;i<H;i++){
    cout << C.at(i) << endl;
    cout << C.at(i) << endl;
  }

  return 0;
}


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

using namespace std;

int main(){
	
	int x,y,a,maxx,maxy,mode;
	string s;
	
	while(1){
		
		x=1; y=1; mode=0;
		
		cin >> maxx >> maxy;
		
		if(maxx==0 && maxy==0)break;
		
		while(1){
			
//			cout << x << " " << y << endl;
		
			cin >> s;
			
			
			if(s == "FORWARD"){
				
				cin >> a;
				if(mode==0)y=y+a;
				else if(mode==1) x=x+a;
				else if (mode==2) y=y-a;
				else if(mode==3) x=x-a;
				
			}
			else if(s == "BACKWARD"){
				
				cin >> a;
				if(mode==0)y=y-a;
				else if(mode==1) x=x-a;
				else if (mode==2) y=y+a;
				else if(mode==3) x=x+a;				
				
			}		
			
			else if(s == "RIGHT"){
				mode = (mode+1)%4;
			}
			
			else if(s == "LEFT"){
				mode = (mode+3)%4;
			}
			
			else if(s == "STOP") break;
			
			if(1 > x) x=1;
			if(x > maxx) x=maxx;
			if(1 > y) y=1;
			if(y > maxy) y=maxy;
		}
		
		cout << x << " " << y << endl;
		
	}
	
	return 0;
		
	
}

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

int main()
{
    long long n,k,s,j=1000000000;
    cin>>n>>k>>s;
    if(s!=j)
    {
        for(int i=0; i<k; i++)
            cout<<s<<" ";
        for(int i=0; i<n-k; i++)
            cout<<j<<" ";
        cout<<endl;
    }
    else
    {
        for(int i=0; i<k; i++)
            cout<<j<<" ";
        for(int i=0; i<n-k; i++)
            cout<<1<<" ";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

size_t ldistance(string s, string t) {
    /* Levenshtein Distance */
    size_t slen=s.length(), tlen=t.length();
    vector<vector<size_t>> dp(slen+1, vector<size_t>(tlen+1));

    for (size_t i=0; i<=slen; ++i)
        dp[i][0] = i;

    for (size_t j=0; j<=tlen; ++j)
        dp[0][j] = j;

    for (size_t i=1; i<=slen; ++i)
        for (size_t j=1; j<=tlen; ++j) {
            size_t icost=min(dp[i-1][j], dp[i][j-1])+1;
            size_t scost=dp[i-1][j-1]+(s[i-1]!=t[j-1]);
            dp[i][j] = min(icost, scost);
        }

    return dp[slen][tlen];
}

int main() {
    char buf[1024];
    scanf("%s", buf);
    string s1(buf);

    scanf("%s", buf);
    string s2(buf);

    printf("%zu\n", ldistance(s1, s2));
    return 0;
}

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

using namespace std;

class dsu {
  vector<int> p, sz;
public:
  dsu(int n) {
    p.resize(n);
    sz.resize(n, 1);
    iota(p.begin(), p.end(), 0);
  }

  int get(int v) {
    return (v == p[v] ? v : p[v] = get(p[v]));
  }

  bool unite(int u, int v) {
    u = get(u), v = get(v);
    if (u == v) {
      return false;
    }
    if (sz[u] > sz[v]) {
      p[v] = u;
      sz[u] += sz[v];
    } else {
      p[u] = v;
      sz[v] += sz[u];
    }
    return true;
  }

  int size(int v) {
    return sz[get(v)];
  }
};

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

  int n, m;
  cin >> n >> m;
  dsu d(n);
  while (m--) {
    int a, b;
    cin >> a >> b;
    d.unite(a - 1, b - 1);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) ans = max(ans, d.size(i));
  cout << ans;

  return 0;
}


Measured memory_bytes: 4776
import java.util.Scanner;

public class Main {
	
	static long[] maxPas = new long[5];
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		for(int i=0; i<M; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		
		int Lmax = max(L);
		int Rmin = min(R);
		
		if(Rmin >= Lmax) {
			System.out.println(Rmin - Lmax + 1);
		} else {
			System.out.println(0);
		}
		
		
	}
	
	private static int max(int[] a) {
		int max = a[0];
		for(int i=0; i<a.length; i++) {
			int v = a[i];
			if(v>max) {
				max = v;
			}
		}
		return max;
	}

	private static int min(int[] a) {
		int min = a[0];
		for(int i=0; i<a.length; i++) {
			int v = a[i];
			if(v<min) {
				min = v;
			}
		}
		return min;
	}

}


Measured memory_bytes: 84460
import sys
sdin = sys.stdin.readline

N,Ma,Mb = map(int, sdin().split())
ABC = []
for i in range(N):
    ABC.append(tuple(map(int, sdin().split())))


sum_a = [0]
sum_b = [0]
for a,b,c in ABC:
    sum_a.append(sum_a[-1]+a)
    sum_b.append(sum_b[-1]+b)
    
INF = float("inf")
MAX_W = 400
dp = [[[INF for _ in range(sum_b[-1]+1)] for _ in range(sum_a[-1]+1)] for _ in range(N+1)]
for i in range(N+1):
    dp[i][0][0] = 0

for i, (ai, bi, ci) in enumerate(ABC):
    for a in range(sum_a[i+1]+1):
        for b in range(sum_b[i+1]+1):
            if a-ai>=0 and b-bi>=0:
                dp[i+1][a][b] = min(dp[i][a][b], dp[i][a-ai][b-bi]+ci)
            else:
                dp[i+1][a][b] = dp[i][a][b]
        
k = 1           
ans = INF
while (k*Ma<=sum_a[-1] and k*Mb<=sum_b[-1]):
    ans = min(ans, dp[N][k*Ma][k*Mb])
    k += 1
    
if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 91996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef long double lb;
#define ri register int
const lb PI=3.141592653589793238462643383279;
const ll inf=1000000000000000000ll;
const int N=1000005,M=998244353;
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		b>>=1;
		s=s*s%M;
	}
	return ans;
}
ll n,a,b; 
int main()
{
	cin>>n>>a>>b;
	if(abs(b-a)&1)
		cout<<min(a+b,2*n+2-a-b)/2;
	else
		cout<<abs(a-b)/2;
}


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

int main(){
  string s, t;
  int n, m;
  cin >> s;
  cin >> t;
  n = s.size();
  m = 0;
  for(int i = 0; i < n; i++){
    if(s.at(i) == t.at(i)){
      m = m + 1;
    }
  }
  if(m == n){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]!=s[i+1]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int w,h,x,y,r;
    
    cin>>w>>h>>x>>y>>r;
    
    if((r<=x && x<=w-r) && (r<=y && y<=h-r)){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    
    return 0;
    
}


Measured memory_bytes: 3212
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define MOD 1000000007
#define MX 200005

using namespace std;

typedef long long ll;

ll fac[MX], faci[MX];

ll qpow(ll x, ll t)
{
	ll ans = 1;
	while(t)
	{
		if(t & 1) ans = ans*x%MOD;
		t = t>>1;
		x = x*x%MOD;
	}
	return ans;
}

ll inv(ll x)
{
	return qpow(x, MOD-2);
}

void init()
{
	fac[0] = 1;
	for(int i=1; i<MX; i++) fac[i] = fac[i-1]*i%MOD;
	faci[MX-1] = inv(fac[MX-1]);
	for(int i=MX-1; i>=1; i--) faci[i-1] = faci[i]*i%MOD;
}

ll C(int n, int m)
{
	if(n<0 || m<0 || m>n) return 0;
	return fac[n] * faci[m] % MOD * faci[n-m] % MOD;
}

ll dway[MX];

int main()
{
	int n, m, a, b;
	init();
	scanf("%d%d%d%d", &n, &m, &a, &b);
	ll ans = 0;
	for(int i=b; i>=1; i--) ans = (ans+C(m-i+a-1, a-1)*C(i-1+n-a-1, n-a-1))%MOD;
	printf("%lld\n", (C(n+m-2, m-1) - ans + MOD) % MOD);
	return 0;
}

Measured memory_bytes: 3328