akhauriyash/Code-Regression huggingface dataset:
sx,sy,tx,ty=map(int,input().split())
ans=[]
if ty-sy>=0:
    for i in range(ty-sy):
        ans.append('U')
else:
    for i in range(sy-ty):
        ans.append('D')
if tx-sx>=0:
    for i in range(tx-sx):
        ans.append('R')
else:
    for i in range(sx-tx):
        ans.append('L')
if ty-sy>=0:
    for i in range(ty-sy):
        ans.append('D')
else:
    for i in range(sy-ty):
        ans.append('U')
if tx-sx>=0:
    for i in range(tx-sx+1):
        ans.append('L')
else:
    for i in range(sx-tx+1):
        ans.append('R')
if ty-sy>=0:
    for i in range(ty-sy+1):
        ans.append('U')
else:
    for i in range(sy-ty+1):
        ans.append('D')
if tx-sx>=0:
    for i in range(tx-sx+1):
        ans.append('R')
else:
    for i in range(sx-tx+1):
        ans.append('L')
if ty-sy>=0:
    ans.append('D')
else:
    ans.append('U')
if tx-sx>=0:
    ans.append('R')
else:
    ans.append('L')
if ty-sy>=0:
    for i in range(ty-sy+1):
        ans.append('D')
else:
    for i in range(sy-ty+1):
        ans.append('U')
if tx-sx>=0:
    for i in range(tx-sx+1):
        ans.append('L')
else:
    for i in range(sx-tx+1):
        ans.append('R')
if ty-sy>=0:
    ans.append('U')
else:
    ans.append('D')

print(''.join(ans))

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

map<ll, ll> fmap;

