akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b) gcd(b, a);
	long long  r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
inline long long mod(long long a, long long m) {
	return (a % m + m) % m;
}

// 拡張 Euclid の互除法
// ap + bq = gcd(a, b) となる (p, q) を求め、d = gcd(a, b) をリターンします
long long extGcd(long long a, long long b, long long &p, long long &q) {
	if (b == 0) { p = 1; q = 0; return a; }
	long long d = extGcd(b, a%b, q, p);
	q -= a / b * p;
	return d;
}

// 中国剰余定理
// リターン値を (r, m) とすると解は x ≡ r (mod. m)
// 解なしの場合は (0, -1) をリターン
//amari,mod,amari,mod
pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2, long long m2) {
	long long p, q;
	long long d = extGcd(m1, m2, p, q); // p is inv of m1/d (mod. m2/d)
	if ((b2 - b1) % d != 0) return make_pair(0, -1);
	long long m = m1 * (m2 / d); // lcm of (m1, m2)
	long long tmp = (b2 - b1) / d * p % (m2 / d);
	long long r = mod(b1 + m1 * tmp, m);
	return make_pair(r, m);
}
typedef pair<int, int>p;
int n, a, b, c;
int l[10];
int num(int x) {
	int ans = 0;
	while (x > 1) {
		ans += x / 2;
		x = (x + 1) / 2;
	}
	return ans;
}
int dfs(int x, int y, int z, int now,int numx,int numy,int numz) {
	if (now == n) {
		if (numx == 0 || numy == 0 || numz == 0)return INT_MAX;
		return abs(x - a) + abs(y - b) + abs(z - c) + num(numx)*10 + num(numy)*10+num(numz)*10;
	}
	else {
		return min(min(dfs(x + l[now], y, z, now + 1,numx+1,numy,numz), dfs(x, y + l[now], z, now + 1, numx, numy+1, numz)), min(dfs(x, y, z + l[now],now+1, numx, numy, numz+1), dfs(x, y, z, now + 1,numx,numy,numz)));
	}
}
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	cout << dfs(0, 0, 0, 0,0,0,0);
}


Measured memory_bytes: 256
import math
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)

n = int(input())

