akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include <iterator>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<cstdint>
#include<chrono>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

using namespace std;



signed main() {

	int N;
	cin >> N;
	vector<pair<int, int>>BA;
	rep(i, N) {
		int A, B;
		cin >> A >> B;
		BA.push_back(make_pair(B, A));
	}
	sort(ALL(BA));

	int time = 0;
	rep(i, N) {
		time += BA[i].second;
		if (BA[i].first < time) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
	// your code goes here
	ll n, w;
	cin >> n >> w;
	vector<vector<ll> > dp(n+1, vector<ll>(1e5+1, w+1));
	dp[0][0]=0;
	for(ll i=0; i<n; i++){
		ll weight, value;
		cin >> weight >> value;
		for(ll j=0; j<=1e5; j++){
			if(j+value<=1e5)
				dp[i+1][j+value]=min(dp[i+1][j+value], dp[i][j]+weight);
			dp[i+1][j]=min(dp[i][j], dp[i+1][j]);
		}
	}
	ll ans=(ll)INT_MIN;
	for(ll j=0; j<=1e5; j++)
		if(dp[n][j]<=w)
			ans=max(ans, j);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80256
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public void main() {
        Scanner sc = new Scanner(new InputStreamReader(System.in));

        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a > b) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        println(Math.max(b - (a + w), 0));
    }

    public void print(Object o) {
        System.out.print(o);
    }

    public void println(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        new Main().main();
    }
}


Measured memory_bytes: 21716
<?php

fscanf(STDIN, '%d', $n);
for ($i = 0; $i < $n; $i++) {
    $line = trim(fgets(STDIN));
    $arr = str_split($line);
    sort($arr);
    $min = (int)implode('', $arr);
    rsort($arr);
    $max = (int)implode('', $arr);
    echo $max - $min, PHP_EOL;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		int ans = 0;
		out:
		for (int i = a; i <= b; i++) {
			char[] s = Integer.toString(i).toCharArray();

			for (int j = 0; j < s.length / 2; j++) {
				if (s[j] != s[s.length - 1 - j]) {
					continue out;
				}
			}

			ans++;
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 30420
#include <iostream>
#include <vector>
 
void printArray(std::vector<int> a) {
  int n = (int)a.size();
  for (int i = 0; i < n; i++) {
    std::cout << a[i] <<std::endl; 
  }
}
 
int insertionSort(std::vector<int> &a, int g) {
  int cnt = 0, n = (int)a.size();
  for (int i = g; i < n; i++) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j = j - g;
      cnt++;
    }
    a[j + g] = v;
  }
  return cnt;
}
 
int shellSort(std::vector<int> &a) {
  std::vector<int> g;
  for (int i = 1; i <= (int)a.size(); i = i * 3 + 1) {
    g.push_back(i);
  }
  int m = (int)g.size();
  std::cout << m << std::endl;
 
  int cnt = 0;
  for (int i = m - 1; i >= 0; i--) {
    cnt += insertionSort(a, g[i]);
 
    std::cout << g[i];
    if (i > 0)
      std::cout << " ";
    else
      std::cout << std::endl;
  }
 
  return cnt;
}
 
int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
 
  std::cout << shellSort(a) << std::endl;
  printArray(a);
}


Measured memory_bytes: 10768
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  var read = 0;
  var resultCase = 1;
  while(true){
    var maxWeight = +input[read++];
    if(!maxWeight){
      break;
    }
    
    var treasures = +input[read++];
    var pdp = new Int32Array(maxWeight + 1);
    for(var i = treasures; i--;){
      var c = input[read++].split(",");
      var tv = +c[0];
      var tw = +c[1];

      var dp = new Int32Array(maxWeight + 1);

      for(var w = 1; w < tw; w++){
        dp[w] = pdp[w];
      }
      
      for(var w = tw; w <= maxWeight; w++){
        dp[w] = max(pdp[w-tw] + tv, pdp[w]);
      }
      pdp = dp;
    }

    var resultWeight = 1001;
    var resultCost = 0;
    for(var i = 0; i <= maxWeight; i++){
      if(pdp[i] > resultCost){
        resultCost = pdp[i];
        resultWeight = i;
      }
    }
    
    console.log("Case " + resultCase++ + ":\n" + resultCost + "\n" + resultWeight);
  }
}

