akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int c[10][10];
int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int A;
			cin >> A;
			if (A != -1) sum += c[A][1];
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
x, k, d = map(int,input().split())

x = abs(x)

if(x - k*d >=0):
  print(x - k*d)
  
elif((k - int(x/d)) %2 == 0):
  print(x - int(x/d)*d)

else:
  print(abs((x - int(x/d)*d)-d))

Measured memory_bytes: 9188
import sys
sys.setrecursionlimit(10000000)
n=int(input())
tex=['3','5','7']

def dfs(value):
  ans=0
  if value != '' and int(value) > n:
    return 0
  for x in tex:
    if not x in value:
      break
  else:
    ans += 1 
  for x in tex:
    ans += dfs(value+x)
  #print(value,ans)
  return ans

print(dfs(''))

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

int main() {
    int n,m,p;
    string s;

    cin>>n>>m;

    vector<bool> judge(n,false);
    vector<int> pena(n,0);

    int count = 0, penacount=0;
    rep(i,m) {
        cin >> p >> s;
        if (judge.at(p-1) == true) continue;

        if (s == "WA") {
            pena.at(p-1)++;
        } else {
            count++;
            penacount+=pena.at(p-1);
            judge.at(p-1) = true;
        }
    }

    cout << count << " " << penacount << endl;
}


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

