akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#define NIL -1
using namespace std;
struct Node{int l, p, r, s, deg;};
int D[30], H[30];
Node T[30];
void setDepth(int r, int d)
{
  if(r == NIL) return;
  D[r] = d;
  setDepth(T[r].l, d+1);
  setDepth(T[r].r, d+1);
}

int setHeight(int u)
{
  int h1, h2;
  h1 = h2 = 0;
  if(T[u].l != NIL)
    h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL)
    h2 = setHeight(T[u].r) + 1;
  return H[u] = max(h1, h2);
}

void print(int i)
{
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, T[i].p, T[i].s, T[i].deg, D[i], H[i]);
  if(T[i].p == NIL)
    printf("root\n");
  else if(T[i].l == NIL && T[i].r == NIL)
    printf("leaf\n");
  else printf("internal node\n");
}
int main()
{
  int n;
  int left, right, root, temp, v;
  scanf("%d", &n);
  for(int i=0; i<n; i++)
  {
    T[i].l = T[i].p = T[i].r = T[i].s = NIL;
    T[i].deg = 0;
  }
  for(int i=0; i<n; i++)
  {
    scanf("%d", &v);
    scanf("%d%d", &left, &right);
    T[v].l = left; T[v].r = right;
    T[left].p = T[right].p = v;
    T[left].s = right; T[right].s = left;
    if(left != NIL)
      T[v].deg++;
    if(right != NIL)
      T[v].deg++;
  }
  for(int i=0; i<n; i++)
  {
    if(T[i].p == NIL) root = i;
  }
  setDepth(root, 0);
  setHeight(root);
  for(int i=0; i<n; i++)
    print(i);

  return 0;
}



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

void solve() 
{
    string s;cin>>s;
    for(int i=0;i<s.size();i+=2)cout<<s[i];cout<<endl;
}

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

Measured memory_bytes: 592
h,w = map(int,input().split())
M = []
for i in range(h):
    M.append(input())
L = []
R = []
U = []
D = []
Total = []
for i in range(h):
    s = [0]*w
    L.append(s)
for i in range(h):
    s = [0]*w
    R.append(s)
for i in range(h):
    s = [0]*w
    U.append(s)
for i in range(h):
    s = [0]*w
    D.append(s)
for i in range(h):
    s = [0]*w
    Total.append(s)
for i in range(h):
    for j in range(w):
        if M[i][j] == '#':
            None
        else:
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1]+1
for i in range(h):
    for j in range(w-1,-1,-1):
        if M[i][j] == '#':
            None
        else:
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1]+1
for i in range(h):
    for j in range(w):
        if M[i][j] == '#':
            None
        else:
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j]+1
for i in range(h-1,-1,-1):
    for j in range(w):
        if M[i][j] == '#':
            None
        else:
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j]+1
for i in range(h):
    for j in range(w):
        Total[i][j] += L[i][j]+R[i][j]+U[i][j]+D[i][j]-3
ans = 0
for i in range(h):
    for j in range(w):
        if Total[i][j] > ans:
            ans = Total[i][j]
print(ans)

Measured memory_bytes: 211716
#include <bits/stdc++.h>
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
 
using namespace std;
const ll maxn=3e3+100,inf=1e18,LOG=23,mod=1e9 + 7;
int block = 300, timer = 0;
const ld EPS = 1e-7;
 
#define bt(i) (1 << (i))
#define int ll

int n, pref[maxn][maxn], suff[maxn][maxn], dp[maxn][maxn];
string s;

main()
{
	cin >> n >> s;
	dp[1][1] = 1;
	pref[1][1] = 1;
	suff[1][1] = 1;
	forn(2, i, n)
	{
		forn(1, j, i)
		{
		//	dp[i][j] = dp[i - 1][j];
			if(s[i - 2] == '<')
				dp[i][j] += pref[i - 1][j - 1];
			else
				dp[i][j] += suff[i - 1][j];
			//cout << i << " " << j << " " << dp[i][j] << endl;
			dp[i][j] %= mod;
		}
		forn(1, j, i)
		{
			pref[i][j] = pref[i][j - 1] + dp[i][j];
			pref[i][j] %= mod;
		}
		nfor(1, j, i)
		{
			suff[i][j] = suff[i][j + 1] + dp[i][j];
			suff[i][j] %= mod;
		}
	}
	cout << pref[n][n];
}

Measured memory_bytes: 221824
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c,d;cin >>a>>b>>c>>d;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout << "Possible";
  }else{
    cout << "Impossible";
  }
}


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

#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)


