akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n , k ;
	cin >> n>> k ;
	string s;
	cin >> s;
	s[k-1] = (s[k-1]-'A' + 'a');
	cout << s;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int i=0;
    while(i<s.size()){
        if(s[i]!=t[i]){
            cout<<"No";
            return 0;
        }
        i++;
    }
    cout<<"Yes";
    return 0;
}



Measured memory_bytes: 3624
#include <iostream>

using namespace std;
int n,a,ans[1000000],i;
int main()
{
   cin >> n;
   for (i=1; i<=n; i++)
   {
       cin >> a;
       ans[a]=i;
   }
   for (i=1; i<=n; i++)
   cout<<ans[i]<<" ";

    return 0;
}


Measured memory_bytes: 3916
from collections import defaultdict

n, k = map(int, input().split())
A = list(map(int, input().split()))

accm = [0] * (n + 1)
for i in range(n):
  accm[i + 1] = accm[i] + A[i]
  
li = [(val - itr) % k for itr, val in enumerate(accm)]

ans = 0
box = defaultdict(int)

for i in range(n + 1):
  if i >= k:
    box[li[i - k]] -= 1
  ans += box[li[i]]
  box[li[i]] += 1

print(ans)


Measured memory_bytes: 50664
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int N;
int a[10000];
int b[10000];

int main(int argc, char* argv[])
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &b[i]);
	}
	ll A = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] < b[i]) {
			int j = (b[i] - a[i]) / 2 + (b[i] - a[i]) % 2;
			A += j;
			a[i] += j * 2;
		}
	}
	ll B = 0;
	for (int i = 0; i < N; i++) {
		B += a[i] - b[i];
	}
	if (A >= B) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 384
// Author @MAC_19

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define double long double
#define pb push_back
#define pf push_front
#define mkp make_pair
#define ft first
#define sd second
#define sz(x) (ll)x.size()
#define fbo find_by_order
#define ook order_of_key
#define sp " "
#define nl "\n"
#define loop int t; cin>>t; while(t--)

#define vi vector<ll>
#define vpii vector<pii>
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define mi map<ll,ll>

#define VARGS_(_10, _9, _8, _7, _6, _5, _4, _3, _2, _1, N, ...) N  
#define VARGS(...) VARGS_(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#define CONCAT_(a, b) a##b
#define CONCAT(a, b) CONCAT_(a, b)
#define f_4(x,a,b,B) for(int x=a;(B ? x<=b : x<b); ++x) 
#define f_3(x,a,b) f_4(x,a,b,0)
#define f(...) CONCAT(f_, VARGS(__VA_ARGS__))(__VA_ARGS__)
#define rf_4(x,a,b,B) for(int x=a;(B ? x>=b : x>b); --x) 
#define rf_3(x,a,b) rf_4(x,a,b,0)
#define rf(...) CONCAT(rf_, VARGS(__VA_ARGS__))(__VA_ARGS__)
#define elif else if
#define beg(a) a.begin()
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()  
#define allf(i) for(auto it=i.begin(); it!=i.end(); it++)
#define inf LLONG_MAX

using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> PBDS;

const ll LIM=2e5+7;
const ll MAX=1e9+7;
const ll MOD=998244353;

template<typename T> istream& operator >> (istream& i, vector<T>& a){ for(auto &x : a) i>>x; return i; }
template<typename T> ostream& operator << (ostream& o, vector<T>& a){ for(auto &x : a) o<<x<<sp; return o; }

void deb(){ cerr<<nl; }
template <typename T1, typename ... T2>
void deb(T1 p, T2... lp) { cerr<<p<<sp; deb(lp...); }
#define deb(...) cerr<<"["<<#__VA_ARGS__<<"] : "; deb(__VA_ARGS__)

/*ll fact[1000005];
void _fact(ll M)
{
	ll x=1;
	fact[0]=1;
	f(i,1,200005)
	{
		x=(x*i)%M;
		fact[i]=x;
	}
}

ll pow(int x, int y, ll p=MAX) 
{ 
	ll ans = 1; 
	x = x % p;    
	while (y > 0) 
	{ 
		if (y & 1) 
			ans = (ans*x) % p;
		y = y>>1; 
		x = (x*x) % p;   
	} 
	return ans; 
}*/

