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

using namespace std;

int main(){
  int N;
  string S;
  cin>>N>>S;
  bool ok=true;
  if(N%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0;i<(N/2);i++){
    if(S[i]!=S[i+N/2])ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int p,q,a,n;

int solve(int sum, int mul, int rest, int upper){
	int count = 0;
	for (int i=min(upper,a/mul);i>0;--i){
		int check = i*p*mul - q*(i*sum+mul);
		if (check > 0) {
			if (rest > 0) {
				count += solve(i*sum+mul, i*mul, rest-1, i);
			}
		} else if(check == 0) {
			++count;
			break;
		}
	}
	return count;
}

int main(){
	while (true){
		cin >> p >> q >> a >> n;
		if (p==0 && q==0 && a==0 && n==0) break;
		int result = solve(0,1,n-1,a);
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N=int(input())
x=[int(i) for i in input().split()]
x.append(0)
cnt=0
while x.count(0)!=N+1:
    for i in range(N):
        if x[i+1]==0 and x[i]>0:
            cnt+=1
        if x[i]>0:
            x[i]-=1
print(cnt)

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();
string s, t;
int c=0;

cin>> s>> t;


for(int i=0; i<t.size(); i++)
{
    if(t[i]!= s[i])
        c++ ;
}

cout<< c;
nl;


    return 0;
}




Measured memory_bytes: 3812
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.1415926535
 
 
int main()
 {
	double a,b,h,m;
	double answer,deg,adeg,bdeg,rad;
	
	scanf("%lf%lf%lf%lf",&a,&b,&h,&m);

	adeg=30.0*h+m*0.50;
	
	bdeg=6.0*m;

	deg=fabs(adeg-bdeg);

	rad=deg*PI/180.0;
	
	answer=sqrt(a*a+b*b-2.0*a*b*cos(rad));

	printf("%.9f",answer);

			return 0;
	}


	







Measured memory_bytes: 2600
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10 ;
int dp[N][2] ;
int main()
{
  string s ;
  cin >> s ;
  dp[0][0] = s[0] - '0' ;
  dp[0][1] = 1 + 10 - s[0] + '0' ;
  for(int i = 1; i < s.size() ;i ++)
   {
     int x = s[i] - '0' ;
     dp[i][0] = min(dp[i - 1][0] + x , dp[i - 1][1] + x) ;
     dp[i][1] = min(dp[i - 1][0] + 10 - x + 1 , dp[i - 1][1] - 1 + 10 - x) ;
   }
   cout << min(dp[s.size() - 1][1] , dp[s.size() - 1][0] ) << endl ;
  return 0 ;
}


Measured memory_bytes: 9220
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	S[3] = '8';
	cout << S;

	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*
願はくは花の下にて春死なんそのきさらぎの望月のころ（西行 1118-1190）
--This is old Japanese poem expressing the desire to die under tree on the full moon night.(written by Saigyo)
In my research, there is possibility that the tree may be seg-tree.
*/

/*Coding Space*/
int main(){
  vt<ll> in(3);
  ll k; cin >> in[0] >> in[1] >> in[2] >> k;
  rep(i,k){
    *max_element(ALL(in)) = *max_element(ALL(in))*2;
  }
  cout << in[0] + in[1] + in[2] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    int tmpa, tmpb;
    tmpa = a/k;
    tmpb = b/k; 

    if(tmpa==tmpb){
        if(a%k==0){
            cout << "OK" << endl;
        }
        else{
            cout << "NG" << endl; 
        }
    }
    else{
        cout << "OK" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,i,even=0,ans=0;
    cin>>n;
    int ara[n+5];
    for(i=0;i<n;i++)
    {
        cin>>ara[i];
        if(ara[i]%2==0)
            even++;
    }
    for(i=0;i<n;i++)
    {
        if((ara[i]%3==0 || ara[i]%5==0) && ara[i]%2==0)
            ans++;
    }
    if(ans==even)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(ll i = 0;i < n;i++)
#define FOR(i,a,b) for(ll i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

struct edge { ll to, cost; };

int main() {
	IOS;
	int n;
	cin >> n;
	int color[8] = {};
	int tourist = 0;
	REP(i, n) {
		int a;
		cin >> a;
		int tmp = 0;
		if (a >= 3200)tourist++;
		else {
			REP(i, 8) {
				tmp += 400;
				if (tmp > a) {
					color[i]++;
					break;
				}
			}
		}
	}
	if (tourist == n) {
		cout << 1 << ' ' << n << endl;
		return 0;
	}
	int Min = 0;
	REP(i, 8) {
		if (color[i])Min++;
	}
	cout << Min << ' ' << Min + tourist;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
int n,w,z,a[2001];
main(){
	cin >> n >> z >> w;
 
	r(i,n) cin >> a[i];
  if(n!=1)cout<<max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w))<<endl;
  else cout<<abs(a[n-1]-w)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	string s;
	//cin >> s;

	//int A[5]
	//sort(A, A + 5);

	long long ac, ad, bc, bd;

	ac = a * c;
	ad = a * d;
	bc = b * c;
	bd = b * d;

	if (ac >= ad && ac >= bc && ac >= bd)
	{
		cout << ac << endl;
	}
	else if (ad >= ac && ad >= bc && ad >= bd)
	{
		cout << ad << endl;
	}
	else if (bc >= ad && bc >= ac && bc >= bd)
	{
		cout << bc << endl;
	}
	else if (bd >= ad && bd >= bc && bd >= ac)
	{
		cout << bd << endl;
	}

}

Measured memory_bytes: 3624
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long lint;
typedef long long ll;
int qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e10;
const int MAX_N = 1 << 17;

int main(void) {
	lint n, q; cin >> n >> q;
	vector<pair<lint, pair<lint, lint>>> pos(n);
	for (int i = 0; i < n; i++)
	{
		lint s, t, x; cin >> s >> t >> x;
		pos[i] = mp(x, mp(s - x, t - x - 1));
	}
	sort(all(pos));
	vector<lint> tm(q);
	vector<pair<lint, lint>> ans;
	for (int i = 0; i < q; i++)
	{
		cin >> tm[i];
	}
	for (int i = 0; i < n; i++)
	{
		vector<lint>::iterator it1 = lower_bound(all(tm), pos[i].second.first);
		vector<lint>::iterator it2 = upper_bound(all(tm), pos[i].second.second);
		int j = 0;
		while (true) {
			if (it1 + j == it2) break;
			ans.pb(mp(*(it1 + j), pos[i].first));
			j++;
		}
		tm.erase(it1, it2);
		if (tm.empty()) break;
	}
	for (auto i : tm) {
		ans.pb(mp(i, -1));
	}
	sort(all(ans));
	for (auto i : ans) {
		cout << i.second << endl;
	}
	return 0;
}

Measured memory_bytes: 12656
#include <bits/stdc++.h>
using namespace std;
string s;
int ans,n,b;
int a=210000;
int main() {
	cin >> s;
	n=s.length();
	
	for(int i=0;i<n;i++){
		
		if(s[i]=='A')a=min(a,i);
		if(s[i]=='Z')b=max(b,i);
	}
	cout<<b-a+1<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
const int Max=0x7fffffff;
const int P=1000000007;
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b)cout<<c<<endl;
    if(a==c)cout<<b<<endl;
    if(b==c)cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] aegs) {
		Scanner sc=new Scanner(System.in);

		double x1=sc.nextDouble();
		double y1=sc.nextDouble();
		double x2=sc.nextDouble();
		double y2=sc.nextDouble();

		double kyori=Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2));

		System.out.println(kyori);
		sc.close();
	}

}