function max(a, b) {
  var t = a - b;
  return a - (t & (t >> 31));
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int k;
    cin >>k;
    vector<string> I(k), N(k);
    rep(i,k) cin >>I[i];
    rep(i,k) cin >>N[i];

    int res=-1;
    int pi=0, pn=0;
    rep(i,k)
    {
        // printf("Power: I.%d N.%d\n", pi,pn);

        int ai,an;
        if(I[i][0]=='m') ai=0;
        else if(I[i][0]=='t') ai=1;
        else if(I[i][0]=='k') ai=2;
        if(N[i][0]=='m') an=0;
        else if(N[i][0]=='t') an=1;
        else if(N[i][0]=='k') an=2;

        bool zero_i=false, zero_n=false;

        // printf("ai:%d, an:%d\n", ai,an);

        if(ai==0)
        {
            if(an==2 && pn==5)
            {
                res=1;
                break;
            }
        }
        else if(ai==1)
        {
            pi=min(pi+1,5);
            if(an==2 && pn>0)
            {
                res=1;
                break;
            }
        }
        else
        {
            if(an==2 && pi<pn)
            {
                res=1;
                break;
            }

            if(pi==0) zero_i=true;
        }

        if(an==0)
        {
            if(ai==2 && pi==5)
            {
                res=0;
                break;
            }
        }
        else if(an==1)
        {
            pn=min(pn+1,5);
            if(ai==2 && pi>0)
            {
                res=0;
                break;
            }
        }
        else
        {
            if(ai==2 && pn<pi)
            {
                res=0;
                break;
            }

            if(pn==0) zero_n=true;
        }

        if(zero_n || zero_i)
        {
            if(zero_n && zero_i) continue;
            if(zero_n) res=0;
            if(zero_i) res=1;
        }

        if(res!=-1) break;

        if(ai==2) pi=0;
        if(an==2) pn=0;
    }

    string ans="Hikiwake";
    if(res==0) ans="Isono";
    else if(res==1) ans="Nakajima";
    cout << ans+"-kun" << endl;
    return 0;
}

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

struct TRAMP{
    char mark;
    int number;
};

int main(){
    int n,min;
    char buf[3];
    scanf("%d",&n);

    TRAMP selectArray[n],bubbleArray[n];

    for(int i=0;i<n;i++){
        scanf("%s",&buf);
        selectArray[i].mark=buf[0];
        selectArray[i].number=buf[1]-'0';
        bubbleArray[i]=selectArray[i];
    }

    for(int i=n-1;i>=0;i--){
        for(int j=0;j<i;j++){
            if(bubbleArray[j].number>bubbleArray[j+1].number)swap(bubbleArray[j],bubbleArray[j+1]);
        }
    }

    for(int i=0;i<n-1;i++){
        min = i;
        for(int j=i+1;j<n;j++){
            if(selectArray[j].number<selectArray[min].number)min=j;
        }
        if(i != min)swap(selectArray[i],selectArray[min]);
    }

    for(int i=0;i<n-1;i++)printf("%c%d ",bubbleArray[i].mark,bubbleArray[i].number);
    printf("%c%d\n",bubbleArray[n-1].mark,bubbleArray[n-1].number);
    printf("Stable\n");
    for(int i=0;i<n-1;i++)printf("%c%d ",selectArray[i].mark,selectArray[i].number);
    printf("%c%d\n",selectArray[n-1].mark,selectArray[n-1].number);

    int p;
    for(p=0;p<n;p++){
        if(selectArray[p].number != bubbleArray[p].number || selectArray[p].mark != bubbleArray[p].mark)break;
    }
    if(p==n)puts("Stable");
    else{puts("Not stable");}
    return 0;
}


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

