akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll a,b,c; cin >> a >> b >> c;
  if(a+b>=c) cout << "Yes" << endl;
  else cout << "No" << endl;
} 

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a,b,c,d,w,x,y,z;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d %d %d %d\n",c+b-d,d+c-a,a+b-d,b-a+c);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

#define NIL -1
struct node
{
    int p, l, r;
} t[MAXN];
int n;

void preorder(int root) //先序遍历
{
    if (root == NIL) return;
    printf(" %d", root);
    preorder(t[root].l);
    preorder(t[root].r);
}

void inorder(int root)  //中序遍历
{
    if (root == NIL) return;
    inorder(t[root].l);
    printf(" %d", root);
    inorder(t[root].r);
}

void postorder(int root)  //后序遍历
{
    if (root == NIL) return;
    postorder(t[root].l);
    postorder(t[root].r);
    printf(" %d", root);
}

int main()
{
    int root, id, left, right;
    cin >> n;
    rep(i, 0, n-1){
        t[i].p = t[i].l = t[i].r = NIL;
    }
    rep(i, 0, n-1){
        cin >> id >> left >> right;
        t[id].l = left;
        t[id].r = right;
        if (left != NIL) t[left].p = id;
        if (right != NIL) t[right].p = id;
    }
    rep(i, 0, n-1){
        if (t[i].p == NIL){
            root = i;
            break;
        }
    }
    printf("Preorder\n");
    preorder(root);
    printf("\nInorder\n");
    inorder(root);
    printf("\nPostorder\n");
    postorder(root);
    putchar('\n');

    return 0;
}



Measured memory_bytes: 3120
#include <stdio.h>

int main(void){

  char s[7];
  scanf("%s", s);

  if (s[0] == 'S') {
    printf("Cloudy\n");
  }
  if (s[0] == 'C') {
    printf("Rainy\n");
  }
  if (s[0] == 'R') {
    printf("Sunny\n");
  }

  return 0;
}

Measured memory_bytes: 128
a,b,c,d=map(int,input().split())
 
if c%b==0:
  e=c//b
else:
  e=c//b+1
  
if a%d==0:
  f=a//d
else:
  f=a//d+1  

if e<=f:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9068
#include <iostream>

long long to_l(const double &d){
	return d * 1000000;
}
int main(){
	double xa, ya, xb, yb, xc, yc, xd, yd;
	long long ixa, iya, ixb, iyb, ixc, iyc, ixd, iyd;
	while (std::cin >> xa){
		std::cin >> ya >> xb >> yb >> xc >> yc >> xd >> yd;
		ixa = to_l(xa);
		iya = to_l(ya);
		ixb = to_l(xb);
		iyb = to_l(yb);
		ixc = to_l(xc);
		iyc = to_l(yc);
		ixd = to_l(xd);
		iyd = to_l(yd);
		if ((ixa - ixb) * (ixc - ixd) + (iya - iyb) * (iyc - iyd) == 0){
			std::cout << "YES\n";
		}else{
			std::cout << "NO\n";
		}
	}
}