t, a = map(int, input().split())
t0, a0 = t, a
s = t + a
for i in range(1, n):
    # print(s, t0, a0)
    t, a = map(int, input().split())
    g = GCD(t, a)
    t, a = t // g, a // g

    m = max((t0+t-1)//t,
            (a0+a-1)//a)
    s =  (t+a) * m
    t0, a0 = t * m, a * m

print(s)


Measured memory_bytes: 3064
#include<stdio.h>

int main(){

  int data[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int month, day, i, result;

  while(1){
    scanf("%d %d",&month,&day);

    if(month == 0 || day == 0){
      break;
    }

    result = 0;

    for(i = 0; i < month-1; i++){
      result += data[i];
    }

    result += day;

    switch(result % 7){
    case 0: 
      printf("Wednesday\n");
      break;
    case 1 :
      printf("Thursday\n");
      break;
    case 2:
      printf("Friday\n");
      break;
    case 3:
      printf("Saturday\n");
      break;
    case 4:
      printf("Sunday\n");
      break;
    case 5:
      printf("Monday\n");
      break;
    case 6:
      printf("Tuesday\n");
      break;
    default :
      break;
    }

  }

  return 0;
}

Measured memory_bytes: 0
from fractions import gcd

n, k = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

g = A[0]
for i in range(n):
    g = gcd(g, A[i])

if k <= max(A) and k % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 16280
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
     
     while(true){
         vector<int> ad;
         vector<int> cd;

         int a,b,c;
         cin >> a >> b >>c;
         if(a==0&&b==0&&c==0)return 0;
         for(int i= -10000;i<=10000;i++){
             if(i==0){if(c==0)cd.push_back(0);continue;}
            if(c%i==0)cd.push_back(i);
         }
         for(int i=1;i<=10000;i++){
            if(a%i==0)ad.push_back(i);
         }
         bool flag=true;
         for(int i=0;flag&& i<ad.size();i++)
             for(int k=0;flag&& k<cd.size();k++){
                int p=ad[i];
                int r=a/ad[i];
                if(r>p)swap(p,r);
                int q=cd[k];
                int s= cd[k]==0?0:c/cd[k];
                if(p==r){
                    if(s>q)swap(s,q);
                }
                if(b==p*s+q*r){
                    flag=false;
                    cout << p << " " << q << " " << r << " " << s <<endl; 
                    break;
                }
                swap(s,q);
                if(b==p*s+q*r){
                    flag=false;
                    cout << p << " " << q << " " << r << " " << s <<endl; 
                    break;
                }

             }
         if(flag){
            cout << "Impossible" << endl;
         }
     }
}

Measured memory_bytes: 1052
n = int(input())
i = 1
while i <= n:
    # iが3で割り切れる場合、出力
    if i % 3 == 0:
        print(f" {i}", end="")
    else:
        x = i
        # xを10で割り余りが３になる場合、出力（再起的に10で割った商を返していく）
        while x != 0:
            if x % 10 == 3:
                print(f" {i}", end="")
                break
            x //= 10
    i += 1
print()



Measured memory_bytes: 5888
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;

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

int a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;

  int ma = 0;
  REP(i, n) cin >> a[i], ma = max(ma, a[i]);

  int g = a[0];
  REP(i, n) {
    g = gcd(g, a[i]);
  }

  cout << (ma >= k && k % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int a,p;
	cin>>a>>p;
	a=a*3+p;
	cout<<((int)a/2);
}

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

int n, m;
char arr[10][10];
bool vis[10][10];

bool dfs(int x, int y) {
  bool ret = false;
  vis[x][y] = true;
  if(x == n-1 && y == m-1) {
    for(int i = 0 ; i < n ; i++)
      for(int j = 0 ; j < m ; j++) {
        if(arr[i][j] == '#' && vis[i][j] != true) {
          return false;
        }
      }
    return true;
  }
  if(arr[x+1][y] == '#') ret = dfs(x+1, y);
  if(ret) return true;
  if(arr[x][y+1] == '#') ret = dfs(x, y+1);
  vis[x][y] = false;
  return ret;
}

int main(){
  scanf("%d %d", &n, &m);
  for(int i = 0 ; i < n ; i++){
    scanf("%s", arr[i]);
  }
  bool get = dfs(0,0);
  if(get) puts("Possible");
  else puts("Impossible");
  return 0;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        m[a]++;
    }

    int t = 0;
    for (const auto p : m) {
        if (p.first < p.second) {
            t += p.second - p.first;
        } else if (p.first > p.second) {
            t += p.second;
        }
    }

    cout << t << endl;
}


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

