akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define ALL(_a) _a.begin(), _a.end()
#define EPS 1e-9
#define PI acos(-1.0)
#define MAX 200005
#define MOD 1000000007
#define INF (1 << 31)
#define nl '\n'
#define ms0(x) memset((x), 0, sizeof((x)));
#define ms1(x) memset((x), -1, sizeof((x)));
#define pqmin(x) priority_queue<x, vector<x>, greater<x>>
#define pqmax(x) priority_queue<x>
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) __lcm(x, y)
#define fact(x) factorial(x)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define fast ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0)
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> pii;
typedef pair<int, pii> tii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;

//*    Aauzubillaahi minaash shaaitwanir razeem
//*        Bismillaahir rahmaanir raheem
//*            Raabbi Zidnee Ilmaa
//!code starts from here.............................................
int main()
{
    fast;
    int n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include <numeric>
using namespace std;

long long int gcd(long long int m,long long int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

int main()
{	
	long long int N, M;
	scanf("%lld %lld", &N, &M);
	char S[N+1];
	char T[M+1];
	scanf("%s",S);
	scanf("%s",T);
	long long int g;
	g=gcd(N,M);
	int judge=0;
	long long int answer;
	
	for(long long int i=0;i<g;i++){
		if(S[i*N/g]!=T[i*M/g])
		{	
			judge=-1;
		}
	}
	if(judge==0)
	{
		answer=N*M/g;
	}
	else
	{
		answer=-1;
	}
	printf("%lld", answer);	
}


Measured memory_bytes: 384
fun main(args:Array<String>){
    val line = readLine()!!.split(" ").map{it.toInt()}
    val list = readLine()!!.split(" ").map { it.toInt() }.sorted()
    val n = line[0]
    val m = line[1]
    if(list[n-m]*4*m<list.sum())println("No") else println("Yes")
}

Measured memory_bytes: 37948
s = input()
if s.count("+") == 0:
    print(-4)
elif s.count("+") == 1:
    print(-2)
elif s.count("+") == 2:
    print(0)
elif s.count("+") == 3:
    print(2)
elif s.count("+") == 4:
    print(4)

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

int a[1000005],n,k,dp[1000004][2],dp1[1000004][2];
int f(int m) {
	for(int i=0;i<n;i++) dp[i][0] = 0,dp[i][1] = 0, dp1[i][0] = 0,dp1[i][1] = 0;
	if(k%2) {
		int c = 0;
		if(a[0]<=m) c++;
		for(int i=2;i<n;i++) {
			if(a[i]<=m) {
				if(i==0) {
					dp1[i][0] = 0;
					dp1[i][1] = 1;
				} else {
					dp1[i][0] = max(dp1[i-1][0],dp1[i-1][1]);
					dp1[i][1] = dp1[i-1][0]+1;
				}
			} else {
				if(i==0) {
					dp1[i][0] = 0;
					dp1[i][1] = 0;
				} else {
					dp1[i][0] = max(dp1[i-1][0],dp1[i-1][1]);
					dp1[i][1] = 0;
				}
			}
		}
		if(c+max(dp1[n-1][0],dp1[n-1][1])>=(k+1)/2) return 1;
	}
	//if(m==1) printf("yo");
	int i = 0;
	if(k%2) i++;
	for(;i<n;i++) {
		if(a[i]<=m) {
			if(i==0) {
				dp[i][0] = 0;
				dp[i][1] = 1;
			} else {
				dp[i][0] = max(dp[i-1][0],dp[i-1][1]);
				dp[i][1] = dp[i-1][0]+1;
			}
		} else {
			if(i==0) {
				dp[i][0] = 0;
				dp[i][1] = 0;
			} else {
				dp[i][0] = max(dp[i-1][0],dp[i-1][1]);
				dp[i][1] = 0;
			}
		}
	}
	//printf("%d %d\n",dp[n-1][1],dp[n-1][0]);
	return max(dp[n-1][1],dp[n-1][0]) >= k/2;
}
int main() {
	char ch;
	scanf(" %c",&ch);
	if(ch>='A' && ch<='Z') {
		printf("A");
	} else printf("a");
}

Measured memory_bytes: 3756
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

vector<pint> list;










void floyd(int N, ll** d) {

	rep(k, N+1){
		rep(i, N+1) {
			if (d[i+1][k+1] == inf) continue;
			rep(j, N+1) {
				if (d[j+1][k+1] == inf) continue;

				d[i+1][j+1] = min(d[i+1][j+1], d[i+1][k+1] + d[j+1][k+1]);

			}

		}
	}




}


ll vis[100005];
ll d[100005];
vector<ll> M[100005];
vector<ll> anslist;


stack<int> to_1;

ll col[100005];

void dfs(ll K, ll dist) {

	
	d[K] = dist;
	vis[K] = 1;

		
	for (int i = 0; i < M[K].size(); i++) {
		if (vis[M[K][i]] == 0) {
			
			dfs(M[K][i], dist + 1);
			
		}
	}

}



vector<unsigned long long> v;

ll a[45], b[45], c[45];
ll dp[45][500][500];

int main() {
	ll N, Ma, Mb;

	cin >> N >> Ma >> Mb;

	rep(i, N)
		cin >> a[i + 1] >> b[i + 1] >> c[i + 1];



	rep(k, 45)
		rep(i, 500)
		rep(j, 500)
		dp[k][i][j] = inf;

	rep(k, 45)
		dp[k][0][0] = 0;

	dp[0][0][0] = 0;


	rep(k, N)
		rep(i, 500) {
		rep(j, 500) {

			if (j >= b[k+1] && i >= a[k+1])
				dp[k + 1][i][j] = min(dp[k][i][j], dp[k][i - a[k + 1]][j - b[k + 1]] + c[k + 1]);
			else
				dp[k + 1][i][j] = dp[k][i][j];

		}
	}
	ll ans = inf;
	for (int i = 1; i * Ma <= 400 && i * Mb <= 400; i++) {
		ans = min(ans, dp[N][i*Ma][i*Mb]);
	}

	if (ans == inf) {
		cout << -1 << endl;
	}

	else {
		cout << ans << endl;
	}
	

	return 0;
	
}

Measured memory_bytes: 92416
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 1000000007
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
int qpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=mul(ans,x);
		x=mul(x,x);
		y>>=1;
	}
	return ans;
}
int Inv(int x){return qpow(x,mod-2);}
signed main()
{
	int n=read();
	int a=0,b=0;
	for(int i=1;i<=n;i++)
	{
		int x=read();
		a=add(a,mul(x,x)),b=add(b,x);
	}
	b=sub(mul(b,b),a);
	cout<<mul(b,Inv(2))<<endl;
	return 0;
}




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