Measured memory_bytes: 1188
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    char ch;
    while (1)
    {
        scanf("%c", &ch);
        if (isalpha(ch))
        {
            if (islower(ch))
            {
                printf("%c", toupper(ch));
            }
            else
            {
                printf("%c", tolower(ch));
            }
        }
        else
        {
            printf("%c", ch);
        }
        if (ch == '\n') break;
    }
    
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    vector<pair<double, pair<int, double>>> ev;
    vector<int> d(Q);
    REP(i, N)
    {
        int s, t, x;
        cin >> s >> t >> x;
        ev.emplace_back(s - 0.5 - x, make_pair(1, x));
        ev.emplace_back(t - 0.5 - x, make_pair(-1, x));
    }
    REP(i, Q)
    {
        cin >> d[i];
    }
    ev.emplace_back(INF, make_pair(-1, -1)); //必ずwhile文の最初の判定で外れるようにする。
    sort(ALL(ev));
    set<int> st;
    int i = 0;
    REP(index, Q)
    {
        while (ev[i].first <= d[index])
        {
            if (ev[i].second.first == 1)
            {
                st.insert(ev[i].second.second);
            }
            else if (ev[i].second.first == -1)
            {
                st.erase(ev[i].second.second);
            }
            i++;
        }
        cout << (st.empty() ? -1 : *(st.begin())) << "\n";
    }
}
//https://atcoder.jp/contests/abc128/submissions?f.Language=3003&f.Status=AC&f.Task=abc128_e&f.User=&orderBy=created

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

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    int res = 0;
    while (res < n)
    {
        res += 1000;
    }
    cout << res - n << endl;
    return 0;
}

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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  
  int cnt = 0, a_cnt = 0, b_cnt = 0, double_cnt = 0;
  string s;
  for (int i = 0;i < N;i++) {
    cin >> s;
    
    for (int j = 0;j < s.length()-1;j++) {
      if (s[j] == 'A') {
        if (s[j+1] == 'B') cnt++;
      }
    }
    
    if (s[0] == 'B') b_cnt++;
    if (s[s.length() - 1] == 'A') a_cnt++;
    if (s[0] == 'B' && s[s.length() - 1] == 'A') double_cnt++;
  }
  
  if (double_cnt == a_cnt && a_cnt == b_cnt) {
    a_cnt = max(0, a_cnt-1);
    b_cnt = max(0, b_cnt-1);
  }
  cout << cnt + min(a_cnt, b_cnt) << endl;

}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
q=int(input())
def primes(n):
    m=int(pow(n,0.5))
    is_prime=[True]*(n+1)
    is_prime[0]=False
    is_prime[1]=False
    for i in range(2,m+1):
        if not is_prime[i]:
            continue
        for j in range(i*2,n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]
s=set(primes(10**5))
count=[0]*(10**5+1)
count[1]=0
count[2]=0
for i in range(3,10**5+1):
    if i in s and (i+1)//2 in s:
        count[i]=count[i-1]+1
    else:
        count[i]=count[i-1]
for i in range(q):
    l,r = map(int,input().split())
    print(count[r]-count[l-1])


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

int main() {
  string s;
  cin >> s;
  int an,zn;
  an=-1;
  zn=-1;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'){
      an=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s.at(i)=='Z'){
      zn=i;
      break;
    }
  }
  cout << zn-an+1 << endl;
}


Measured memory_bytes: 640
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

long f(ref long[] a) {
    long n = a.length;
    if(a[0] <= 3*n) {
        long ans = 0;
        while(a[0] >= n) {
            a[0] -= n;
            a[1..$] += 1;
            a.sort!"a > b"();
            ++ans;
        }
        return ans;
    }
    long j = a.assumeSorted!("a > b").lowerBound(a[0]-n-1-1).array.length;
    if(j == n) {
        long x = a[0] - 2*n;
        foreach(i; iota(n)) {
            a[i] -= x;
        }
        a.sort!"a > b"();
        return x*n;
    }
    long l = 0;
    long u = long.max/100;
    while(l+1 < u) {
        long m = (l+u)/2;
        if(a[j-1] - m*(n-(j-1)) >= n && a[0]-m*(n-(j-1)) > a[j] + m*j) {
            l = m;
        } else {
            u = m;
        }
    }
    foreach(i; iota(n)) {
        if(i < j) {
            a[i] -= l*(n-(j-1));
        } else {
            a[i] += l*j;
        }
    }
    a.sort!"a > b"();
    return l*j;
}

void main(){
    auto n = readLong();
    auto a = readLongs();
    a.sort!"a > b"();
    long ans = 0;
    while(a[0] >= n) {
        ans += f(a);
    }
    writeln(ans);
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        
        char c[] = str.toCharArray();
        int n = c.length;
        String str2 = sc.next();
        
        char c2[] = str2.toCharArray();
        boolean ok = true;
        for (int i = 0; i < n; i++) {
            if (c[i] != c2[i]) {
                ok = false;
            }
        }
        if (ok) {
        System.out.println("Yes");
        } else {
            
        System.out.println("No");
        }
    }
}