int main() {
  uint64_t n, a, b;
  cin >> n >> a >> b;
  uint64_t tmp1 = n / (a + b);
  uint64_t tmp2 = n % (a + b);
  tmp2 = min(tmp2, a);
  cout << tmp1 * a + tmp2 << endl;
  return 0;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, Y = LI()

m = [10000, 5000, 1000]


"""
2000枚をどうふりわけるかで考える？
2000 0 0
1999 1 0
1998 2 0
的な
左端を固定、残りを右側でdfsしたら、
例えば1000なら、1000通り試せば良い
10**6ぐらいで終わるか？
"""
for i in range(N + 1):
    # i は1万円札の数
    ten = m[0] * i
    rest = N - i
    # 残りを5000/1000の振り分けを行う
    for j in range(rest + 1):
        five = m[1] * j
        one = m[2] * (rest - j)
        if ten + five + one == Y:
            print(i, j, rest - j)
            exit()
else:
    print(-1, -1, -1)


Measured memory_bytes: 6476
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

    if((n+1)/2 >= k){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n){
    cin >> v[i];
  }
  int a[] = {0, 0, 0};
  ll ans = 1;
  rep(i,n){
    int cnt = 0;
    bool push = 0;
    rep(j,3){
      if(v[i] == a[j]){
        cnt++;
        if(!push){
          a[j]++;
          push = 1;
        }
      }
    }
    ans *= cnt;
    ans %= mod;
    // cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

enum
{
  A = 0,
  T,
  G,
  C
};

int dp[101][4][4][4];

signed main()
{
  ios();
  int N;
  cin >> N;
  //The initial state is only 1 pattern
  //,and recent 3 tokens  is made 'T' to have no restriciton
   dp[0][T][T][T] = 1;
   rep(i,N)
   {
     rep(j,4)rep(k,4)rep(l,4)
    {
      if(dp[i][j][k][l] == 0) continue;
      rep(n,4)
      {
        if (k == A && l == G && n == C)
          continue;
        if (k == G && l == A && n == C)
          continue;
        if (k == A && l == C && n == G)
          continue;
        if (j == A && k == G && n == C)
          continue;
        if (j == A && l == G && n == C)
          continue;

        (dp[i + 1][k][l][n] += dp[i][j][k][l]) %= MOD;
      }
    }
   }   
   int ans = 0;
  rep(i,4)rep(j,4)rep(k,4) (ans += dp[N][i][j][k]) %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
 
#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forln(i, l, n) for (int i = l; i < n; ++i)

#define LOCAL

using namespace std;

#ifdef LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n';
#else 
	#define dbg(x)
#endif

//tg: @galebickosikasa
 
const int maxn = (int) 3e5;
const ll inf = (ll) 2e9;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

random_device rd;
mt19937 SuperRandom(rd());



int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> goo = {a,b, c};
	sort (all (goo));
	if (goo[0] == goo[1] && goo[1] != goo[2] || goo[1] == goo[2] && goo[0] != goo[1]) cout << "Yes";
	else cout << "No";






}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <climits>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <bitset>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <deque>
#include <ctime>
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define s2(a,b) scanf("%d%d",&a,&b)
#define SET(p)      memset(p,-1,sizeof(p))
#define CLR(p)      memset(p,0,sizeof(p))
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL long long
#define ULL unsigned long long
#define R freopen("in","r",stdin)
#define W freopen("out","w",stdout)
using namespace std;

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	if(a>b){
		puts("0");
	} else {
		if(n==1) {
			if(a==b){
				puts("1");
			} else {
				puts("0");
			}
		} else if(n==2) {
			puts("1");
		} else {
			long long ans = 1LL*(b-a)*(n-2) + 1;
			printf("%lld\n", ans);
		}
	}
}

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

using namespace std;

int main(){
    int x=0,a=0,b=0;
    cin >> x >> a >> b;
    if(abs(x-a)>abs(x-b)){
        cout << "B" << endl;
    }else{
        cout << "A" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int a,b; cin>>a>>b;
  if(a>0) cout<<"Positive"<<endl;
  else if(a<=0&&b>=0) cout<<"Zero"<<endl;
  else if(a<0&&(a-min(b,0))%2!=0) cout<<"Positive"<<endl;
  else cout<<"Negative"<<endl;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code
template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	int n = s.size() + 1;
	VL a(n,0);
	for (int i = 0; i < n-1; i++) {
		if (s[i] == '<') chmax(a[i+1], a[i]+1);
	}
	for (int i = n-2; i >= 0; i--) {
		if (s[i] == '>') chmax(a[i], a[i+1]+1);
	}
	cout << accumulate(a.begin(), a.end(), 0LL) << endl;
	return 0;
}


Measured memory_bytes: 4764
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    ll n=s.sz,c=1,f=0,ans=0;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            f=1;
            break;
        }
    }
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='R'&&s[i-1]=='R')
        {
            c++;
        }
        else
        {
            if(c>1)
                ans=(ans,c);
            c=1;
        }
    }
    if(c>1)
        ans=max(ans,c);
    if(f)
    {
        ans=max(ans,(ll)1);
        cout<<ans;
    }
    else
    {
        cout<<ans;
    }
    return 0;
}


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