int main()
{
	long long n,k,q;
	cin>>n>>k>>q;
	vector <int> v(n+1,k);
	vector <int> freq(n+1,q);
	vector <int> answered(q+1);
	for (int i = 1 ; i <= q ; i++)
	{	
		cin>>answered[i];
	}
	for(int j = 1 ; j <= q ; j++)
	{
		freq[answered[j]]--;
	}
	for(int k = 1 ; k <= n ; k++)
	{
		v[k] = v[k] - freq[k];
		if(v[k] > 0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vector<set<ll>> E(1e5+10);
vec sorted(1e5+10,-1);
ll dfs(ll n, ll num) {
  sorted[n]=num;
  for(ll t:E[n]) {
    if(sorted[t]>-1) continue;
    sorted[n]=dfs(t,sorted[n]);
  }
  return sorted[n]+1;
}

int main() {
  ll n,m;
  cin >> n >> m;
  vector<set<ll>> V(1e5+10);
  set<ll> nroot;
  for(ll i=0;i<n+m-1;i++) {
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    E[a].insert(b);
    V[b].insert(a);
    nroot.insert(b);
  }
  queue<ll> q;
  vec ans(n,-1);
  for(ll i=0;i<n;i++) {
    if(!nroot.count(i)) {
      dfs(i,0);
      ans[i]=0;
    }
  }
  for(ll i=0;i<n;i++) {
    if(ans[i]>-1) continue;
    for(ll t:V[i]) {
      if(ans[i]<0) ans[i]=t+1;
      else if(sorted[ans[i]-1]>sorted[t]) ans[i]=t+1;
    }
  }
  for(ll i=0;i<n;i++) {
    cout << ans[i] << endl;
  }
}

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

using namespace std;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int ao = ceil(a/(float)d);
	int tak = ceil(c / (float)b);
	// cout << tak << " " << ao << endl;
	if(tak <= ao)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a;
    cin >> a ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( abs(a - b) % 2 != 0 ){
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << abs(a - b) / 2 + min(a, b) << endl;
    }
    //*/
    
    cout << 3 * a * a << endl;

    return 0; 
}


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

    cin >> N;

    int res = 0;
    for (int i = 0; i < N.size(); i++)
    {
        if(N.at(i)=='7'){
            res = 1;
        }
    }

    if(res == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3624
// Copyright: lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
    ll x=0,f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

ll num;

inline void work() {
    char s[11];
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    rep(i, 1, len) num = num * 10 + s[i] - '0';
    int a[11], b[11];
    rep(i, 0, 9) a[i] = i;
    ll ans = -1;
    ll xx = 1;
    rep(i, 1, len) xx = xx * 10;
    do {
        ll nw = 0;
        rep(i, 0, len - 1) nw = nw * 10 + a[i];
        ll tmp = min(abs(num - nw), xx - abs(num - nw));
        if (ans < tmp) {
            ans = tmp;
            rep(i, 0, len - 1) b[i] = a[i];
        }
    } while (next_permutation(a, a + 10));
    rep(i, 0, len - 1) cout<<b[i]; cout<<endl;
}

int main(){
    #ifdef LZT
        freopen("in","r",stdin);
    #endif

    work();

    #ifdef LZT
        Debug("My Time: %.3lf s\n", (double)clock() / CLOCKS_PER_SEC);
    #endif
}



Measured memory_bytes: 3224
/*
ABHIJEET BISWAS
CSE 4th SEM 
MNNIT ALLAHBAD
https://atcoder.jp/contests/dp/tasks/dp_n
*/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define MAX 1000009
#define pb push_back
#define mp map<int,int>
#define f first
#define s second
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ld pi=2.0*acos(0.0);
int n;
ll dp[404][404];
ll arr[404];
ll sum[404];
ll solve(int a,int b)
{
	if(a==b)
	{
		return 0;
	}
	if(dp[a][b]!=-1)
	return dp[a][b];
	ll &ans=dp[a][b];
	ans=INF;
	
	for(int k=a;k<b;k++)
	{
		ans= min(ans , solve(a,k)+solve(k+1,b)+sum[b]-sum[a-1]);
		
	}
	return ans;
}
int main() {
	fastIO
	cin>>n;
	sum[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
		sum[i]=sum[i-1]+arr[i];
	}
	for(int i=0;i<=n;i++)
	for(int j=0;j<=n;j++)
	dp[i][j]=-1;
	cout<<solve(1,n)<<endl;
	return 0;
}

Measured memory_bytes: 1536
X, N = map(int, input().split())
P = [int(p) for p in input().split()]

is_exit = [False] * 101

for p in P:
    is_exit[p] = True

if not is_exit[X]:
    print(X)
else:
    l = X - 1
    r = X + 1
    while True:
        if 1 <= l:
            if not is_exit[l]:
                print(l)
                exit()
        else:
            print(l)
            exit()
        if r <= 100:
            if not is_exit[r]:
                print(r)
                exit()
        else:
            print(r)
            exit()
        l -= 1
        r += 1


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

using namespace std;

int main()
{
    long long int a , b , n;
    cin>>a>>b>>n;
    if(a%b==0)
    {
        cout<<a*(min(b-1 , n))/b<<endl;
    }
    else
    {
        cout<<a*(min(b-1,n))/b<<endl;
    }
}

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

 

int main() {
    ll N, M;
    cin >> N >> M;
    ll C = 1900 * M + 100 * (N - M);
    ll ans = C * pow(2LL, M);
    cout << ans << endl;
}


Measured memory_bytes: 4060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    rep(i,s.size()) {
        s[i] = 'x';
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
vector<int>H={0,1,2,3,4,5,6,7,8,9};
string s[12];
int a[256];
bool ng[256];
int n;
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i<256;i++)a[i]=ng[i]=0;
		set<char>S;
		for(int i=0;i<n;i++)
		{
			cin>>s[i];
			int p=1;
			for(int j=0;j<s[i].size();j++)p*=10;
			for(char c:s[i])
			{
				S.insert(c);
				p/=10;
				a[c]+=(i==n-1?-1:1)*p;
			}
			ng[s[i][0]]|=s[i].size()>1;
		}
		int ans=0;
		do{
			int now=0;
			int i=0;
			for(char c:S)
			{
				if(ng[c]&&H[i]==0)
				{
					now=-1;
					break;
				}
				now+=a[c]*H[i];
				i++;
			}
			ans+=!now;
		}while(next_permutation(H.begin(),H.end()));
		for(int i=0;i+S.size()<10;i++)ans/=i+1;
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3068
import java.util.Scanner;

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


		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int zolome = 0;

		for (int i=0; i<n; i++){
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();

			if (d1 == d2){
				zolome++;
			} else {
				zolome = 0;
			}
			if (zolome == 3){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}

}

Measured memory_bytes: 36140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;


void input(){

}

void solve(){

}

void output(){
  
}

int main(){
  int a;
  cin>>a;
  cout<<3*a*a<<endl;
  
  input();
  solve();
  output();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}

const ll big=998244353;
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
 
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

typedef pair<int,int> p;



int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
  int n,m;
  cin >> n >> m;
  set<p> a;
  rep(i,n){
    int k;cin >> k;
    a.insert(p(k,i));
  }
  rep(i,m){
    p s=*rbegin(a);
    if(s.first==0)break;
    a.erase(s);
    s.first/=2;
    a.insert(s);
  }
  ll ans=0;
  for(p s:a){
    ans+=s.first;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8284
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
using namespace std;
int main()
{
    char a[10],b[10];
    scanf("%s",a);
    scanf("%s",b);
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
typedef long long ll;
#define mod 1000000007

int N;
typedef pair<ll, int> P;
const ll INF = 1e15;
struct edge { int to; ll cost; };

class Dijk {
public:
  vector<edge> G[100005];
  ll dist[100005];
  int used[100005];

  void dijk(int s, int V) {
    priority_queue<P,vector<P>,greater<P>> Q;
    rep(i, 0, V) dist[i] = INF;
    rep(i, 0, V) used[i] = 0;
    dist[s] = 0;
    Q.push({0, s});

    while(!Q.empty()) {
      P p = Q.top(); Q.pop();
      int v = p.second;
      if(used[v]) continue;
      used[v] = 1;
      for(auto &e : G[v]) {
        if(dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          Q.push({dist[e.to], e.to});
        }
      }
    }
  }
};


int main() {
  cin >> N;
  Dijk D;
  rep(i, 0, N - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    D.G[a].push_back({b, c});
    D.G[b].push_back({a, c});
  }
  D.dijk(0, N);

  rep(i, 0, N) {
    cout << D.dist[i] % 2 << endl;
  }
  return 0;
}


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

int w[100];

int main(){
	int n,i,j,t,k,s1=0,s2=0,s,min=9999;
	cin >> n;
	for(i=0;i<n;i++)
		cin >> w[i];
	for(t=0;t<n;t++){
		s1 = s2 = 0;
		for(j=0;j<=t;j++)
			s1=s1+w[j];
			for(k=t+1;k<n;k++)
				s2=s2+w[k];
	s=abs(s1-s2);
	
	if(s<min)
		min=s;
	}
	cout << min;
		
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if(abs(b-a)<=t*(v-w))cout<<"YES";
	else cout<<"NO";
	return 0;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 100005;
LL arr[MAXN], f[MAXN], suf[MAXN];
int n, m;

int main() {
	scanf("%d%d", &n, &m);
	int tp = 0;
	arr[++tp] = n;
	for (int i = 1; i <= m; i++) {
		LL a; scanf("%lld", &a);
		while (tp > 0 && arr[tp] >= a) --tp;
		arr[++tp] = a;
	}
	m = tp;
	f[m] = 1;
	for (int i = m; i > 1; i--) {
		LL c = arr[i];
		while (c > 0) {
			if (c < arr[1]) {
				suf[c] += f[i], c = 0;
				break;
			}
			int l = 1, r = i;
			while (l + 1 < r) {
				int mid = (l + r) >> 1;
				if (arr[mid] > c) r = mid;
				else l = mid;
			}
			f[l] += c / arr[l] * f[i];
			c %= arr[l];
		}
	}
	suf[arr[1]] += f[1];
	for (int i = arr[1]; i > 0; i--) suf[i] += suf[i + 1];
	for (int i = 1; i <= n; i++) printf("%lld\n", suf[i]);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

ll N,K,Q;
ll A[2010];

bool ok (ll mid) {
    REP(i,N) {
        ll base = A[i];
        bool flag1[2010] = {};
        bool flag2[2010] = {};
        REP(j,N) {
            if (A[j] >= base && A[j] - base <= mid) {
                flag1[j] = true;
            }
            if (A[j] >= base) {
                flag2[j] = true;
            }
        }
        ll sum = 0;
        ll cnt1 = 0;
        ll cnt2 = 0;
        REP(j,N) {
            if (flag2[j]) {
                cnt2++;
                if (flag1[j]) {
                    cnt1++;
                }
                if (j == N - 1) {
                    sum += max(0LL, min(cnt2 - K + 1, cnt1));
                }
            } else {
                sum += max(0LL, min(cnt2 - K + 1, cnt1));
                cnt1 = 0;
                cnt2 = 0;
            }
            
        }
        if (sum >= Q) return true;
    }
    return false;
}

int main() {

    cin >> N >> K >> Q;
    REP(i,N) cin >> A[i];

    ll l = -1, r = 1e10;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (ok (mid)) r = mid;
        else l = mid;
    }

    cout << r << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  int result = 0;
  int flag = 0;
  for (i = 0; i < n - 1; i++) {
    if (h[i] >= h[i + 1]) {
      flag++;
    } else {
      flag = 0;
    }
    result = max(result, flag);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();

        int pt = 0;
        int px = 0;
        int py = 0;
        for (int i = 0; i < n; i++) {
            int t = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();

            int d = Math.abs(px - x) + Math.abs(py - y);
            if (t - pt < d || ((t - pt) + d) % 2 == 1) {
                out.println("No");
                return;
            }
        }

        out.println("Yes");
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


Measured memory_bytes: 42544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static final int mod = 998244353, UNCALC = -1;
    static int n, s, a[], memo[][];

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        n = sc.nextInt();
        s = sc.nextInt();
        a = sc.nextIntArray(n);
        memo = new int[n][s + 1];
        for (int[] b : memo)
            Arrays.fill(b, UNCALC);
        int ans = 0;
        for (int i = 0; i < n; i++)
            ans = add(ans, dp(i, 0));
        out.println(ans);
        out.flush();
        out.close();
    }

    static int dp(int i, int sum) {
        if (i == n) return sum == s ? 1 : 0;
        if (memo[i][sum] != UNCALC) return memo[i][sum];
        int cnt = 0;
        if (sum == s) cnt = add(1, dp(i + 1, sum));
        else {
            if (sum + a[i] <= s) cnt = dp(i + 1, sum + a[i]);
            cnt = add(cnt, dp(i + 1, sum));
        }
        return memo[i][sum] = cnt;
    }

    static int add(int a, int b) {
        int c = a + b;
        if (c >= mod) c -= mod;
        return c;
    }


    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        boolean ready() throws IOException {
            return br.ready();
        }

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

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        int nextChar() throws IOException {
            return next().charAt(0);
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

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

    }
}


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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

const int MOD = 1000000007;

int main()
{
  IO;
  int n; cin >> n;
  vector <vector <char>> a(2, vector <char> (n));

  for (int i = 0; i < 2; ++i)
  for (int j = 0; j < n; ++j)
    cin >> a[i][j];

  long long res = 1;
  int k = 0;
  if (a[0][k] == a[1][k])
    res = 3;
  else res = 6;


  while (k + 1 < n)
  {
    if (a[0][k] == a[1][k])
    {
      if (a[0][k + 1] == a[1][k + 1])
      {
        res *= 2; res %= MOD;
      }
      else {
        res *= 2; res %= MOD;
      }
      ++k;
    }
    else {
        if (k + 2 < n)
        if (a[0][k + 2] != a[1][k + 2])
        {
          res *= 3; res %= MOD;
        }
      k += 2;
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    ll n,k;
    cin>>n>>k;
    double ans = 0;
    rep(i,1,n){
        if(i<k){
            ll hoge = i;
            ll cnt = 0;
            while(hoge<k){
                hoge = hoge * 2;
                cnt++;
            }
            ans += (1.0 / (double)n) * 1.0 / (double)pow(2,cnt);
        }
        else ans += (1.0 / (double)n);
    }
    printf("%.14f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
   if ((x-r)>=0&&(x+r)<=W&&(y-r)>=0&&(y+r)<=H){
        cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
}



Measured memory_bytes: 3100
package main

import (
	"fmt"
)

//var coins []int = [500, 100, 50, 10, 5, 1]
func main() {
	solve()
}

func solve() {
	var a int
	fmt.Scan(&a)
	var sum int
	for {
		if a-500 >= 0 {
			a -= 500
			sum += 1000
		} else if a-5 >= 0 {
			a -= 5
			sum += 5
		} else {
			fmt.Println(sum)
			break
		}
	}
}


Measured memory_bytes: 512
local n=io.read("n","l")
local s=io.read()

local _,white=s:gsub("%.","")
local black=0
local result=black+white
for i=1,n do
    if s:sub(i,i)=="#" then
        black=black+1
    else
        white=white-1
    end
    result=math.min(result,black+white)
end
print(result)

Measured memory_bytes: 2904
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>

using namespace std;

int main() {
    int n = 0;
    int m = 0;
    cin >> n >> m;
    int s[m];
    int c[m];
    int check = 0;
    for (int i= 0; i < m; i++) {
        cin >> s[i] >> c[i];
    }
    vector<int> sum;
    int b = 0;
    int d = 0;
    if (n == 1) {
        for (int i = 0; i < m; i++) {
            if (s[i] == 1 && c[i] == 0) {
                check++;
            } else {
                d++;
            }
        }
        if (check != 0 && d == 0) {
            cout << "0" << endl;
            return 0;
        }
    if (m == 0 && n == 1) {
        cout << "0" << endl;
        return 0;
    }
    if (m == 0) {
        cout << pow(10, n-1);
        return 0;
    }
    }
    for (int i = pow(10, n-1); i < pow(10, n); i++) {
        b = i;
        for (int k = 0; k < n; k++) {
            sum.push_back(b%10);
            b/=10;
        }
        reverse(sum.begin(), sum.end());
        for (int j = 0; j < m; j++) {    
            if (sum[s[j]-1] == c[j]) {
                check++;
            }
        }
        if (check == m) {
            cout << i << endl;
            return 0;
        }
        check = 0;
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace regio
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            string str;
            string[] arr;

            int kosuu,T;

            str = Console.ReadLine();
            arr = str.Split(' ');

            kosuu = int.Parse(arr[0]);
            T = int.Parse(arr[1]);

            int[] c = new int[kosuu];
            int[] t = new int[kosuu];
            int min;

            for (int i = 0; i < kosuu; i++)
            {
                str = Console.ReadLine();
                arr = str.Split(' ');

                c[i] = int.Parse(arr[0]);
                t[i] = int.Parse(arr[1]);
            }

            min = 2147483647;

            for (int i = 0; i < kosuu; i++)
            {
                if (t[i]<=T)
                {
                    if (c[i]<min)
                    {
                        min = c[i];
                    }
                }
            }

            if (min == 2147483647)
            {
                Console.WriteLine("TLE");
            }
            else
            {
                Console.WriteLine("{0}", min);
            }
        }
    }
}


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

int main(){
  string s;
  cin >> s;
  s+=s.at(11);
  for(int i=10;i>=4;--i){
    s.at(i+1)=s.at(i);
  }
  s.at(4)=' ';
  cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int i, j, d, w, e[10][10], ds, ws, dl, wl, x, y, min, max, total, res;
	while (1) {
		res = 0;
		scanf("%d", &d);
		scanf("%d", &w);
		if ((d == 0) && (w == 0)) {
			break;
		}
		for (i = 0; i < d; i++) {
			for (j = 0; j < w; j++) {
				scanf("%d", &e[i][j]);
			}
		}
		for (ds = 0; ds < d - 2; ds++) {
			for (ws = 0; ws < w - 2; ws++) {
			//	printf("ds:%d ws:%d\n", ds, ws);
				for (dl = 2 + ds; dl < d; dl++) {
					for (wl = 2 + ws; wl < w; wl++) {
					//	printf("dl:%d wl:%d\n", dl, wl);
						min = 10;
						max = 0;
						total = 0;
						for (x = ds; x <= dl; x++) {
						//	printf("%d %d\n", e[x][ws],e[x][wl]);
							if (min > e[x][ws]) {
								min = e[x][ws];
							}
							if (min > e[x][wl]) {
								min = e[x][wl];
							}
						//	printf("min:%d\n", min);
						}
						for (y = ws; y <= wl; y++) {
						//	printf("%d %d\n", e[ds][y], e[dl][y]);
							if (min > e[ds][y]) {
								min = e[ds][y];
							}
							if (min > e[dl][y]) {
								min = e[dl][y];
							}
						//	printf("min:%d\n", min);
						}
						for (x = ds + 1; x < dl; x++) {
							for (y = ws + 1; y < wl; y++) {
								if (max<e[x][y]) {
									max = e[x][y];
								}
								total += min - e[x][y];
							}
						}
						if (max >= min) {
							total = 0;
						}
						if (res < total) {
							res = total;
						}
						//printf("finish\n");
						//printf("res:%d total:%d\n", res, total);
					}
				}
			}
		}
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define P1 31
#define EPS 0.00000000001
#define MOD int(10e9 + 9)
#define PI acos(-1)
#define INF 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

int main()
{
    double l, ans;
    cin>>l;
    l = l/3;
    ans = l*l*l;
    cout<<fixed<<setprecision(12)<<ans<<endl;

    return 0;
}


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

#define ll long long
int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  
  if (K < A) {
    cout << A-K << " " << B;
  } else if (K < A + B) {
    cout << 0 << " " << B - (K - A);
  } else {
    cout << 0 << " " << 0;
  }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {
       int a = nextInt();
       String s = reader.readLine();
       if( a >= 3200 ) {
           writer.println(s);
       } else {
           writer.println("red");
       }
    }

    public static void main(String[] args) {

        new Main().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("a_1.txt"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new PrintWriter("aa_1.txt");
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while(tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define mod 1000000007;
using namespace std;


int main(){
    int N,K,u;
    double l;
    l=0;
    cin >> N >> K ;
    for(int i=1;;i*=2){
        if(i>K){
            u=i;
            break;
        }
    }
    for(int i=1;i<=N;i++){
        if(i*u/2<K){
            l+=1/(double)u;
        }
        else{
            u/=2;
            l+=1/(double)u;
        }
        if(u==1){
            l+=N-i;
            break;
        }
    }

    printf("%.20lf\n",l/(double)N);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}


int main()
{
	fast;

	int h,w;cin>>h>>w;
	char mat[101][101];
	int flg1[101] = {0};
	int flg2[101] = {0};
	FOR(i,1,h)FOR(j,1,w)cin>>mat[i][j];
	FOR(i,1,h){
		int flag = 1;
		FOR(j,1,w)if(mat[i][j] == '#')flag = 0;
		flg1[i] = flag;
	}
	FOR(i,1,w){
		int flag = 1;
		FOR(j,1,h)if(mat[j][i] == '#')flag = 0;
		flg2[i] = flag;
	}	

	FOR(i,1,h){
		FOR(j,1,w){
			if(flg1[i]==0 && flg2[j]==0)cout << mat[i][j];
		}
		if(flg1[i]==0)
		cout << "\n";
	}

	return 0;
}

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

int main(void){
	int H,W;
	cin>>H>>W;
	int map[H][W],queue[H*W],head=0,tail=0,bcnt=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			char c;
			cin>>c;
			if(c == '#'){
              map[i][j] = -1;
              bcnt++;
            }
			else map[i][j] = 10000;
		}
	}

	int i,j,count=0;
	queue[0] = 0;
	int ans = -1;
	map[0][0] = 0;
	while(true){
		int temp = queue[head];
		head = (head+1)%(H*W);
		i=temp/50;
        j=temp%50;
		if(map[i+1][j] != -1 && i+1<H && map[i+1][j] > map[i][j]+1){
			if(i+1 == H-1 && j == W-1){
              ans = map[i][j]+1;
              break;
            }
			map[i+1][j] = map[i][j]+1;
          	tail = (tail+1)%(H*W);
			queue[tail] = (i+1)*50+j;
		}
		if(map[i-1][j] != -1 && i-1>-1 && map[i-1][j] > map[i][j]+1){
			if(i-1 == H-1 && j == W-1){
              ans = map[i][j]+1;
              break;
            }
			map[i-1][j] = map[i][j]+1;
          	tail = (tail+1)%(H*W);
			queue[tail] = (i-1)*50+j;

		}
		if(map[i][j+1] != -1 && j+1<W && map[i][j+1] > map[i][j]+1){
			if(i == H-1 && j+1 == W-1){
              ans = map[i][j]+1;
              break;
            }
			map[i][j+1] = map[i][j]+1;
            tail = (tail+1)%(H*W);
			queue[tail] = i*50+j+1;
		}
		if(map[i][j-1] != -1 && j-1>-1 && map[i][j-1] > map[i][j]+1){
			if(i == H-1 && j-1 == W-1){
              ans = map[i][j]+1;
              break;
            }
			map[i][j-1] = map[i][j]+1;
        	tail = (tail+1)%(H*W);
			queue[tail] = i*50+j-1;
		}
		if(head == tail+1)break;
	}
	if(ans == -1)cout<<-1<<endl;
	else cout<<(H*W-bcnt-ans-1)<<endl;

	return 0;
}



Measured memory_bytes: 256
N, M = map(int,input().split())
mat = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))
ans = 0

for i in range(M):
    del mat[i][0]

for i in range(2 ** N):
    sw2 = str(format(i, 'b'))
    if len(sw2) < N:
        sw2 = '0' * (N-len(sw2)) + sw2
    lumpcnt = 0
    for lump in range(M):
        on = 0
        for swno in mat[lump]:
            if sw2[swno-1] == '1':
                on += 1
        if on % 2 == p[lump]:
            lumpcnt += 1
    if lumpcnt == M:
        ans += 1


print(ans)  


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

const int L = 0, W = 1;
int st[100005];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, k; read(n, k);
	vector<int> a(n);
	rep(i, 0, n) read(a[i]);
	
	rep(i, 0, k + 1) {
		st[i] = L;
		rep(j, 0, n) if (i - a[j] >= 0 && st[i - a[j]] == L) st[i] = W;
	}

	if (st[k] == W) die("First"); else die("Second");
}


Measured memory_bytes: 640
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    // ll t;
    // cin>>t;
    // while(t--)
    // {
        
    // }
    ll k;
    cin>>k;
    ll a,b;
    cin>>a>>b;
    ll rem=k-a%k;
    if(k>a&&k>b)
    {
        cout<<"NG";
    }
    else if(a%k==0||b%k==0)
    {
        cout<<"OK";
    }
    else if(a+rem<=b)
    {
        cout<<"OK";
    }
    else
    {
        cout<<"NG";
    }
    return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 1e3 + 5;
queue<int> q[N];
unordered_set<int> st;
typedef pair<int, int> pii;
void Main() {
  int n; cin >> n;
  for(int i = 1; i <= n; i++) {
    for(int j = 0; j < n - 1; j++) {
      int t; cin >> t;
      q[i].push(t);
    }
  }
  queue<pii> Q, nQ;
  for(int i = 1; i <= n; i++) {
    const int cur = q[i].front();
    if(st.find(i) == st.end() && st.find(cur) == st.end() && q[cur].front() == i) {
      q[i].pop();
      q[cur].pop();
      Q.push({i, cur});
      st.insert(i);
      st.insert(cur);
    }
  }
  int cnt = 0, ans = 0;
  while(true) {
    if(Q.empty()) {
      if(cnt == n * (n - 1) / 2) {
        cout << ans << "\n";
      } else {
        cout << "-1\n";
      }
      break;
    }
    ans++;
    st.clear();
    while(!Q.empty()) {
      cnt++;
      pii p = Q.front();
      Q.pop();
      if(st.find(p.first) == st.end() && !q[p.first].empty()) {
        const int cur = q[p.first].front();
        if(st.find(cur) == st.end() && q[cur].front() == p.first) {
          q[p.first].pop();
          q[cur].pop();
          nQ.push({p.first, cur});
          st.insert(p.first);
          st.insert(cur);
        }
      }
      if(st.find(p.second) == st.end() && !q[p.second].empty()) {
        const int cur = q[p.second].front();
        if(st.find(cur) == st.end() && q[cur].front() == p.second) {
          q[p.second].pop();
          q[cur].pop();
          nQ.push({p.second, cur});
          st.insert(p.second);
          st.insert(cur);
        }
      }
    }
    while(!nQ.empty()) {
      Q.push(nQ.front());
      nQ.pop();
    }
  }
}


Measured memory_bytes: 4736
fun main(args: Array<String>) {
    abc093b()
}

fun abc093b() {
    val (a, b, k) = readLine()!!.split(" ").map { it.toLong() }

    val answer = (a..b).filter { it < a + k || it > b - k }

    println(answer.joinToString(separator = System.lineSeparator()))
}


Measured memory_bytes: 38500
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    int n;
    cin>>n;
    vector<int> h(n+1),dp(n+1,mod);
    REP(i,1,n) {
        cin>>h[i];
    }
    dp[n] = 0;
    REPN(i,n-1,1) {
        if(i+1<=n) dp[i] = min(dp[i],abs(h[i+1]-h[i])+dp[i+1]);
        if(i+2<=n) dp[i] = min(dp[i],abs(h[i+2]-h[i])+dp[i+2]);
    }
    cout<<dp[1];
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

ans = 1
up, dn = False, False
for i in range(N-1):
    if A[i] < A[i+1]:
        up = True
    elif A[i] > A[i+1]:
        dn = True
    if up and dn:
        ans += 1
        up, dn = False, False
print(ans)


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;

bool prime(int x){
    if(x <= 1)return 0;

    for(int i = 2 ; i*i <= x ; i ++)if(x%i == 0)return 0;
    return 1;
}

void solve(int testCase){

    int x;
    cin >> x;

    for(int i = x ; ; i ++){
            if(prime(i)){
                    cout << i << endl;
                    return;
            }
    }

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
from collections import deque
n=int(input())
a=list(map(int,input().split()))
rflag=0
b=deque()
for i in range(n):
 if i%2==0:
  b.appendleft(a[i])
 else:
  b.append(a[i])
if n%2==0:
 b.reverse()
print(*list(b),sep=" ")
 

Measured memory_bytes: 100380
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=998244353;

//for(i=0; i<N; i++) cin >> a[i];



int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  ll a[MAX];
  
    
  for(i=0; i<=N; i++) cin >> a[i];
  
  if(N==0) {
    pt(2*(a[0]==1)-1);
    return 0;
  }
  
  if(a[0]>0) { pt(-1); return 0; }
  
  ll c[MAX]={}, f[MAX];
  f[0]=1;
  for(i=1; i<=N; i++) f[i]=INF;
  for(i=1; i<=N; i++) {
    chmin(f[i], f[i-1]*2-a[i]);
    if(f[i]<0) { pt(-1); return 0; }
  }
  
  c[N+1]=0;
  for(i=N; i>=0; i--) {
    if(f[i]*2<c[i+1]) { pt(-1); return 0; }
    c[i]=min(f[i], c[i+1])+a[i];
  }
  
  
  ll ans=0;
  for(i=0; i<=N; i++) ans+=c[i];
  pt(ans);
  
}
 
 




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

using namespace std;

typedef long long llint;

const int MAXN = 55;

int n, sol;
string s[MAXN], r;
int t[MAXN];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i];
    }
    cin >> r;
    for (int i = n-1; i >= 0; i--) {
        if (s[i] == r) break;
        sol += t[i];
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);

    var sortTable = [a,b,c].sort(function(a,b) {
        return a - b;
    });

    console.log(sortTable.join(' '));

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15528
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)

typedef long long ll;

ll a,b;

int main(){

    cin>>a>>b;
	ll res=0;
	if(a>=13) res=b;
	else if(a>=6) res=b>>1;
	cout<<res<<endl;
    return 0;

}


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

int main(){
  int N,sum;
  cin >> N;
  sum =0;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
    sum += P.at(i);
  }
  sort(P.begin(),P.end());
  cout << sum - P.at(N-1)/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    i64 N, M;
    cin >> N >> M;

    i64 ans = 0;
    for(i64 i = 1; i*i <= M; i++){
        if(M%i==0){
            i64 k = M/i;
            if(M/i >= N) ans = max(ans, i);
            if(M/k >= N) ans = max(ans, k);
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256