const int INF = 1012345678;

int main()
{
	int n = 0;
	cin >> n;
	string ans = "";
	int a = n;
	int x = 0;
	while (n > 0)
	{
		x += n % 10;
		n /= 10;
	}
	ans = a % x == 0 ? "Yes" : "No";

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
int a[N],b[N],c[N];

signed main()
{
	int n=read()+1;
	for (int i=1;i<=n;i++) a[i]=read();
	b[n]=c[n]=a[n];
	if (n==0)
	{
		if (a[1]==1) puts("1");
				else puts("-1");
		return 0;
	}
	for (int i=n-1;i>=1;i--)
	{
		c[i]=a[i]+(c[i+1]+1)/2;
		b[i]=a[i]+b[i+1];
	}
	if (c[1]>1)
	{
		puts("-1");
		return 0;
	}
	int ans=1,cnt=1;
	for (int i=2;i<=n;i++)
	{
		cnt-=a[i-1];
		cnt=min(cnt*2,b[i]);
		ans+=cnt;
	}
	print(ans);

	return 0;
}

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

#define ll long long

using namespace std;

ll n, a[int(1e5) + 4], sol;

int main() {
    cin >> n;
    for (int i = 1; i <= n + 1; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i) {
        ll b;
        cin >> b;
        sol += min(b, a[i]);
        b -= min(b, a[i]);
        sol += min(b, a[i + 1]);
        a[i + 1] -= min(b, a[i + 1]);
    }

    cout << sol;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}

ll n;



    vector<pair<ll,ll>>p;
void fs(ll a){
    for(ll i=2;i*i<=n;i++){
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        p.emplace_back(i,cnt);
    }
    return;
}


ll di[]={1,0,-1,0};
ll dj[]={0,-1,0,1};
int main(){
   int n;
   cin>>n;
    long long int a[n],ans=0,i;
    int mod=1000000007;
    long long int sum=0;
 
    for( i = 0 ; i < n ; i++ ){
            cin>>a[i];
        sum = sum + a[i];
    }
    for( i = 0 ; i < n ; i++ ){
        sum = sum - a[i];
 
        ans+=(sum%mod * a[i]%mod)%mod;
    }
    cout<<ans%mod;
 
    return 0;
}
 




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


vector<ll> amari,imos;
int idx;

void inc()
{
	amari[idx+1] += imos[idx+1];
	imos[idx+2] += imos[idx+1];
	idx++;
}

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n+1);

	for(auto &i:a)cin >> i;
	//ll ans = 0;

	ll now = 1;
	ll pre = 0;
	
	vector<ll> mx(n+1);//iのときの最大の頂点数
	mx[n] = a[n];
	for(int i = n-1;i>=0;i--)
	{
		mx[i] = max(a[i],mx[i+1]);
	}
	amari = vector<ll>(n+5,1);
	imos = vector<ll>(n+5,0);
	idx = 1;
	ll ans = n+1;
	a[n] --;
	amari[0]=0;
	
	for(int i = 0;i<n+1;i++)
	{
		while(a[i])
		{
			ll x = min(a[i],amari[idx]);
			a[i] -= x;
			amari[idx]-=x;
			imos[idx+1]+=x;
			//imos[i+1] += x;
			imos[i+1] -= x;
			ans += (i-idx+1)*x;
			if(amari[idx]==0)inc();
			if(idx>i+1){cout<<-1<<endl;return 0;}
		}
		//cout<<ans<<endl;
	}

	inc();
	inc();
	//for(auto i:amari)cout<<i<<' ';cout<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (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);
}
struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
void aoj(vector<int> bs) {
    REP(i, bs.size() - 1) { cout << bs[i] << " "; }
    cout << bs[bs.size() - 1] << endl;
}