int main(){
	int N, K, i;
	scanf("%d%d", &N, &K);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%1d", &A[i]);
	}
	vector<int> swich(N, 0);
	for(i = 1; i < N; i++){
		if(A[i] == A[i - 1]){
			swich[i] = swich[i - 1];
		}
		else{
			swich[i] = swich[i - 1] + 1;
		}
	}
	int ans = 0, now;
	for(i = 0; i < N; i++){
//		printf("i = %d\n", i);
		if(A[i] == 0){
			now = lower_bound(swich.begin(), swich.end(), swich[i] + 2 * K) - swich.begin();
		}
		else{
			now = lower_bound(swich.begin(), swich.end(), swich[i] + 2 * K + 1) - swich.begin();
		}
//		printf("now = %d\n", now);
		ans = max(ans, now - i);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int N = sc.nextInt();
        String ans = "No";
        for(int i = 0;i<3;i++ ){
        if((N%10)==7) {
        ans = "Yes";
        break;
        }
        else
        N = N/10;
        
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35584
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <math.h>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define CIN(s) int (s);cin>>(s);
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; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;
//ここから
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l;
    cin>>n>>l;
    V vec(n);
    rep(i,n)cin>>vec[i];
    rep(i,n){
        if(vec[i]>=l){
            cout<<"Possible"<<endl;
            rep(j,i){
                cout<<j+1<<endl;
            }
            for(int j=n-2;j>=i;j--){
                cout<<j+1<<endl;
            }
            return 0;
        }
    }
    rep(i,n-1){
        if(vec[i]+vec[i+1]>=l){
            cout<<"Possible"<<endl;
            rep(j,i){
                cout<<j+1<<endl;
            }
            for(int j=n-2;j>=i+1;j--){
                cout<<j+1<<endl;
            }
            
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<"Impossible"<<endl;
}



Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
int main(void){
  int a,b,i;
  scanf("%d %d",&a,&b);
  char code[11];
  scanf("%s",code);
  if(strlen(code)!=a+b+1){
    printf("No");
    return 0;
  }
  for(i=0;i<strlen(code);i++){
    if(i==a){
      if(code[a]!='-'){
        printf("No");
        return 0;
      }
    }else{
      if(code[i]-'0'<0||code[i]-'0'>9){
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int w, h, x, y, s, t, ans;
        char map[105][105] = {false};
        
        cin >> w >> h;
        for (int i = 0; i < n; i++) {
            cin >> x >> y;
            map[y - 1][x - 1] = true;
        }
        cin >> s >> t;

        ans = 0;
        for (int i = 0; i <= h - t; i++) 
            for (int j = 0; j <= w - s; j++) {
                int tmp = 0;
                for (int y = i; y < i + t; y++)
                    for (int x = j; x < j + s; x++) 
                        if (map[y][x])
                            tmp++;
                ans = max(tmp, ans);
            }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1176
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in);
    val a, b = sc.nextInt;
    println(calc(a * b));
  }

  def calc(pro:Int) : String = {
    if (pro % 2 == 0) "Even" else "Odd"
  }
}

Measured memory_bytes: 27344
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll p[]={1,1,1,1,-1,-1,-1,-1};
ll q[]={1,-1,1,-1,1,-1,1,-1};
ll r[]={1,1,-1,-1,1,1,-1,-1};

int main(){
    int n,m;
    cin >> n >> m;
    vector<ll>x(n),y(n),z(n);
    rep(i,n)cin >> x[i] >> y[i] >> z[i];
    vector<ll> v(n);
    ll ma = 0;
    ll tmp;
    rep(k,8){
    rep(i,n)v[i]=0;
    rep(i,n){
        v[i]+=p[k]*x[i];
        v[i]+=q[k]*y[i];
        v[i]+=r[k]*z[i];
    }
    sort(v.begin(),v.end(),greater<ll>());
    tmp = 0;
    rep(i,m){
        tmp += v[i];
    }
    ma=max(ma,tmp);
    }
    
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define el "\n"
vector<int> v(10001, 0);

void solution() {
    for (int x=1; x<=101; ++x) {
        for (int y=1; y <= 101; ++y) {
            for (int z=1; z<= 101; ++z) {
                int sol = x*x + y*y + z*z + z*x + x*y + y*z;
                if (sol < 10001)
                    v[sol]++;
            }
        }
    }
}
  
int main() {
    solution();
    int n; cin >> n; 
    for (int i=1; i <= n; ++i) {
        cout << v[i] << el;
    }

    return 0;
}


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

using namespace std;

int select(int pos, int dice, vector<int>& dist, array<int, 6> a, vector<int>& next){
    int M = dist.size();
    for(int sign = -1; sign <= 1; sign += 2){
        int npos = pos + sign * a[ dice - 1 ];
        if(npos < 0 || npos >= M) continue;
        npos = next[npos];
        if(dist[npos] <= dist[pos]) return sign;
    }
    return 0;
}

int main(){
    int M;
    cin >> M;
    array<int, 6> a;
    REP(i, 6) cin >> a[i];
    int s, g;
    cin >> s >> g;
    s--; g--;
    vector<int> next(M);
    REP(i, M){
        cin >> next[i];
        next[i] += i;
    }
    queue<int> que;
    vector<int> dist(M, INT_MAX);
    que.push(g);
    dist[g] = 0;
    while(!que.empty()){
        int u = que.front();
        que.pop();
        for(int v = 0; v < M; v++){
            for(int sign = -1; sign <= 1; sign += 2){
                for(int ai : a){
                    int nv = v + ai * sign;
                    if(nv < 0 || nv >= M) continue;
                    nv = next[nv];
                    if(nv == u && dist[v] > dist[u] + 1){
                        dist[v] = dist[u] + 1;
                        que.push(v);
                    }
                }
            }
        }
    }
    int dice;
    int pos = s;
    assert(dist[pos] < INT_MAX);
    while(scanf("%d", &dice)){
        int act = select(pos, dice, dist, a, next);
        pos += act * a[dice - 1];
        if(act != 0) pos = next[pos];
        printf("%d\n", act); fflush(stdout);
        if(pos == g) break;
        //fprintf(stderr, "pos = %d\n", pos);
    }
    return 0;
}

Measured memory_bytes: 1304
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=3;i++)
		if((i*n*m)&1)
		{
			printf("Yes");
			return 0;
		}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int H, W;
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));
    vector<vector<int>> cost(H, vector<int>(W));
    rep(i,10){
        rep(j,10){
            cin >> c[i][j];
        }
    }
    rep(k,10){
        rep(i,10){
            rep(j,10){
                if(c[i][j]>c[i][k]+c[k][j]) c[i][j]=c[i][k]+c[k][j];
            }
        }
    }
    ll res=0;
    rep(i,H){
        rep(j,W){
            int A;
            cin >> A;
            if(A>=0) res+=c[A][1];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
int a[100001];
int b[100001];


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

    int n;
    cin >> n;
    
    REP(i, n){
        cin >> a[i];
        b[i] = a[i];
    }

    // スタートがマイナス
    llint ans = 0;
    bool nextNega = false;
    if(a[0] >= 0){
        ans += a[0] + 1;
        a[0] = -1;
    }
    REP(i, n-1){
        a[i+1] += a[i];
        if(nextNega){
            if(a[i+1] >= 0){
                ans += a[i+1] + 1;
                a[i+1] = -1;
            }
            nextNega = false;
        }else{
            if(a[i+1] <= 0){
                ans += -a[i+1] + 1;
                a[i+1] = 1;
            }
            nextNega = true;
        }
    }
    llint tmp = ans;
    // スタートがプラス
    ans = 0;
    if(b[0] <= 0){
        ans += -b[0] + 1;
        b[0] = 1;
    }
    nextNega = true;
    REP(i, n-1){
        b[i+1] += b[i];
        if(nextNega){
            if(b[i+1] >= 0){
                ans += b[i+1] + 1;
                b[i+1] = -1;
            }
            nextNega = false;
        }else{
            if(b[i+1] <= 0){
                ans += -b[i+1] + 1;
                b[i+1] = 1;
            }
            nextNega = true;
        }
    }
    cout << min(ans, tmp) << "\n";
    // REP(i ,n){
    //     cout << a[i] << " " << b[i] << "\n";
    // }


    return 0;
}
 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;

  vector<vector<int>> g(n);
  map<pair<int,int>,int> hen;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
    hen[{a,b}]=i;
    hen[{b,a}]=i;
  }

  int m;
  cin>>m;

  vector<vector<bool>> p(m,vector<bool>(n-1));

  rep(i,m){
    int c,d;
    cin>>c>>d;
    c--;d--;
    
    vector<vector<bool>> h(n,vector<bool>(n-1,false));
    vector<int> dist(n,-1);
    deque<int> que;
    dist[c]=0;
    que.pb(c);

    while(!que.empty()){
      int v=que.front();
      que.pop_front();

      for(int nv : g[v]){
        if(dist[nv]!=-1) continue;
        dist[nv]=dist[v]+1;
        int x=hen.at({v,nv});
        h[nv]=h[v];
        h[nv][x]=true;
        que.pb(nv);
      }

    }

    p[i]=h[d];
  }

  

  //——————————————bit全探索——————————————
  ll ans=0;
  rep(i, (1<<m)){
    int gk=0;
    vector<bool> q(n-1,false);
    rep(j,m){
      if(i & (1<<j)){
        rep(k,n-1){
          if(p[j][k]) q[k]=true;
        }
        gk++;
      }
    }
    int cnt=0;
    rep(j,n-1){
      if(!q[j]) cnt++;
    }
    if(gk%2==0) ans+=pow(2,cnt);
    else ans-=pow(2,cnt);
  }

  cout << ans << endl;

  //——————————————————————————————————————



}

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

int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+') {
		cout << a + b << endl;
	}
	else {
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>

using namespace std;

void solve(int n, vector<int> button) {
    vector<bool> flag(n, false);
    int i = 0;
    int ans = 0;
    bool aval = false;
    while (!flag[i]) {
        flag[i] = true;
        i = button[i]-1;
        ans++;
        if (i == 1) {
            aval = true;
            break;
        }
    }
    if (aval) {
        std::cout << ans << std::endl;
    } else {
        std::cout << -1 << std::endl;
    }
}

int main() {
    struct timeval start,end;
    long long span;
    int n;

    gettimeofday(&start,NULL);

    std::cin >> n;
    vector<int> button(n);
    for (int i = 0; i < n; i++) {
        std::cin >> button[i];
    }
    solve(n, button);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 1024
//30/05/2020
/*A step of a tortoise in search of happiness and true act of goodwill.!*/
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll x,y;
};
struct cmp1{
    bool operator()(const Node &a,const Node &b)const{
        if(a.x==b.x) return a.y<b.y;
        else return a.x>b.x;
    }
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
class NumberTheory{
public:
    ll n;
    bool chk[99999995];
    ll GetMod(ll x,ll m);
    ll BigMod (ll b,ll p,ll m){if (p == 0) return 1;if (p%2 == 0){ll s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
    ll ModInv (ll b,ll m){return BigMod(b,m-2,m);}
    ll gcd(ll a,ll b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
    ll lcm(ll a,ll b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
    void sieve(ll x);
    bool IsPrime(ll x);
    bool IsPrime1(ll x){return !chk[x];}
};

/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
set<Node,cmp1>st1;
map<Node,ll,cmp1>mp1;
priority_queue<Node,deque<Node>,cmp1>pq1;
Pbds<ll>ost;


int main(){
    _fastio
    string s;
    cin>>s;
    for(ll i=0;i<s.length();i++){
        if(s[i]=='?') s[i]='D';
    }
    cout<<s<<en;



    return 0;
}

void NumberTheory::sieve(ll x){
    for(ll i=2;i*i<=x;){
        if(chk[i]==0){
            for(ll j=i*i;j<=x;j+=i){
                chk[j]=1;
            }
        }
        if(i==2) i++;
        else i+=2;
    }
}
bool NumberTheory::IsPrime(ll x){
    bool f=true;
    for(ll i=2;i*i<=x;i++){
        if(!x%i){
            f=false;break;
        }
    }
}
ll GetMod(ll x,ll m){
    if(x>=0) return x%m;
    else{
        ll y=abs(x)/m;x+=(y*m+m+m);
        return x%m;
    }
}


Measured memory_bytes: 3796
#include <iostream>

using namespace std;

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

	int ans = 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])){
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int N, result = 0;
    if(scanf("%d", &N) == EOF) exit(1);

    result = N % 1000;
    if (result != 0) result = 1000 - result;
    printf("%d", result);

    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18+10;
const lli MOD = 200003;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7

int main(){_
	lli n,k; cin>>n>>k;
	vvi v(n+1); fore(i,0,n){
		int a; cin>>a; v[i+1].pb(a);
	}
	vl x(n+1); fore(i,0,n)cin>>x[i+1];

	vi vis(n+1, 0);
	vl acum;
	auto f=[&](auto f,int u, lli sum)->void{
		vis[u]=1;
		acum.pb(sum);
		for(auto i:v[u])if(!vis[i])f(f,i,sum+x[i]);
	};
	lli mx = -INF;
	fore(i,1,n+1){
		vis= vi(n+1,0);
		acum = vl();
		f(f,i,x[i]);
		lli res = x[i];
		if(k>=sz(acum))res = max(res,*max_element(all(acum)));
		if(k>=sz(acum))res = max(res,k/sz(acum) * acum.back());
		if(k%sz(acum))res = max(res, k/sz(acum) * acum.back() + *max_element(acum.begin(),acum.begin()+k%sz(acum)));
		if(k%sz(acum))res = max(res, *max_element(acum.begin(),acum.begin()+k%sz(acum)));
		if(k>=sz(acum))fore(j,0,sz(acum))res = max((k-(j+1))/sz(acum) * acum.back() + acum[j],res);
		mx = max(res,mx);
	}
	cout<<mx<<ENDL;




}


Measured memory_bytes: 4472
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;

const int N=105;

int n,m;
int a[N],b[N];
int f[N][N][N*3];

void Up(int &x,int y)
{
	if(y>x) x=y;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	int w1=a[1];
	for(int i=1;i<=n;i++) a[i]-=w1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			for(int k=0;k<=j*3;k++)
				f[i][j][k]=f[i-1][j][k];
			for(int k=a[i];k<=j*3;k++)
				Up(f[i][j][k],f[i-1][j-1][k-a[i]]+b[i]);
		}
	}
	int Ans=0;
	for(int i=1;i<=n;i++)
	{
		if((long long)i*w1>m) break;
		int j=m-i*w1;
		for(int k=0;k<=min(i*3,j);k++)
			Up(Ans,f[n][i][k]);
	}
	cout<<Ans<<endl;
}
	

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

    int arr[n][3];
    int i,j;

    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++) cin>>arr[i][j];
    }
    int dp[n][3];

    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];

    for(i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+arr[i][2];
    }

    int k=max(dp[n-1][0],dp[n-1][1]);
    k=max(k,dp[n-1][2]);
    cout<<k<<endl;
}