Measured memory_bytes: 35696
#include <cstdio>
#include <iostream>
using namespace std;
const int maxRen = 105;
int n, x[maxRen];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &x[i]);
	int ans = 2e9;
	for (int i = 1; i <= 100; ++i) {
		int nowAns = 0;
		for (int j = 1; j <= n; ++j) {
			nowAns += (i - x[j]) * (i - x[j]);
		}
		ans = min(ans, nowAns);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
ll n;ll a[200005],pos[200005],k,aa[200005];
bool check(ll x){
    ll cnt=0;
    rep(i,1,n) {
        if(a[i] > 0){
            // round up
            ll val=x;if(val>=0) val=(val+a[i]-1)/a[i];else val=val/a[i];
            cnt += n -(lower_bound(aa+1,aa+n+1,val) - aa - 1);
            //if(x==8)cout<<val<<' '<<n -(lower_bound(aa+1,aa+n+1,val) - aa - 1)<<'\n';
        }
        if(a[i] < 0){
            a[i]=-a[i];
            ll val=x;
            if(val>=0) val=(val+a[i]-1)/a[i]; else val=val/a[i];
            a[i]=-a[i];
            val=-val;
            cnt += upper_bound(aa+1,aa+n+1,val) - aa - 1;
            //if(x==8) cout<<val<<' '<<upper_bound(aa+1,aa+n+1,val) - aa - 1<<'\n';
        }
        if(a[i] == 0){
            if(x<=0) cnt += n;
        }
    }
    rep(i,1,n) if(a[i] * a[i] >= x) cnt--;
    cnt/=2;
    //cout<<x<<' '<<cnt<<endl;
    return cnt >= k;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    k=n*(n-1)/2-k+1;
    rep(i,1,n) scanf("%lld",a+i),aa[i]=a[i];
    sort(aa+1,aa+n+1);
    //check(8);
    ll l=-1e18,r=1e18;
    while(l<r){
        ll mid=(l+r+1)>>1;
        if(check(mid)) l=mid;
        else r=mid-1;
    }
    printf("%lld\n",l);
    return 0;
}

Measured memory_bytes: 4480
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	//std::ifstream in("../../test.txt");
	//std::cin.rdbuf(in.rdbuf());


	ll N, L;
	cin >> N >> L;

	ll sum = 0;

	if (L<0 && -L < N) {
		rep(i, N) {
			sum += L + i;
		}
	}
	else if(L<0){
		rep(i, N - 1) {
			sum += L + i;
		}
	}
	else {
		rep(i, N - 1) {
			sum += L + i + 1;
		}
	}


	cout << sum << endl;



	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>
#include <chrono>
#include <climits>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned int uint;
typedef unsigned long long ull;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
// default_random_engine generator;
// mt19937 rnd(1);


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

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


    string s;
    cin >> s;
    ll res = 0;
    int n = sz(s);

    int cur = 0;

    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == 'A') {
            if (cur & 1) {
                cur = 0;
            } else {
                res += cur / 2;
            }
        } else {
            if (s[i] == 'C' - (cur & 1))  {
                ++cur;
            } else {
                cur = (s[i] == 'C');
            }
        }
    }   

    cout << res << endl;
}   




Measured memory_bytes: 720
k = int(input())
ab = input().split(" ")
a = int(ab[0])
b = int(ab[1])
n = a
m = 0
while n <= b:
  if n % k == 0:
    print("OK")
    m = 1
    break
  n += 1
if m == 0:
  print("NG")


      
  

Measured memory_bytes: 9180
#include<stdio.h>

int main() {
	char a[4];
	gets(a);
	int f = 0;
	for (int i = 0; i < 3; i++)
		if (a[i] == '7')
			f = 1;
	if (f)
		printf("Yes");
	else
		printf("No");

}


Measured memory_bytes: 1604
A = int(input()) #500
B = int(input()) #100
C = int(input()) #50
X = int(input()) #sum
count = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                count += 1

print(count)


Measured memory_bytes: 39536
def dp_a_frog1(stones):
    if len(stones) == 0:
        return 0
    dp = [0] * len(stones)
    for i in range(1, len(stones)):
        cost_jump = dp[i - 1] + abs(stones[i - 1] - stones[i])
        if i > 1:
            cost_jump_2 = dp[i - 2] + abs(stones[i - 2] - stones[i])
            cost_jump = min(cost_jump, cost_jump_2)
        dp[i] = cost_jump
    return dp[len(stones) - 1]


if __name__ == '__main__':
    N = int(input())
    h = list(map(int, input().split()))
    print(dp_a_frog1(h))