signed main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (a == 0) {
        cout << 1 << endl;
        return 0;
    }
    if (b == 0) {
        cout << 2 << endl;
        return 0;
    }
    if (c == 0) {
        cout << 3 << endl;
        return 0;
    }
    if (d == 0) {
        cout << 4 << endl;
        return 0;
    }
    if (e == 0) {
        cout << 5 << endl;
        return 0;
    }
}


Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int l = s.length();
	bool flag = true;
	for (int i = 0; i <= l; i++) {
		for (int j = i + 1; j <= l; j++) {
			if (s[i] == s[j]) flag = false;
		}
	}
	if (flag == true) {
		cout << "yes" << endl;
	} else {
		cout << "no" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  int x=M/N;
  int ans;
  for(int i=x;0<i;i--){
  if(M%i==0){ans=i; break;}
  
  }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long tot=1;
	long long now=1;
	while(n>1){
		now*=2;
		tot+=now;
		n/=2;
	}
	cout<<tot<<endl;
	return 0;
}

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

int main() {
    int d;
    cin>>d;
    if (d==22) {
        cout<<"Christmas Eve Eve Eve"<<endl;
    } else if(d==23) {
        cout<<"Christmas Eve Eve"<<endl;
    } else if(d==24) {
        cout<<"Christmas Eve"<<endl;
    } else {
        cout<<"Christmas"<<endl;
    }
}


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

using namespace std;
int ans;
struct Grid {
    const int direction[5] = {0, -1, 0, 1, 0};
    vector<string> grid;
    int height, width;
    const char blockChar = '#';
    Grid(int h, int w, vector<string> &s) {
        height = h;
        width = w;
        grid = s;
    }
    int bfs(int i, int j) {
        vector<bool> passed(height * width);
        queue<pair<int, int>> q;
        if (grid[i][j] == blockChar) return 0;
        q.push({i, j});
        int dist = 0;
        passed[i * width + j] = true;
        while (!q.empty()) {
            ++dist;
            int size = q.size();
            while (size--) {
                auto fi = q.front().first, fj = q.front().second;
                q.pop();
                for (int d = 0; d < 4; ++d) {
                    if (fi + direction[d] < 0 || fi + direction[d] >= height) continue;
                    if (fj + direction[d + 1] < 0 || fj + direction[d + 1] >= width) continue;
                    if (passed[(fi + direction[d]) * width + fj + direction[d + 1]]) continue;
                    if (grid[fi + direction[d]][fj + direction[d + 1]] == blockChar) continue;
                    q.push({fi + direction[d], fj + direction[d + 1]});
                    passed[(fi + direction[d]) * width + fj + direction[d + 1]] = true;
                }
            }
        }
        return --dist;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    queue<pair<int, int>> q;
    for (auto &s : S) cin >> s;
    auto g = Grid(H, W, S);
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            ans = max(ans, g.bfs(i, j));
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

s=input()
t=input()
count=0
for i in range(3):
    if s[i:i+1]==t[i:i+1]:
        count+=1
print(count)


Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = 0;
		for(int i = 0 ; i < 10 ;i++){
			int a = sc.nextInt();
			p += a;
		}
		System.out.println(p);
		sc.close();
	}

}

Measured memory_bytes: 17180
from fractions import gcd

A, B, C, D = map(int, input().split())

lcm = (C * D) // gcd(C, D)

A -= 1
numA = A - (A // C + A // D - A // lcm)
numB = B - (B // C + B // D - B // lcm)

print(numB - numA)


Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ll const con = 1000000000000000000;

int main() {
    int n; cin >> n;
    vector<ull> vec(n);
    ll ans = 1;
    bool zero = true;
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
        if (vec.at(i) == 0) zero = false;
    }

    if(zero) {
        for (int i = 0; i < n; i++) {
            if(vec.at(i) <= con / ans) ans *= vec.at(i);
            else {
                ans = -1;
                break;
            }
        }
        cout << ans << endl;
    }
    else cout << '0' << endl;
}

Measured memory_bytes: 4016
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		for(;;)
		{
			int N = sc.nextInt();
			if (N==0) break;
			
			int[] S = new int[N];
			for (int i = 0; i < N; i++) S[i] = sc.nextInt();
			Arrays.sort(S);
			int sum = 0;
			for (int i = 1; i < N - 1; i++) sum += S[i];
			System.out.println(sum / (N - 2));
		}
	}
}