const int MAXN = 1e6;
const int mod = 1e9 + 7;
const int inf = 1e9;



int main(){
	
	fastio;
	string s, t;
	cin >> s;
	cin >> t;

	int cnt = 0;

	for(int i = 0;i < 3;i++){
		if(s[i] == t[i]) cnt++;
	}

	cout << cnt<< endl;

	return 0;
 }	

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int x,y,z;
  scanf("%d %d",&x,&y);
  if(x<y){
    for(;;){
      z=y%x;
      if(z==0) break;
      y=x;
      x=z;
    }
    printf("%d",x);
  }

  else{
    for(;;){
      z=x%y;
      if(z==0) break;
      x=y;
      y=z;
    }
    printf("%d",y);
  }
  printf("\n");
 return 0;
}



Measured memory_bytes: 2092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#define SS(i) scanf("%s",i)
#define SC(i) scanf("%d",&i)
#define SCC(i,j) scanf("%d%d",&i,&j)
#define SCCC(i,j,z) scanf("%d%d%d",&i,&j,&z)
#define PR(i) printf("%d\n",i)
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define CL(i,x) memset(i,x,sizeof(i))
#define IN freopen("in.txt","r",stdin)
#define OUT  freopen("out.txt","w",stdout)
#define PB(i) push_back(i)
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
using namespace std;
const int N=5e4+10;
const int inf = 2e9;

int main()
{
#ifndef ONLINE_JUDGE
   // IN;
#endif

    LL n, m;
    scanf("%lld %lld", &n, &m);
    LL ans;
    if(2*n<=m)
    {
        ans = (n*2+m)/4;
    }
    else
    {
        ans = m/2;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
//pantyhose(black) + glasses = infinity

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

#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".inp", "r", stdin);
		//freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int64_t n, m;
	string s, t;
	cin >> n >> m >> s >> t;
    int64_t d = __gcd(n, m);
    int64_t p = n/d, q = m/d;
    for (int64_t i=0, j=0; i<n && j<m; i+=p, j+=q) {
        if (s[i]!=t[j]) {
            cout << -1;
            return 0;
        }
    }
    cout << n*m/__gcd(m, n);
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.length()
using namespace std;
typedef unsigned long long ll;

int main(void){
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	ll num = min({a,b,c,d,e});
	cout << (n + num - 1) / num + 4 << endl;

	return 0;
}


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

int main() {
	int n, d;
	cin >> n >> d;
	int x[n][d];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < d; j++){
			cin >> x[i][j];
		}
	}
	int out = 0;
	for(int i = 0; i < n - 1; i++){
		for(int j = i + 1; j < n; j++){
			double distance = 0;
			for(int k = 0; k < d; k++){
				distance += abs(x[i][k] - x[j][k]) * abs(x[i][k] - x[j][k]);
			}
			if((int)sqrt(distance) == sqrt(distance)) out++;
		}
	}
	cout << out << endl;
}


Measured memory_bytes: 3588
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a,b,c;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		System.out.println((a-c)/(b+c));
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;

int main( ){
    int N;
    cin>>N;
    vpii conne[N];
    rep(i,0,N-1){
        int u,v,w;
        cin>>u>>v>>w;
        u--,v--;
        pii p=make_pair(v,w);
        conne[u].push_back(p);
        p.first=u;
        conne[v].push_back(p);
    }
    using pill =pair<int,ll>;
    queue<pill> q;
    vll dist(N,-1);
    q.emplace(0,0);
    dist[0]=0;
    while(!q.empty()){
        pill now=q.front();
        q.pop();
        for(pii next:conne[now.first]){
            if(dist[next.first]!=-1)continue;
            dist[next.first]=next.second+now.second;
            q.emplace(next.first,next.second+now.second);
        }
    }
    rep(i,0,N)cout<<dist[i]%2<<endl;
    return 0;
}




Measured memory_bytes: 7168
import sys
def input(): return sys.stdin.readline().rstrip()
class Sieve: #区間[2,n]の値の素因数分解 前処理O(nloglogn)素因数分解O(logn)
    def __init__(self,n=1):
        self.primes=[]
        self.f=[0]*(n+1) #ふるい（素数ならその値）
        self.f[0]=self.f[1]=-1
        for i in range(2,n+1): #素数リスト作成
            if self.f[i]: continue
            self.primes.append(i)
            self.f[i]=i
            for j in range(i*i,n+1,i):
                if not self.f[j]:
                    self.f[j]=i  #最小の素因数を代入
    def is_prime(self, x):
        return self.f[x]==x
    def prime_fact(self,x): #素因数分解 {2:p,3:q,5:r,...}
        fact_dict=dict()
        while x!=1:
            p=self.f[x]
            fact_dict[p]=fact_dict.get(p,0)+1
            x//=self.f[x]
        return fact_dict