signed main() 
{
	fast
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	
	
	ll n,k; cin>>n>>k; vi v(n+1); v[0]=MAX;
	f(i,1,n+1) cin>>v[i];
	vi cost(n+1,-1);
	cost[1]=0;
	f(i,2,n+1)
	{
	   int Min=MAX;
	   f(j,1,k,1)
	   {
	       Min=(i-j<1? Min: min(Min*1LL,cost[i-j]+abs(v[i]-v[i-j])));
	   }
	   cost[i]=Min;
	}
	cout<<cost[n]<<nl;
}

Measured memory_bytes: 4792
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(a,d+1):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d+1):
    if i==1:
        continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
    if res[i-1]=="#" and res[i]=="#":
        print("No")
        exit()
        
print("No")
exit()


Measured memory_bytes: 4916
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cfloat>
#include <cmath>

int N;
std::vector<int> a;

int main(void){
    std::cin >> N;
    a.resize(N);
    for(int i=0; i<N; ++i){
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());
    double ave = (1.*std::accumulate(a.begin(), a.end(), 0))/a.size();
    int mid = 0;
    long ans = 0.0;

    if(fabs(ave - (int)ave) < DBL_EPSILON){
        mid = ave;
        std::transform(a.begin(), a.end(), a.begin(), [&](int x){return (x-mid)*(x-mid);});
        ans = std::accumulate(a.begin(), a.end(), 0);
    }else{
        std::vector<int> b(a);

        mid = ave;
        std::transform(a.begin(), a.end(), a.begin(), [&](int x){return (x-mid)*(x-mid);});

        mid += 1;
        std::transform(b.begin(), b.end(), b.begin(), [&](int x){return (x-mid)*(x-mid);});

        ans = std::min(std::accumulate(a.begin(), a.end(), 0), std::accumulate(b.begin(), b.end(), 0));
    }

    std::cout << ans << std::endl;
}


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

long floor_sum(long n, long m, long a, long b) {
    long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }
    long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << "\n";
  }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

// FOR DEBUGGING
// vector<string> vec_splitter(string s) {
// 	s += ',';
// 	vector<string> res;
// 	while(!s.empty()) {
// 		res.push_back(s.substr(0, s.find(',')));
// 		s = s.substr(s.find(',') + 1);
// 	}
// 	return res;
// }

// void debug_out(
// vector<string> __attribute__ ((unused)) args,
// __attribute__ ((unused)) int idx, 
// __attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
// template <typename Head, typename... Tail>
// void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
// 	if(idx > 0) cerr << ", ";
// 	else cerr << "Line(" << LINE_NUM << ") ";
// 	stringstream ss; ss << H;
// 	cerr << args[idx] << " = " << ss.str();
// 	debug_out(args, idx + 1, LINE_NUM, T...);
// }

// #ifndef XOX
// #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
// #else
// #define debug(...) 42
// #endif

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	ll n, k;
	cin >> n >> k;

	ll ans = 0;
	for(ll i=k;i<=n+1;i++){
		ll var1 = (i*(i-1))/2;
		ll var2 = (i*(2*n+1-i))/2;
		ll var = var2 - var1;
		var++;
		var %= mod;
		// cout << var1 << " " << var2 << " " << var <<"\n";
		ans += var;
		ans %= mod;
	}
	cout << ans;

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();
		int ans1 = a * b;
		int ans2 = 2 * a + 2 *b;
		System.out.println(ans1 + " " + ans2);

		sc1.close();

	}

}