Measured memory_bytes: 12000
n, m = gets.split.map!(&:to_i)
hgts = gets.split.map!(&:to_i).unshift(nil)

nbrs = Array.new(n + 1) { [] }
m.times do
  a, b = gets.split.map!(&:to_i)
  ha, hb = hgts[a], hgts[b]
  nbrs[a] << b if ha <= hb
  nbrs[b] << a if hb <= ha
end

puts nbrs.drop(1).count(&:empty?)

load __FILE__ unless $stdin.eof?


Measured memory_bytes: 25032
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    writeln((lread() - lread()) % lread());
}


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

int main() {
    int N;
    int T;
    int A;
    cin >> N >> T >> A;
    vector<double> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H.at(i); 
    }
    for (int i = 0; i < N; i++)
    {
        H.at(i) = A - ( T - H.at(i) * 0.006);
        if(H.at(i)<0) H.at(i) *= -1;
    }
    int ans = 1;
    double tmp = H.at(0);
    for (int i = 1; i < N; i++)
    {
        if(tmp > H.at(i)){
            tmp = H.at(i);
            ans = (i+1);
        }
    }
    cout << ans << endl;
}

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

typedef long long int ll;


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	
	ll n;
	cin>>n;
	
	ll ans = 0;
	
	for(ll i=1;i<=n;i++)
	{
		ll z = 0;
		ll y = i;;
		while(y>0)
		{
			z++;
			y = y/10;
		}
		if(z%2==1)ans++;
		
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>a(N), b(N);
	int suma = 0;
	int sumb = 0;
	rep(i, N)cin >> a[i];
	rep(i, N)suma += a[i];
	rep(i, N)cin >> b[i];
	rep(i, N)sumb += b[i];
	int num = sumb - suma; //操作回数
	int A = 0, B = 0;
	rep(i, N) {
		int sa = a[i] - b[i];
		if (sa > 0) {
			B += sa;
		}
		else if (sa < 0) {
			sa *= -1;
			if (sa & 1) {
				B++;
				sa++;
			}
			A += sa / 2;
		}
	}
	if (A <= num && B <= num && (num - A) * 2 == num - B)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 384
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = input()
    print("ABC" + N)


if __name__ == '__main__':
    main()


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

int main()
{
	unsigned int n,y;
	bool flg;


	string s, t = "", cnd[4] = { "eraser","erase","dreamer","dream" },ret;
	cin >> s;

	for (int i = 0; i < 4; i++) {
		while ((int)s.find(cnd[i]) >= 0) {
			s= s.erase((int)s.find(cnd[i]),cnd[i].length());
		}
	}
	if (s.length() == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long n,i,c=0,k;
 cin>>n;
 for(i=1;i<=n;i++)
 {
    cin>>k;
    if(k%2==1 && i%2==1) c++;
 }
 cout<<c<<endl;
 return 0;

}


Measured memory_bytes: 3552
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
a.sort(key=lambda x:x[1])

cost = [0 for i in range(n+1)]
time = [0 for i in range(n+1)]
for i in range(1,n+1):
  cost[i] = cost[i-1] + a[i-1][0]
  time[i] = a[i-1][1]

flag = True
for c, t in zip(cost, time):
  if c > t:
    flag = False
    break
print("Yes" if flag else "No")

Measured memory_bytes: 59908
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll A, B, C;
	cin >> A >> B >> C;

	cout << min(A*B*(C % 2), min(B*C*(A % 2), A*C*(B % 2)));





}


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


#define N_MAX 100005
#define len 10

typedef struct task{
  char name[len];
  int time;
}T;



int main(void){
  int i,n,q,take=0,head,tail;
  T Q[N_MAX];

  scanf("%d %d",&n,&q);//入力
  

  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].time);
  }

  head=1;
  tail=n+1;

  while(head!=tail){
    if(Q[head].time<=q && Q[head].time!=0){
      take+=Q[head].time;
      printf("%s %d\n",Q[head].name,take);
      if(head==N_MAX-1) head=0;            
    }
    
    else {
      take+=q;
      Q[head].time-=q;
      Q[tail]=Q[head];//引いた値を最後尾へ
      if(head==N_MAX-1) head=0;
      if(tail==N_MAX-1) tail=0;
      tail++; 
    }
    head++;
  }

  
  return 0;
}



Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int a, b, N;
    cin >> a >> b >> N;
    int s[N], f[N];
    for (int i = 0; i < N; i++) {
        cin >> s[i] >> f[i];
    }
    for (int i = 0; i < N; i++) {
        if (b <= s[i] || f[i] <= a) continue;
        cout << "1\n";
        return 0;
    }
    cout << "0\n";
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];


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