class Sieve2: #√nまでの素因数で試し割り 前処理O(√nloglogn+√n/logn)
    def __init__(self,n):
        self.primes=[]
        self.f=[0]*(int(n**0.5)+1) #ふるい（素数ならその値）
        self.f[0]=self.f[1]=-1
        for i in range(2,int(n**0.5)+1): #素数リスト作成
            if self.f[i]: continue
            self.primes.append(i)
            self.f[i]=i
            for j in range(i*i,int(n**0.5)+1,i):
                if not self.f[j]:
                    self.f[j]=i  #最小の素因数を代入
    def prime_fact(self,x): #素因数分解 {2:p,3:q,5:r,...}
        fact_dict=dict()
        for p in self.primes:
            if p*p>x:break
            while x%p==0:
                x//=p
                fact_dict[p]=fact_dict.get(p,0)+1
        if x>1:fact_dict[x]=fact_dict.get(x,0)+1
        return fact_dict

def main():
    n=int(input())
    A=list(map(int,input().split()))
    mod=10**9+7
    p_lis={}
    Prime=Sieve2(10**6+5)
    for a in A:
        f=Prime.prime_fact(a)
        for key in f:
            p_lis[key]=max(p_lis.get(key,0),f[key])
    lcm=1
    for key in p_lis:
        lcm=(lcm*pow(key,p_lis[key],mod))%mod
    ans=0
    for a in A:
        b=lcm*pow(a,mod-2,mod)%mod
        ans=(ans+b)%mod
    print(ans)