Measured memory_bytes: 26332
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct Trie {
	struct Node {
		int child[26];
		int key;
	} a[MAXN];
	int root, size; ll ans;
	bool vis[MAXN][26];
	void insert(string s) {
		int len = s.size();
		s = ' ' + s;
		for (int i = 1; i <= len; i++) {
			memcpy(vis[i], vis[i - 1], sizeof(vis[i]));
			vis[i][s[i] - 'a'] = true;
		}
		int pos = root;
		for (int i = len; i >= 1; i--) {
			for (int j = 0; j <= 25; j++)
				if (vis[i][j]) ans += a[a[pos].child[j]].key;
			int ch = s[i] - 'a';
			if (a[pos].child[ch] == 0) a[pos].child[ch] = ++size;
			pos = a[pos].child[ch];
		}
		a[pos].key = 1;
	}
} Trie;
int n, len[MAXN], p[MAXN];
string s[MAXN];
int main() {
	read(n);
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		len[i] = s[i].size();
		p[i] = i;
	}
	sort(p + 1, p + n + 1, [&] (int x, int y) {
		return len[x] < len[y];
	});
	for (int i = 1; i <= n; i++)
		Trie.insert(s[p[i]]);
	cout << Trie.ans << endl;
	return 0;
}


Measured memory_bytes: 165368
def is_prime(n):
    if n == 1 or n == 2:
        return True
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

n = int(input())
ans = 0
for _ in range(n):
    if is_prime(int(input())):
        ans += 1
print(ans)


Measured memory_bytes: 5704
import sys
input = sys.stdin.readline
#N, K = (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
S = input()
if S[1] == "B":
    print("ARC")
else:
    print("ABC")



Measured memory_bytes: 61684
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define maxn 100005
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
inline void Max(int& x,int y){x=x>y?x:y;}
inline void Min(int& x,int y){x=x>y?y:x;}
#define ls k<<1
#define rs k<<1|1
int n,m,N;
struct op{ll x,y;}a[maxn];
struct node
{
    ll x;int id;
    bool operator <(const node& b){return x==b.x?id<b.id:x<b.x;}
}b[maxn];
vector<int>G[maxn<<2];
int id[maxn],iid[maxn<<2];
inline void built(int k,int l,int r)
{
    if(l==r){id[l]=k;iid[k]=l;Max(N,k);return ;}
    int mid=(l+r)>>1;
    built(ls,l,mid);built(rs,mid+1,r);
    G[k].push_back(ls);G[k].push_back(rs);
}
inline void connect(int k,int l,int r,int x,int y,int v)
{
    if(x<=l&&r<=y){G[v].push_back(k);return ;}
    int mid=(l+r)>>1;
    if(x<=mid)connect(ls,l,mid,x,y,v);
    if(y>mid)connect(rs,mid+1,r,x,y,v);
}
int dfn[maxn<<2],low[maxn<<2],inst[maxn<<2];
int zhan[maxn<<2],top,tot,cnt;
int vis[maxn<<2],bel[maxn<<2];
inline void Tarjan(int u)
{
    dfn[u]=low[u]=++cnt;zhan[++top]=u;inst[u]=1;
    for(int v:G[u])
    {
        if(!dfn[v])Tarjan(v),Min(low[u],low[v]);
        else if(inst[v])Min(low[u],dfn[v]);
    }
    if(dfn[u]!=low[u])return ;
    inst[u]=0;int v;++tot;
    while(zhan[top]!=u)
    {
        v=zhan[top--];inst[v]=0;
        bel[v]=tot;
    }--top;bel[u]=tot;
}
inline int check(int d)
{
    reg int i,l,r;cnt=0;--d;
    for(i=1;i<=N;++i)G[i].clear();
    built(1,1,m*2);
    for(i=1;i<=m;++i)
    {
        l=lower_bound(b+1,b+1+m,node{b[i].x-d,0})-b;
        r=lower_bound(b+1,b+1+m,node{b[i].x+d+1,0})-b-1;
        if(l<i)connect(1,1,m*2,l+m,i-1+m,id[i]);
        if(i<r)connect(1,1,m*2,i+1+m,r+m,id[i]);
    }
    for(i=1;i<=n;++i)
    {
        l=a[i].x;r=a[i].y;
        G[id[l]].push_back(id[r+m]);
        G[id[r+m]].push_back(id[l]);
        G[id[l+m]].push_back(id[r]);
        G[id[r]].push_back(id[l+m]);
    }
    /* for(i=1;i<=N;++i) */
    /* { */
    /*     cout<<iid[i]<<" "<<i<<":"; */
    /*     for(int v:G[i])cout<<v<<" "; */
    /*     cout<<"\n"; */
    /* } */
    /* cout<<"\n"; */
    /* for(i=1;i<=N;++i) */
    /* { */
    /*     for(int u:G[i])cout<<i<<" "<<u<<"\n"; */
    /* } */
    memset(dfn,0,sizeof dfn);
    memset(low,0,sizeof low);
    Tarjan(1);
    for(i=1;i<=m;++i)
        if(bel[id[i]]==bel[id[i+m]])
            return 0;
    return 1;
}
int main()
{
    n=read();reg int i,x,y;
    for(i=1;i<=n;++i)
    {
        x=read(),y=read();
        b[++m]=node{x,i},b[++m]=node{y,i};
    }
    sort(b+1,b+1+m);
    for(i=1;i<=m;++i)
    {
        if(vis[b[i].id])a[b[i].id].y=i;
        else vis[b[i].id]=1,a[b[i].id].x=i;
    }
    reg int l=0,r=1e9+1,mid;
    while(l<r-1)
    {
        mid=(l+r)>>1;
        if(check(mid))l=mid;
        else r=mid;
    }
    printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 30080
H, W = map(int, input().split())
input_list = []
for i in range(H):
    input_list.append(input())
def contain_sharp(x, y):
    if input_list[y][x] == ".": return True
    dxy = [[0,1], [0, -1], [1,0],[-1,0]]
    for dx,dy in dxy:
        if 0<= y + dy < H and 0 <= x + dx < W:
            if input_list[y+dy][x+dx] == "#":
                return True
    else :
        return False


for y in range(H):
    for x in range(W):
        if not contain_sharp(x,y):
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto i = (m).begin(); i != (m).end(); ++i)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