ll nCr(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll nHr(ll n, ll r) { if (n == 0 && r == 0) return 1; else return nCr(n + r - 1, r); }
ll nPr(ll n, ll r) { if (r < 0 || n < r) return 0; else return (fac[n] * finv[n-r]) % MOD; }


int main(){
    ll n, m; cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    ll ans = fac[n]*fac[m] % MOD;
    if(n == m) MUL(ans, 2);
    cout << ans << endl;
}


Measured memory_bytes: 15564
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let s = read_line().split("").map(|e|e.parse().unwrap())
	.collect::<Vec<String>>();
	if (s[1] == s[2] && s[2] == s[3]) || (s[2] == s[3] && s[3] == s[4]){
		println!("Yes")
	}else{
		println!("No");
	}
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
//#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef vector<string> vi;
typedef pair<int,int> pi;

      ll bigmod ( long long a, int p, int m )
{
    if ( p == 0 )return 1; // If power is 0 ( a ^ 0 ), return 1

    if ( p & 1 ) // If power is odd
    {
        return ( ( a % m ) * ( bigmod ( a, p - 1, m ) ) ) % m;
    }
    else
    {
        long long tmp = bigmod ( a, p / 2, m );
        return ( tmp * tmp ) % m;
    }
}

int main()
{
         //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
           int t=1,caseno = 0;

   // scanf("%d",&t);

     while(t--){

      ll a,b;
      cin >> a >> b;

       for(int i  = 1; i<=100000; i++){
        if((i*8)/100==a && (i*10)/100==b){
            cout << i << endl;
            return 0;
        }
       }
       cout << "-1" << endl;

    }

    return 0;
}



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

int main(){
    int a;
    scanf("%d",&a);
    int b;
    for(int e = 1;;e++){
        if(a <= 100 * e + 10 * e + e ){
            b = e;
            break;
        }

    }

    printf("%d\n",100 * b + 10 * b + b);
}

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

#define INF (1 << 28)
#define BIT(x) (1ull << (x))
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define PQ(t) priority_queue<t>
#define PQL(t) priority_queue<t, vector<t>, greater<t> >
#define MP make_pair
#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define UNIQ(v) do {sort(ALL(v)); (v).erase(unique(ALL(v)), (v).end());} while (0)
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b; return true;} return false;}

int main()
{
	int sum = 0;
	REP(i, 10){
		int a;
		scanf("%d", &a);
		sum += a;
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 1188
/* e */
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int n;
long long m, ans;

int a[N];
long long psum[N];

bool check(int mid) {
	int r = n;
	long long cnt = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] + a[i] < mid) break;
		while(r > i && a[r] + a[i] < mid) --r;
		if(r >= i) {
			++cnt;
			cnt += (r - i) << 1;
		}
	}
	return cnt >= m;
}