if __name__ == '__main__':
    main()



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) {
        int tmp;
        cin >> tmp;
        a[i] = abs(x-tmp);
    }
    int ans = a[0];
    rep(i, n) {
        ans = __gcd(ans, a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
from numpy import*
k,A,F=[int64(t.split())for t in open(0)]
l=-1
r=10**12
while r-l>1:
 m=l+r>>1
 if sum(A-minimum(sort(A),m//sort(F)[::-1]))>k[1]:l=m
 else:r=m
print(r)

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

int main(){
string w;
   cin>>w;
  
  int count=0;
  bool flag=true;
  for(int i=0; i<w.size(); i++){
   for(int j=0; j<w.size(); j++){
    if(w[i]==w[j]){count++;}
   }
    if(count%2!=0){flag=false; break;}
    count=0;
  }
 if(!flag){cout<<"No";}
 else{cout<<"Yes";}
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int n;
  cin >> n;

  for (int i = n; i < 1000; i++) {
    int a = i / 100;
    int b = i % 100 / 10;
    int c = i % 10;
    if (a == b && b == c) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const int N=10E5+2;
long long arr[N];
int main()
{


long long n;
cin>>n;
for(int i=0;i<n;i++)cin>>arr[i];
long long maxi=0;
long long counter=0;
for(int i=0;i+1<n;i++){


    if(arr[i]>=arr[i+1])counter++;
    else{
        maxi=max(maxi,counter);
        counter=0;

    }





}
maxi=max(counter,maxi);
cout<<maxi;

}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/


int main() {

//  freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  int x, y;cin>>x>>y;
  for(int i = 0;i <= x;i++) {
    if(2*i + 4*(x-i) == y) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";

  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	int ans = 1000;
	int now = A[0];
	rep(i, N) {
		if (i == 0)continue;
		if (now < A[i]) {
			int num = ans / now;
			ans -= num * now; 
			ans += num * A[i];
			now = A[i];
		}
		else now = A[i];
	}
	cout << ans;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    int a,b,N,i,s,f,x=0;
    cin >> a >> b;
    cin >> N;
    
    for(i=1; i<=N; i++){
        cin >> s >> f;

        if(b <= s || a >= f){
                
        }
        else{
             x=1;
        }
    }
    cout << x << endl;    
}    


Measured memory_bytes: 3084
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "No";
    int p = 0;
    int q = 0;
    int r = 0;
    for(int i = 0; i < 3; i++) {
      if(s.charAt(i) == 'a') p++;
      if(s.charAt(i) == 'b') q++;
      if(s.charAt(i) == 'c') r++;
    }
    if((p > 0) && (q > 0) && (r > 0)) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main()
{
    ll n;
    cin >> n;
    if(n%2==0) cout << n;
    else cout << 2*n;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  long long int N,K;
  cin >> N >> K;
  if(K%2!=0){
    long long int di = N/K;
    cout << di*di*di << endl;
  }else{
    long long int KK = K/2;
    bool can_div=false;
    if(K%2==0)can_div=true;
    long long int cnt1=0,cnt2=0;
    for(int i=1;i<=N;i++){
      if(i%KK == 0){
        if(i%K == 0){
           cnt1++;
        }else if(can_div && i%K == K/2){
           cnt2++;
        }
      }
    }
    //cout << cnt1 << " " << cnt2 << endl;
    cout << cnt1*cnt1*cnt1 + cnt2*cnt2*cnt2;
  }
  return 0;
}


Measured memory_bytes: 256
n, q = [ int(v) for v in input().split() ]
num = [ 0 for i in range(n) ]
num[0] = 1
num[1] = 2
p = 0
for i in range(q):
    a, b = [ int(v)-1 for v in input().split() ]
    num[a], num[b] = num[b], num[a]
    if num[a] == 1:
        p = a
    elif num[b] == 1:
        p = b
    if p > 0:
        num[p-1] = 2
    if p < n-1:
        num[p+1] = 2
print(n - num.count(0))

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

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

unordered_map<string,int> id;
int V;

int getid(const string& s){
  if(id.find(s)!=id.end())return id[s];
  id[s]=V++;
  return id[s];
}

int p,q;
int N;
map<int,vector<int> > con[301];
bool vis[1001];
bool vis0[301];
bool mv[301][301];
vector<int> g[301];
vector<P> es[1001];

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

  {
    string a,b;
    cin>>a>>b;
    p=getid(a); q=getid(b);
  }
  cin>>N;
  rep(i,N){
    int m;
    cin>>m;
    rep(j,m){
      string a,b;
      cin>>a>>b;
      es[i].push_back(P(getid(a),getid(b)));
      con[getid(a)][getid(b)].push_back(i);
    }
  }
  rep(i,V)mv[i][i]=true;

  queue<int> que;
  rep(i,N){
    rep(j,es[i].size()){
      if(es[i][j]==P(p,q)){
        que.push(i);
        vis[i]=true;
        mv[p][q]=true;
        break;
      }
    }
  }
  while(que.size()){
    int v=que.front(); que.pop();
    for(P e : es[v]){
      if(exist(g[e.fi],e.se))continue;
      g[e.fi].push_back(e.se);
    }
    rep(s,V){
      queue<int> que0;
      rep(j,V){
        if(mv[s][j]){
          que0.push(j);
        }
      }
      while(que0.size()){
        int v0=que0.front(); que0.pop();
        for(int nv0 : g[v0]){
          if(!mv[s][nv0]){
            if(s!=nv0&&mv[nv0][s]){
              cout<<"No"<<endl;
              return 0;
            }
            mv[s][nv0]=true; que0.push(nv0);
            for(int i : con[s][nv0]){
              if(!vis[i]){
                vis[i]=true;
                que.push(i);
              }
            }
          }
        }
      }
    }
  }
  
  cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 11516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  char c;
  cin >> c;
  cout << (char)(c + 1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int main()
{
    int t;
    string n;
    while(1){
        cin >> t >> n;
        if(t == 0 && n == "0") break;
        int num[7][7] = {};
        for(int i = 0; i < 7; i++){
            for(int j = 0; j < 7; j++){
                num[i][j] = -1;
            }
        }
        int cnt = 6;
        int l = n.length();
        for(int i = 1; i < l + 1; i++){
            num[i][1] = n[i - 1] - '0';
        }
        for(int i = 1; i < l + 1; i++){
            // cout << num[i][1] << endl;
            // if(num[i][1] == 0) continue;
            for(int j = 2; i + j <=  l + 1; j++){
                // if(num[i][j - 1] == -1) continue;
                num[i][j] = num[i][j - 1] * 10 + num[i + j - 1][1];
                // cout << num[i][j] << endl;
            }
        }
        bool isrejected = false;
        bool iserror = true;
        int ans = 1000000;
        vector<int> ansv;
        // cout << ans << endl;
        for(int i = 0; i < (1 << (l - 1)); i++){
            int result = 0;
            int start = 1;
            int cnt = 1;
            vector<int> resultv;
            bool isend = false;
            while(start + cnt <= l + 1){
                while(start + cnt <= l && (i & (1 << (start + cnt - 2))) == 0) cnt++;
                // cout << num[start][cnt] << endl;
                // if(num[start][cnt] == -1){
                //     isend = true;
                //     break;
                // }
                result += num[start][cnt];
                resultv.push_back(num[start][cnt]);
                start = start + cnt;
                cnt = 1;
            }
            // if(isend) continue;
            // cout << result << endl;
            // cout << endl;
            if(result <= t){
                if(abs(ans - t) == abs(result - t)){
                    isrejected = true;
                }
                else if(abs(ans - t) > abs(result - t)){
                    ans = result;
                    ansv = resultv;
                    isrejected = false;
                    iserror = false;
                }
            }
        }
        if(iserror){
            cout << "error" << endl;
        } else if(isrejected){
            cout << "rejected" << endl;
        } else {
            cout << ans;
            for(int i = 0; i < ansv.size(); i++){
                cout << " " << ansv[i];
            } 
            cout << endl;
        }
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    for(ll i = 0;i < a;++i) {
        cin>>p[i];
    }
    for(ll i = 0;i < b;++i) {
        cin>>q[i];
    }
    for(ll i = 0;i < c;++i) {
        cin>>r[i];
    }
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    sort(r.begin(),r.end());
    ll pi=a-1,qi=b-1,ri=c-1;
    ll ans=0;
    ll cc=0;
    while((x>0||y>0)&&(cc<x+y)){
//cerr<<x<<" "<<y<<" "<<cc<<endl;
        if(x<=0){
            if(qi<0){
                ans+=r[ri];
                ++cc;
                --ri;
            }
            else{
                if(q[qi]<r[ri]){
                    ans+=r[ri];
                    ++cc;
                    --ri;
                }
                else {
                    ans+=q[qi];
                    --y;
                    --qi;
                }
            }
            continue;
        }
        if(y<=0){
            if(ri<0){
                ans+=p[pi];
                --x;
                --pi;
            }
            else {
                if(p[pi]<r[ri]){
                    ans+=r[ri];
                    ++cc;
                    --ri;
                }
                else {
                    ans+=p[pi];
                    --x;
                    --pi;
                }
            }
            continue;
        }
        if(ri<0){
            if(q[qi]<p[pi]){
                ans+=p[pi];
                --x;
                --pi;
            }
            else{
                ans+=q[qi];
                --y;
                --qi;
            }
            continue;
        }
        if(p[pi]<q[qi]){
            if(y<=0){
                if(p[pi]<r[ri]){
                    ans+=r[ri];
                    ++cc;
                    --ri;
                }
                else{
                    ans+=p[pi];
                    --x;
                    --pi;
                }
            }
            else if(q[qi]<r[ri]){
                ans+=r[ri];
                ++cc;
                --ri;
            }
            else {
                ans+=q[qi];
                --y;
                --qi;
            }
        }
        else if(r[ri]<p[pi]&&x>=1) {
            ans+=p[pi];
            --x;
            --pi;
        }
        else {
            ans+=r[ri];
            ++cc;
            --ri;
        }
    }

//cerr<<x<<" "<<y<<" "<<cc<<endl;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2688
L,x[1<<17];d[21][1<<17];i,k,l,r,m;
main(n){
	for(scanf("%d",&n);i<n;)scanf("%d",++i+x);
	for(scanf("%d%*d",&L);k++<20;)for(i=0;i++<n;d[k][i]=l)
		for(l=d[k-1][d[k-1][i]],r=n+1;k<2&r-l>1;)x[m=l+r>>1]>x[i]+L?r=m:(l=m);
	for(;~scanf("%d%d",&l,&r);printf("%d\n",m))
		for(m=l<r||(l^=r^=l^=r),k=21;--k;)d[k][l]<r?m+=1<<k-1,l=d[k][l]:0;
}

Measured memory_bytes: 10880
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
const int mode=1000000007;
int n;
int a[100005];
int main()
{
    ios::sync_with_stdio(false);
    int flag=0,x;
    ll sum=1;
    memset(a,0,sizeof(a));
    cin>>n;
    for(int i=0;i<n;++i)
    {
        cin>>x;
        a[x]++;
    }
    if(n&1)
    {

        for(int i=0;i<n;i+=2)
        {
            if(i==0)
            {
                if(a[0]!=1)
                {
                    flag=1;
                    break;
                }
            }else
            if(a[i]!=2)
            {
                flag=1;
                break;
            }
        }
        for(int i=1;i<=n/2;i++)
        {
            sum=((sum%mode)*2)%mode;
        }
        if(flag==1)
        {
            cout<<0<<endl;
        }else
        cout<<sum<<endl;
    }else
    {
        for(int i=1;i<n;i+=2)
        {
            if(a[i]!=2)
            {
                flag=1;
                break;
            }
        }
        for(int i=1;i<=n/2;i++)
        {
            sum=((sum%mode)*2)%mode;
        }
        if(flag==1)
        {
            cout<<0<<endl;
        }else
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sf(a) scanf("%d",&a)
#define MX 1100010
#define inf 1e9
#define m_p make_pair
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))
#define MOD 100000

int main() {
    int n;
    sf(n);
    int arr[n];
    for(int i=0;i<n;i++) sf(arr[i]);

    int cnt = 0;
    for(int i=0; i<n-1; i++)
    {
        for(int j=0; j<n-i-1; j++)
        {
            if(arr[j]>arr[j+1]){
                swap(arr[j],arr[j+1]);
                cnt++;
            }
        }
    }

    for(int i=0;i<n;i++){
        if(i+1==n) printf("%d\n",arr[i]);
        else printf("%d ",arr[i]);
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 3172
s = input()
dlist = []

for i in range(len(s)-2):
    x = s[i:i+3]
    x = int(x)
    d = x - 753
    
    if d < 0:
        d = -d
        dlist.append(d)
    else:
        dlist.append(d)
        
print(min(dlist))


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

int main(){
  int A,B;
  cin>>A>>B;
  set<int> S;
  S.insert(1);
  S.insert(2);
  S.insert(3);
  S.erase(A);
  S.erase(B);
  for(auto p:S){cout<<p<<endl;}
}


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

template <typename T>
class weighted_union_find {
public:
    weighted_union_find(size_t n)
    :par(n, -1), weight_diff(n, 0) {}

    // weight(y) - weight(x) = w
    bool unite(int x, int y, T w) {
        w += weight(x);
        w -= weight(y);

        if((x = find(x)) == (y = find(y))) {
            return false;
        } else {
            if(par[y] < par[x]) {
                swap(x, y);
                w = -w;
            }
            par[x] += par[y];
            par[y] = x;
            weight_diff[y] = w;
            return true;
        }
    }

    int find(int x) {
        if(par[x] < 0) {
            return x;
        } else {
            int root = find(par[x]);
            weight_diff[x] += weight_diff[par[x]];
            return par[x] = root;
        }
    }

    T weight(int x) {
        find(x);
        return weight_diff[x];
    }

    T diff(int x, int y) {
        return weight_diff[y] - weight_diff[x];
    }

    int size(int x) {
        return -par[find(x)];
    }

private:
    vector<int> par;
    vector<T> weight_diff;
};


int main() {
    int N, M; cin >> N >> M;
    weighted_union_find<int> uf(N);

    bool yes = true;
    while(M--) {
        int l, r, d;
        cin >> l >> r >> d;
        --l; --r;
        if(uf.find(l) != uf.find(r)) {
            uf.unite(l, r, d);
        } else if(uf.diff(l, r) != d) {
            yes = false;
        }
    }
    cout << (yes ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

int main() {
  int n;
  cin >> n;
  vector<string> str;
  string t;
  ll ans = 0;

  map<int, int> mp;
  rep(i, n) {
    cin >> t;
    int s = t.size();
    rep(j, s-1) {
      if (t[j] == 'A' and t[j + 1] == 'B') ans += 1;
    }
    str.push_back(t);

    if (t.front() == 'B' and t.back() == 'A') mp[0] += 1;
    else if (t.front() == 'B') mp[1] += 1;
    else if (t.back() == 'A') mp[2] += 1;
    else mp[3] += 1;
  }
  
  if (mp[0] > 0) {
    ans += mp[0] - 1;
  }
  if (mp[0] > 0 and (mp[1] > 0 or mp[2] > 0)) {
    mp[2] += 1; // 先頭Bを1つ追加
    mp[1] += 1; // 末尾Aを1つ追加
  }

  ans += min(mp[2], mp[1]);
  cout << ans << endl;
}


Measured memory_bytes: 768
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = nextInt();
        String s = next();
        boolean flag = true;

        if (n % 2 == 1) {
        	flag = false;
        }

        String before = s.substring(0, n/2);
        String after = s.substring(n/2);

        for (int i = 0; i < n/2; i++) {
        	if (!before.substring(i, i + 1).equals(after.substring(i, i + 1))) {
        		flag = false;
        	}
        }
        if (flag) {
        	println("Yes");
        } else {
        	println("No");
        }
    }

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+15
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
ll ans=0;
int main(){
	string s;
	cin>>s;
	ll p=(ll)s.size();
	for(ll i=0;i<s.size();i++){
		if(s[i]!=s[p-i-1]){
			ans++;
			s[p-i-1]=s[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int a[1111], b[1111], c[1111], d[1111], p[333];

int main(){
  
  while(cin >> a[0] >> b[0] >> c[0], *a+=*b+*c){
    for(int i=332;i;) p[i--] = 2;
    
    cin >> p[0];
    for(int i=0;i++<*p;) cin >> a[i] >> b[i] >> c[i] >> d[i];
    
    for(int i=0;i++<*p;){
      for(int j=0;j++<*p;){
	if(d[j]) p[a[j]] = p[b[j]] = p[c[j]] = 1;
	else{
	  if(p[a[j]]&p[b[j]]&1) p[c[j]] = 0;
	  if(p[a[j]]&p[c[j]]&1) p[b[j]] = 0;
	  if(p[b[j]]&p[c[j]]&1) p[a[j]] = 0;
	}
      }
    }
    for(int i=0;i<*a;) cout << p[++i] << endl;
  }
  
}

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

int main(){
	int N,K;
	int max=1000000000;
	cin>>N>>K;
	int *p;
	p= new int[N];
	for(int a;a<N;a++){
		cin>>p[a];
	}
	sort(p,p+N,greater<int>());

	int n,i;
	n=0;
	int q;
	while(1){
		q=p[n]-p[n+K-1];
		if(max>q){
			max=q;
		}
		if(n+K-1==N-1){
			cout<<max<<endl;
			break;
		}
		n++;
	}
	delete [] p;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;

int main(){
  lli N;
  cin >> N;
  vector<lli> max_n(5);
  for (int i = 0; i < 5; i++) {
    cin >> max_n.at(i);
  }
  lli min;
  min = *min_element(max_n.begin(), max_n.end());
  cout << setprecision(16) << ceil(N / double(min)) + 4 << endl;
}


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

int main(){
  int n,k; cin >>n>>k;
  string s; cin >>s;
  vector<int> v;
  char copy=s[0];
  bool f0=false;
  if(s[0]=='0')f0=true;
  for(int i=0;i<n;i++){
    int cnt=0;
    while(copy==s[i]){
      cnt++;
      i++;
    }
    copy=s[i];
    i--;
    v.push_back(cnt);
  }
  int ans=0;
  int cnt=0;
  int sum=0;
  if(f0){
    int size=v.size()/2+v.size()%2;
    if(k>=size){
      cout << n << endl;
      return 0;
    }
    for(int i=0;i<v.size();i++){
      while(cnt<2*k){
        sum+=v[i];
        cnt++;
        i++;
        if(i==v.size())break;
      }
      ans=max(ans,sum);
      if(v.size()==i)break;
      sum-=v[i-2*k];
      sum-=v[i-2*k-1];
      cnt-=2;
      i--;
    }
    cout << ans << endl;
    return 0;
  }
  else{
    int size=v.size()/2;
    if(k>=size){
      cout << n << endl;
      return 0;
    }
    for(int i=0;i<v.size();i++){
      while(cnt<2*k+1){
        sum+=v[i];
        cnt++;
        i++;
        if(i==v.size())break;
      }
      ans=max(ans,sum);
      if(i==v.size())break;
      sum-=v[i-2*k];
      sum-=v[i-2*k-1];
      cnt-=2;
      i--;
    }
    cout << ans << endl;
    return 0;
  }
}

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

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


int main() {
	long long n, k,cnt;
	cin >> n >> k;
	if (n * 2LL <= k) {
		cout << n << endl;
	}
	else if (n < k) {
		cout << k - n << endl;
	}
	else if (n == k) {
		cout << 0 << endl;
	}
	else {
		cnt = n/k;
		n = n - k * cnt;
		if (n * 2LL <= k) {
			cout << n << endl;
		}
		else {
			cout << k - n << endl;
		}
	}

}


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

using namespace std;

void trace(int A[], int N) {
  for (int i = 0; i < N; i++) {
    cout << A[i];
    if (i < N - 1) cout << " ";
  }
  cout << endl;
}

void insertionSort(int A[], int N) {
  for (int i = 1; i < N; i++) {
    int v = A[i];
    int j = i - 1;

    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  trace(A, N);
  insertionSort(A, N);
  return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b;
	cin >> a >>b;
	cout << 6 - a - b << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <stdio.h>

int main()
{
	char s[6];
	scanf("%s", &s);
	if (s[2] == s[3] && s[4] == s[5]) 
	{
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

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

	cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	cin >> s;

	int i, j;
	int goal = max(c, d);

	for (i = a+1; i <= goal; i++) {
		if (s[i] == '#' && s[i - 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}

	bool check = false;
	goal = min(c, d) + 1;
	if (c > d) {
		for (i = b + 1; i <= goal; i++) {
			if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') {
				check = true;
				break;
			}
		}
		if (check == false) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;

}


Measured memory_bytes: 640
n,k = gets.chomp.split.map(&:to_i)
h = [0] + gets.chomp.split.map(&:to_i)

dp = Array.new(n+1, 10**10)
dp[1] = 0

1.upto(n - 1) do |ashiba|
    ashiba_now = h[ashiba]
  1.upto(k) do |jump|
    ashiba_index = ashiba + jump
    next if ashiba_index > n
    ashiba_new = h[ashiba_index]
    jump_cost = ashiba_now < ashiba_new ? ashiba_new - ashiba_now : ashiba_now - ashiba_new
    tmp_cost = dp[ashiba] + jump_cost
    dp[ashiba_index] = tmp_cost if dp[ashiba_index] > tmp_cost
  end
end

p dp.last


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


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n, m;
	cin >> n >> m;
	if(n==1 && m==0){
		print("0");
		return 0;
	}
	string str(n, 'a');
	rep(i, m) {
		int first,second;
		cin >> first>>second;
		first -= 1;
		if(str.compare(first,1,"a")!=0 && str.compare(first, 1, to_string(second)) != 0){
			print("-1");
			return 0;
		}
		str.replace(first, 1, to_string(second));
	}
	if (str.compare(0, 1, "0") == 0) {
		if (n == 1) print(0);
		else print("-1");
		return 0;
	}
	if (str.compare(0, 1, "a") == 0) str.replace(0, 1, "1");

	rep1(i, n) {
		if (str.compare(i, 1, "a") == 0)str.replace(i, 1, "0");
	}
	print(str);
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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 n; cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    sort(all(A)); int num = A.back();
    auto iter = lower_bound(all(A), num/2);
    int res = *iter;
    if(iter != A.begin()){
        iter--;
        int tmp = *iter;
        if(num/2-tmp < res - num/2) res = tmp;
        if(res == num) res = *iter;
    }
    
    cout << num << " " << res << ln;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long     ll;
#define fr            first
#define sc            second
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
using namespace std;
int n,m,x;
int ans=INT_MAX;
int lvl[12][12],c[12];

void recc(int pos,vector<int>con,int cost)
{
    if(pos==n)
    {
        bool ok=true;
        for(int a:con)
        {
            if(a<x)
            {
                ok=false;
            }
        }
        if(ok)
            ans=min(cost,ans);
    }
    else
    {
        recc(pos+1,con,cost);
        com(i,m)
        {
            con[i]+=lvl[pos][i];
        }
        recc(pos+1,con,cost+c[pos]);
    }
}


void solve()
{
    cin>>n>>m>>x;
    com(i,n)
    {
        cin>>c[i];
        com(j,m)
        {
            cin>>lvl[i][j];
        }
    }
    recc(0,vector<int>(m,0),0);
    if(ans==INT_MAX)
        cout << -1;
    else
        cout << ans << endl;
}

int main()
{
    solve();
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
#define PI 3.14159265359
int R;
int main() {
    cin >> R;
    double res = R * 2 * PI;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3808
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int W, H, N;
  ci(W, H, N);
  ve<int> x(N), y(N), p(N);
  rep(i, N){
    ci(x.at(i), y.at(i), p.at(i));
  }
  int a = 0, b = W, c = 0, d = H;
  rep(i, N){
    if(p.at(i) == 1){
      a = max(a, x.at(i));
    }
    else if(p.at(i) == 2){
      b = min(b, x.at(i));
    }
    else if(p.at(i) == 3){
      c = max(c, y.at(i));
    }
    else{
      d = min(d, y.at(i));
    }
  }
  if(b - a > 0 && d - c > 0){
    co((b - a) * (d - c));
  }
  else{
    co(0);
  }
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n=arr.shift()-0;
var a=arr.shift().split(" ").map(Number);
var m=arr.shift()-0;
var b=arr.shift().split(" ").map(Number);
for(var i=0;i<m;i++){
   if(a.length-1<i || b[i]>a[i]){
      console.log(1);
      break;
   }else if(b[i]<a[i]){
      console.log(0);
      break;
   }
}
if(i==m)console.log(0);


Measured memory_bytes: 16228