int main()
{
    int b[21];
 int n,m,c,sum=0,cnt=0;
cin >> n >> m >> c;
for(int i=0;i<m;i++){
cin >> b[i];
}
for(int j=0;j<n;j++){
for(int i=0;i<m;i++){
int temp;
cin >> temp;
sum += b[i] * temp;
}   
if(sum + c> 0){
cnt++;
//cout << "j=" << j <<endl;
}
sum =0;
}
cout << cnt << endl;
   return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i, a, n) for(LL i = (a), i##_max = (n); i < i##_max; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##min = (a); i >= i##min; --i)
#define ALL(arr) (arr).begin(), (arr).end()
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
template <class T>
T Next() { T buf; cin >> buf; return buf; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "UnionFind.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "FlowSolver.h"
#include "Tree.h"
#include "SuffixArray.h"
#include "Geometry.h"
#include "Matrix.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "BIT.h"
#include "Rational.h"
#include "Position.h"
#include "Factorization.h"
#include "Math.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
// template <class T>
// auto Is(const T& value) { return [value](const auto& comparand) -> bool { return comparand == value; }; }
#endif



int n;
int main() {
	vector<int> a(4);
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	sort(a.begin(), a.end());
	YESNO(a == vector<int>{1, 4, 7, 9});
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define inRange(x, y, w, h) (0 <= x && x < w && 0 <= y && y < h)

using namespace std;

int w, h, n;
int dx[] = { 0, 0, -1, 1 };
int dy[] = { -1, 1, 0, 0 };

void drop( int map[30][30] )
{
	for(int y=h-1; y > -1; --y)
		for(int x=w-1; x > -1; --x) {
			if(map[y][x] != '.') {
				for(int my=h-1; my != y; --my) {
					if(map[my][x] == '.') {
						map[my][x] = map[y][x];
						map[y][x] = '.';
						break;
					}
				}
			}
		}
}

bool clear( int map[30][30] )
{
	int cl[30][30] = { 0 };
	bool hit = false;
	for(int y=0; y < h; ++y)
		for(int x=0; x < w; ++x) {
			if(map[y][x] == '.') continue;
			for(int k=0; k < 4; ++k) {
				int count = 0;
				int mx = x, my = y;
				while(inRange(mx, my, w, h) && map[y][x] == map[my][mx]) {
					mx += dx[k];
					my += dy[k];
					++count;
				}
				if(count >= n) {
					int sx = x, sy = y;
					for(int i=0; i < count; ++i) {
						cl[sy][sx] = -1;
						sx += dx[k];
						sy += dy[k];
					}
					hit = true;
				}
			}
		}
	if(hit) {
		for(int y=0; y < h; ++y)
			for(int x=0; x < w; ++x)
				if(cl[y][x] == -1) map[y][x] = '.';
	}
	return hit;
}

bool judge(int map[30][30]) {
	for(int y=0; y < h; ++y)
		for(int x=0; x < w; ++x)
			if(map[y][x] != '.') return false;
	return true;
}

void copy_array(int map[30][30], int map2[30][30])
{
	for(int y=0; y < h; ++y)
		for(int x=0; x < w; ++x)
			map[y][x] = map2[y][x];
}

int main( void )
{
	int map[30][30];
	int save[30][30];
	
	while(cin >> h >> w >> n)
	{
		for(int y=0; y < h; ++y)
			for(int x=0; x < w; ++x) {
				char c;
				cin >> c;
				map[y][x] = save[y][x] = (int)c;
			}

		bool hit = false, next = true;
		for(int y=0; y < h && next; ++y) {
			for(int x=0; x < w-1 && next; ++x) {
				if(map[y][x] != map[y][x+1]) {
					int n;
					swap(map[y][x], map[y][x+1]);
					drop(map);
					while(clear(map)) { drop(map); }
					if(judge(map)) {
						hit = true;
						next = false;
					}
					copy_array(map, save);
				}
			}
		}
		if(hit)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int H, N; cin >> H >> N;
    vec A(N); cin >> A;
    int S = 0;
    REP(i, N) S += A[i];
    Ans(S >= H, "Yes", "No");

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll ans1 = 0;
        for (int j = 0; j < i; ++j) {
            if(v[j] > v[i]) ans1++;
        }
        ll ans2 = 0;
        for (int j = 0; j < n; ++j) {
            if(v[j] > v[i]) ans2++;
        }
        (ans += k*(ans1*2%MOD+(k-1)*ans2%MOD)%MOD*500000004) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdio>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<iomanip>
#include<list>
#include<set>
#include<utility>
using namespace std;

//repetition
//------------------------------------------

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
//#define INF (1 << 30)
#define pii pair<int, int>

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, -1, 0, 1, -1, -1, 1, 1};

static const int INF = 1000000010;
string bl[110];
string re[110];

int main() {
  int n,m;
  cin >> n;
  rep(i,n){
    cin >> bl[i];
  }
  cin >> m;
  rep(i,m){
    cin >> re[i];
  }
  int ans = 0;
  rep(i,n){
    string tango = bl[i];
    int num = 0;
    rep(j,n){
      if(tango==bl[j]){
        num++;
      }
    }
    rep(k,m){
      if(tango==re[k]){
        num--;
      }
    }
    if(ans<num){
      ans = num;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <utility>
#include <vector>

int testcase_ends() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);
  if (n == 0) return 1;

  intmax_t inf = 1e9;
  std::vector<std::vector<intmax_t>> dl(n, std::vector<intmax_t>(n, inf));
  auto ds = dl;
  for (size_t i = 0; i < n; ++i) dl[i][i] = 0;

  for (size_t i = 0; i < m; ++i) {
    size_t x, y;
    intmax_t t;
    char c;
    scanf("%zu %zu %jd %c", &x, &y, &t, &c);
    --x;
    --y;
    if (c == 'S') {
      ds[x][y] = ds[y][x] = t;
      ds[x][x] = ds[y][y] = 0;
    } else if (c == 'L') {
      dl[x][y] = dl[y][x] = t;
    }
  }

  for (size_t k = 0; k < n; ++k)
    for (size_t i = 0; i < n; ++i)
      for (size_t j = 0; j < n; ++j) {
        dl[i][j] = std::min(dl[i][j], dl[i][k]+dl[k][j]);
        ds[i][j] = std::min(ds[i][j], ds[i][k]+ds[k][j]);
      }

  size_t r;
  scanf("%zu", &r);
  std::vector<size_t> z(r);
  for (auto& zi: z) {
    scanf("%zu", &zi);
    --zi;
  }

  std::vector<std::vector<intmax_t>> dp(r, std::vector<intmax_t>(n, inf));
  dp[0][z[0]] = 0;
  for (size_t i = 0; i+1 < r; ++i) {
    for (size_t j = 0; j < n; ++j) {
      for (size_t k = 0; k < n; ++k) {
        intmax_t dist = dp[i][j];
        if (j != k) {
          dist += dl[z[i]][j]+ds[j][k]+dl[k][z[i+1]];
        } else {
          dist += std::min(dl[z[i]][j]+ds[j][k]+dl[k][z[i+1]], dl[z[i]][z[i+1]]);
        }
        dp[i+1][k] = std::min(dp[i+1][k], dist);
      }
    }
  }

  printf("%jd\n", *std::min_element(dp[r-1].begin(), dp[r-1].end()));
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 4864
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
VI G[100011];
int par[100011];
VI ord;
int nim[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }

    ord.reserve(N);
    ord.push_back(0);
    REP (i_, N) {
	int v = ord[i_];
	EACH (e, G[v]) if (*e != par[v]) {
	    par[*e] = v;
	    ord.push_back(*e);
	}
    }

    REP (i_, N) {
	int v = ord[N-1-i_];
	EACH (e, G[v]) if (*e != par[v]) {
	    nim[v] ^= nim[*e] + 1;
	}
    }

    puts(nim[0]? "Alice": "Bob");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 7040
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {

	if (n == r)
	{
		dp[n][n] = 1;
		
	}
	else if (r == 0) {
		return dp[n][0] = 1;
		
	}
	else if (r == 1) {
		
		return dp[n][1]=n;
	}
	else {
		dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
		return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;
	}
}

int main() {
	ll L, R;
	cin >> L >> R;
	ll s = ((L%2019)*((L+1)%2019)) % 2019;
	ll m;
	ll x = R;
	if (L + 2019 < R)x = L + 2019;
	for (int i = L;i <= x;i++) {
		for (int j = i+1;j <= R;j++) {
			m = ((i % 2019)*(j%2019))%2019;
			if (s > m) { s = m; }
			if (s == 0) { break; }
		}
	}
	cout << s<< endl;
	return 0;
}

Measured memory_bytes: 256
# ABC149 B
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
a,b,k=map(int, input().split())

if a<k:
    k-=a
    a=0
elif a>=k:
    a-=k
    print(a,b)
    exit()

if k>0:
    if b>=k:
        b-=k
    elif b<k:
        b=0

print(a,b)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC106_B();
        }

        static void ABC106_B()
        {
            var N = int.Parse(Console.ReadLine());
            var ans = 0;
            for (var n = 1; n <= N; n+=2)
            {
                var count = 0;
                for (var i = 1; i <=n; i++)
                {
                    if (n % i == 0)
                        count++;
                }
                if (count == 8)
                    ans++;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		PriorityQueue<Long> Q=new PriorityQueue<Long>();
		long sum=0;
		long[] ary=new long[3*N];
		long[][] awase=new long[N+1][2];
		for(int i=0; i<N*3; i++) {
			long tmp=sc.nextLong();
			ary[i]=tmp;
			if(i<N) {
				Q.offer(tmp);
				sum+=tmp;
				awase[0][0]=sum;
			}
			else if(i>=N && i<2*N){
				long a=Q.peek();
				if(a<tmp) {
					Q.poll();
					Q.offer(tmp);
					sum+=(tmp-a);
				}
				else {
					//
				}
				awase[i-(N-1)][0]=sum;
			}
		}
		Q=new PriorityQueue<Long>();
		sum=0;
		for(int i=3*N-1; i>=N; i--) {
			long tmp=-ary[i];
			if(i>=2*N) {
				Q.offer(-ary[i]);
				sum+=ary[i];
				awase[Math.min(i-N,N)][1]=sum;
				//pl(Q.size());
			}
			else {
				long a=Q.peek();
				if(a<tmp) {
					Q.poll();
					Q.offer(tmp);
					sum-=(tmp-a);
				}
				else {
					//
				}
				awase[Math.min(i-N,N)][1]=sum;
			}
		}
		long max=Long.MIN_VALUE;
		for(int i=0; i<=N; i++) {
			max=Math.max(awase[i][0]-awase[i][1], max);
		}
		pl(max);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 67320
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

int main(){
    ll N; cin >> N;
    vll a(N+1);
    rep(i, 0, N+1){
        cin >> a[i];
    }
    vll l(N+1);
    ll sum = 0;
    rrep(i, N, -1){
        l[i] = sum;
        sum += a[i];
    }
    ll maxl = 1;
    ll ans = 1; bool t = false;
    if(a[0] != 0&&N!=0){t = true;}
    rep(i, 0, N){
        ll m = 2*maxl;
        m -= a[i+1];
        ans += a[i+1];
        if(m < 0){
            t = true;
            break;
        }else{
            maxl = m;
        }
        if(maxl > l[i+1]){
            maxl = l[i+1];
        }
        ans += maxl;
    }
    if(N==0&&a[0]!=1){prt(-1);}
    else if(N==0&&a[0]==1){prt(1);}
    else{
    if(t){prt(-1);}
    else{prt(ans);}
    }
}

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

int main() {
  int N;
  cin >>  N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];}
  for (int i = 0; i < N; ++i) {
    B[i]=A[i];}

  sort(A.begin(), A.end());
  int count = 0;
  for (int i = 0; i < N; ++i) {
    if (A[i]!=B[i]){count +=1;}}
  if (count==2 || count == 0){cout<<"YES";}
  else{cout<< "NO";}
return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

base = [0]*(n+1)
base[0] = 1
h_max = max(h)
count = 0

for i in range(h_max):
  for j in range(1,n+1):
    if i == h[j-1]:
      base[j] = 1

    if (base[j-1] == 1) and (base[j] == 0):
      count = count + 1
    
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v(n);
   // ll sum=0;

    rep(i,n){
        cin>>v[i];
        //sum+=v[i];
    }

    int ans=-10000001;
    int lim=min(n,k);
    for(int l=0;l<=lim;l++){
        for(int r=0;r<=lim-l;r++){

            vector<int> te;
            int sum=0;

        for(int i=0;i<l;i++){
            sum+=v[i];
            if(v[i]<0) {
                te.push_back(v[i]);
            }
        }
            for(int i=0;i<r;i++){
                sum+=v[n-i-1];
                if(v[n-i-1]<0) {
                    te.push_back(v[n - i - 1]);
                }
            }

            int a=k-(l+r);
            int b=te.size();
            sort(te.begin(),te.end());
            for(int tt=0;tt<min(a,b);tt++){
             if(te[tt]<0){

                 sum-=te[tt];
             }else{break;}
             //cout<<l<<" "<<r<<" "<<sum<<endl;

            }
            if(ans<sum){
                ans=sum;
            }



        }
    }

    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, A, B := sc.NextInt(), sc.NextInt(), sc.NextInt()

	if abs(N-A) < abs(N-B) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}

}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007

long mod_pow(long x, long n, long p=MOD){
  if(x==0) return 0;
  long res=1;
  x %= p;
  while(n>0){
    if(n&1) res=res*x%p;
    x=x*x%p;
    n>>=1;
  }
  return res;
}
inline long mod_inv(long x, long p=MOD){ return mod_pow(x%p, p-2, p); }

long inv2[200];

long p[1<<15];
bool g[15][15];

int outnum[1<<15];
int outs[1<<15];

int main(){
  int n,m;
  cin>>n>>m;
  fill(g[0], g[15], false);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a][b] = g[b][a] = true;
  }

  inv2[0] = 1;
  inv2[1] = mod_inv(2);
  rep(i,2,200) inv2[i] = inv2[i-1] * inv2[1] %MOD;

  for(int ini=1; ini<=2; ini++){
    p[ini] = 1;
    rep(mask, ini+4, 1<<n) if(mask%4 == ini){
      // calc p[mask]
      p[mask] = 1;
      for(int nmask = (mask-1)&mask; nmask>0; nmask = (nmask-1)&mask) if(p[nmask]>0){
        int cnt = 0;
        int dmask = mask - nmask;
        rep(i,n) if( (dmask>>i)%2 ){
          rep(j,n) if(g[i][j] && (nmask>>j)%2) cnt++;
        }
        p[mask] -= p[nmask] * inv2[cnt] %MOD;
      }
      p[mask] %= MOD;
      if(p[mask] < 0) p[mask] += MOD;
    }
  }

  rep(mask, 1<<n) if(mask%4==1 || mask%4==2){
    outnum[mask] = 0;
    outs[mask] = 0;
    rep(i,n) if( (mask>>i)%2 ){
      rep(j,n) if(g[i][j] && ((mask>>j)%2 == 0)){
        outnum[mask]++;
        outs[mask] |= (1<<j);
      }
    }
  }

  long ans = 1;
  rep(maskA, 1, 1<<n) if(maskA%4 == 1 && p[maskA]>0){
    int invmask = (~maskA)&( (1<<n) - 1);
    for(int maskB = invmask; maskB>0; maskB = (maskB-1)&invmask) if(maskB%4 == 2 && p[maskB]>0){
      if(outs[maskA]&maskB) continue;
      if(outs[maskB]&maskA) continue;

      ans -= p[maskA] * p[maskB] %MOD * inv2[outnum[maskA]+outnum[maskB]] %MOD;
    }
  }

  ans %= MOD;
  if(ans < 0) ans += MOD;
  rep(i,m) ans = ans*2%MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
#include "iostream"
using namespace std;

int main(){
	int a;
	while(cin >> a){
		if(a == 0) break;
		int count = 0;
		for(int i = 1; i <= a; i ++){
			int buf = i;
			while(buf % 5 == 0 ){
				buf /= 5;
				count ++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
x,y  = map(int,input().split())
hon = 0
flag = False
for i in range(1,x+1):
    turu = i
    kame = x - i

    hon=2*turu+4*kame
    if hon == y:
        flag = True
        
for i in range(1,x+1):

    turu = x-i
    kame = i 

    hon=2*turu+4*kame
    if hon == y:
        flag = True
    
if flag == True:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 9196
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int m,a,b;
int g,n;
pii card[110];
int dp[100][1010];
int main(){
	while(cin>>m,m){
		memset(card,0,sizeof(card));
		memset(dp,0,sizeof(dp));
		rep(i,m){
			cin>>a>>b;
			card[i].first=a;
			card[i].second = b;
		}
		cin>>g;
		for(int j =0;j <=card[0].second&&card[0].first*j<=1000;j++){
			dp[0][card[0].first*j]++;
		}
		int j;
		for(int i =1;i <m;i++){
			j =card[i].first;
			for(int k =0;k <=card[i].second;k++){
				for(int l =0;l+j*k<=1000;l++){
					dp[i][l+j*k]+=dp[i-1][l];
					//cout <<dp[i][l+j*k]<<endl;
				}
			}
		}

		rep(i,g){
			cin>>n;
			cout <<dp[m-1][n]<<endl;
		}
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007;

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


void Main() {
    int h, w;
    cin >> h >> w;
    vector<string> sv(h);
    REP(i, h) {
        string s;
        cin >> s;
        sv[i] = s;
    }
    queue<int> que;
    que.push(0);
    VI ansv(h*w, -1);
    ansv[0] = 0;
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        if (v % w != 0) {
            if(sv[v/w][(v-1)%w] != '#' && ansv[v-1] == -1) {
                ansv[v-1] = ansv[v] + 1;
                que.push(v-1);
            }
        }
        if (v % w != w-1) {
            if(sv[v/w][(v+1)%w] != '#' && ansv[v+1] == -1) {
                ansv[v+1] = ansv[v] + 1;
                que.push(v+1);
            }
        }
        if (v / w != 0) {
            if(sv[v/w-1][v%w] != '#' && ansv[v-w] == -1) {
                ansv[v-w] = ansv[v] + 1;
                que.push(v-w);
            }
        }
        if (v / w != h-1) {
            if(sv[v/w+1][v%w] != '#' && ansv[v+w] == -1) {
                ansv[v+w] = ansv[v] + 1;
                que.push(v+w);
            }
        }
    }
    int count = 0;
    REP(i, h) {
        REP(j, w) {
            if (sv[i][j] == '.') {
                count++;
            }
        }
    }
    if (ansv[w*h-1] == -1) {
        cout << -1 << endl;
    } else {
        cout << count - ansv[w*h-1]-1 << endl;
    }
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}



Measured memory_bytes: 3676
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}
template<class T> T read_val() { throw 1; }
template<> int read_val() { int tmp; scanf("%" PRId32, &tmp); return tmp; }
template<> long long read_val() { long long tmp; scanf("%" PRId64, &tmp); return tmp; }
auto read_int = read_val<int>; auto read_long = read_val<long long>;
template<class T> void scanf_vec(vector<T>& vec) { for (int i = 0; i < vec.size(); i++) vec[i] = read_val<T>(); }

#define MOD 1000000007
#define inf 2000000000
#define FWT_SIZE 2000000
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())



int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	cin >> p;
	stack<int> min_p;
	int nearest = n, ans = 0, been_none=0;
	set<int> ss;
	for (int j = p.size() - 1; j >= 0; j--)
	{
		if (j + k < n)
			ss.erase(p[j + k]);

		while (min_p.size() > 0 && p[min_p.top()] >= p[j])
			min_p.pop();

		bool changes = false;
		if (min_p.size() > 0 && p[j] > p[min_p.top()])
		{
			changes = min_p.top() < j + k;
			nearest = min(nearest, min_p.top());
		}
		if (j + k < n && p[j + k] < *ss.rbegin())
			changes = true;

		min_p.push(j);
		ss.insert(p[j]);

		if (j + k - 1 < n && nearest < j + k && (j+k==n || changes))
		{
			ans++;
		}

		if (j + k - 1 < n && nearest >= (j + k))
			been_none = 1;
	}

	cout << ans+been_none;

	return 0;
}

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

int solve(string s){
  char c[s.size()];
  c[0] = s[0];
  int count = 0;
  for(int i=1; i<s.size(); i++){
    c[i] = s[i];
    if(c[i] != c[i-1]){
      count += 1;
    }
  }
  return count;
}

int main(){
  string S;
  cin >> S;
  cout << solve(S) << endl;
  return 0;
}


Measured memory_bytes: 640
s=str(input())
S=[]

for i in s:
    S.append(i)

if len(S)==1:
    print(0)
elif S[0]=='1':
    T=[0 for i in range(len(S)) if (i%2==0 and S[i]=='0') or (i%2==1 and S[i]=='1')]
    print(len(T))
elif S[0]=='0':
    T=[0 for i in range(len(S)) if (i%2==0 and S[i]=='1') or (i%2==1 and S[i]=='0')]
    print(len(T))


Measured memory_bytes: 4476
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <tuple>

using namespace std;

#define D(x) x
#define REP(i,a,b) for (int i = (a); i < (b); ++i)

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    string s;
    cin >> s;
    REP(i,0,4)
        cout << s[i];
    cout << " ";
    REP(i,4,s.length())
        cout << s[i];
    cout << endl;
	return 0;
}


Measured memory_bytes: 256
/*
Created by Rishu Sahu @ covid 20-20
*/
/*
*****************************************************************
*/

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pai pair<int,int>
#define pal pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,a,b) for(int i=a;i<=b;i++)
#define ff first 
#define ss second
#define sz(x) (int)x.size()
#define vi vector<int>
#define vl vector<ll>
#define mpl map<ll,ll>
#define mpi map<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()

const int mod = 1e9+7;
const int INF = INT_MAX;

vi adj[100005];
int ind[100005];
int longest[100005];


void solve(){
    int n,m;
    cin>>n>>m;
    int mat[n][m];
    ll dp[n][m];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            char ch;
            cin>>ch;
            if(ch=='.') mat[i][j]=1;
            else mat[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(int i=1;i<m;i++){
        if(dp[0][i-1]&&mat[0][i]) dp[0][i]=1;
    }
    for(int i=1;i<n;i++){
        if(dp[i-1][0]&&mat[i][0]) dp[i][0]=1;
    }

    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(mat[i][j]) dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[n-1][m-1]%mod<<endl;

}

int main(){
    solve();
}


Measured memory_bytes: 17608
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
int main(){
    int n,q; cin >> n >> q;
    queue<pair<string,int> > que;
    for(int i = 0; i < n; i++){
        string s; int t; cin >> s >> t;
        que.push({s,t});
    }
    int time = 0;
    //cout << endl;
    while(que.size()){
        pair<string,int> p;
        p = que.front();
        que.pop();
        if (p.second > q){
            p.second -= q;
            time += q;
            que.push(p);
        } else {
            time += p.second;
            cout << p.first << " " << time << endl;
        }
    }
}
  




Measured memory_bytes: 6200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
const int maxn = 15;
int n;
bool vis[maxn];
int p[maxn] , q[maxn] , t[maxn];
bool dfs(int *a , int dep) {
	if(dep > n) {
		for(register int i = 1; i <= n; ++i)
			if(a[i] != t[i]) {
				a[n + 1]++;
				return false;
			}
		return true;
	}
	bool ret;
	for(register int i = 1; i <= n; ++i) {
		if(!vis[i]) {
			vis[i] = 1;
			t[dep] = i;
			ret = dfs(a , dep + 1);
			if(ret)
				return true;
			vis[i] = 0;
		}
	}
	return false;
}
int main() {
	cin >> n;
	for(register int i = 1; i <= n; ++i) cin >> p[i];
	for(register int i = 1; i <= n; ++i) cin >> q[i];
	dfs(p , 1);
	memset(t , 0 , sizeof(t));
	memset(vis , 0 , sizeof(vis));
	dfs(q , 1);
	int a = p[n + 1] , b = q[n + 1];
	if(a - b > 0)	
		cout << a - b;
	else cout << b - a;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
long long int dp[99][21];
int ary[100];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&ary[i]);
	dp[0][ary[0]]=1;
	for(int i=1;i<(n-1);i++) {
		for(int j=0;j<=20;j++) {
			if((j-ary[i])>=0) dp[i][j]+=dp[i-1][j-ary[i]];
			if((j+ary[i])<=20)dp[i][j]+=dp[i-1][j+ary[i]];
		}
	}
	printf("%lld\n",dp[n-2][ary[n-1]]);
}

Measured memory_bytes: 1044
import Control.Applicative

isPrime :: Int -> Int
isPrime n
  | n == 2         = 1
  | n `mod` 2 == 0 = 0
  | otherwise      = _isPrime 3 n
  where
        _isPrime :: Int -> Int -> Int
        _isPrime i n
          | i >  d    = 1
          | r == 0    = 0
          | otherwise = _isPrime (i+1) n
            where
                (d, r) = n `divMod` i

main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    c <- loop n
    print c
    where
        loop :: Int -> IO Int
        loop n
          | n == 0    = return 0
          | otherwise = do
              m <- read <$> getLine :: IO Int
              (+ (isPrime m)) <$> loop (n - 1)



Measured memory_bytes: 10312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,head,tail;
ll f[200005],C,h[200005];
pair<ll,ll> st[200005];
double pl[200005];
int main()
{
	scanf("%d%lld",&n,&C);
	for(int i=1;i<=n;i++) scanf("%lld",&h[i]);
	f[1]=0;
	st[++tail]=make_pair(-2*h[1],h[1]*h[1]+f[1]);
	head=1;
	for(int i=2;i<=n;i++)
	{
		while(head<tail&&h[i]>=pl[head+1]) head++;
		f[i]=st[head].first*h[i]+st[head].second+h[i]*h[i]+C;
		ll k=-2*h[i],b=h[i]*h[i]+f[i];
		while(head<=tail)
		{
			ll k1=st[tail].first,b1=st[tail].second;
			double x=(1.0*(b-b1))/(1.0*(k1-k));
			if(x<pl[tail]) tail--;
			else
			{
				st[++tail]=make_pair(k,b);
				pl[tail]=x;
				break;
			}
		}
		//printf("f(%d)=%lld\n",i,f[i]);
	}
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc164/abc164_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while(A > 0 && C > 0) {
    C -= B;
    if (C <= 0) break;
    A -= D;
  }

  cout << (A > 0 ? "Yes" : "No") << endl;
}

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

int main(){
  string s;
  cin >> s;
  if(s.at(0)==s.at(1) && s.at(1)==s.at(2)){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}
    

Measured memory_bytes: 256