Measured memory_bytes: 5928
#include <stdio.h>

int min(int A, int B) {
	if (A >= B) {
		return B;
	} else {
		return A;
	}
}

int main(void) {
	int N;
	scanf("%d", &N);
	int i;
	int B[99];
	for(i = 0; i < N - 1; i++) {
		scanf("%d", &B[i]);
	}
	int sum = B[0];
	for(int k = 0; k <= i; k++) {
		if (k == i - 1) {
			//printf("bail! B[k] = %d\n", B[k]);
			sum += B[k];
			break;
		}
		sum += min(B[k], B[k + 1]);
		//printf("Sum is now %d\n", sum);
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
// #define mp make_pair
// #define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define show(x) cout << #x << " = " << x << endl;

int memo[301];

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

}


int main(){
  ll n, m;
  cin >> n;
  ll a, sum=0;
  deque<ll> qa;

  REP(i,n){
    cin >> a;
    if((n-i)%2 ==1){
      qa.push_front(a);
    }else{
      qa.push_back(a);
    }
  }
  for(auto itr = qa.begin(); itr != qa.end()-1; itr++){
    cout << *itr << " ";
  }
  cout << qa[qa.size()-1] << endl;


  return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

lint calc(int bit, lint n) {
    lint base = 1LL << bit;
    lint q = n / (base << 1);

    lint res = 0;
    res += base * q;

    n %= (base << 1);

    if (n >= base) {
        res += (n % base) + 1;
    }

    return res;
}

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

    lint res = 0;

    rep(i, 40) {
        auto d = calc(i, b) - calc(i, a-1);
        res |= (d % 2) << i;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    string s1;
    cin >> s;

    int dp[11] = {0};
    for(int i = 0; i< s.size();i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            dp[i+1] = dp[i] + 1;
        }
    }
    
    cout << *max_element(begin(dp),end(dp));
}


Measured memory_bytes: 256
S = input()
N = len(S)
ans = True
h = (N-1)//2
for i in range(h + 1):
    if S[i] != S[-1-i]: ans = False
hh = h // 2
for i in range(hh+1):
    if S[i] != S[-1-h-1-i]: ans = False
print('Yes' if ans else 'No')

Measured memory_bytes: 38384