Measured memory_bytes: 27880
"use strict";

const main = (input) => {
    const [s, t] = input.split('\n');
    const n = s.length;
    let ans = 0;
    for (let i = 0; i < n; i++){
        if (s[i] !== t[i]) ans++;
    }

    console.log(ans);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 34240
N, M = map(int, input().split())
B = []
for m in range(M):
    B.append(list(map(int, input().split())))
B = sorted(B, key=lambda x: x[1])

check = [B[0][1]-1]

for a, b in B:
    if a <= check[-1]:
        continue
    check.append(b-1)
print(len(check))

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

const int N = 41;
typedef long long ll;

ll dp[N][N][N][N], dp1[N][N][N][N];
bool vis[N][N][N][N];
char s[N][N];

void dfs(int i, int j, int u, int v){
    if (i > j || u > v || vis[i][j][u][v]){
        return;
    }
    vis[i][j][u][v] = true;
    if (i == j && u == v){
        if (s[i][u] == '1'){
            dp[i][j][u][v] = dp1[i][j][u][v] = 1;
        }
        return;
    }
    for (int p = i; p <= j; ++ p){
        for (int q = u; q <= v; ++ q){
            dfs(i, p - 1, p + 1, j);
            dfs(u, q - 1, q + 1, v);
            if (s[p][q] == '1'){
                dp[i][j][u][v] += (i == j ? 1 : dp1[i][p - 1][p + 1][j]) * (u == v ? 1 : dp1[u][q - 1][q + 1][v]);
            }
        }
    }
    dp1[i][j][u][v] = dp[i][j][u][v];
    for (int p = i; p <= j; ++ p){
        for (int q = u; q <= v; ++ q){
            dfs(i, p, q, v);
            dfs(p + 1, j, u, q - 1);
            dp1[i][j][u][v] += dp[i][p][q][v] * dp1[p + 1][j][u][q - 1];
        }
    }
}

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < 2 * n; ++ i){
        scanf("%s", s[i]);
    }
    if (n == 1){
        putchar(s[0][1]);
        puts("");
        return 0;
    }
    dfs(1, 2, 4, 5);
    for (int i = 0; i < 2 * n; ++ i){
        for (int j = i; j < 2 * n; ++ j){
            for (int u = j + 1; u < 2 * n; ++ u){
                for (int v = u; v < 2 * n; ++ v){
                    dfs(i, j, u, v);
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i < 2 * n; ++ i){
        if (s[0][i] == '1'){
            ans += dp1[1][i - 1][i + 1][2 * n - 1];
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 44672
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	ll vcnt,ecnt;
	E  e[200010];//適宜変える
	ll id[100010];//適宜変える
}G;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
G g;
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[i].s=x;
		g.e[i].g=y;
	}
	g.vcnt=n;
	g.ecnt=2*m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//一応番兵
}

int flag[100010];
int memo[100010];
int f(int k){
	if(flag[k])return memo[k];
	flag[k]=1;
	ll ans=0;
	rep(i,g.id[k],g.id[k+1])ans=max(ans,f(g.e[i].g)+1);
	return memo[k]=ans;
}

int main(){
	readgraph();
	ll ans=0;
	rep(i,0,g.vcnt)ans=max(ans,f(i));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7420
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int dp[s.length() + 1][t.length() + 1];
    for (int i = 0; i <= s.length(); i++) for (int j = 0; j<= t.length(); j++) dp[i][j] = 0;
    for (int i = 0; i < s.length(); i++)
        for (int j = 0; j < t.length(); j++){
            if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
            dp[i + 1][j + 1] = max(max(dp[i+1][j+1], dp[i][j+1]), dp[i+1][j]);
        }
    string ans = "";
    //cout << dp[s.length()][t.length()] << endl;
    int i = s.length(), j = t.length();
    while (i > 0 && j > 0){
        if (s[i - 1] == t[j - 1]){
            i--;
            j--;
            ans = s[i] + ans;
        } else if (dp[i-1][j] > dp[i][j-1]){
            i--;
        } else j--;
    }
    cout << ans;
}


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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll long long int
 
using namespace std;

 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
	     cin>>a[i];
	}
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<k;i++)
	{
	     sum+=a[i];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    if(s.substr(0, 4) == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int32_t main(){
  DESYNC;
  int n;
  cin >> n;
  int wrong = 0;
  for(int i=1; i<=n; i++){
    int x;
    cin >> x;
    if(x != i) wrong++;
  }
  if(wrong <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}



Measured memory_bytes: 256
#!/usr/bin/ruby
class Fixnum
	def pow_binary_mod(y)
		x = self
		z = 1
		while y != 0
			while y % 2 == 0
				x = x * x % $N
				#y = y / 2
				y = y >> 1
			end
			y = y - 1
			z = z * x % $N
		end
		z
	end
	def /(n)
		m=(n%$N+$N)%$N
		raise if m==0
		self*m.pow_binary_mod($N-2)%$N
	end
end
loop{
	n,exp=gets.chomp.gsub(' ','').split(':')
	$N=n.to_i
	break if $N==0
	begin
		puts "#{exp} = #{(eval(exp)%$N+$N)%$N} (mod #{$N})"
	rescue
		puts :NG
	end
}

Measured memory_bytes: 9980
from operator import mul
from functools import reduce


def cmb(n, r):
	r = min(n - r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n - r, -1))
	denom = reduce(mul, range(1, r + 1))
	return numer // denom % INF


N, K = map(int, input().split())
INF = 10 ** 9 + 7

for i in range(1, K + 1):
	if N - K + 1 >= i:
		print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % INF)
	else:
		print(0)


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

int main() {
  ll n;
  cin >> n;
  ll low, upp;
  low = 1; upp = n;
  for (ll i = 2; i * i <= n; ++i) {
    if (n%i == 0) {
      low = i; upp = n/i;
    }
  }
  ll ans = low + upp - 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a[6][2];
	a[0][0] = 1;
	a[0][1] = 3;
	a[1][0] = -1;
	a[1][1] = 2;
	a[2][0] = 4;
	a[2][1] = 5;
	a[3][0] = 1;
	a[3][1] = -1;
	a[4][0] = 5;
	a[4][1] = 3;
	a[5][0] = 3;
	a[5][1] = 1;
	string b;
	while (cin >> b&&b != "#") {
		int t = 0;
		for (int i = 0; i < b.length(); i++) {
			int c = (int)b[i] - '0';
			if (a[t][c] != -1) t = a[t][c];
			else break;
		}
		if (t == 5)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<char> left{'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
    string s;
    while (cin>>s) {
        if (s=="#") {
            break;
        } else {
            string flag="";
            int count=0;
            for (int i=0;i<s.size();i++) {
                if (i==0) {
                    if (find(left.begin(),left.end(),s.at(i))!=left.end()) {
                        flag="left";
                    } else {
                        flag="right";
                    }
                } else {
                    if ( flag=="left"&&find( left.begin(),left.end(),s.at(i) )==left.end() ) {
                        count++;
                        flag="right";
                    } else if ( flag=="right"&&find( left.begin(),left.end(),s.at(i) )!=left.end() ) {
                        count++;
                        flag="left";
                    }
                }
            }
            cout<<count<<endl;
        }
    }
}



Measured memory_bytes: 3116
// 未完成
#include <iostream>
#include <climits>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <ios>
#include <iomanip>

using namespace std;

// 最大公約数
long long gcd(long long a, long long b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

// 最小公倍数
long long lcm(long long a, long long b){
    long long g = gcd(a,b);
    return a / g * b;
}

int main(){

  int N, X, x[100001], y[100001];

  cin >> N >> X;

  for(int i = 0; i < N; i++) cin >> x[i];

  for(int i = 0; i < N; i++) y[i] = abs(x[i] - X);

  sort(y, y+N);
  
  int D = gcd(y[1], y[0]);
  for(int i = 2; i < N; i++) D = gcd(y[i], D);
  
  cout << D << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll N, K;

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

  ll d = N % K;
  ll d_abs = d - K < 0 ? K - d : d - K;
  ll ans = min(d, d_abs);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

}

Measured memory_bytes: 17156
package main

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

const (
	mod = int64(1000000007)
)

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	s := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		s[i], _ = strconv.Atoi(scanner.Text())
	}
	t := make([]int, m)
	for i := 0; i < m; i++ {
		scanner.Scan()
		t[i], _ = strconv.Atoi(scanner.Text())
	}

	dp := make([][]int64, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int64, m+1)
		for j := 0; j <= m; j++ {
			if i == 0 || j == 0 {
				dp[i][j] = 1
				continue
			}

			if s[i-1] == t[j-1] {
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod
			} else {
				dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod
			}
		}
	}

	fmt.Println((dp[n][m] + mod) % mod)
}


Measured memory_bytes: 33920
#!/usr/bin/env python3
import sys

def div(n, k):
    while n % k == 0:
        n //= k
    return n

def solve_slow(N):
    def f():
        ans = 0
        for i in range(2, N+1):
            if div(N, i) % i == 1:
                yield i
    return set(f())

def solve(N: int):
    from itertools import takewhile
    def f():
        for i in takewhile(lambda x: x*x<=N-1, range(1, N)) :
            if (N - 1) % i == 0:
                yield i
                yield (N-1)//i
    def g():
        for i in takewhile(lambda x: x*x<=N, range(2, N)) :
            if N % i == 0:
                if div(N, i) % i == 1:
                    yield i
                if div(N, N // i) % (N // i) == 1:
                    yield N // i
        yield N
    return set(g()) | set(f()) - set([1])

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(len(solve(N)))

def test():
    for i in range(2, 1000):
        if solve(i) != solve_slow(i):
            print(i, solve(i), _solve(i),)

if __name__ == '__main__':
    main()
    #test()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int a; cin>>a;
	cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3628
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s1 = input()
s2 = input()

ans = 3
i = 1
while i < n:
    if i == 1 or s1[i-1] != s1[i-2]:
        if i == n-1 or s1[i] != s1[i+1]:
            ans = ans * 2 % ( 10**9 + 7 )
            i += 1
        else:
            ans = ans * 2 % ( 10**9 + 7 )
            i += 2
    else:
        if i == n-1 or s1[i] != s1[i+1]:
            ans = ans * 1 % ( 10**9 + 7 )
            i += 1
        else:
            ans = ans * 3 % ( 10**9 + 7 )
            i += 2
print(ans)

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

int svx[2002][2002];
int svy[2002][2002];
int sv[2002][2002];
char grid[2002][2002];


int main () {
  int n, m, q;

  cin >> n >> m >> q;

  for(int i = 0; i < n + 2; i++) {
    for(int j = 0; j < m + 2; j++) {
      grid[i][j] = '0';
      sv[i][j] = 0;
      svx[i][j] = 0;
      svy[i][j] = 0;
    }
  }

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      sv[i][j] = sv[i][j-1] + sv[i-1][j] - sv[i-1][j-1];
      svx[i][j] = svx[i][j-1] + svx[i-1][j] - svx[i-1][j-1];
      svy[i][j] = svy[i][j-1] + svy[i-1][j] - svy[i-1][j-1];

      cin >> grid[i][j];
      if(grid[i][j] == '0') continue;

      sv[i][j] += 1;
      if(grid[i-1][j] == '1') svx[i][j] += 1;
      if(grid[i][j-1] == '1') svy[i][j] += 1;
    }
  }

  int x0, y0, x1, y1;
  for(int i = 0; i < q; i++) {
    cin >> x0 >> y0 >> x1 >> y1;
    int v = sv[x1][y1] - sv[x0-1][y1] - sv[x1][y0-1] + sv[x0-1][y0-1];
    int e = svy[x1][y1] - svy[x0-1][y1] - svy[x1][y0] + svy[x0-1][y0];
    e += svx[x1][y1] - svx[x0][y1] - svx[x1][y0-1] + svx[x0][y0-1];

    cout << (v - e) << endl;
  }

  return 0;
}