Measured memory_bytes: 13928
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<string, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll k;

string next_runrun(string v) {
    int l = (int)v.size();
    string res = "";
    for (int i = l-1; i >= 0; i--) {
        int w = (int)(v[i]-'0');
        if (i == 0) {
            if (w < 9) {
                w++;
                for (int j = 0; j < l; j++) {
                    res += to_string(w);
                    w = max(0, w-1);
                }
            } else {
                res += '1';
                for (int j = 0; j < l; j++) res += '0';
            }
            return res;
        } else {
            int x = (int)(v[i-1]-'0');
            if (w < 9 && x >= w) {
                w++;
                for (int j = 0; j < i; j++) {
                    res += v[j];
                }
                for (int j = 0; j < l-i; j++) {
                    res += to_string(w);
                    w = max(0, w-1);
                }
                return res;
            }
        }
    }
    return res;
}

string solve() {
    string v = "0";
    for (int i = 0; i < k; i++) {
        v = next_runrun(v);
    }
    return v;
}

void input() {
    cin >> k;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a, b;
bool flag;
int main(void)
{
	cin >> a, b;
	for (int i = 1; i < 10; i++)
	{
		if (a % i == 0 && (a / i) > 0 && (a / i) < 10)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a, b, ans = 0;
  string s, t;
  //ll x;
  cin >> s >> t;
  //vector<int> v(n), c(n);
  //if(1) {}
  //for(int i = 0; i < n; i++){}
  cout << t << s << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a;
    a.pb(0);
    rep(i,n){
        int t; cin>>t;
        a.pb(t);
    }
    a.pb(0);
    vi sum1(n+2), sum2(n+2);
    rep(i,n+1) sum1[i+1] = abs(a[i+1]-a[i]);
    rep(i,n+1) sum1[i+1]+=sum1[i];
    reverse(all(a));
    rep(i,n+1) sum2[i+1] = abs(a[i+1]-a[i]);
    rep(i,n+1) sum2[i+1]+=sum2[i];
    reverse(all(a));
    FOR(i,1,n){
        cout<<sum1[i-1]+sum2[n-i]+abs(a[i-1]-a[i+1])<<endl;
    }
    return 0;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

	ll n; cin >> n;
	const ll r = 10;
	vector<vector<ll>> num(r, vector<ll>(r, 0));
	for (ll i = 1; i <= n; i++) {
		vector<ll> d;
		ll iTmp = i;
		while (iTmp) {
			d.push_back(iTmp % 10);
			iTmp /= 10;
		}
		ll p = d[0];
		ll q = d[d.size() - 1];
		if (p == 0 || q == 0) continue;
			num[p][q]++;
	}
	ll ans = 0;
	for (ll p = 1; p < r; p++) {
		for (ll q = 1; q < r; q++) {
			ans += num[p][q] * num[q][p];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3548
#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;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Yes";
const string NO = "No";
bool is_kaibun(const string &s){
  string t=s;
  reverse(t.begin(),t.end());
  if(s==t)return true;
  return false;
}
void solve(std::string S){

  if(is_kaibun(S)&&is_kaibun(S.substr(0,(S.size()-1)/2))){
    cout<<YES<<endl;
  }else{
    cout<<NO<<endl;
  }
}

int main(){
  cout<<setprecision(1000);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

void yes(vector<ll>& ans){
  cout << "Yes" << endl;
  ll m = ans.size();
  REP(i,m) cout << ans[i] << endl;
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  ll N, x; cin >> N >> x;
  if(x==1 || x==2*N-1) no();
  vector<ll> ans(2*N-1);
  if(x==2) REP(i,2*N-1) ans[(N-2+i)%(2*N-1)] = i+1;
  else REP(i,2*N-1) ans[(2*N-1+ N-x+i)%(2*N-1)] = i+1;
  yes(ans);
}



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

#define endl '\n'

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(0);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

int main() { BUFF
  string s, t; cin >> s >> t;
  for(int i=0; i<s.size(); i++) {
    if(s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> A;

    if (A & 1)
      continue;

    if (A % 3 == 0 || A % 5 == 0)
      continue;
    
    std::cout << "DENIED" << std::endl;
    
    return 0;
  }

  std::cout << "APPROVED" << std::endl;
  
  return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}


struct Henkaku {
  ld first;
  complex<ld> second;
};

bool operator< (Henkaku &h1, Henkaku &h2) {
  return h1.first < h2.first;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(11);

  int n; cin >> n;
  vector<Henkaku> v;
  for(int i=0;i<n;++i) {
    int x, y; cin >> x >> y;
    //if(x == 0 && y == 0) continue;
    v.push_back({0.0, complex<ld>(0, 0)});
    v[i].second = complex<ld>(x, y);
    
    v[i].first = arg(v[i].second);
    //cout << v[i].first << " " << v[i].second << endl;
  }
  n = SZ(v);
  sort(v.begin(), v.end());
  
  
  
  ld ma = 0;
  for(int i=0;i<n;++i) {
    complex<ld> now(0, 0);
    for(int j=0;j<n;++j) {
      now += v[(i+j)%n].second;
      ma = max(ma, sqrt(now.real() * now.real() + now.imag() * now.imag()));
      //cout << sqrt(now.real() * now.real() + now.imag() * now.imag()) << endl;
    }
  }
  cout << ma << endl;
  

}


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

using namespace std;

const int N = 100000 + 7;

int main() {
  int n;
  scanf("%d", &n);

  int a[N];
  int neg = 0;
  for(int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if(a[i] < 0) ++neg;
  }
  sort(a, a + n);

  if(n == 1) {
    printf("%d\n", a[0]);
    return 0;
  }

  if(neg <= 1) {
    int m = 0;
    for(int i = 1; i < n; ++i) m += a[i];
    m -= a[0];

    printf("%d\n", m);
    int r = 1;
    int x = a[0], y = a[r];
    while(r < n - 1) {
      printf("%d %d\n", x, y);
      x -= y;
      ++r;
      y = a[r];
    }
    printf("%d %d\n", y, x);
  } else if(neg < n - 1) {
    int r = 1;
    while(r < n && a[r] < 0) ++r;
    int l = r - 2;

    int m = 0;
    for(int i = 0; i < n; ++i) m += abs(a[i]);

    printf("%d\n", m);
    int x = a[r - 1], y = a[r];
    while(r < n - 1) {
      printf("%d %d\n", x, y);
      x -= y;
      ++r;
      y = a[r];
    }
    printf("%d %d\n", y, x);
    x = y - x;
    y = a[l];
    while(l >= 0) {
      printf("%d %d\n", x, y);
      x -= y;
      --l;
      y = a[l];
    }

  } else {
    reverse(a, a + n);

    int m = 0;
    for(int i = 1; i < n; ++i) m -= a[i];
    m += a[0];

    printf("%d\n", m);
    int r = 1;
    int x = a[0], y = a[r];
    while(r < n) {
      printf("%d %d\n", x, y);
      x -= y;
      ++r;
      y = a[r];
    }
    /*
    printf("%d %d\n", y, x);
    */
  }
  return 0;
}


Measured memory_bytes: 2304
// 二択を繰り返すDP
// 状態: 区間[i,j), O(N^2)個
// DPの結果: その場合の解
// 遷移: O(1)

#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#define IFD(...)
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/hana/functional/fix.hpp>
using boost::hana::fix;
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    vector<i64> a_s(n);
    rep(i, n) { cin >> a_s[i]; }

    // [i,j)での(先手)-(後手)
    vector dp(n + 1, vector<i64>(n + 1, 0));
    FOR(l, 1, n)
    {
        rep(i, n - l + 1)
        {
            auto j = i + l;
            dp[i][j] = max(a_s[i] - dp[i + 1][j], a_s[j - 1] - dp[i][j - 1]);
        }
    }
    cout << dp[0][n] << '\n';

    return 0;
}


Measured memory_bytes: 73664
#include <stdio.h>
int main(void) {
  int N;
  scanf("%d", &N);
  int A[N];
  int seCnt = 0;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    if (A[i] % 2 == 0) {
      seCnt++;
      if ((A[i] % 3 == 0 || A[i] % 5 == 0)) {
        cnt++;
      }
    }
  }
  if (seCnt == cnt) {
    printf("APPROVED\n");
  } else {
    printf("DENIED\n");
  }
  return 0;
}

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

int main(void){
  vector<string> I;
  vector<string> N;
  int K;
  cin >> K;
  for(int i=0; i < K; i++){
    string tmp; cin >> tmp;
    I.push_back(tmp);
  }
  for(int i=0; i < K; i++){
    string tmp; cin >> tmp;
    N.push_back(tmp);
  }

  int power[2] = {0, 0};
  int winner = -1;
  for(int i=0; i < K; i++){
    if(I[i] == "kougekida"){
      if(N[i] == "kougekida"){
        if(power[0] == 0){
          if(power[1] == 0){
            continue;
          }else{
            winner = 1;
            break;
          }
        }else if(power[1] == 0){
          winner = 0;
          break;
        }
        if(power[0] == power[1]){
          power[0] = power[1] = 0;
          continue;
        }else if(power[0] > power[1]){
          winner = 0;
          break;
        }else{
          winner = 1;
          break;
        }
      }else if(power[0] == 0){
        winner = 1;
        break;
      } else if(N[i] == "mamoru"){
        if(power[0] == 5){
          winner = 0;
          break;
        }
        power[0] = 0;
        continue;
      }else{
        winner = 0;
        break;
      }

    }else if(I[i] == "mamoru"){
      if(N[i] == "mamoru") continue;
      else if(N[i] == "tameru"){
        power[1] = min(power[1]+1, 5);
        continue;
      }else if(N[i] == "kougekida"){
        if(power[1] == 0){
          winner = 0;
          break;
        }
        if(power[1] == 5){
          winner = 1;
          break;
        }else{
          power[1] = 0;
          continue;
        }
      }

    }else{
      if(N[i] == "kougekida"){
        if(power[1] == 0){
          winner = 0;
          break;
        }else{
          winner = 1;
          break;
        }
      }else if(N[i] == "mamoru"){
        power[0] = min(power[0]+1, 5);
        continue;
      }else{
        power[0] = min(power[0]+1, 5);
        power[1] = min(power[1]+1, 5);
      }
    }
  }
  if(winner == -1){
    cout << "Hikiwake-kun" << endl;
  }else if(winner == 0){
    cout << "Isono-kun" << endl;
  }else{
    cout << "Nakajima-kun" << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <stdlib.h>
int main() {
    int i, N, H, W, *A, *B, cnt = 0;
    if (scanf("%d %d %d%*c", &N, &H, &W) == -1) return -1;
    A = (int *)malloc(sizeof(int) * N);
    B = (int *)malloc(sizeof(int) * N);
    if (!A || !B) return -1;
    for (i = 0; i < N; i++) {
        if (scanf("%d %d%*c", &A[i], &B[i]) == -1) return -1;
        if (A[i] >= H && B[i] >= W) cnt++;
    }
    printf("%d\n", cnt);
    free(A); free(B);
    return 0;
}

Measured memory_bytes: 128
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() { 
    int n;
    cin>>n;
    VI a(n),b(n);
    rep(i,n) cin>>a[i];

    for(int i=n-1;i>=1;i--){
        if(a[i]<=a[i-1]){
            b[i-1]=b[i]+1;
        }else{
            b[i-1]=0;
        }
    }
    
    int maxv=-1;
    rep(i,n){
        maxv=max(maxv,b[i]);
    }

    cout<<maxv<<endl;
    
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)

#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long ll;
const int N = 1e5+1 , M = 5e5+1, OO = 0x3f3f3f3f,MOD = 1e9+7;
vector<int>adj[N];
int par[N],sz[N];
int n,m,k;
void init()
{
  fill(sz,sz+n,1);
  iota(par,par+n,0);
}
int find(int p)
{
  return p==par[p]?p:par[p]=find(par[p]);
}
bool sameset(int a,int b)
{
  return find(a)==find(b);
}
void join(int a,int b)
{
  a = find(a),b = find(b);
  
  if(a==b) return;
  if(sz[a] < sz[b]) swap(a,b);

  par[b]=a;
  sz[a]+=sz[b];
}

int main()
{
  scanf("%d%d%d",&n,&m,&k);
  init();
  for(int i=0;i<m;++i)
  {
    int u,v;
    scanf("%d%d",&u,&v);
    u--,v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
    join(u,v);
  }
  for(int i=0;i<k;++i)
  {
    int u,v;
    scanf("%d%d",&u,&v);
    u--,v--;
    if(sameset(u,v))
    {
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    
  }
  for(int i=0;i<n;++i)
  {
    error(i+1,sz[find(i)],adj[i].size());
    printf("%ld ",sz[find(i)]-adj[i].size()-1);
  }
  
    
  
  #ifdef _LOCAL_DEFINE  
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 10112
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var map = new long[n, 3];
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < 3; j++)
                map[i, j] = long.Parse(line[j]);
        }
        Console.WriteLine(getAns(map, m));
    }
    public static long getAns(long[,] map, int m)
    {
        var n = map.GetLength(0);
        var ret = Int64.MinValue;
        for (int i = 0; i < 8; i++)
        {
            var te = new long[n];
            for (int j = 0; j < n; j++)
                for (int k = 0; k < 3; k++)
                    if (((i >> k) & 1) == 1) te[j] += map[j, k];
                    else te[j] -= map[j, k];
            var te2 = te.OrderByDescending(x => x).Take(m).Sum();
            ret = Math.Max(ret, te2);
        }
        return ret;
    }
}



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


int main() {
    string s, t;
    cin >> s >> t;
    stable_sort(s.begin(), s.end());
    stable_sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
  int n;
  cin>>n;
  int l;
  cin>>l;
  vector <string> s(n);
  for (int i=0;i<n;i++)
  {
    cin>>s[i];
  }
  sort(s.begin(),s.end());
  for (int i=0;i<n;i++)
    cout<<s[i];
}


Measured memory_bytes: 256
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

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

struct Node {
    int parent;
    vector<int> children;
    Node() : parent(-1), children() {}
};

vector<Node> read_problem()
{
    int n;
    scanf("%d\n", &n);

    vector<Node> nodes(n);
    REP(i, n) {
        int id;
        int k;
        scanf("%d %d", &id, &k);
        Node& node = nodes[id];

        REP(j, k) {
            int child;
            scanf("%d", &child);
            node.children.emplace_back(child);
            nodes[child].parent = id;
#if 0
            printf("%d %d %lu\n", id, child, node.children.size());
#endif
        }
    }

    return nodes;
}

int depth(const vector<Node>& nodes, int id)
{
    int d = 0;
    for(Node node = nodes[id]; node.parent != -1; node = nodes[node.parent]) {
        ++d;
    }

    return d;
}

string node_typ(const Node& node)
{
    if(node.parent == -1)
        return "root";
    else if(node.children.empty())
        return "leaf";
    else
        return "internal node";
}

int main()
{
    vector<Node> nodes = read_problem();
    int n = nodes.size();

    REP(i, n) {
        Node& node = nodes[i];
        int k = node.children.size();
        int d = depth(nodes, i);
        string typ = node_typ(node);

        printf("node %d: parent = %d, depth = %d, %s, [", i, node.parent, d, typ.c_str());
        REP(j, k) {
            printf("%d%s", node.children[j], j == k-1 ? "" : ", ");
        }
        puts("]");
    }

    return 0;
}

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

int n, k, d[15];

bool check(int x) {
	while (x) {
		int a = x%10;
		x/=10;
		for (int i = 0; i < k; i++) {
			if (a == d[i]) {
				return 1;
			}
		}
	}
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}

	while (check(n)) {
		n++;
	}
	cout << n << '\n';

	return 0;
}

Measured memory_bytes: 256
# H and V
# 高々 2 ** 12 通りなので全探索で良い
import numpy as np
H,W,K = map(int,input().split())
HW = np.repeat('', H*W).reshape(H,W) 
ans = 0
for _ in range(H):
    HW[_] = np.array(list(input()))

for _ in range(1<<(H+W)):
    # print(format(_, 'b').zfill(H+W))
    choices = format(_, 'b').zfill(H+W)
    r = [i for i, v in enumerate(choices[:H]) if v == '1']
    c = [i for i, v in enumerate(choices[H:]) if v == '1']
    ans += [0, 1][np.sum(HW[r,:][:,c] == '#') == K]

print(ans)
    
    

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

bool judge_if_second(vector<int> numbers){
    return ((numbers[0] < numbers[1]) && (numbers[1] < numbers[2])) || ((numbers[2] < numbers[1]) && (numbers[1] < numbers[0]));
}

int main(){
    int n;
    cin >> n;
    vector<int> numbers(n);

    for (int i=0;i<n;i++){
        cin >> numbers[i];
    }

    int count = 0;
    for (int i=1; i<n-1; i++){
        vector<int> target{numbers[i-1], numbers[i], numbers[i+1]};
        if (judge_if_second(target)){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
ll getSum(ll BITree[], int index) 
{ 
    ll sum=0;
    index++;
    while(index>0) 
    {
        sum+=BITree[index]; 
        index-=index&(-index); 
    } 
    return sum; 
} 
void updateBIT(ll BITree[], int n, int index, ll val) 
{ 
    index++;
    while(index<=n) 
    { 
        BITree[index]+=val; 
        index+=index&(-index); 
    } 
} 
ll *construct(ll arr[], int n) 
{ 
    ll *BITree=new ll[n+1]; 
    loop(i,1,n+1)
    {
        BITree[i]=0;
    }
    loop(i,0,n)
    {
        updateBIT(BITree, n, i, arr[i]); 
    }
    return BITree; 
} 
int main()
{
    vok();
    ll a,v;
    IN a>>v;
    ll b,w;
    IN b>>w;
    ll t;
    IN t;
    if(a<b)
    {
        ll temp=a+(v*t);
        ll temp2=b+(w*t);
        if(temp>=temp2)
        {
            OUT "YES"<<endl
        }
        else
        {
            OUT "NO"<<endl
        }
    }
    else
    {
        ll temp=a-(v*t);
        ll temp2=b-(w*t);
        if(temp<=temp2)
        {
            OUT "YES"<<endl
        }
        else
        {
            OUT "NO"<<endl
        }
    }
    return 0;
}

Measured memory_bytes: 3644
import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [input() for _ in range(H)]
for h, w in itertools.product(range(H), range(W)):
    if A[h][w] == 'S':
        break
visited = [[False] * W for _ in range(H)]
ans = min([h, H - 1 - h, w, W - 1 - w])
res = K - 1
Q = collections.deque([[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                       [h, w + 1, res]])
while Q:
    h, w, res = Q.popleft()
    if 0 <= h < H and 0 <= w < W and A[h][w] == '.' and not visited[h][w]:
        visited[h][w] = True
        ans = min([ans, h, H - 1 - h, w, W - 1 - w])
        if res:
            res -= 1
            Q += [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                  [h, w + 1, res]]
print(1 + math.ceil(ans / K))


Measured memory_bytes: 90844
#include <bits/stdc++.h>
using namespace std;
int p[101],q[101],r[101],b[101],used[102];

int saiki(int ima){
  int A=1,B=1;
  if(r[ima])A=saiki(r[ima]);
  if(b[ima])B=saiki(b[ima]);
  int res=__gcd(A*p[ima],B*q[ima]);
  int resA=(A*p[ima])/res,resB=(B*q[ima])/res;
  return (A*resB)+(B*resA);
}

int main(){
  int n;
  while(cin>>n,n){
    memset(used,0,sizeof(used));
    for(int i=1;i<=n;i++){
      cin>>p[i]>>q[i]>>r[i]>>b[i];
      int res=__gcd(p[i],q[i]);
      p[i]/=res,q[i]/=res;
      used[r[i]]=used[b[i]]=1;
    }
    for(int i=1;i<=n;i++)if(!used[i]) cout<<saiki(i)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int64_t N;
    cin >> N;
    int64_t count = 0;
    for (int64_t a=1; a<N; a++) {
        for (int64_t b=1; b<N; b++) {
            if (a * b >= N) {
                break;
            }

            count += 1;
        }
    }

    cout << count << endl;
    return 0;
}

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

int main()
{
	while (true)
	{
		int r, l;
		string op;
		cin >> r >> op >> l;
		if (op == "?")
		{
			break;
		}
		if (op == "+")
		{
			cout << r + l << endl;
		}
		if (op == "-")
		{
			cout << r - l << endl;
		}
		if (op == "*")
		{
			cout << r * l << endl;
		}
		if (op == "/")
		{
			cout << static_cast<int>(r / l) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1208