void factSearch(ll x){
  FOR(i, 2, x+1){
    while(x % i == 0){
      x /= i;
      fmap[i]++;   
    }
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  
  FOR(i, 2, n+1)
    factSearch(i);
  
  ll ans = 1;
  REP(i, n){
    ans *= fmap[i+1] + 1;
    ans %= mod;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


int main() {
    int A, B, C;  cin >> A >> B >> C;

    int res = C- (A - B);
    if (res >= 0) print(C-(A-B));
    else print(0);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin >> a;
    int b;
    cin >> b;
    long long s = 0;
    for(int i = 0; i < b; ++i){
        int c; 
        cin >> c;
        s += c;
    }
    if(s >= a){
        cout << "Yes" << '\n';
    }
    else 
        cout << "No" << '\n';
}


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

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

using namespace std;

int n;
vector<pair<int,int>> T[100000];

int color[100000];

void dfs(int u,int p,int c){
	color[u]=c;
	for(auto e:T[u]){
		int v=e.first,w=e.second;
		if(v!=p){
			dfs(v,u,(c+w)%2);
		}
	}
}

int main(){
	scanf("%d",&n);
	rep(i,n-1){
		int u,v,w; scanf("%d%d%d",&u,&v,&w); u--; v--;
		T[u].emplace_back(v,w);
		T[v].emplace_back(u,w);
	}

	dfs(0,-1,0);

	rep(u,n) printf("%d\n",color[u]);

	return 0;
}


Measured memory_bytes: 8320
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=int(2e5+5);
typedef long long LL;
LL f[MAXN];
char s[MAXN];
int main()
{
	scanf("%s",s+1);
	LL ans=0,n=strlen(s+1);
	for(LL i=n;i>=1;i--) {
		f[i]=f[i+1];
		if(s[i]=='W')
			f[i]+=1;
	}
	for(LL i=1;i<=n;i++)
		if(s[i]=='B') ans+=f[i];
	printf("%lld",ans);
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <iterator>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int M = max(max(A,B),C);
  int m = min(min(A,B),C);
  FOR(X,M,M+3){
    if((3 * X - A - B - C) % 2 == 0){
      cout << (3 * X - A - B - C) / 2 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll K, N;
    cin >> K >> N;
    vl A(2 * N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i + N] = A[i];

    ll ans = INF;
    rep(i, N) chmin(ans, (K + A[i + N - 1] - A[i]) % K);
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	vector<vector<char> >a[10];
	vector<char>b;
	char c,d;
	int n;
	int x, y, z;
	int s, ans;
	b.push_back('a');
	a[0].push_back(b);
	f(i, 9) {
		f(j, a[i].size()) {
			b = a[i][j];
			c = 'a';
			f(ii, b.size()) {
				if (c < b[ii])c = b[ii];
			}
			f(ii, c - 'a' + 2) {
				d = 'a' + ii;
				b.push_back(d);
				a[i + 1].push_back(b);
				b.pop_back();
			}
		}
	}
	scanf("%d", &n);
	n--;
	f(i, a[n].size()) {
		f(j, n + 1)printf("%c", a[n][i][j]);
		printf("\n");
	}
	

	return 0;
}

Measured memory_bytes: 9264
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dist[2010][2010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,X,Y;
    cin >> N >> X >> Y;
    X--; Y--;
    if(X+1 >= Y) exit(1);
    rep(i,0,N){
        rep(j,i+1,N){
            dist[i][j] = abs(i - j);
        }
        ll dx = min(abs(i - X), abs(i - Y)+1);
        rep(j,i+1,N){
            dist[i][j] = min(dist[i][j], dx + abs(X - j));
        }
        ll dy = min(abs(i - Y), abs(i - X) + 1);
        
        rep(j,i+1,N){
            dist[i][j] = min(dist[i][j], dy + abs(Y - j));
        }
    }
    ll ans[2010] = {};
    rep(i,0,N){
        rep(j,i+1,N){
            ans[dist[i][j]]++;
            // print(i,j,dist[i][j]);
        }
    }
    rep(i,1,N) print(ans[i]);
    

}


Measured memory_bytes: 31232
#include<bits/stdc++.h>
using namespace std;
int main(){
    int X;
    cin >> X;

    if(400 <= X && X <= 599 )cout << 8 << endl;
    if(600 <= X && X <= 799 )cout << 7 << endl;
    if(800 <= X && X <= 999 )cout << 6 << endl;
    if(1000 <= X && X <= 1199 )cout << 5 << endl;
    if(1200 <= X && X <= 1399 )cout << 4 << endl;
    if(1400 <= X && X <= 1599 )cout << 3 << endl;
    if(1600 <= X && X <= 1799 )cout << 2 << endl;
    if(1800 <= X && X <= 1999 )cout << 1 << endl;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        ArrayList<Integer> A = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int ax = scanner.nextInt();
            if (ax % 2 == 0) {
                A.add(ax);
            }
        }

        long filteredCount = A.stream().filter((it) -> it % 3 == 0 || it % 5 == 0).count();
        System.out.println(A.size() == filteredCount ? "APPROVED" : "DENIED");
    }
}


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

#define lowbit(a) (a&-a)
typedef long long ll;
const int maxn = 100010; const ll inf = 1LL<<60;
int N,T,E,X[maxn]; ll tree1[4*maxn],tree2[4*maxn],f[maxn];

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

inline void build(int now,int l,int r)
{
	tree1[now] = tree2[now] = inf;
	if (l == r) return; int mid = (l+r) >> 1;
	build(now<<1,l,mid); build(now<<1|1,mid+1,r);
}

inline void modify(ll *tree,int now,int l,int r,int pos,ll key)
{
	if (l == r) { tree[now] = key; return; } int mid = (l+r)>>1;
	if (pos <= mid) modify(tree,now<<1,l,mid,pos,key);
	else modify(tree,now<<1|1,mid+1,r,pos,key);
	tree[now] = min(tree[now<<1],tree[now<<1|1]);
}

inline ll query(ll *tree,int now,int l,int r,int ql,int qr)
{
	if (ql == l&&qr == r) return tree[now]; int mid = (l+r)>>1;
	if (qr <= mid) return query(tree,now<<1,l,mid,ql,qr);
	else if (ql > mid) return query(tree,now<<1|1,mid+1,r,ql,qr);
	else return min(query(tree,now<<1,l,mid,ql,mid),query(tree,now<<1|1,mid+1,r,mid+1,qr));
}

int main()
{
	//freopen("G.in","r",stdin);
	//freopen("G.out","w",stdout);
	N = gi(); E = gi(); T = gi();
	for (int i = 1;i <= N;++i) X[i] = gi(),tree1[i] = tree2[i] = 1LL<<60;
	for (int i = 1;i <= N;++i)
	{
		modify(tree1,1,1,N,i,f[i-1]-2LL*(ll)X[i]-(ll)X[i-1]);
		modify(tree2,1,1,N,i,f[i-1]-(ll)X[i-1]);
		int l = 0,r = i-1,mid; f[i] = inf;
		while (l <= r)
		{
			mid = (l+r)>>1;
			if (T-2LL*(X[i]-X[mid+1]) > 0) r = mid-1;
			else l = mid+1;
		}
		if (r+1) f[i] = query(tree1,1,1,N,1,r+1)+3LL*X[i];
		if (r+2 <= i) f[i] = min(f[i],query(tree2,1,1,N,r+2,i)+(ll)X[i]+(ll)T);
	}
	cout << f[N]+(ll)E-(ll)X[N] << endl;
	return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
  #define pb push_back
#define f first
#define s second
  #define MAXN 100005
using namespace std;
int arr[MAXN];
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	if(n==7||n==5||n==3) {
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}

	return 0;
}


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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

ll dp[101][100001];

int main(){
    ll N,W;
    cin >> N >> W;
    ll w,v;
    rep(i,N){
        rep(j,100001){
            dp[i][j] = INF;
        }
    }
    cin >> w >> v;
    dp[0][v] = w;

    cout << endl;
    for(int i=1; i<N; i++){
        cin >> w >> v;
        rep(j,100001){
            dp[i][j] = dp[i-1][j];
            if(j-v>=0) dp[i][j] = min(dp[i][j], dp[i-1][j-v]+w);
        }
        dp[i][v] = min(dp[i][v],w);
    }

    ll ans = 0;
    for(ll j=0; j<100001; j++){
        if(dp[N-1][j]<=W){
            ans = max(ans, j);
        }
    }
    cout << ans;
    
    
    return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
//#include<cmath>
//#include<algorithm>
//#include<cstring>
//#include<map>
using namespace std;
inline int read()
{
    int p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
int main()
{
	int a=read(),b=read();
	if(a*b%2==0)cout<<"Even";
	else cout<<"Odd";
	return 0;
} 

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
double r, g;
/**********************************************/

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

    cin >> r >> g;
    for(int i = -10000; i <= 10000; i++){
        if((r + i)/2 == g){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 384
#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>;

const int MAX = 200005;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    COMinit();
    ll ans = 0;
    ll c = m;
    for (int i = n-1; i >= 0; --i) {
        ll tmp = c * COM(n-1, i);
        if (i <= k) {
            ans += tmp;
            ans %= MOD;
        }
        c = c * (m-1) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    for(int i=1; i<N; ++i) {
        int a, b; cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N, -1);
    dist[0] = 0;
    queue<int> Q; Q.push(0);
    while(!Q.empty()) {
        int cur = Q.front(); Q.pop();
        for(int to : G[cur]) {
            if(dist[to] == -1) {
                dist[to] = dist[cur] + 1;
                Q.push(to);
            }
        }
    }

    int red = 0, blue = 0;
    for(int d : dist) ((d & 1) ? ++red : ++blue);

    vector<int> res(N, -1);
    if(red > N / 3 && blue > N / 3) {
        int r = 1, b = 2;
        for(int i=0; i<N; ++i) {
            if((dist[i] & 1) && r <= N) {
                res[i] = r; r += 3;
            } else if((dist[i] & 1) == 0 && b <= N) {
                res[i] = b; b += 3;
            }
        }
        int g = 3;
        for(int i=0; i<N; ++i) {
            if(res[i] == -1) {
                res[i] = g;
                g += 3;
            }
        }
    } else if(red <= N / 3) {
        int y = 3;
        for(int i=0; i<N; ++i) {
            if(dist[i] & 1) {
                res[i] = y;
                y += 3;
            }
        }
        int r = 1, b = 2;
        for(int i=0; i<N; ++i) {
            if(res[i] != -1) continue;
            if(y <= N) {
                res[i] = y; y += 3;
            } else if(r <= N) {
                res[i] = r; r += 3;
            } else {
                res[i] = b; b += 3;
            }
        }
    } else {
        int y = 3;
        for(int i=0; i<N; ++i) {
            if((dist[i] & 1) == 0) {
                res[i] = y;
                y += 3;
            }
        }
        int r = 1, b = 2;
        for(int i=0; i<N; ++i) {
            if(res[i] != -1) continue;
            if(y <= N) {
                res[i] = y; y += 3;
            } else if(r <= N) {
                res[i] = r; r += 3;
            } else {
                res[i] = b; b += 3;
            }
        }
    }

    for(int i=0; i<N; ++i) cout << res[i] << (i+1==N ? '\n' : ' ');
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

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

    int N; cin >> N;

    vector<int>V(N);
    REP(i, N) cin >> V[i];

    REP(i, N) {
        int c; cin >> c;
        V[i] -= c;
    }

    sort(V.rbegin(), V.rend());

    int res = 0;
    REP(i, N) {
        if (V[i] < 0) break;

        res += V[i];
    }

    cout << res << endl;
}


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

int main(){
  int N;
  cin >> N;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(N==i*j){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int n;
  cin >> n;
  cout << 180 * (n - 2) << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var a, b int
	fmt.Fscanf(in, "%d%d", &a, &b)

	t := a * b

	if t%2 == 0 {
		fmt.Fprintln(out, "No")
	} else {
		fmt.Fprintln(out, "Yes")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

const int inf = 1<<24;

const int size = 9;
int w, h;
bool O[size][size];
bool F[size][size];

typedef pair <int, int> PII;
typedef pair <PII, PII> Node;
typedef priority_queue <Node, vector<Node>, greater<Node> > Queue;

const int dr[4] = { 0, 0, 1, -1 };
const int dc[4] = { 1, -1, 0, 0 };

int solve( int sr, int sc, int gr, int gc ) {
    Queue Q;
    Node start( PII( 0, 0 ), PII( sr, sc ) );
    Q.push( start );
    int M[6][size][size];
    for ( int i = 0; i < 6; i++ ) {
        for ( int j = 0; j < size; j++ ) {
            for ( int k = 0; k < size; k++ ) {
                M[i][j][k] = inf;
            }
        }
    }

    while ( !Q.empty() ) {
        Node node = Q.top();
        Q.pop();

        int cost = node.first.first;
        int hp = node.first.second;
        int r = node.second.first;
        int c = node.second.second;

        if ( r == gr && c == gc ) {
            return cost;
        }

        for ( int i = 0; i < 4; i++ ) {
            int nr = r + dr[i];
            int nc = c + dc[i];
            if ( nr < 0 || nr >= h || nc < 0 || nc >= w ) {
                continue;
            }

            int nhp = hp + 1;
            if ( nhp >= 6 ) {
                continue;
            }

            if ( O[nr][nc] ) {
                continue;
            }

            if ( F[nr][nc] ) {
                nhp = 0;
            }

            int ncost = cost + 1;
            if ( ncost >= M[nhp][nr][nc] ) {
                continue;
            }
            M[nhp][nr][nc] = ncost;

            Node nnode( PII( ncost, nhp ), PII( nr, nc ) );
            Q.push( nnode );
        }
    }

    return -1;
}

int main() {
    while ( cin >> w >> h ) {
        if ( w == 0 && h == 0 ) break;
        int D[size][size];
        for ( int i = 0; i < h; i++ ) {
            for ( int j = 0; j < w; j++ ) {
                cin >> D[i][j];
            }
        }

        // obstacles
        for ( int i = 0; i < h; i++ ) {
            for ( int j = 0; j < w; j++ ) {
                O[i][j] = ( D[i][j] == 0 );
            }
        }

        int sr, sc;
        for ( int i = 0; i < h; i++ ) {
            for ( int j = 0; j < w; j++ ) {
                if ( D[i][j] == 2 ) {
                    sr = i;
                    sc = j;
                }
            }
        }

        int gr, gc;
        for ( int i = 0; i < h; i++ ) {
            for ( int j = 0; j < w; j++ ) {
                if ( D[i][j] == 3 ) {
                    gr = i;
                    gc = j;
                }
            }
        }

        // foods
        for ( int i = 0; i < h; i++ ) {
            for ( int j = 0; j < w; j++ ) {
                F[i][j] = ( D[i][j] == 4 );
            }
        }

        cout << solve( sr, sc, gr, gc ) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
/* In the name of Allah */

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

#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define LL_INF 1LL << 62
#define INF 1 << 30
#define SetBit(x, k) (x |= (1LL << k))
#define ClearBit(x, k) (x &= ~(1LL << k))
#define CheckBit(x, k) (x & (1LL << k))
#define mod 1000000007

int main()
{
  int n, m;
  cin >> n >> m;
  int x[n][m];

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      char c;
      cin >> c;
      if(c=='#') x[i][j] = -1;
      else x[i][j] = 0;
    }
  }
  x[0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(x[i][j]==-1) continue;
      if(i-1>=0 && x[i-1][j]!=-1) x[i][j] = (x[i][j] + x[i-1][j])%mod;
      if(j-1>=0 && x[i][j-1]!=-1) x[i][j] = (x[i][j] + x[i][j-1])%mod;
    }
  }

  cout << x[n-1][m-1] << "\n";

  return 0;
}

Measured memory_bytes: 7460
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

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

  int64_t A, B, C;
  cin >> A >> B >> C;
  int64_t cnt = 0;
  while (A % 2 == 0 and B % 2 == 0 and C % 2 == 0) {
    int64_t _A = A;
    int64_t _B = B;
    int64_t _C = C;
    A = _B / 2 + _C / 2;
    B = _C / 2 + _A / 2;
    C = _A / 2 + _B / 2;
    cnt++;
    if (A == B and B == C and C == A) {
      cout << -1;
      return 0;
    }
  }

  cout << cnt;

  return 0;
}


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

int F[102][102];

void
DFS (int Y, int X, int A)
{
  if (F[Y][X] != A)
    return;

  F[Y][X] = 7;

  DFS (Y - 1, X, A);
  DFS (Y, X + 1, A);
  DFS (Y + 1, X, A);
  DFS (Y, X - 1, A);
}

int
main ()
{
  int w, h;
  int xs, ys;
  int xg, yg;
  int n;
  int c, d, x, y;

  while (true)
    {
      cin >> w >> h;
      if (w == 0 && h == 0)
	break;
      cin >> xs >> ys;
      cin >> xg >> yg;
      cin >> n;

      for (int i = 0; i < n; i++)
	{
	  cin >> c >> d >> x >> y;
	  if (d == 0)
	    {
	      for (int a = 0; a < 4; a++)
		{
		  for (int b = 0; b < 2; b++)
		    {
		      F[y + b][x + a] = c;
		    }
		}

	    }
	  else
	    {
	      for (int a = 0; a < 2; a++)
		{
		  for (int b = 0; b < 4; b++)
		    {
		      F[y + b][x + a] = c;
		    }
		}
	    }

	}


      if (F[ys][xs] == 1 || F[ys][xs] == 2 || F[ys][xs] == 3
	  || F[ys][xs] == 4 || F[ys][xs] == 5)
	{
	  DFS (ys, xs, F[ys][xs]);
	}

      if (F[yg][xg] == F[ys][xs])
	{
	  cout << "OK" << endl;
	}
      else
	{
	  cout << "NG" << endl;
	}
   
    /*for (int y = 0; y < h; y++)
	{
	  for (int x = 0; x < w; x++)
	    {
	      cout << F[y][x];
	    }
         cout << endl;
	}*/
   
    /*for (int y = 1; y <= h; y++)
	{
	  for (int x = 1; x <= w; x++)
	    {
	      F[y][x] = 0;
	    }
	}*/

    
   
    }

  return 0;
}

Measured memory_bytes: 3084
R, G, B, N = map(int, input().split())

count = 0

for i in range (0, N//R+1):
	for j in range (0, N//G+1):
		if (N-R*i-G*j)>= 0 and (N-R*i-G*j)%B == 0:
			count+=1

print(count)

Measured memory_bytes: 68164
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
long long int __lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
 //__gcd 最大公約数
 //__lcm 最小公倍数
 //double 少数（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
 
int main() {
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  cout<<min({2*c*max(x,y),a*x+b*y,2*c*min(x,y)+a*max(0,x-y)+b*max(0,y-x)});
  }

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<deque>
#include<tuple>
#include<iomanip>
using namespace std;
#define int                  int64_t
#define double               long double
#define vi                   vector<int>
#define di                   deque<int>
#define si                   set<int>
#define vpii                 vector<pair<int,int>>
#define pi                   pair<int,int>
#define pub                  push_back
#define puf                  push_front
#define pob                  pop_back
#define pof                  pop_front
#define all(a)               (a).begin(),(a).end()
#define rall(a)              (a).rbegin(),(a).rend()
#define PI                   3.1415926535897932384626433832795
#define read(a)              for(auto& x:a) cin>>x
#define speak(a)             for(auto x:a) cout<<x<<' '
#define rep(i,s,n)           for(int i=s;i<n;++i)
#define repe(i,s,n)          for(int i=s;i<=n;++i)
#define repr(i,n,s)          for(int i=n;i>=s;--i)
#define endl                 '\n'
#define gap                  ' '
#define MAX                  LLONG_MAX
#define MIN                  LLONG_MIN
#define min3(a,b,c)          min(a, min(b, c))
#define max3(a,b,c)          max(a, max(b, c))
#define MOD                  1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,c=0;
    double m;cin>>n>>m;
    double a[n],s=0; rep(i,0,n) cin>>a[i],s+=a[i];
    double ans=s/(4*m);
    rep(i,0,n) c+=(a[i]>=ans);
    cout<<(c>=m?"Yes":"No");
}


Measured memory_bytes: 3728
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n>=m:
    print(0)
    exit()
a=[0]*(m-1)
for i in range(m-1):
    a[i]=x[i+1]-x[i]
a.sort()
print(sum(a[:m-n]))

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

int main(){
    int yy, mm, dd;
    char c1, c2;
    cin >> yy >> c1 >> mm >> c2 >> dd;
    if(mm<=4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "dddd"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using ll = long long;
using ld = long double;
using ull = unsigned long long;
const ll mod = 1e9 + 7;
using namespace std;
const int N = 2002;
const int M = 1e6;
ll tong, m, n, k, t, T, ntest, ans, a[M], dp[N][N], b[M], c[M];

struct dang
{
    ll id;
    vector<int> vc;
};
string s;
vector<ll> adj[5];
vector<ll> pre;
list<pll> ds;

inline void sol()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        ll x, y;
        cin >> x >> y;
        adj[0].pb(x-y);
        adj[1].pb(-x-y);
        adj[2].pb(x+y);
        adj[3].pb(-x+y);
    }
    sort(adj[0].begin(), adj[0].end());
    sort(adj[1].begin(), adj[1].end());
    sort(adj[2].begin(), adj[2].end());
    sort(adj[3].begin(), adj[3].end());
    ans = max(ans, adj[0].back() - adj[0].front());
    ans = max(ans, adj[1].back() - adj[1].front());
    ans = max(ans, adj[2].back() - adj[2].front());
    ans = max(ans, adj[3].back() - adj[3].front());
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    sol();
}



Measured memory_bytes: 9720
#include<stdio.h>
#define MAX 2000000

int s, M[MAX+1];
void heap(int);
int main(){
  scanf("%d", &s);
  int i;
  for(i=1;i<=s;i++)scanf("%d", &M[i]);  
  for(i=s/2;i>=1;i--)heap(i);
  for(i=1;i<=s;i++){
    printf(" %d", M[i]);
  }
  printf("\n");
  return 0;
}
void heap(int i){
  int l, r, lt, t;
  l = 2*i;
  r = 2*i+1;
  if (l<=s&&M[l]>M[i])lt = l;
  else lt = i;
  if (r<=s&&M[r]>M[lt])lt = r;
  if (lt!=i){
    t=M[i];M[i]=M[lt];M[lt]=t;
    heap(lt);
  }
}



Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>
#define _USE_MATH_DEFINES
#define ll long long int
using namespace std;
//mp.reserve(1024);
//mp.max_load_factor(0.25);
bool sortit(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return (a.first -a.second > b.first-b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    // freopen("mr_x_input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
	ll n;
	cin>>n;
	vector<ll>v(10050);
	for(ll i=1;i<=105;i++){
		for(ll j=1;j<=105;j++){
			for(ll z=1;z<=105;z++){
				ll temp =i*i+j*j+z*z+i*j+i*z+z*j;
				if(temp<10050){
					v[temp]+=1;
				}
			}
		}
	}
	for(ll i=1;i<=n;i++){
		cout<<v[i]<<endl;
	}
  	return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N,M;
	string tmp;
	map<string,int>  mp;

	cin >> N;
	for(int i=0;i<N;i++){
		cin >> tmp;
		if(mp.find(tmp) == mp.end()) mp[tmp] = 1;
		else mp[tmp]++;
	}
	cin >> M;
	for(int i=0;i<M;i++){
		cin >> tmp;
		if(mp.find(tmp) == mp.end()) mp[tmp] = -1;
		else mp[tmp]--;
	}
	int max=0;
	for(auto i=mp.begin(); i!= mp.end();i++){
		if(max < i->second) max = i->second;
	}

	cout << max << "\n";
	return 0;
}

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


int main(){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int x[N],y[M];
    for (int i=0;i<N;++i) cin >> x[i];
    for (int i=0;i<M;++i) cin >> y[i];

    bool flag1=true,flag2=true;

    for (int j=X+1;j<=Y;++j){
        flag1=true,flag2=true;
        for (int i=0;i<N;++i){
            if(x[i]>=j) {
                flag1=false;
                break;
            }
        }
        for (int i=0;i<M;++i){
            if(y[i]<j) {
             flag2=false;
             break;
            }
        }
        if(flag1 && flag2) break;
    }
    if(flag1 && flag2) cout << "No War" << endl;
    else cout << "War" << endl;
}




Measured memory_bytes: 256
N = gets.chomp.to_i

answers = {}
N.times do |i|
  answer_count = gets.to_i
  answers[i] = {}
  answer_count.times do
    x, y = gets.chomp.split(' ').map(&:to_i)
    answers[i][x-1] = (y == 1)
  end
end
result = 0
catch :ok do 
  [true, false].repeated_permutation(N) do |honests|
    catch :ng do
      N.times do |i|
        next unless honests[i]
        answers[i].each do |target, honest|
          throw :ng if honests[target] != honest
        end
      end
      result = honests.find_all{|t| t }.count
      throw :ok
    end
  end
end

puts result

Measured memory_bytes: 2044
#include <stdio.h>

int m, d;
int ocunt;

int main(void)
{
	scanf("%d %d", &m, &d);
	
	for(int i = 1 ; i <= m ; i++)
	{
		for(int j = 1 ; j <= d ; j++)
		{
			int d10 = j / 10;
			int d1 = j % 10;
			
			if(d10 >= 2 && d1 >= 2)
			{
				if(d10 * d1 == i)
				{
					ocunt++;
				}
			}
		}
	}
	
	printf("%d", ocunt);
	return 0;
}

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

int main() {
  vector<int> a(110);
  int N;
  cin >> N;
  for(int i=0;i<N;i++) cin>>a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int A=0,B=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      A+=a.at(i);
    } else{
      B+=a.at(i);
    }
  }
  cout<<A-B<<endl;
  return 0;
}


Measured memory_bytes: 3576
n,m=map(int,input().split())
w=[list(map(int,input().split())) for i in range(n)]
w.sort(key=lambda x:x[0])  #1個目の要素で昇順並び替え

money=0 
num_drink=0 #mになるまで買う
for i in range(n):
    if num_drink==m:
        break
    elif num_drink + w[i][1] <= m:
        num_drink += w[i][1]
        money += w[i][0] * w[i][1]
    elif num_drink + w[i][1] > m:
        money += w[i][0] * (m - num_drink)
        num_drink += m - num_drink
print(money)

Measured memory_bytes: 64600
#include <stdio.h>

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	int a,flag=0;
	for(a=0;a<=x;a++){
		int z=x+a;
		if(y==2*z){
			flag++;
			break;
		}
	}
	if(flag>0) printf("Yes\n");
	else       printf("No\n");
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <tgmath.h>
#define MOD 1000000007
using namespace std;

#define INT_MAX 2147000000
#define LONG_MAX 9223372036854775806

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int N;
int main(){
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    ll right = 0;
    ll sum = 0;
    ll ans = 0;
    rep(left,N){
        while((sum^A[right])==(sum+A[right])&&right<N){
            sum += A[right];
            right++;
        }
        ans += right-left;
        if(left==right)right++;
        else{
            sum -= A[left];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE


    int n; cin>>n;
    int arr[n];
    int dp[n];
    for(int i = 0; i < n; ++i){
        cin>>arr[i];
    }
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i = 2; i < n; ++i){
        int posa = dp[i-1] + abs(arr[i] - arr[i-1]);
        int posb = dp[i-2] + abs(arr[i] - arr[i-2]);
        dp[i] = min(posa, posb);
    }
//    for(auto it : dp) cout<<it<<endl;
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        boolean[] done = new boolean[N];
        HashMap<Integer, List<Integer>> edges = new HashMap<>();
        for (int i = 0; i < M; i++) {
            int a = scan.nextInt()-1;
            int b = scan.nextInt()-1;
            if (!edges.containsKey(a)) {
                edges.put(a, new ArrayList<Integer>());
            }
            if (!edges.containsKey(b)) {
                edges.put(b, new ArrayList<Integer>());
            }
            edges.get(a).add(b);
            edges.get(b).add(a);
        }
        int answer = dfs(0, done, edges);
        System.out.println(answer);
    }
    public int dfs(int current, boolean[] done, HashMap<Integer, List<Integer>> edges) {
        if (done[current]) {
            return 0;
        }
        done[current] = true;
        boolean all_visited = true;
        for (int i = 0; i < done.length; i++) {
            if (!done[i]) {
                all_visited = false;
                break;
            }
        }
        if (all_visited) {
            return 1;
        }
        List<Integer> neighbors = edges.get(current);
        int answer = 0;
        for (int next : neighbors) {
            if (done[next]) {
                continue;
            }
            answer += dfs(next, done, edges);
            done[next] = false;
        }
        return answer;
    }
}


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


int main() {
    int x;
    cin >> x;
    if (x < 4) {
        cout << 1 << endl;
        return 0;
    }

    int cand = 4;
    int b = 2, p = 2;
    while (pow(b, p) <= x) {
        while (pow(b, p) <= x) {
            int n = pow(b, p);
            if (n > cand) cand = n;
            p++;
        }
        p = 2;
        b++;
    }
    cout << cand << endl;
    return 0;
}


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

static const long long MOD=1e9+7;

long long modpow(long long b, long long e, long long p=MOD) {
    /* Exponentiation by squaring */
    // returns n == b**e (mod p)
    long long n=1, a=b%p;
    while (e) {
        if (e & 1)
            (n *= a) %= p;

        (a *= a) %= p;
        e >>= 1;
    }
    return n;
}

int main() {
    long long m, n;
    scanf("%lld %lld", &m, &n);

    printf("%lld\n", modpow(m, n));
    return 0;
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define os_find(k) find_by_order(k)
//#define os_order(k) order_of_key(k)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

signed main()
{
    fast

    int n;
    cin>>n;

    int h[n];
    f0(i,0,n) cin>>h[i];

    int dp[n];
    f0(i,0,n) dp[i] = LLONG_MAX;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    f0(i,2,n)
    {
        dp[i] = min(abs(h[i]-h[i-1]) + dp[i-1], abs(h[i]-h[i-2]) + dp[i-2]);
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 5188
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,a[200001],sum[200001],res=INF_LL;
  cin >> N;
  REP(i,N)cin >> a[i];
  sum[0] = a[0];
  REP(i,N-1)sum[i+1] = sum[i] + a[i+1];
  res = min(res,abs(sum[N-1]-2*sum[0]));
  for(int i=1;i<N-1;i++){
    res = min(res,abs(2*sum[i-1]-sum[N-1]));
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

ll M = 1000000007;
static ll c[2001][2001];

ll comb(ll x, ll y) {
  // printf("comb x=%d, y=%d\n", x, y);
  if (c[x][y] != 0) {
    // printf("memo return %d\n", c[x][y]);
    return c[x][y];
  }
  for (int i = 0; i <= x; i++) {
    for (int j = 0; j <= i; j++) {
      if (c[i][j] != 0) {
        continue;
      }
      if (j == 0 || i == j) {
        c[i][j] = 1;
      } else {
        c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % M;
      }
      // printf("i=%d, j=%d, c=%d\n", i, j, c[i][j]);
      if (i == x && j == y) {
        return c[x][y];
      }
    }
  }
  return c[x][y];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;

  memset(c, 0, 2001 * 2001);

  comb(max(n - k + 1, k - 1), k);
  for (int i = 1; i <= k; i++) {
    // printf("next i=%d\n", i);
    cout << (comb(n - k + 1, i) * comb(k - 1, i - 1)) % M << endl;
  }
  // cout << comb(2000, 2000) << endl;
  return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int h, w;
    cin >> h >> w;
    vi cnt(26);
    rep(i, h) {
        string a;
        cin >> a;
        rep(j, w) cnt[a[j]-'a']++;
    }
    vi nums(h*w+1);
    rep(i, sz(cnt)) if (cnt[i]!=0) nums[cnt[i]]++;
    if (h%2==0 && w%2==0) {
        bool ok = true;
        for (int i=0; i<sz(nums); ++i) {
            if (i%4==0) continue;
            if (nums[i]!=0) ok =false;
        }
        if (!ok) cout << NO << endl;
        else cout << YES << endl;
    }
    else if (h%2==0 || w%2==0) {
        int val = 0;
        if (h%2!=0) val = w/2;
        else val = h/2;
        bool ok = true;
        for (int i=0; i<sz(nums); ++i) {
            if (i%4==0) continue;
            if (i%2==0) {
                val -= nums[i];
                if (val < 0) ok = false;
            }
            else if (nums[i]!=0) ok = false;
        }
        if (!ok) cout << NO << endl;
        else cout << YES << endl;
    }
    else {
        int val = w/2 + h/2, val2 = 1;
        bool ok = true;
        for (int i=0; i<sz(nums); ++i) {
            if (i%4==0) continue;
            if (i%2==0) {
                val -= nums[i];
                if (val < 0) ok = false;
            }
            else {
                val2 -= nums[i];
                if (val2 < 0) ok = false;
            }
        }
        if (!ok) cout << NO << endl;
        else cout << YES << endl;
    }
    return 0;
}


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

int main() {
    int64_t a, b, c;
    cin >> a >> b >> c;
    if(a == b) cout << (2 * (a + b) < c ? "Yes" : "No") << '\n';
    else {
        if(2 * (a + b) <= c) {
            cout << "Yes" << '\n';
        } else {
            cout << (sqrt(a) + sqrt(b) < sqrt(c) ? "Yes" : "No") << '\n';
        }
    }
    return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int m,k,i,j;

	scanf("%d %d",&m,&k);
	int sor = 0;
	for(i=0;i<(1<<m);i++){
		if(i != k){
			sor ^= i;
		}
	}
	if(k == 0){
		for(i=0;i<(1<<(m));i++){
			if(i){printf(" ");}
			printf("%d %d",i,i);
		}
		printf("\n");
		return 0;
	}
	// printf("sor: %d\n",sor);
	if(sor == k){
		deque<int> q;
		q.pb(k);
		for(i=0;i<(1<<m);i++){
			if(i != k){
				q.pb(i);
				q.push_front(i);
			}
		}
		q.pb(k);
		bool first = true;
		for(int i=0;i<q.size();i++){
			if(!first){printf(" ");}

			printf("%d", q[i]);
			first = false;
		}
		printf("\n");
	}else{
		printf("-1\n");
	}
	return 0;
};

Measured memory_bytes: 2944
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];

    int count = 0;
    for (int i = 0; i < n-2; i++) {
        if ((p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2])) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	int n,x,m[110];
	int min=10000;
	int sum=0;
	
	scanf("%d%d",&n,&x);
	
	for(int i=0;i<n;i++){
		scanf("%d",&(m[i]));
		if(min>m[i]){
			min=m[i];
		}
		sum=sum+m[i];
	}
	
	printf("%d\n",(x-sum)/min+n);
	
	return 0;
}

Measured memory_bytes: 128
st_N=input()
N=int(st_N)


output=0
for i in range(1<<(len(st_N)-1)):
    f=st_N[0]
    for j in range(len(st_N)-1):

        if((i>>j) & 1)==1:
            f=f+'+'
        f=f+st_N[j+1]
    #print(f)
    output=output+sum(map(int,f.split('+')))

print(output)


Measured memory_bytes: 41452
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		String W=" "+in.nextLine()+" ";
        String T="";
        String n=in.nextLine();
        while(!n.equals("END_OF_TEXT")){
        	T+=" "+n.toLowerCase().replace(" ", "  ")+" ";
        	n=in.nextLine();
        }
        int c=0;
        int i=-1;
        int l=W.length();
        while(true){
            i=T.indexOf(W, i+1);
            if(i==-1){
            	break;
            }else{
            	c++;
            	i+=l-1;
            }
        }
        System.out.println(c);
	}
}

Measured memory_bytes: 17268