Measured memory_bytes: 52736
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<P> a;
  rep(i, n){
    int t;
    cin >> t;
    a.emplace_back(t, i + 1);
  }
  sort(ALL(a));
  rep(i, n) cout << a[i].second << endl;
}


Measured memory_bytes: 1780
import java.util.Scanner;

public class Main {
	static byte ans[][];

	public static boolean f(int a[][], int s[], int n) {
		if (10 <= n) {
			int b[][] = new int[10][10];
			ans = new byte[10][10];
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					b[i][j] = a[i][j];
				}
			}
			for (int i = 0; i < 10; i++) {
				if (s[i] == 1) {
					reverse(b, 0, i);
					ans[0][i] = 1;
				}
			}
			for (int i = 1; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					if (b[i - 1][j] == 1) {
						reverse(b, i, j);
						ans[i][j] = 1;
					}
				}
			}
			if (check(b)) {
				return true;
			}
		} else {
			s[n] = 0;
			if (f(a, s, n + 1)) {
				return true;
			}
			s[n] = 1;
			if (f(a, s, n + 1)) {
				return true;
			}
		}
		return false;
	}

	public static void reverse(int a[][], int i, int j) {
		a[i][j] = (a[i][j] + 1) % 2;
		if (0 <= i - 1) {
			a[i - 1][j] = (a[i - 1][j] + 1) % 2;
		}
		if (i + 1 < 10) {
			a[i + 1][j] = (a[i + 1][j] + 1) % 2;
		}
		if (0 <= j - 1) {
			a[i][j - 1] = (a[i][j - 1] + 1) % 2;
		}
		if (j + 1 < 10) {
			a[i][j + 1] = (a[i][j + 1] + 1) % 2;
		}
	}

	public static boolean check(int a[][]) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (a[i][j] == 1) {
					return false;
				}
			}
		}
		return true;
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int a[][];

		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			a = new int[10][10];
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					a[j][k] = sc.nextInt();
				}
			}
			f(a, new int[10], 0);
			for (int j = 0; j < 10; j++) {
				String s = "";
				for (int k = 0; k < 10; k++) {
					System.out.print(s + ans[j][k]);
					s = " ";
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 29388
Scanf.scanf "%d %d %d" (fun n a b ->
    let module M = Map.Make (struct type t = int let compare a b = compare b a end) in
    let rec loop i acc =
        if i = n then acc else
            let acc = Scanf.scanf " %d" (fun v ->
                M.add v (1 + try M.find v acc with _ -> 0) acc
            )
            in
            loop (i + 1) acc
    in
    let map = loop 0 M.empty in
    let bin a b =
        let rec loop x y acc =
            if y > b then acc else
                loop (x - 1) (y + 1) (acc * x / y)
        in
        loop a 1 1
    in
    let rec loop sum count = function
        | [] -> failwith "??"
        | (v, c) :: tl ->
                if count + c < a then loop (sum + v * c) (count + c) tl else (
                    if sum > 0 then (
                        let sum = sum + v * (a - count) in
                        let avg = float sum /. float a in
                        let comb = bin c (a - count) in
                        avg, comb
                    ) else (
                        let avg = float v in
                        let mx = min b c in
                        let rec loop i acc =
                            if i > mx then acc else
                                let acc = acc + bin c i in
                                loop (i + 1) acc
                        in
                        let comb = loop a 0 in
                        avg, comb
                    )
                )
    in
    let avg, comb = loop 0 0 (M.bindings map) in
    Printf.printf "%.8f\n%d\n" avg comb
)

Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <iterator>
#include <deque>
#include <assert.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}

ll M = 1e9+7, a, b, n;

ll p2(ll n){
    if (!n) return 1;
    ll k = p2(n/2);
    k = (k*k)%M;
    if (n&1) k = (k*2)%M;
    return k;
}

int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>a>>b;

    ll factna = 1,ifacta = 1, factnb = 1, ifactb = 1, P = p2(n), A, B;
    for (ll i = n-a+1; i <= n; i++){
        factna = (factna*i)%M;
    }
    for (ll i = n-b+1; i <= n; i++){
        factnb = (factnb*i)%M;
    }
    for (ll i = 1; i <= a; i++){
        ifacta = (ifacta*inv(i,M))%M;
    }
    for (ll i = 1; i <= b; i++){
        ifactb = (ifactb*inv(i,M))%M;
    }

    P = (P-1+M)%M;
    A = (factna*ifacta)%M;
    B = (factnb*ifactb)%M;

    P = (P-A+M)%M;
    P = (P-B+M)%M;

    cout<<P<<"\n";

    return 0;
    
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, L;
    cin >> N >> L;
    int sum = 0;
    for(int i = 1; i <= N; i++){
        sum += L + i - 1;
    }
    if(L >= 0){
        cout << sum - L << endl;
    }
    else if(L <= -N + 1){
        cout << sum - (L + N - 1) << endl;
    }
    else{
        cout << sum << endl;
    }
    return 0;
}

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


int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}

	sort(p.begin(), p.end());

	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += p.at(i);
	}

	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main() {
	int i,x;
	i = 1;
	while(1){
		scanf("%d",&x);
		if ( x == 0 ){
			break;
		} else {
			printf("Case %d: %d\n",i,x);
			i++;
		}
	}
	return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
// # define M_PIl        3.141592653589793238462643383279502884
using namespace std;

typedef long long ll;
typedef long double ld;
#define faster       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  // faster;
  ll n;
  cin >> n;
  ll ans=1;
  bool ex = false;
  bool zero=false;
  for(ll i=0;i<n;i++){
    ll a;
    cin >> a;
    if(a==0){
      cout << 0;
      return 0;
    }
    if((1000000000000000000/a)<ans){
      ex = true;
    }
    ans*=a;
  }
  if(ex){
    cout << -1;
    return 0;
  }
  else{
    cout << ans;
    return 0;
  }
}