ll pow_(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = (x * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return x;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N;
  vector<ll> A;
  string I;
  cin >> I;
  ll M = 0;
  ll score;
  FOR(i, 0, I.size() - 2) {
    score = (int(I[i] - '0') * 100) + int(I[i + 1] - '0') * 10 +
            int(I[i + 2] - '0');
    if (abs(score - 753) < abs(M - 753))
      M = score;
  }
  cout << abs(M - 753) << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=1;i<=n;i++){
    cin >> a.at(i);
  }
  
  int cnt=0;
  for(int i=1;i<=n;i++){
    if(i % 2 == 1 && a.at(i) % 2 == 1){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return(0);
}

Measured memory_bytes: 3624
#include<cstdio>
using namespace std;
int n,a[101],ans=0x7fffffff;
int main()
{
	scanf("%d",&n);for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=-100;i<=100;++i) {
		int cnt=0;
		for(int j=1;j<=n;++j) cnt+=(a[j]-i)*(a[j]-i);
		if(cnt<ans) ans=cnt;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
int main() {
    int H, W;
    cin >> H >> W;
    
    char A[64];
    for (int i=0; i < H * W; ++i) cin >> A[i];
    
    int r = 0;
    
    string res = "Possible";
    
    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            if (A[w+h * W] == '#' && w < r) {
                res = "Impossible";
            }
            else if (A[w+h * W] == '#') r = w;
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC" <<endl;
	} else {
		cout << "ARC" <<endl;
	}

	return 0;
}



Measured memory_bytes: 256
"""
賢過ぎる解法.汎用性が高そう.
"""
from bisect import bisect

N = int(input())
inputs = [-int(input()) for _ in range(N)]

data = [inputs[0]]
for i in range(1, N):
    index = bisect(data, inputs[i])
    if index == len(data):
        data.append(inputs[i])
    else:
        data[index] = inputs[i]

print(len(data))

Measured memory_bytes: 7832
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int r,d;
  vector<ll> x(11);
  cin >> r >> d >> x[0];
  rep(i,10) {
    x[i+1] = x[i]*r - d;
  }
  rep(i,10) {
    cout << x[i+1] << endl;
  }
  return 0;
}

Measured memory_bytes: 512
using System;

namespace ABC066_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var n = s.Length;
            for (var i = n - 2; i >= 0; i -= 2)
            {
                if (s.Substring(0, i / 2) == s.Substring(i / 2, i / 2))
                {
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

template< typename T>
T mod_add(T a, T b, const T &p)
{
  a%=p;
  b%=p;
  return (a+b+p)%p;
}

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

    ll ans_ary[k+1];
    rep(i,k+1) ans_ary[i] = 0;

    for (ll i=k;i>0;i--)
    {
      ans_ary[i] = mod_pow(k/i,n,MOD);
      if (i*2<=k)
      {
        ll tmpn = 2;
        while(i*tmpn<=k)
        {
          ans_ary[i] -= ans_ary[i*tmpn];
          tmpn++;
        }
      }
    }
    ll ans = 0;
    rep(i,k)
    {
      ans = mod_add(ans, ans_ary[i+1]*(i+1), MOD);
      // cout << ans_ary[i+1] << " ";
    }
    // cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 4368
#include<bits/stdc++.h>
using namespace std;
#define MN 100000
struct P{int x,y;}p[MN*2+5];
bool cmp(const P&a,const P&b){return a.x<b.x;}
int u[MN+5];
int main()
{
	int n,i,x=0,y=0;long long ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d%d",&p[i].x,&p[i+n].x),p[i].y=i,p[i+n].y=-i;
	sort(p+1,p+n+n+1,cmp);
	for(i=1;i<=n;++i)ans+=p[i].x,x|=u[abs(p[i].y)]++,y|=1LL*p[i].y*p[i-1].y<0;
	printf("%lld",x||!y?ans:p[n].y==-p[n+1].y?ans+min(p[n+2].x-p[n].x,p[n+1].x-p[n-1].x):ans-p[n].x+p[n+1].x);
}

Measured memory_bytes: 2176
def main():
  import sys
  input = sys.stdin.readline
  n=int(input())
  h=list(map(int,input().split()))
  m=min(h)
  h.append(0)
  ans=m
  for i in range(0,n):
    if h[i]<=h[i+1]:
      continue
    else:
      ans+=h[i]-m
      m=h[i+1]
  print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 3060
use std::io;
use std::collections::HashMap;


/// https://beta.atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_qualb_b
fn main() {
    let _ = read_one::<usize>();
    let dn = read::<usize>();
    let _ = read_one::<usize>();
    let tm = read::<usize>();

    let mut hmd = HashMap::new();
    let mut hmt = HashMap::new();
    for d in &dn {
        *hmd.entry(d).or_insert(0) += 1;
    }
    for t in &tm {
        *hmt.entry(t).or_insert(0) += 1;
    }

    let mut flg = true;
    for t in hmt.keys() {
        if *hmd.get(t).unwrap_or(&0) < *hmt.get(t).unwrap() { flg = false; }
    }

    if flg { println!("YES"); }
    else { println!("NO"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 25784
// #include "bits/stdc++.h"
#include<iostream>
#include<algorithm>
#include<bitset>
#include<string>
#include<vector>
#include<string.h>

using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;


int dp[19][1 << 18];

int main() {
    input;
    int n;
    cin >> n;
    int a[n], b[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];

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

    }
    int ans = 1e9;
    for(int mask = 0; mask < (1 << n); mask++) {
        vector<pair<int, int>> v;
        vector<pair<int, int>> odd, even;
        for(int j = 0; j < n; j++) {
            if((1 << j) & mask) {
                if(j % 2)
                    even.push_back({b[j], j});
                else
                    odd.push_back({b[j], j});

            }
            else {
                if(j % 2)
                    odd.push_back({a[j], j});
                else
                    even.push_back({a[j], j});
            }
        }
        if(odd.size() != (n / 2))
            continue;
        sort(odd.begin(), odd.end());
        sort(even.begin(), even.end());
        int inv = 0;
        for(int i = 0; i < n; i++) {
            if(i % 2)
                v.push_back(odd[i / 2]);
            else
                v.push_back(even[i / 2]);
            if(i > 0) {
                if(v.back().first < v[i - 1].first)
                    inv = 1e9;
            }
        }
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                if(v[i].second > v[j].second)
                    inv++;
            }
        }
        ans = min(ans, inv);
        
    }

    cout << (ans == 1e9 ? -1 : ans);

}   

Measured memory_bytes: 256
n = int(input())

a = list(map(int,input().split()))

ans = 1

if 0 in a:
  ans = 0
else:
  for i in range(n):
    ans = ans * a[i]
    if ans > (10 ** 18): 
      break
      
if ans > (10 ** 18):
  print("-1") 
else:
  print(ans)

Measured memory_bytes: 21652
#include <bits/stdc++.h>
struct fastio { fastio() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _fastio_;
template<class T> bool chmin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
	int n, x, t;
	std::cin >> n >> x >> t;
	std::cout << (n + x - 1) / x * t << '\n';
	
	return 0;
}

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

#define NR 101000

vector<int> g[NR];
int n;

int dfs(int x, int fa) {
	int mask = 0;
	int top = -1;
	for (int v : g[x]) if (v != fa) {
		int s = dfs(v, x);
		for (int d = 20; d > top; --d) if ((mask >> d & 1) && (s >> d & 1)) { top = d; break; }
		mask |= s;
	}
	//printf("!%d %d %d\n", x, mask, top);
	for (++top; mask >> top & 1; ++top);
	if (top > 0) mask &= ~((1 << top) - 1);
	mask |= 1 << top;
	
	//printf("%d %d %d\n", x, mask, top);

	return mask;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v;
	
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int mask = dfs(1, 0), ans = 0;
	for (int i = 0; i < 20; ++i) if (mask >> i & 1) ans = i;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10240
#include<iostream>
#include<queue>
#include<bitset>
#include<algorithm>
#include<climits>
#include<vector>
#include<deque>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define dump(a) rep(i,a.size()){ cout<<a[i]<<" "; } cout<<endl;
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define INF INT_MAX/3
#define EPS 1e-7


int main(){
  ll n;
  ll a[100001];
  ll s=0; // sum
  cin>>n;
  rep(i,n){
    cin>>a[i];
    s+=a[i];
  }
  bool can = true;
  if((s*2) % (n*(n+1)) != 0) can = false;
  ll m=(s*2)/(n*(n+1)); // 総操作回数

  rep(i,n-1){
    if( (m + a[i] - a[i+1])%n != 0 || (m+a[i]-a[i+1])/n < 0 ) can = false;
  }
  if( (m + a[n-1] - a[0])%n != 0 || (m+a[n-1]-a[0])/n < 0 ) can = false;

  if(can) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include "iostream"
#include "string"
using namespace std;


int main(){
  string s;
  cin>>s;
  int d=0;
  for(int i=0;i<4;i++){
    if(s[i]==s[0]){
      d++;

    }
  }
  if((d==3)||((d==1)&&(s[1]==s[2]==s[3]))){
    cout<<"Yes"<<endl;
  }
  else if((d==2)){
    string h[2];
    int y=0;
    for(int i=1;i<4;i++){

      if(s[0]!=s[i]){
        h[y]=s[i];
        y++;

      }
    }
    if(h[0]==h[1]){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int A,B,C; cin>>A>>B>>C;
  string ans="No";
  if(C-A-B>=0&&4*A*B<(C-A-B)*(C-A-B)) ans="Yes";
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<iterator>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define lli long long int
#define mp make_pair
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define fo(i,n) for(lli i=0;i<(n);i++)
#define FO(i,x,n) for(lli i=(x);i<(n);i++)
#define pb push_back
#define vi vector<lli>
#define pi pair<lli,lli>
#define vii vector<pi >
#define Endl endl
#define ITA 200005
#define ROH 100005
#define deb(x) cout<<(#x)<<" "<<x<<endl
using namespace std;
lli mod = 1e9 +7,test; 
lli max(lli a,lli b){return a>b?a:b;}
lli min(lli a,lli b){return a>b?b:a;}




void solve(){

lli d,l,r;
cin>>l>>r>>d;
lli cnt = 0;
FO(i,l,r+1){
    if(i%d == 0){
        cnt++;
    }
}
cout<<cnt<<Endl;


}

int main(){
    ULTRA_INSTINCT;
    lli t =1;
    // cin>>t;
    fo(i,t){
        solve();
    }
    return 0;
}

 // #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

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


Measured memory_bytes: 3608
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  int n; rd(n);
  auto a=readln.split.to!(long[]);

  import std.container;
  alias Heap=RedBlackTree!(long, "a>b", true);
  Heap[] heap;
  foreach(_; 0..3) heap~=new Heap;
  foreach(i; 0..n) heap[0].insert(a[i]);
  foreach(i; (n*2)..(n*3)) heap[2].insert(a[i]);
  long score=a[0..n].sum-a[(n*2)..(n*3)].sum, best=score;
  foreach(i; n..(n*2)){
    if(a[i]<heap[2].front){
      score-=(a[i]-heap[2].front);
      best=max(best, score);
      heap[1].insert(heap[2].front);
      heap[2].insert(a[i]);
      heap[2].removeFront;
    }else{
      heap[1].insert(a[i]);
    }
  }
  // writeln(score, " ", best);
  foreach(i; n..(n*2)){
    if((heap[2].equalRange(a[i]).empty)==false){
      score+=(a[i]-heap[1].back);
      heap[2].insert(heap[1].back);
      heap[2].removeKey(a[i]);
      heap[1].removeBack;
    }else{
      assert((heap[1].equalRange(a[i]).empty)==false);
      heap[1].removeKey(a[i]);
    }
    // writeln(i, " ", score, " ", best);        
    if(heap[0].back<a[i]){
      score+=(a[i]-heap[0].back);
      heap[0].removeBack;
      heap[0].insert(a[i]);
    }
    best=max(best, score);
    // writeln(i, " ", score, " ", best);
    // foreach(k; 0..3) writeln(heap[k]);
  }
  writeln(best);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int cnt = 1, ans = 0;;
    while (cnt < b) {
        cnt--;
        cnt += a;
        ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,Q;
  string S;
  cin>>N>>Q>>S;
  vector<ll> vec(N);
  for(ll i=0;i<N-1;i++){
    if(S.at(i)=='A' && S.at(i+1)=='C'){vec.at(i+1)=vec.at(i)+1;}
    else{vec.at(i+1)=vec.at(i);}
  }
  for(ll i=0;i<Q;i++){
    ll a,b;
    cin>>a>>b;
    cout<<vec.at(b-1)-vec.at(a-1)<<endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int s=0;
	int m=n;
	while(m>0){
		s+=m%10;
		m/=10;
	}
	cout<<(n%s==0 ? "Yes" : "No")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  int N;
  vector<ll> A(1);
  cin >> N;
  cin >> A[0];
  REP(i,N-1){
    ll in;
    cin >> in;
    if(A.back() != in) A.pb(in);
  }
  int ans = 1;
  REPS(i,(int)(A.size())-2){
    if((A[i]-A[i-1])*(A[i+1]-A[i]) < 0){
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define pb push_back
#define fi first
#define se second
using namespace std ;
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
ll powmod(ll a, ll b) { ll ret = 1 ; while(b) { if(b&1) ret = (ret*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return ret ; }
const int maxn = 1e5 + 5 ;
int n ;
vi gph[maxn] ;
ll dp[maxn][2] ;
void dfs(int v, int p)
{
    for(auto u: gph[v])
    {
        if(u != p)
        {
            dfs(u, v) ;
            dp[v][1] = (dp[v][1]*dp[u][0])%mod ;
            dp[v][0] = (dp[v][0]*(dp[u][1] + dp[u][0]))%mod ;
        }
    }
}
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> n ;
    rep(i,0,n-2)
    {
        int u, v ;
        cin >> u >> v ;
        gph[u].pb(v) ;
        gph[v].pb(u) ;
    }
    rep(i,1,n)
    {
        dp[i][0] = 1 ;
        dp[i][1] = 1 ;
    }
    dfs(1,0) ;
    ll res = 0 ;
    res = (dp[1][0] + dp[1][1])%mod ;
    cout << res << "\n" ;
    return 0 ;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N, Y;
    cin >> N >> Y;
    for (int a = 0; a <= N; a++) {
        for (int b = 0; b <= N - a; b++) {
            lint c = N - (a + b);
            if (10000 * a + 5000 * b + 1000 * c == Y) {
                cout << a << ' ' << b << ' ' << c << endl;
                return 0;
            }
        }
    }

    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll h, w; cin >> h >> w;
    ll c[10][10];
    REP(i, 10) REP(j, 10) cin >> c[i][j];
    vector<vector<ll>> a(h, vector<ll>(w, 0));
    REP(i, h) REP(j, w) cin >> a[i][j];

    REP(k, 10) REP(i, 10) REP(j, 10)
        chmin(c[i][j], c[i][k] + c[k][j]);

    ll ans = 0;
    REP(i, h) REP(j, w) {
        if (a[i][j] >= 0) {
            ans += c[a[i][j]][1];
        }
    }
    cout << ans << endl;
    
}

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

int main(){
  int l,r,d;
  cin >> l >> r >> d;
  
  int cnt = 0;
  for(int i=l; i<=r; i++){
    if(i%d == 0) cnt++;
  }
  
  cout << cnt << endl;

}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main()
{
  int c, t = 0, h = 0;
  cin >> c;
  rep(i, c)
  {
    string a, b;
    cin >> a >> b;
    int res = a.compare(b);
    if (res > 0)
    {
      t += 3;
    }
    else if (res < 0)
    {
      h += 3;
    }
    else
    {
      t++;
      h++;
    }
  }
  cout << t << ' ' << h << endl;
  return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  map<string, int> mp;
  rep(i,0,N) {
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<string> vec = {"AC", "WA", "TLE", "RE" };
  for(auto s: vec) {
    cout << s << " x " << mp[s] << endl;
  }
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if (a < b){
		cout <<"a < b"<< endl;
	}
	else if (a > b){
		cout << "a > b"<< endl;
	}
	else if (a == b){
		cout <<"a == b"<< endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  ll N;
  cin>>N;
  vector<vector<ll>> A(N,vector<ll>(N-1));
  cin>>A;
  vector<ll> idx(N,0);
  for(auto &I:A){
    for(auto &J:I){J--;}
  }
  vector<ll> dp;
  vector<ll> nx;
  for(int i=0;i<N;i++){
    if(A[A[i][0]][0]==i){dp.push_back(i);}
  }
  ll ans=0;
  int cnt=0;
  while(cnt<N){
    ans++;
    for(auto &I:dp){
      idx[I]++;
      int num=idx[I];
      if(num==N-1){cnt++; continue;}
      int en=A[I][num];
      assert(idx[en]<N);
      if(A[en][idx[en]]==I){
        nx.push_back(I);
        nx.push_back(en);
      }
    }
    dp.clear();
    swap(dp,nx);
    if(cnt<N && dp.empty()){cout<<-1<<endl; return 0;}
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 10112
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for (auto &e : a) std::cin >> e;
	
	std::sort(a.begin(), a.end(), std::greater<int>{});
	int point = 0;
	for (int i = 0; i < n; i++) {
		point += i % 2 ? -a[i] : a[i];
	}
	
	std::cout << point << std::endl;
	
	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define F first
#define S second
int n,T;
pii a[3005];
int dp[3005][6005];
int main()
{
	cin>>n>>T;
	for (int i=1;i<=n;++i) cin>>a[i].F>>a[i].S;
	sort(a+1,a+n+1);
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for (int i=0;i<n;++i){
		for (int t=0;t<T;++t){
			if (dp[i][t]<0) continue;
			dp[i+1][t]=max(dp[i+1][t],dp[i][t]);
			dp[i+1][t+a[i+1].F]=max(dp[i+1][t+a[i+1].F],dp[i][t]+a[i+1].S);
		}
		for (int t=T;t<6003;++t) dp[i+1][t]=max(dp[i+1][t],dp[i][t]);
	}
	int ans=0;
	for (int t=0;t<6003;++t) ans=max(ans,dp[n][t]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 70784