int main() {
	scanf("%d%lld", &n, &m);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n, greater<int>());
	for(int i = 1; i <= n; ++i) psum[i] = a[i] + psum[i - 1];
	int l = 1, r = 2e5, mid, mpos = l;
	while(l <= r) {
		mid = l + r >> 1;
		if(check(mid)) {
			if(mid > mpos) mpos = mid;
			l = mid + 1;
		} else {
			r = mid - 1;
		}
	}
	r = n;
	long long cnt = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] + a[i] <= mpos) break;
		while(r > i && a[r] + a[i] <= mpos) --r;
		if(r >= i) {
			++cnt;
			cnt += (r - i) << 1;
			ans += (psum[r] - psum[i - 1]) << 1;
			ans += 1LL * a[i] * ((r - i) << 1);
		}
	}
	ans += (m - cnt) * mpos;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  char a,b;
  cin >> a >> b;

  if(a > b){
    cout << ">" << endl;
  }else if(a < b){
    cout << "<" << endl;
  }else{
    cout << "=" << endl;
  }
    
  return 0;
}


Measured memory_bytes: 256
/*
    JAI JAGANNATH!
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

void ss()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
string help(lli n) {
	if (n == 0) {
		return "";
	}
	return help((n - 1) / 26) + (char)('a' + (n - 1) % 26);
}
void solve() {
	lli n;
	cin >> n;
	cout << help(n) << endl;
}
int main()
{
	ss();
	solve();
	return 0;
}

Measured memory_bytes: 3656
# coding: utf-8
N = int(input())
D = list(map(int, input().split()))
l = [0] * N
top = max(D)
mod = 998244353

for i in range(N):
    l[D[i]] += 1
# print(*l)
ans = 1
for i in range(1, top+1):
    if l[i] != 0:
        ans *= l[i-1] ** l[i]
    if l[i] == 0:
        print(0)
        exit()
    ans = ans % mod
if D[0] != 0:
    ans = 0
if l[0] != 1:
    ans = 0
    

print(ans)

Measured memory_bytes: 53300
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {
	string s;
	int k;
	cin >> s >> k;
	vector<string> a;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 1; i + j <= s.size(); j++) {
			if (j < 6) {
				a.push_back(s.substr(i, j));
			}
		}
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());

	cout << a.at(k-1) << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector <int> vec(n);
  for (int i = 0; i < n; i++){
  cin >> vec.at(i);
  }
  int count = 0;
  for (int i = 0; i < n-2; i++){
  if(vec.at(i) <= vec.at(i+1) && vec.at(i+2) >= vec.at(i+1)){
  count += 1;
  }else if(vec.at(i) >= vec.at(i+1) && vec.at(i+2) <= vec.at(i+1)){
    count += 1;
  }
  }
  cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
 
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int dp[11][353];

// int dfs(int cnt, int msk, int cur){
//   if(cnt>10 || cur>330) return 0;
//   if(cnt == 0) return (cur==0?1:0);
//   if(dp[cnt][cur][msk] != -1) return dp[cnt][cur][msk];
//   dp[cnt][cur][msk] = 0;
//   REP(i,10){
//     if(msk&(1<<i))continue;
//     int nmsk = msk | (1<<i);
//     int ncur = cur - cnt*i;
//     if(ncur >= 0)
//       dp[cnt][cur][msk] += dfs(cnt-1,nmsk,ncur);
//   }
//   return dp[cnt][cur][msk];
// }

int main(){
  vi ar(10);
  REP(i,10)ar[i]=i;
  do{
    int sum = 0;
    REP(i,10){
      sum += ar[i]*(i+1);
      ++dp[i+1][sum];
    }
  }while(next_permutation(ALL(ar)));
  int perm[11];
  perm[0] = 1;
  REPR(i,11)perm[i]=perm[i-1]*i;
  REPR(i,11)REP(j,353)dp[i][j]/=perm[10-i];
  int n,s;
  while(~scanf("%d%d",&n,&s)){
    if(n>10 || s>330){
      cout<<0<<endl;
    }else{
      cout<<dp[n][s]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
 
int dic(char c1[],char c2[]){
  int a=0,i=0;
  while(1){
    if(c1[i]<c2[i])return 1;
    if(c1[i]>c2[i])return 2;
    if(c1[i]=='\0'&&c2[i]=='\0')return 0;
    if(c1[i]=='\0')return 1;
    if(c2[i]=='\0')return 2;
    i++;
  }
  return 0;
}
 
int main(){
  int n,p1=0,p2=0,i,a;
  char c1[102],c2[102];
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",&c1);
    scanf("%s",&c2);
    a=dic(c1,c2);
    if(a==0){
      p1+=1;
      p2+=1;
    }else if(a==1)p2+=3;
    else p1+=3;
  }
  printf("%d %d\n",p1,p2);
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main () {
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
   ll sum=0;
   ll n;
   cin>>n;
   for (ll i=1;i<=n;i++){
    for (ll j=1;j<=n;j++){
        for (ll d=1;d<=n;d++){
            sum+=__gcd(__gcd(i,j),d);
        }
    }
   }
   cout<<sum;
return 0;
}


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

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

using namespace std;

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> P;

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

	int k;
	cin >> k;

	int g[k+1];
	rep(i,k+1) g[i] = INF;

	g[1] = 0;

	
	// dijkstra

	priority_queue<P,vector<P>,greater<P> > q;
	q.push(P(0,1));

	while(!q.empty()){
		P p = q.top();
		q.pop();

		if(p.first > g[p.second]) continue;
		
		int i = p.second;
		if(g[(i+1)%k] > p.first + 1){
			g[(i+1)%k] =  p.first + 1;
			q.push(P(g[(i+1)%k],(i+1)%k));
		}

		if(g[(i*10)%k] > p.first){
			g[(i*10)%k] =  p.first;
			q.push(P(g[(i*10)%k],(i*10)%k));
		}
	}

	cout << (g[0] + 1) << endl;
}

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

int main(){

    int m,n_min,n_max,gap,temp_gap,n;
    int p[200];

    while(cin>>m>>n_min>>n_max,m||n_min||n_max){

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

        gap=p[n_min-1]-p[n_min];

        for(int i=n_min;i<=n_max;i++){
            temp_gap=p[i-1]-p[i];
            if(temp_gap>=gap){
                gap=temp_gap;
                n=i;
            }
        }

        cout<<n<<endl;
    }

    

    return 0;

}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    if (a[n - 1] == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (n % 3 != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    int N = n / 3;
    if (a[N - 1] == 0 && a[N] == a[3 * N - 1])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (a[0] == a[N - 1] && a[N] == a[2 * N - 1] && a[2 * N] == a[3 * N - 1] && (a[0] ^ a[N] ^ a[2 * N]) == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#include <queue>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    fast_io();

    int n,k,ai;
    std::cin >> n >> k;
    rep(i,n){
        std::cin >> ai;
    }
    std::cout << (n-1+k-1-1)/(k-1) << "\n";
    return 0;
}


Measured memory_bytes: 3652
n =int(input())
l = list(map(int,input().split()))

def check_tri(x):#x==[a,b,c]
  x = sorted(x)
  #print("sort",x)
  if x[0]==x[1] or x[0]==x[2] or x[1]==x[2]:
    return 0
  elif x[2]<x[0]+x[1]:
    return 1
  else:
    return 0
s = 0
for i in range(0,n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a,b,c = l[i],l[j],l[k]
      #print(i,j,k)
      x =check_tri([a,b,c])
      #print("ch",x)
      s+=x
print(s)

Measured memory_bytes: 9004
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

using ll = long long;

int main()
{
	
	
	int N, M;
	cin >>N>>M;
	ll a[105];

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

	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		sum += a[i];
	}

	int c = 0;
	double v = sum / (4 * M);
	for (int i = 0; i < N; i++)
	{
		if (a[i] >= v)
			c++;
		if (c >= M) {
			cout<<"Yes";
			return 0;
		}
	}

	

	cout<<"No";
	

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c = map(int, input().split())
ans = c-(a-b)
if ans < 0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 60012