akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int check(int n){

    string s = to_string(n);
    for(int i = 0; i < s.size() / 2; i++){
        if(s[i] != s[s.size()-1-i]) return 0;
    }

    return 1;
}

int main(){

    int a, b;
    cin >> a >> b;
    ll ans = 0;
    for(int i = a; i <= b; i++){
        if(check(i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  	string str;
  	cin >> str;
  	int sum = 0;
  	for(int i=0; i < str.size(); i++){
      	if(str.at(i) == '1')
          sum++;
    }
  	cout << sum << endl;
  	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    int ans;
    cin>>ans;
    char t;
    int n;
    while(cin>>t){
        if(t=='=') break;
        cin>>n;
        // cout<<n<<" "<<t<<endl;
        if(t=='+') ans+=n;
        if(t=='-') ans-=n;
        if(t=='*') ans*=n;
        if(t=='/') ans/=n;
    }
    cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
      cout<<fixed<<setprecision(20);
    mainmain();
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

/*
flag = trueで正順，falseで逆順
true, F=1, 先頭
true, F=2, 末尾
false, F=1, 末尾
false, F=2, 先頭

+= で文字を追加していきたい
先頭につける文字列は最後反転
末尾につける文字列
*/

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

    string front = "", back = "";
    bool flag = true;

    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1)
            flag = !flag;
        if (t == 2) {
            int f;
            char c;
            cin >> f >> c;
            if ((flag && f == 1) || (!flag && f == 2)) {
                front.push_back(c);
            } else {
                back.push_back(c);
            }
        }
    }

    reverse(front.begin(), front.end());
    string out = front + s + back;
    if (!flag)
        reverse(out.begin(), out.end());
    cout << out << endl;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    int sum = 0;
    rep(i, N) {
        cin >> v[i];
        sum += v[i];
    }
    sort(v.begin(), v.end());
    int max = v[N - 1];
    if(sum - max > max) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

string Caesar(string a) {
	for (int b = 0; b < a.length(); b++) {
		if (a[b] == 'z')a[b] = 'a';
		else if (a[b] >= 'a'&&a[b] < 'z')a[b] = a[b] + 1;
	}
	return a;
}
int main() 
{
	string a;
	while (getline(cin, a)) {
		for (int b = 0; b < 26; b++) {
		    a=Caesar(a);
			for (int c = 0; c < a.length() - 4; c++) {
				if (a[c] == 't'&&a[c + 1] == 'h') {
					if (a[c + 2] == 'e') { cout << a << endl; goto l; }
					else	if (a[c + 2] == 'a'&&a[c + 3] == 't') { cout << a << endl; goto l; }
					else	if (a[c + 2] == 'i'&&a[c + 3] == 's') { cout << a << endl; goto l; }
				}
			}
			if(a[a.length()-1]=='t'&&a[a.length() - 2] == 'h'&&a[a.length() - 3] == 'e') { cout << a << endl; break; }
		l:;
		}
	}
}

Measured memory_bytes: 2952
#include <bits/stdc++.h>
#define me(a,b) memset(a,b,sizeof(a))
using namespace std;
/*int n,m;
int vis[250][250];
char mp[250][250];
int fx[4][2]={0,1,0,-1,1,0,-1,0};
int yx,yy,mx,my,sum;
struct pointb
{
    int x,y,leny,lenm,step;
}ed[250*250];
queue<point>q;
void(int pi,int pj,int f)
{
    while(q.size())   q.pop();
    point now,kai,next;

}
int main()
{
    while(scanf("%d %d",&n,&m)!=EOF)
    {
        sum=0;
        me(ed,0);
        for(int i=0;i<n;i++)
        {
            scanf("%s",mp[i]);
            for(int j=0;j<m;j++)
            {
                if(mp[i][j]=='@')
                {
                    ed[sum].x=i;
                    ed[sum++].y=j;
                }
                else if(mp[i][j]=='Y')
                {
                    yx=i;
                    yy=j;
                }
                else if(mp[i][j]=='M')
                {
                    mx=i;
                    my=j;
                }
            }
        }
        bfs(yx,yy,0);
        bfs(mx,my,1);
        int mi=0x3f3f3f3f;
        for(int i=0;i<sum;i++)
        {
            ed[i].leny=0x3f3f3f3f;
            ed[i].lenm=0x3f3f3f3f;
        }
        for(int i=0;i<sum;i++)
        {
            mi=min(ed[i].leny+ed[i].lenm,mi);
        }
        printf("%d\n",mi);
    }
    return 0;
}

int main()
{
    int a,b,t;
    while(scanf("%d %d %d",&a,&b,&t)!=EOF)
    {
        int sum=0;
        for(int i=1;i*a<=t;i++)
        {
            sum+=b;
        }
        printf("%d\n",sum);
    }
}
#include <stdio.h>
 long long zxgbs(long long x,long long y)
 {
     int i;
    for(i=1;x*i%y;i++);
        return x*i;
  }
 int main()
 {
     int i,j,n,flag=0,max;
     long long a[1000],sum,temp;
     while(scanf("%d",&n)!=EOF)
     {
         for(i=0;i<n;i++)
         scanf("%lld",&a[i]);
         for(i=0;i<n;i++)
         {
             max=i;
             for(j=i+1;j<n;j++)
                 if(a[max]<a[j])
                     max=j;
                    temp=a[i];
                 a[i]=a[max];
                 a[max]=temp;
         }
         sum=a[0];
         for(i=1;i<n;i++)
         {
             sum=zxgbs(sum,a[i]);
             for(j=i+1;j<n;j++)
             {
                 if(sum%a[j])
                 {
                      flag=0;
                      break;
                 }
                 else
                    flag=1;
             }
             if(flag==1)
             {
                 flag=0;
                 break;
              }
         }
         printf("%lld\n",sum);
     }
     return 0;
 }*/
 int k,n;
 long long a[100005];
 //long long b[100005];
 int main()
 {
     scanf("%d %d",&n,&k);
     for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
     sort(a,a+n);
     int mi=0x3f3f3f3f;
     int b;
     for(int i=0;i<=n-k;i++)
     {
         b=a[i+k-1]-a[i];
         mi=min(mi,b);
     }
     //for(int i=0;i<n-k)
     printf("%d\n",mi);
 }








Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, m, c, a[30][30], b[30];

    cin >> n >> m >> c;

    REP(i, m)
    cin >> b[i];

    REP(i, n)
    REP(j, m)
    cin >> a[i][j];

    int res = 0;

    REP(i, n)
    {
        int s = c;

        REP(j, m)
        {
            s += b[j] * a[i][j];
        }

        res += s > 0;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

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

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){
	ll x,k,d;
	cin >> x >> k >> d;
	if(abs(x)/d>k){
		if(x>0){
			cout << x - k * d << endl;
		}
		else{
			cout << abs(x + k * d) << endl;
		}
	}
	else{
		ll st = x - (x / d) * d;
		ll kst = k - (abs(x) / d);
		if(kst%2==0){
			cout << abs(st) << endl;
		}
		else{
			cout << d-abs(st) << endl;
		}
	}
}

int main(){
	
	solve();
	
    return 0;
}



Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
#define int long long
#define INTMAX 1e15+5
#define mp make_pair
#define N 1000005
#define pb push_back
#define pencho ios_base::sync_with_stdio(false);cin.tie(NULL);
#define s second
/*STL:
       (1) PRIORITY_QUEUE pq:
       -> priority_queue < int > pq; // max_heap
       -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap
       -> pq.top()   --> returns the maximum or minimum element
       -> pq.push()  --> push element into the queue
       -> pq.pop()   --> remove top most element
       -> pq.empty() --> checks whether queue is empty or not

       (2) set / multiset  ss;
       --> ss.insert(key); (insertion)
       --> ss.erase(ss.find(key)) .. (deletion)
       --> ss.find(key) != ss.end() ..existence check
       --> ss.lower_bound(x) -> smallest value which is greater than or equals to x
       --> ss.upper_bound(x) --> first value strictly greater than x
       --> multiset< data_type , greater<data_type> > ms; // for max ordering

       (3) common functions
       lower_bound(v.begin(),v.end(),x) - v.begin() --> smallest value greater than or equals to x
       upper_bound(v.begin(), v.end(),x)- v.begin() --> smallest value greater than x
       memset(dp , val , sizeof(dp)) -> sets the value of array dp to val

       (4)    Comparator for set
                     struct comp {
                            bool operator()(pair<int, int>a, pair<int, int>b) {
                     };
};
*/
int mod = 1000000007;
int bp(int x, int y) {int ans = 1; x %= mod; while (y) {if (y & 1) ans = ans * x % mod; x = x * x % mod; y >>= 1;} return ans;}
int mod_inverse(int x) {return bp(x, mod - 2); }
int gcd (int a, int b) { while (b) {a %= b; swap(a, b);} return a;}
int max(int a, int b) {     if (a < b)    swap(a, b);   return a;}
int min(int a, int b) { if (a > b) swap(a, b); return a;}
int countSetBits(int n) {int count = 0; while (n) {count += n & 1; n >>= 1;} return count;}

int dp[100005][100];

int solveDp(int val, int index, int item[][2], int n) {
       if (val <= 0)    return 0;
       if (index == n)  return INTMAX;
       if (dp[val][index] != -1)       return dp[val][index];

       dp[val][index] = min(item[index][0] + solveDp(val - item[index][1], index + 1, item, n),
                            solveDp(val, index + 1, item, n));
       return dp[val][index];
}

int calc(int cap, int n, int item[][2]) {
       for (int i = 100000; i >= 0; i--) {
              if (solveDp(i, 0, item, n) <= cap)       return i;
       }
       return 0;
}


void solve() {
       int n, w;      cin >> n >> w;
       int item[n][2];
       memset(dp, -1, sizeof(dp));
       for (int i = 0; i < n; i++) cin >> item[i][0] >> item[i][1];
       cout << calc(w, n, item);
}




signed main()
{
#ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("o.txt", "w", stdout);
#endif

       solve();
}

Measured memory_bytes: 81736
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    long long n;
    int k;
    cin >> n >> k;
    cout << floor(log(n) / log(k)) + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC161(void);
void ABC162(void);
void ABC163(void);
void ABC164(void);

int main(void){
    ABC164();
}

void ABC164(){
    int s,w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}


Measured memory_bytes: 3636
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll N;
	cin >> N;
	string s;
	cin >> s;
	ll cr = 0, cb = 0;
	for (char p : s) {
		if (p == 'R') ++cr;
		else ++cb;
	}
	cout << (cr > cb ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector < set < int > > sts(26);
	for (int i = 0; i < n; ++i) 
		sts[s[i] - 'a'].insert(i);
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int t, l, r, p;
		char c;
		cin >> t;
		if (t == 1) {
			cin >> p >> c;
			sts[s[p - 1] - 'a'].erase(p - 1);
			sts[c - 'a'].insert(p - 1);
			s[p - 1] = c;
		}
		else if (t == 2) {
			cin >> l >> r;
			--l; --r;
			int ans = 0;
			for (int j = 0; j < 26; ++j) {
				auto it = sts[j].lower_bound(l);
				if (it != sts[j].end() && *it <= r)
					++ans;
			}
			cout << ans << '\n';
		}
	}
}


Measured memory_bytes: 24220
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define efo(i,q) for(int i=A[q];i;i=B[i][0])
using namespace std;
typedef long long LL;
const int N=1500;
int read(int &n)
{
	char ch=' ';int q=0,w=1;
	for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n;
int a[N];
LL ans;
LL f[N][N][4];
int main()
{
	int q;
	LL w;
	scanf("%lld",&w);
	for(;w;a[++n]=w%10,w=w/10);
	fo(I,n,n*2)
	{
		f[I][0][0]=1;
		fo(i,1,(I+1)/2)
		{
			fo(j,0+(i==1),9)
			{
				fo(k,0,1)
				{
					int J1=(j+a[i]+k)>9;
					q=(j+a[i]+k)%10;
					if(i==1&&!q)continue;
					if(i==(I+1)/2&&(I&1))
					{
						if(q==j)
							ans+=f[I][i-1][J1*2+k];
						continue; 
					}
					if((a[I-i+1]+q)%10==j)
					{
						f[I][i][J1]+=f[I][i-1][k+2*((a[I-i+1]+q)>9)];
					}
					if((a[I-i+1]+q+1)%10==j)
					{
						f[I][i][J1+2]+=f[I][i-1][k+2*((a[I-i+1]+q+1)>9)];
					}
				}
			}
			if(i==(I+1)/2&&!(I&1))
			{
				ans+=f[I][i][0]+f[I][i][3];
			}
		}
//		printf("%d %d\n",I,ans);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        string input= Console.ReadLine();
        //int input =int.Parse(Console.ReadLine());
        Console.WriteLine((int.Parse(input[2].ToString())*10+int.Parse(input[4].ToString()))%4==0?"YES":"NO");


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N;
ll T;
int main()
{
  cin>>N>>T;
  ll A[N];
  REP(i,0,N){
    cin>>A[i];
  }
  int mi=A[0];
  long long dif=0;
  int tmp=0;
  int ans=1;
  
  REP(i,0,N){
    long long di=A[i]-mi;

    if(di>dif){
      ans=1;
      dif=di;
    }else if(di==dif){
      ans++;
    }
    if(A[i]<mi){
      mi=A[i];
    }

  }
  


  cout<<ans<<endl;

	

  


  return 0;
}

Measured memory_bytes: 1024
import itertools
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
ls = [A,B,C,D,E]
ls2 = []
for i in itertools.permutations(ls,5):
  ls2.append(list(i))
minimum = 10**5
for i in ls2:
  now = 0
  for j in range(5):
    if j == 0:
      now += i[j]
    else:
      if now % 10 == 0:
        now += i[j]
      else:
        now = 10 * (now//10+1)
        now += i[j]
  if now < minimum:
    minimum = now
print(minimum)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
// using ll = long long;
using vi = vector<int>;
// using vvi = vector<vi>;
// #define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
// #define irp(i,s,e) for(int i=(s);i>(e);--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(b<a){a=b;return 1;}return 0;}
// #define NMAX 1000000000
int N,M;
vi A;

bool solve(){
	// rp(i,0,N)cout<<A[i]<<" ";puts("");//

	int tot = 0;
	rp(i,0,N){
		tot+=A[i];
		A[i] *= 4*M;
	}
	int count = 0;
	rp(i,0,N){
		if(tot>A[i]) continue;
		count++;
	}
	if(count >= M) return true;
	return false;
}

int main(){
	cin>>N>>M;
	// cout<<N<<" "<<M<<"\n";//
	A.resize(N);
	rp(i,0,N){
		cin>>A[i];
	}
	cout<< (solve()?"Yes":"No") <<endl;
}


Measured memory_bytes: 256
n,w=map(int,input().split())
l=[]
for i in range(n):
	l.append(list(map(int,input().split())))
max_val=1000*n
dp=[[float('inf') for i in range(max_val+1)] for j in range(n+1)]
dp[0][0]=0

for i in range(1,n+1):
	for j in range(0,max_val+1):
		dp[i][j]=dp[i-1][j]
		if(l[i-1][1]<=j):
			dp[i][j]=min(dp[i][j],dp[i-1][j-l[i-1][1]]+l[i-1][0])

for i in range(max_val,-1,-1):
	if(dp[n][i]<=w):
		print(i)
		break

Measured memory_bytes: 268044
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long Inf = (long) 1e18;
		long[][][] dp = new long[K+1][][];
		for(int k=0;k<=K;k++){
			dp[k] = new long[N+1][];
			for(int i=0;i<=N;i++){
				dp[k][i] = new long[N+1];
				for(int j=0;j<=N;j++) dp[k][i][j] = - Inf;
			}
		}
		//Console.WriteLine("ok");
		dp[0][0][N] = 0;
		for(int k=0;k<K;k++){
			for(int i=0;i<=N;i++){
				for(int j=i;j<=N;j++){
					if(dp[k][i][j] == -Inf) continue;
					dp[k + 1][i][j] = Math.Max(dp[k + 1][i][j], dp[k][i][j]);
					if(i == j) continue;
					dp[k + 1][i + 1][j] = Math.Max(dp[k + 1][i + 1][j], dp[k][i][j] + V[i]);
					dp[k + 1][i][j - 1] = Math.Max(dp[k + 1][i][j - 1], dp[k][i][j] + V[j - 1]);
					if(k + 2 > K) continue;
					dp[k + 2][i + 1][j] = Math.Max(dp[k + 1][i + 1][j], dp[k][i][j]);
					dp[k + 2][i][j - 1] = Math.Max(dp[k + 1][i][j - 1], dp[k][i][j]);
				}
			}
		}
		//Console.WriteLine("ok");
		long ma = 0;
		for(int i=0;i<=N;i++){
			for(int j=0;j<=N;j++){
				ma = Math.Max(ma, dp[K][i][j]);
			}
		}
		Console.WriteLine(ma);
	}
	int N,K;
	long[] V;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		V = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int a[] = new int[100];  // 配列確保（大きめに）
        int n = scanner.nextInt(); // データ数
        int i;
        
        // データ入力
        for (i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
	  	
        for (i = n -1; i >=  0; i--) {
        	if(i > 0)
        		System.out.print(a[i] + " ");
        	else
        		System.out.print(a[i]);
        }
        System.out.print("\n");
        scanner.close();
  }
}



Measured memory_bytes: 26388
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl
 
#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()
 
#define pb push_back
#define ff first
#define ss second
#define hell 1000000007
 
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009
 
ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;cin>>s;
	ll n=s.length();
	rep(i,1,n)
	{
		if(s[i]==s[i-1])
		{
			cout<<i<<" "<<i+1<<endl;
			return 0;
		}
	}
	rep(i,2,n)
	{
		if(s[i]==s[i-2])
		{
			cout<<i-1<<" "<<i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 100;
int n, a[MAX_N];
long long int dp[MAX_N + 1][21];
int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	dp[0][a[0]] = 1;
	for (int i = 1; i < n - 1; i++){
		for (int j = 0; j <= 20; j++){
			if (j + a[i] <= 20)
				dp[i][j] += dp[i - 1][j + a[i]];
			if (j - a[i] >= 0)
				dp[i][j] += dp[i - 1][j - a[i]];
		}
	}

	cout << dp[n - 2][a[n - 1]] << endl;
}

Measured memory_bytes: 1172
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

int log(int x) {
    int i;
    for(i=0;(1ll<<i)<=x;i++);
    return i;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    int n=s.size();
    
    int c=0,ans=0;
    fff(i,n) {
        if(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T')
        c++;
        else {
            ans=max(c,ans);
            c=0;
        }
    }
    ans=max(c,ans);
    cout << ans;
	return 0;
    
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N;
VL A;
V dir;

int main() {
    cin >> N;
    A.resize(N);
    dir.resize(N);
    ll m = LINF;
    ll sum = 0;
    REP(i, N) {
        cin >> A[i];
        if(A[i] < 0)
            dir[i] = -1;
        else
            dir[i] = 1;
        m = min(m, abs(A[i]));
        sum += abs(A[i]);
    }
    REP(i, N - 1) {
        if(dir[i] == -1) {
            dir[i] *= -1;
            dir[i + 1] *= -1;
        }
        if(i == N - 2) {
            if(dir[N - 1] == -1) {
                sum -= 2 * m;
            }
        }
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==LEN){
    tail=0;
  }
  else{
    tail++;
  }

}

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


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

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

  head=1;
  tail=n+1;
  while(head!=tail){
    u=dequeue();
    if(u.t>q){
      u.t-=q;
      elaps+=q;
      enqueue(u);
    }
    else{
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
    }
  }


  return 0;
}



Measured memory_bytes: 11936
/// referenced: https://beta.atcoder.jp/contests/abc056/submissions/2304275
#include<bits/stdc++.h>
using namespace std;
main(){
  int N,K;
  cin>>N>>K;
  vector<int>a(N);
  for(auto&x:a)cin>>x;
  sort(a.begin(),a.end());
  int ans=N,sum=0;
  for(int i=a.size()-1;i>=0;--i)
    if(sum+a[i]<K)
      sum+=a[i];
    else
      ans=i;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    int N, K; cin >> N >> K;

    if (K > 1) {
    	cout << N -K << endl;
    } else {
    	cout << 0 << endl;
    }
    
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

ll n;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	if (n % 2 == 1) return cout << 0, 0;
	ll ans = 0;
	ll Now = 1;
	while (Now * 5 <= n / 2){
		Now *= 5;
		ans += (n / 2) / Now;
	}
	cout << ans;











	return 0;
}


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

typedef long long ll;
ll MOD = 1e9+7;

int main()
{
	int n;
	cin>>n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	vector< vector<int> > memo(n, vector<int>(n, -1));
	for (int i = 0; i < n; i++) {
		int idx = i + 2;
		for (int j = i + 1; j < n; j++) {
			while (idx < n) {
				if (a[idx] == 2 * a[j] - a[i]) {
					memo[i][j] = idx;
					break;
				} else if (a[idx] > 2 * a[j] - a[i]) {
					break;
				}
				idx++;
			}
			if (idx >= n) break;
		}
	}

	vector< vector<int> > dp(n, vector<int>(n, 2));
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (memo[i][j] == -1) continue;
			dp[j][memo[i][j]] = max(dp[j][memo[i][j]], dp[i][j] + 1);
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 198768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=3e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll W[MAXn],E[MAXn];
int main(){
  IOS();
  ll n;
  cin >> n;
  string s;
  cin >> s;

  REP1 (i,n) W[i] = W[i-1] + (s[i-1] == 'W');
  for (ll i=n;i>0;i--) E[i] = E[i+1] + (s[i-1] == 'E');

  ll ans = INF;
  REP1 (i,n) ans = min(ans,W[i-1] + E[i+1]);
  cout << ans << endl;
}


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

using namespace std;

const int N = 1e5 + 10;

int n, k;
char s[N];

int main() {
  cin >> n >> k;
  scanf("%s", s + 1);
  int ans = 0, cnt1 = 0, cnt2 = 0;
  for (int i = 2; i <= n; i++) {
    if (s[i - 1] == 'L' && s[i] == 'L') ans++;
    if (s[i - 1] == 'R' && s[i] == 'R') ans++;
    if (s[i - 1] == 'L' && s[i] == 'R') {
      if (k && cnt2) {
        k--;
        cnt2--;
        ans += 2;
      } else {
        cnt1++;
      }
    }
    if (s[i - 1] == 'R' && s[i] == 'L') {
      if (k && cnt1) {
        k--;
        cnt1--;
        ans += 2;
      } else {
        cnt2++;
      }
    }
  }
  // cout << cnt1 << " " << cnt2 << endl;
  if (k && ((cnt1 && (s[1] == 'L' || s[n] == 'R')) || (cnt2 && (s[1] == 'R' || s[n] == 'L')))) ans++;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

const int INF = 1e9;



int main() {

    int h, w, k, x1, y1, x2, y2; cin >> h >> w >> k >> x1 >> y1 >> x2 >> y2;

    --x1, --y1, --x2, --y2;

    char MP[h][w] = {};

    int dis[h][w] = {};

    for (int i = 0; i < h; i++) 

        for (int j = 0; j < w; j++)

            cin >> MP[i][j], dis[i][j] = INF;

    queue<pair<int, int>> que;

    dis[x1][y1] = 0;

    que.push({x1, y1});

    while (!que.empty()) {

        int x = que.front().first;

        int y = que.front().second;

        que.pop();

        for (int i = 0; i < 4; i++) {

            int nx = x, ny = y;

            int nd = dis[x][y] + 1;

            for (int j = 1; j <= k; j++) {

                nx += dir[i][0];

                ny += dir[i][1];

                if (nx < 0 or ny < 0 or nx >= h or ny >= w or MP[nx][ny] == '@' or dis[nx][ny] < nd)

                    break;

                if (dis[nx][ny] > nd) {

                    dis[nx][ny] = nd;

                    que.push({nx, ny});

                }

            }

        }

    }

    int ans = dis[x2][y2];

    cout << (ans == INF ? -1 : ans);

}



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

using namespace std;

int main()
{
    int a, b, k;
    cin >> k >> a >> b;
    int n = a;
    for (size_t i = a; i < b + 1; i++)
    {
        if (i % k == 0)
        {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 101010;
int parents[N];
int Find(int a) {
  return parents[a] < 0 ? a : parents[a] = Find(parents[a]);
}
void Union(int a,int b) {
  a = Find(a), b = Find(b);
  if (a == b) return;
  if (parents[a] < parents[b]) parents[a] += parents[b], parents[b] = a;
  else parents[b] += parents[a], parents[a] = b;
}
void init() { clr(parents, 0xff); }
int deg[N];
int blk[N];
int main() {
  init();
  int n, m, k; scanf("%d%d%d", &n, &m, &k); 
  rep(i, m) {
    int a, b; scanf("%d%d", &a, &b);
    Union(a, b);
    ++deg[a]; ++deg[b];
  }
  rep(i, k) {
    int a, b; scanf("%d%d", &a, &b);
    if (Find(a) == Find(b)) {
      blk[a]++; blk[b]++;
    }
  }
  Rep(i, n) {
    int x = -parents[Find(i)]  - deg[i] - blk[i] - 1;
    if (i == n) printf("%d\n", x);
    else printf("%d ", x);
  }
  return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

		int a, b, menseki, mawari;

		Scanner scan = new Scanner(System.in);

		a = Integer.parseInt(scan.next());
		b = Integer.parseInt(scan.next());

		if ((a >= 1) && (b <= 100)) {

			menseki = a * b;
			mawari = 2 * (a + b);
			System.out.println(menseki + " " + mawari);
		}
	}
}

Measured memory_bytes: 25904
/*input
3
4294967297 8589934593 12884901890
*/

#include <bits/stdc++.h>
#include <unistd.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e18
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}

void solve(){
    ll i,j,k;
    ll x=0,a,b;
    ll n;
    cin>>n;
    cin>>a>>b;
    rep(i,0,n-2)cin>>j,x^=j;
    if((a+b-x)%2){
        cout<<-1<<endl;
        return;
    }
    ll tmp=(a+b-x)/2;
    //cout<<a<<" "<<b<<" "<<x<<" "<<(x>b)<<endl;
    //cout<<((a-1)^((b+1)^x))<<endl;
    //cout<<tmp<<endl;
    if(tmp&x){
        cout<<-1<<endl;
        return;
    }
    repi(i,50,-1){
        if(((ll)1<<i)&x){
            //cout<<((ll)1<<i)<<" "<<tmp<<endl;
            if(tmp+((ll)1<<i)<a)tmp+=((ll)1<<i);
        }
    }
    if(tmp>a||!tmp){
        cout<<-1<<endl;
        return;
    }
    cout<<a-tmp<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}




Measured memory_bytes: 3616
n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(h[0] -h[1])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]),dp[i-2]+abs(h[i] - h[i-2]))
print(dp[n-1])

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

using namespace std;

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

	int n, m;
	cin >> n >> m;

	vector<vector<int> > G(n);

	for(int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}

	vector<bool> vis(n);
	vector<int> sign(n);

	queue<int> q;
	q.emplace(0);
	vis[0] = true;

	int cnt = 0;

	while(!q.empty()) {
		int u = q.front();
		q.pop();
		++cnt;

		for(int v : G[u]) {
			if(!vis[v]) {
				vis[v] = true;
				q.emplace(v);
				sign[v] = u;
			}
		}
	}

	if(cnt != n) {
		cout << "No" << '\n';
	} else {
		cout << "Yes" << '\n';
		for(int i = 1; i < n; ++i) {
			cout << sign[i] + 1 << '\n';
		}
	}

	return 0;
}


Measured memory_bytes: 10300
// 2014/07/14 Tazoe

#include <iostream>
using namespace std;

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

	if(a>b){
		int tmp = a;
		a = b;
		b = tmp;
	}

	if(b>c){
		int tmp = b;
		b = c;
		c = tmp;
	}

	if(a>b){
		int tmp = a;
		a = b;
		b = tmp;
	}

	cout << a << ' ' << b << ' ' << c << '\n';

	return 0;
}

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/

using namespace std;
typedef long long int ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	ll n;
	ll k;
	cin >> n >> k;
	vector<ll> vv(n+10);
	for (ll i = 1; i <= n; i++) {
		cin >> vv[i];
	}
	vector<bool>visited(1000000,false);
	vector<ll> v;
	ll i = 1;
	v.push_back(1);
	visited[i]=true;
	while (true) {
		if(visited[vv[i]]==true){
			break;
		}
		v.push_back(vv[i]);
		i = vv[i];
		visited[i]=true;
		
	}
	ll first=0;
	for(ll j=0;j<(ll)v.size();j++){
		if(v[j]==vv[i]){
			first=j;
			break;
		}
	}

	if(k<(ll)v.size()){
		cout<<v[k];
	}

	else{
		
		ll last=(ll)v.size()-1;
		k-=first;
		ll r=(k%(last-first+1));
		cout<<v[first+r];
	}


}

Measured memory_bytes: 6988
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back

using namespace std;

ll M , K;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL); cout.tie(NULL);
        cin >> M >> K;
        if(K + 1 > (1LL << M)){
                cout << "-1\n"; return 0;
        }
        if(M == 0){
                cout << "0 0\n"; return 0;
        }
        if(M == 1){
                if(K == 1){
                        cout << "-1\n"; return 0;
                }else cout << "0 0 1 1\n"; return 0;
        }
        vector< ll > a((1LL << (M+1)), 0LL);
        a[a.size()-1] = K;
        a[a.size()- (1LL << M) - 1] = K;
        ll x = 0;
        ll y = a.size()-2;
        for(ll i=0;i<(1LL << M);i++){
                if(i == K) continue;
                a[x] = i;
                a[y]=i;
                x++; y--;
        }
        for(auto &i : a) cout << i << " ";
        return 0;
}


Measured memory_bytes: 3840
x, y = map(int, input().split())
l0 = [1, 3, 5, 7, 8, 10, 12]
l1 = [4, 6, 9, 11]
if (x in l0 and y in l0) or (x in l1 and y in l1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188