// 9223372036854775807

Measured memory_bytes: 3156
#include<cctype>
#include<cstdio>
#include<algorithm>
using i64=long long;
int fetc(){int c=getchar();while(c^'-'&&c^'+')c=getchar();return c;}
int read(){int x=0,c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
int main()
{
    int n=read();i64 ans=read(),b=-1e18,c=-1e18;
    for(int x;n^1;--n) fetc()=='-'?(x=read(),c=b+x,ans=b=std::max(ans-x,c)):(x=read(),ans+=x,c+=x,b=std::max(b-x,c));
    printf("%lld",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int H, W, N;
    cin >> H >> W >> N;

    vec<int> a(N);
    rep(i, N) cin >> a[i];

    vec<vec<int>> ans(H, vec<int>(W));
    rep(i,H)rep(j,W){

        int now = 0;
        rep(k,N) {
            if(a[k] != 0){
                now = k+1;
                --a[k];
                break;
            }
        }

        ans[i][(i%2==0?j:(W-1-j))] = now;
    }
    rep(i,H){
        rep(j,W){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3660
n, m, q = map(int, input().split())
dp = [[0] * (n+1) for i in range(n+1)]

for i in range(m):
    l, r = map(int, input().split())
    dp[l][r] += 1
    
for i in range(n+1):
    for j in range(n):
        dp[i][j+1] += dp[i][j]
        
for i in range(n):
    for j in range(n+1):
        dp[i+1][j] += dp[i][j]
    
for i in range(q):
    p, q = map(int, input().split())
    print(dp[q][q] - dp[q][p-1] - dp[p-1][q] + dp[p-1][p-1])

Measured memory_bytes: 13396
#include<stdio.h>
signed main(void)
{
  int X,Y,z=0;
  if(~scanf("%d %d",&X,&Y))
  {
    if((Y&1))return puts("No"),0;
    if(2*X>Y||4*X<Y)return puts("No"),0;
    if(!((4*X-Y)&1))return puts("Yes"),0;
    else return puts("No"),0;
  }
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

LL mod_pow(LL a, LL n, LL p){
    if(n == 0) return 1;
    if(n%2 == 1) return (a * mod_pow(a, n-1, p)) % p;
    LL t = mod_pow(a, n/2, p);
    return (t*t) % p;
}

LL fact[200010];
LL invfact[200010];
const LL mod = 1e9 + 7;

LL nCr(int n, int r){
    LL ret = fact[n];
    (ret *= invfact[n-r]) %= mod;
    (ret *= invfact[r]) %= mod;
    return ret;
}


int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    fact[0] = 1;
    for(LL i=1; i<=200000; i++){
        fact[i] = (fact[i-1] * i) % mod;
    }
    for(LL i=0; i<=200000; i++){
        invfact[i] = mod_pow(fact[i], mod-2, mod);
    }

    LL ans = 0;
    for(int i=B; i<W; i++){
        LL tmp = nCr((H-A-1)+i, H-A-1);
        (tmp *= nCr((A-1)+(W-i-1), A-1)) %= mod;
        (ans += tmp) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int n,m,cp[30],vis[30];
char s[30][30],t[30][30];
inline void copy(int x,int y){for(int i=0;i<m;i++)t[y][i]=s[x][i];}
bool dfs(int u)
{
	if(u==n)
	{
		for(int i=0,j=0;i<n;i++)
			if(cp[i]==n)copy(i,n/2);
			else if(cp[i]>i){copy(i,j),copy(cp[i],n-j-1);j++;}
		memset(vis,0,sizeof vis);
		for(int i=0,cnt=0;i<m;i++)
			if(!vis[i])
			{
				for(int j=i+1;j<m;j++)
					if(!vis[j])
					{
						bool f=1;
						for(int k=0;k<n;k++)
							if(t[k][i]!=t[n-k-1][j]){f=0;break;}
						if(f){vis[i]=vis[j]=1;break;}
					}
				if(!vis[i])
				{
					if(++cnt>m%2)return 0;
					for(int j=0;j<n;j++)
						if(t[j][i]!=t[n-j-1][i])return 0;
				}
			}
		return 1;
	}
	if(cp[u]!=-1)return dfs(u+1);
	for(int i=u+1;i<n;i++)
		if(cp[i]==-1)
		{
			cp[i]=u;cp[u]=i;
			if(dfs(u+1))return 1;
			cp[i]=cp[u]=-1;
		}
	return 0;
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>s[i];
	memset(cp,-1,sizeof cp);
	if(n&1)
	{
		for(int i=0;i<n;i++)
		{
			cp[i]=n;
			if(dfs(0)){puts("YES");return 0;}
			cp[i]=-1;
		}
		puts("NO");
	}
	else puts(dfs(0)?"YES":"NO");
	return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;

const ll INF = 1001001001;


int main() {

    int n;
    cin >> n;
    vector<int> hs;

    rep(i, n) {
        int h;
        cin >> h;
        hs.push_back(h);
    }

    int pre = -999;
    rep(i, n) {
        if (pre <= hs[i] - 1) {
            pre = hs[i] - 1;
        } else if (pre <= hs[i]) {
            pre = hs[i];
        } else {
            puts("No");
            return 0;
        }
    }
    puts("Yes");


}


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

template<typename T = char>
vector<pair<T, int>> run_length_encode(string &a) {
    vector<pair<T, int>> res;
    for (T &ai: a) {
        if (res.empty() || res.back().first != ai) res.emplace_back(ai, 1);
        else res.back().second++;
    }
    return res;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    cout << run_length_encode(s).size() << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

ll pow5(ll x){
    ll y;
    y=x*x*x*x*x;
    return y;
}

void solve(){

    /*
    ll t = 1;
    while(pow5(t+1)-pow5(t)<=1000000000){
        t++;
    }

    cout << t << endl;
    cout << pow5(t) << " " << pow5(t+1) << endl;
    */

    ll x_;
    cin >> x_;
    
    ll th = 120;

    for(ll i=(-1)*th; i<=th; i++){
        for(ll j=(-1)*th; j<=th; j++){
            if(pow5(i)-pow5(j)==x_){
                cout << i << " " << j << endl;
                return;
            }
        }
    }

}

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


Measured memory_bytes: 3612
import java.util.*;
import java.io.*;
 
 
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int[] al = new int[n];
        int[] bl = new int[n];
        for(int i = 0; i < n; i++){
            al[i] = sc.nextInt();
            bl[i] = sc.nextInt();
        }
        int[][] dpi = new int[n+2][t+1];
        int[][] dpj = new int[n+2][t+1];
        for(int i = 1; i <= n; i++){
            for(int j = 0; j < t; j++){
                dpi[i][j] = dpi[i-1][j];
			    if (j - al[i-1] >= 0) dpi[i][j] = Math.max(dpi[i][j], dpi[i-1][j-al[i-1]]+bl[i-1]);
            }
        }
        for(int i = n; i >= 1; i--){
            for(int j = 0; j < t; j++){
                dpj[i][j] = dpj[i+1][j];
			    if (j - al[i-1] >= 0) dpj[i][j] = Math.max(dpj[i][j], dpj[i+1][j-al[i-1]]+bl[i-1]);
            }
        }
        int max = Math.max(dpi[n][t-1], dpj[1][t-1]);
        for(int i = 0; i < n; i++){
            for(int j = 0; j < t; j++){
                max = Math.max(max,dpi[i][j] + dpj[i+2][t-1-j] + bl[i]);
            }
        }
        System.out.println(max);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

using int64 = long long;

int64 N, K;

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

   // Kの倍数である数値の個数を数える
   int64 a = 0;
   for (int64 x = 1; x <=N; x++) {
      if (x % K == 0) {
         a++;
      }
   }

   // 余りがKの半分となる数値の個数を数える
   int64 b = 0;
   for (int64 x = 1; x <=N; x++) {
      if (x % K == K/2) {
         b++;
      }
   }

   // 全ての要素がKの倍数の場合を足す
   int64 ans = a * a * a;
   // Kが偶数なら余りがK/2の場合も考慮する
   if (K % 2 == 0) {
      // 全ての要素がK/2の場合を足す
      ans += b * b * b;
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<list>
#include<cstring>
#include<cctype>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<ctime>
using namespace std;
using ll = long long;

int main(void){
    int n,m;
    cin >> n >> m;
    
    int a[m],b[m];
    vector<int> v(n+1,0);
    for(int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        if(b[i] == n-1)v[a[i]]++;
    }

    bool check = false;
    for(int i = 0;i < m;i++){
        if(a[i] == 0){
            if(v[b[i]] > 0)check = true;
        }
    }
    
    if(!check)cout << "IM";
    cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 5592
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([] int) int
var FindMax func([] int) int
var StrReverse func(string) string

func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
	StrReverse = strReverse
	GetIntAbs = getIntAbs
}

func main() {
  a := ReadInt()
	s := ReadString()
  if a >= 3200 {
    fmt.Println(s)
  } else {
    fmt.Println("red")
  }
}

func strReverse(s string) string {
	runes := []rune(s)
	l := len(runes)
	for i, j := 0, l-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


func newReadString() func() string {
	sc.Buffer(make([]byte, 202400), 404800)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}

func readInt() int {
	i := ReadInt64()
	return int(i)
}

func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

func getIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 640
s = input()
t = input()
n = len(s)
for i in range(n):
    s = list(s)
    s_last = [s[n - 1]]
    u = s_last + s[0:n - 1]
    s = "".join(u)
    if s == t:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323

// dp[i] - TRUE if the first player wins if there are i stones remaining

void solve()
{
       ll n,k;
       cin>>n>>k;
       vector<int>a(n);
       rep(i,0,n) cin>>a[i];
       vector<bool>dp(k + 1);
       for(int stones=0; stones<=k; stones++){
              for(int x : a){
                     if(stones>=x && !dp[stones-x]){
                            dp[stones] = 1;
                     }
              }
       }
       if(dp[k]) cout << "First";
       else cout << "Second";
}



int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 256