akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
int main(){

  int n,a[10001]={},t;
  vector <int> res;
  cin>>n;
  for(int i=0;i<n&&cin>>t;i++) a[t]++;
  for(int i=0,cnt=0;i<10001;i++) for(;a[i];a[i]--){
      if(cnt) cout<<" "<<i;
      else cout<<i;
      cnt++;
    }
  cout<<endl;
  return 0;

}



Measured memory_bytes: 3152
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int sx, sy, tx, ty;
  cin>>sx>>sy>>tx>>ty;
  string ans = "";
  for(int i=0;i<ty-sy;++i) ans += 'U';
  for(int i=0;i<tx-sx;++i) ans += 'R';
  for(int i=0;i<ty-sy;++i) ans += 'D';
  for(int i=0;i<tx-sx;++i) ans += 'L';
  ans += 'L';
  for(int i=0;i<=ty-sy;++i) ans += 'U';
  for(int i=0;i<=tx-sx;++i) ans += 'R';
  ans += 'D';
  ans += 'R';
  for(int i=0;i<=ty-sy;++i) ans += 'D';
  for(int i=0;i<=tx-sx;++i) ans += 'L';
  ans += 'U';
  cout<<ans<<endl;
}



Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int len,now,ans;
int main()
{
    char s[5];
    int i;
    cin>>s;
    len=3;
    for(i=0;i<len;i++)
    {
        if(s[i]=='R') now++;
        else now=0;
        ans=max(ans,now); 
    }
    cout<<ans;
}
                       


Measured memory_bytes: 3632
<?php
while (true) {
    list($height, $width) = getSpacesByExplodeTrimInput();
    $lines = array();
 
    if ($height == 0 && $width == 0) {
        break;
    }
    
    for ($i = 0; $i < $height; $i++) {
        if ($i % 2) {
                $lines[] = setEvenNumLine($width);
        } else {
                $lines[] = setOddNumLine($width);
        }
    }
 
    echo implode($lines), PHP_EOL;
}
 
function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}
 
function setEvenNumLine($width)
{
    for ($i = 0; $i < $width; $i++) {
        $symbol[] = $i % 2 ? "#" : ".";
    }
    return implode($symbol).PHP_EOL;
}
    
function setOddNumLine($width)
{
    for ($i = 0; $i < $width; $i++) {
        $symbol[] = $i % 2 ? "." : "#";
    }
    return implode($symbol).PHP_EOL;
}
 

Measured memory_bytes: 15380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	ll ans=n;
	rep(i,n-1){
		if(s[i]==s[i+1])continue;
		chmin(ans,max(i+1,n-i-1));
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 512
// abc134c: Exception Handling
#include <stdio.h>

int search(int k, int *a, int n){
  int l=0,r=n,m;
  while(l<r){ m=(l+r)/2; if(a[m]<k) r=m; else l=m+1; }
  return l;
}

int main(){
  int n;scanf("%d",&n);
  int gn = 1, g[n];scanf("%d",g);
  for(int i=1;i<n;i++){
    int a;scanf("%d",&a);
    int j = search(a,g,gn);
    g[ j<gn? j: gn++ ] = a;
  }
  printf("%d\n",gn);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){

  string S;
  cin >> S;

  int flag = 0;
  REP(i, 0, (int)S.length() - 1){
    if ( S[i] == S[i+1] )
      flag = 1;
  }

  if ( flag == 0 )
    cout << "Good" << endl;
  else
    cout << "Bad" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func count(ints []int) int {
	max := ints[0]
	num := 1
	for i := 1; i < len(ints); i++ {
		h := ints[i]
		if max > h {
			continue
		}
		num++
		max = h
	}
	return num
}

func main() {
	n := nextInt()
	ints := nextInts(n)
	r := count(ints)
	fmt.Println(r)
}


Measured memory_bytes: 640
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int A,B; cin >> A >> B;
    if(A==B) cout << "Draw" << endl;
    else if(A==1) cout << "Alice" << endl;
    else if(B==1) cout << "Bob" << endl;
    else if(A>B) cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<set>
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 Cs crops[i]

class Crop
{
public:
	string L;
	double P;
	double A, B, C, D, E;
	double F, S;
	double M;
	double time_sum = 0;
	double income = 0;
	double ef = 0;
	void calc()
	{
		time_sum = A + B + C + D + E + (M - 1)*(D + E);
		income = F*S + F*S*(M - 1);
		ef = (income - P) / time_sum;
	}
};

int main()
{
	while (1)
	{
		Crop crops[50];
		//map<string, double> ans;
		map<double,vector<string>> ans;
		stack<string> str;
		int n;
		cin >> n;
		if (n == 0)break;
		REP(i, n)
		{
			cin >> Cs.L >> Cs.P >> Cs.A >> Cs.B >> Cs.C >> Cs.D >> Cs.E >> Cs.F >> Cs.S >> Cs.M;
			Cs.calc();
			auto itr=ans.find(Cs.ef);
			if (itr != ans.end())(*itr).second.push_back(Cs.L);
			else
			{
				vector<string> temp(1, Cs.L);
				ans.insert(make_pair(Cs.ef, temp));
			}
		}
		for (auto v : ans)
		{
			sort(v.second.begin(), v.second.end());
			reverse(v.second.begin(), v.second.end());
			FOR(i, 0, v.second.size())
			{
				str.push(v.second[i]);
			}
		}
		while (!str.empty())
		{
			cout << str.top() << endl;
			str.pop();
		}
		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector <int> num(N);
  int a, b;

  for (int i=0; i<M; i++){
    cin >> a >> b;
    num.at(a-1)+=1;
    num.at(b-1)+=1;
  }
  for (int i=0; i<N; i++) cout << num.at(i) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

double buff[200200];
double *c;
int t;
int e;


int main(){
  t = getInt();
  e = getInt();

  REP(i, 2 * t + 1) buff[i] = (double)getInt();
  c = &buff[t];

  for(int s = 2; s <= t; s++){
    {
      // merge to left
      double alpha = c[t - s + 1];
      double beta  = c[t - s + 2];
      if(alpha > beta){
	c[t - s + 1] = (alpha + beta * (s - 1)) / s;
      }
    }
    {
      // merge to right
      double alpha = c[-(t - s + 1)];
      double beta  = c[-(t - s + 2)];
      if(alpha > beta){
	c[-(t - s + 1)] = (alpha + beta * (s - 1)) / s;
      }
    }
  }
  
  double alpha = c[-1];
  double beta  = c[0];
  double ganma = c[1];

  double ans;

  double h1 = e / (alpha + ganma + beta / t);
  double h2 = (e - (alpha + ganma) * h1) / beta;
  ans = h1 + h2;

  ans = max(ans, e / beta);

  printf("%.7f\n", ans);

  return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair< int,int>
#define pll pair< ll,ll >
#define vi vector<int>
#define ss second
#define ff first
#define vii vector<pii>
#define vll vector<pll>
#define vl vector<ll>
#define vb vector<bool>
#define f(i,a,b) for(i = a;i < b;i++)
#define rf(i,a,b) for(i = a;i >= b;i--)
//template<class T> void print_data(T& a){ for(auto it : a) cout << it << " "; cout << endl; }

int main(){
	std::ios::sync_with_stdio(false);
	int n,i,j;
	cin >> n;
	vi a(n);
	f(i,0,n){
		cin >> a[i];
		a[i] -= i;
	}

	sort(a.begin(),a.end());

	int b = a[n/2];
	ll ans = 0;
	f(i,0,n){
		ans += 1LL*abs(b - a[i]);
	}
	cout << ans << endl;
	return 0;
}


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

#define INF 0x7fffffff;

int main() {
  int n,l;
  cin >> n >> l;
  vector<string> s(n,"");

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

  sort(s.begin(), s.end());

  for(int i=0;i<n;i++) {
    cout << s[i];
  }
  cout << endl;
}


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;

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

	int N, K;
	cin >> N >> K;

	if(K == 1){
		cout << 0 << endl;
	}else{
		cout << N - K << endl;
	}
}


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

template <typename TypeInt>
std::string Itoa(const TypeInt v, int base) {
  static const char table[] = "zabcdefghijklmnopqrstuvwxy";
  string ret;
  TypeInt n = v;
  while (n >= base) {
    ret += table[n % base];
    if (n % base == 0) {
      n--;
    }
    n /= base;
  }
  ret += table[n];
  std::reverse(ret.begin(), ret.end());

  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  string x;
  x = Itoa(n, 26);
  if (x[0] == 'z') {
    x.erase(0, 1);
  }
  cout << x << '\n';
  return 0;
}

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

using i64 = int64_t;

struct Burger{
    i64 patty, ban;
};

Burger burgers[52]={0};

Burger solve(i64 n){
    i64 patty = 0, ban = 1;
    if(burgers[n-1].patty != -1){
        patty += burgers[n-1].patty;
        ban += burgers[n-1].ban;
    }else{
        Burger b = solve(n-1);
        patty += b.patty;
        ban += b.ban;
    }
    patty++;
    patty += burgers[n-1].patty;
    ban += burgers[n-1].ban;
    ban++;
    return burgers[n] = (Burger){patty, ban};
}

i64 calc_x(i64 n, i64 x){
    i64 patty = 0; x--;
    if(x == 0)return patty;
    if(x >= burgers[n-1].patty + burgers[n-1].ban){
        patty += burgers[n-1].patty;
        x -= burgers[n-1].patty + burgers[n-1].ban;
    }else{
        return patty + calc_x(n-1, x);
    }
    if(x == 0)return patty;
    patty++; x--;
    if(x == 0)return patty;
    if(x >= burgers[n-1].patty + burgers[n-1].ban){
        patty += burgers[n-1].patty;
        x -= burgers[n-1].patty + burgers[n-1].ban;
    }else{
        return patty + calc_x(n-1, x);
    }
    if(x == 0)return patty;
    x--;
//    cout << x << endl;
    assert(x == 0);
    return patty;
}

int main(){
    i64 n, x;
    cin >> n >> x;
    burgers[0] = (Burger){1, 0};
    for(int i=1;i<=50;++i)burgers[i] = (Burger){-1, -1};
    solve(n);
//    cout << burgers[1].patty << " " << burgers[1].ban << endl;
    cout << calc_x(n, x) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(sz(s)>k){
        string s2="";
        s2=s.substr(0,k);
        s2+="...";
        cout<<s2<<endl;
    }
    else cout<<s<<endl;
    return 0;   
}


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

int main(){
  string O, E, S = "";
  int lo, le;
  
  cin >> O >> E;
  lo = O.size();
  le = E.size();
  
  for (int i = 0; i < lo+le; i++){
    if (i % 2 == 0){
      S = S + O.at(i/2);
    }
    else{
      S = S + E.at(i/2);
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n):
    if a[i] % 2 == 1:
        continue

    temp = a[i]
    while temp > 0 and temp % 2 == 0:
        #print('temp: ' + str(temp))
        temp /= 2
        ans += 1

print(ans)

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

int main(){
  ll n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;
  cout << (n-1)/min(a,min(b,min(c,min(d,e))))+5 << endl;
}

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

using namespace std;

int main() {
    int n;

    scanf("%d", &n);

    if(n % 2 != 0) n -= 7;
    while(n >= 0) {
        if(n % 4 == 0) {
            printf("Yes\n");
            break;
        }
        n -= 14;
    }

    if(n < 0) printf("No\n");

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
  int N,K;
  
  cin >> N >> K;
  K-=1;
  char str[N];
  for(int i = 0;i<N;++i)
  	cin >> str[i];
if(str[K]=='A')
  str[K] = 'a';
  if(str[K]=='B')
    str[K] = 'b';
  if(str[K]=='C')
    str[K] = 'c';
 for(int i=0;i<N;++i)
  	cout << str[i];
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
//範圍內的除數
int main() {
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    int i,count=0;
    for(i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2104
def f
  n = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  insertionsort(a, n)
end

def insertionsort(a, n)
  puts a.join(" ")
  for i in 1..n-1
    v = a[i]
    j = i-1
    while j >= 0 && a[j] > v
      a[j+1] = a[j]
      j -= 1
    end
    a[j+1] = v
    puts a.join(" ")
  end
end

f


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


int main() {
  int x;
  cin >> x;
  string ans = "ARC";
  if(x < 1200) ans = "ABC";
  
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
constexpr ll MOD = 1e9 + 7;

ll pow(ll x, ll p){
    ll ret = 1;
    rep(i, p) ret *= x;
    return ret;
}

int main(){
    ll h;
    cin >> h;
    ll ans = log2(h)+1;
    ans = pow(2LL, ans) - 1;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; ++i)
        cin >> x[i] >> y[i];
    double ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < i; ++j)
            ans += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
    cout << setprecision(10) << fixed << ans * 2 / n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>                                               //scanf,printf
#include <algorithm>                                            //max,min
#include <string>                                               //string
#include <cstring>                                              //strlen,strcat
#include <cctype>                                               //isalpha,tolower
#include <cmath>                                                //sqrt,sin
#include <stack>                                                //top,push
#include <queue>                                                //front,push
#include <vector>                                               //push_back,sort
#include <set>                                                  //insert,begin
#include <map>                                                  //insert,find
#include <list>                                                 //push_front,begin
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>                                               //pow,powf
#define INF (1<<21)
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define pl pair<long long, long long>
#define pr pair<int,int>

#define MAX 100002
int num[MAX];

int main(){
  int n;
  cin>>n;
  num[0]=num[n+1]=0;
  int sum=0;
  for(int i=0; i<n; i++){
    int a;
    cin>>a;
    num[i+1]=a;
    sum+=abs(num[i+1]-num[i]);
  }
  sum+=abs(num[n+1]-num[n]);
  for(int i=1; i<=n; i++){
    int ans;
    ans=sum-abs(num[i]-num[i-1])-abs(num[i+1]-num[i])+abs(num[i+1]-num[i-1]);
    cout<<ans<<endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int INF = 1e8;

struct edge { int to, cost; };
typedef pair<int, int>P;	//最短距離,頂点

int N;
vector<edge>G[100000];
int d[100000];
int pre[100000];

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + N, INF);
	fill(pre, pre + N, -1);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
				pre[e.to] = v;
			}
		}
	}
}
vector<int>get_path(int t) {
	vector<int>path;
	for (; t != -1; t = pre[t])path.push_back(t);
	reverse(path.begin(), path.end());
	return path;
}

int main() {
	cin.sync_with_stdio(false);
	cin >> N;
	vector<int>a(N - 1), b(N - 1);
	rep(i, N - 1) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		edge e1, e2;
		e1.to = b[i]; e1.cost = 1;
		e2.to = a[i]; e2.cost = 1;
		G[a[i]].push_back(e1);
		G[b[i]].push_back(e2);
	}
	dijkstra(0);
	vector<int>df(N);
	rep(i, N)df[i] = d[i];
	dijkstra(N - 1);
	int count=0;
	rep(i,N){
		if (df[i] <= d[i])count++;
		else count--;
}
	if (count >0)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;

	return 0;
}

Measured memory_bytes: 8688
while True:
    m, f, r = map(int, input().strip().split())
    if m == f == r == -1: break
    if m == -1 or f == -1 or m + f < 30:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        print('C' if r >= 50 else 'D')

Measured memory_bytes: 6728
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < 3; i++)
		if(s[i] == t[i])
			ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	var h, n int
	fmt.Scanf("%d %d", &h, &n)
	skills := scanIntSlice(n)
	for _, s := range skills {
		h -= s
		if h <= 0 {
			fmt.Println("Yes")
			os.Exit(0)
		}
	}
	fmt.Println("No")
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
    ll N,M; cin>>N>>M;
    ll ans;
    if(N>=2 && M>=2){ ans = (N-2)*(M-2); }
    else if(N==1 && M==1){ ans = 1; }
    else{ ans = max(N,M)-2; }
    cout << ans << "\n";
}

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

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
int N;
typedef vector<int> V;
V ret;
int bg=0;

V f(V p,int k){
    FOR(i,k,N)swap(p[i],p[i-k]);
    return p;
}
V rt(V v){
    bg=(bg+1)%N;
    ret.pb(1);
    return f(v,1);
}
V sw(V v){
    ret.pb(N-1);
    return f(v,N-1);
}

bool check(V v){
    REP(i,N-1)if(v[i]>v[i+1])return false;
    return true;
}
typedef pair<int,V> X;
int main(){
    cin>>N;
    V in(N);
    REP(i,N)in[i]=N-i-1;
#ifndef BTK
    cin>>in;
#endif


    while(check(in)==false){
        if(bg==0)in=rt(in);
        else if(in.front()<in.back())in=sw(in);
        else in=rt(in);
    }
    
    cout<<ret.size()<<endl;
#ifndef BTK
    for(auto &it:ret)cout<<it<<endl;
#endif
    return 0;
}


Measured memory_bytes: 764
#!/usr/bin/env python3
import sys

X = int(input())
ans = 0
if 400 <= X <= 599:
    ans = 8
elif 600 <= X <= 799:
    ans = 7
elif 800 <= X <= 999:
    ans = 6
elif 1000 <= X <= 1199:
    ans = 5
elif 1200 <= X <= 1399:
    ans = 4
elif 1400 <= X <= 1599:
    ans = 3
elif 1600 <= X <= 1799:
    ans = 2
elif 1800 <= X <= 1999:
    ans = 1

print(ans)

Measured memory_bytes: 9192
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		// 計算
		long result = 0;
		long c0 = b/c - (a-1)/c;
		long d0 = b/d - (a-1)/d;
		long l = lcm(c, d);
		long cd0 = b/l - (a-1)/l;
		result = (b - a + 1) - (c0 + d0 - cd0);

		// 出力
		System.out.println(result);
		
	}
	
	static long gcd(long x, long y){
	    if(x < y){
	        long temp = x;
	        x = y;
	        y = temp;
	    }
	    if(x%y == 0) return y;
	    return gcd(y , x%y);
	}
	
	static long lcm(long x, long y){
	    return x*y/gcd(x, y);
	}
}


Measured memory_bytes: 21844
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        n: usize,
        l: usize,
        a: [usize; n],
    }

    for i in 0..n {
        if i + 1 < n && a[i] + a[i + 1] >= l {
            println!("Possible");
            for j in 0..i {
                println!("{}", j + 1);
            }
            for j in (i + 2..n).rev() {
                println!("{}", j);
            }
            println!("{}", i + 1);
            return;
        }
    }
    println!("Impossible");
}


Measured memory_bytes: 4988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string O,E;
    cin>>O>>E;
    string ans="";
    if(O.size()>E.size()){
        rep(i,E.size()){
            ans=ans+O.at(i);
            ans=ans+E.at(i);
        }
        ans=ans+O.at(O.size()-1);
    }else{
        rep(i,E.size()){
            ans=ans+O.at(i);
            ans=ans+E.at(i);
        }        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		// モンスターの体力をPriorityQueueに格納
		PriorityQueue<Long> H = new PriorityQueue<> (Collections.reverseOrder());
		for (int i = 0; i < N; i++) {
			H.offer(sc.nextLong());
		}
		
		// N <= Kの場合は終了
		if (N <= K) {
			System.out.println(0);
			sc.close();
			return;
		}

		// 大きいものから順にK回取り出す
		for (int i = 0; i < K; i++) {
			H.poll();
		}
		
		// 結果の出力
		long sum = 0;
		while (H.size() > 0) {
			sum += H.poll();
		}
		System.out.println(sum);
		
		sc.close();
	}
}


Measured memory_bytes: 93660
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll X; cin >> X;
    ll ans = 0;
    ll res = 100;
    while(res < X) {
        ans++;
        res += res*0.01;
    }
    cout << ans << endl;
}

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


int main(){
	
	int n;
	cin >> n;
	
	vector<int> factors(n + 1, 0);
	for ( int i = 1; i <= n; i++ ){
		for ( int j = i; j <= n; j += i)
			factors[j]++;
	}
	typedef long long ll;
	ll sum = 0;
	for ( ll i = 1; i <= n; i++ ){
		sum += (i * (ll)factors[i]);
	}
	
	cout << sum << endl;
	return 0;
} 

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

using namespace std;

char ch[1000010];

int n;

int main() {
scanf("%d", &n);
int _0 = 0, _1 = 0;
scanf("%s", ch + 1);
for(int i = 1; i <= n; i++) _0 += ch[i] == 'R', _1 += ch[i] == 'B';
puts(_0 > _1 ? "Yes" : "No");
return 0;}

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

using namespace std;

int main()
{
    int n;cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    int dp[n+1];
    for(int i=0;i<=n;i++)
        dp[i]=INT_MAX;
    dp[0]=dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=2;j++)
        {
            if(i-1-j>=0)
            {
                int cost=abs(h[i-1]-h[i-1-j]);
                dp[i]=min(dp[i],dp[i-j]+cost);
            }
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean judge = a <= c && c <= b;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


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

int main(){
    int n,taro_p=0,hanako_p=0;
    string taro,hanako;
    cin >> n;
    
    for (int i=0; i<n; i++){
        cin >> taro >> hanako;
        if (taro > hanako) taro_p+=3;
        else if (taro < hanako) hanako_p+=3;
        else {
            taro_p+=1;
            hanako_p+=1;
        }
    }
    
    cout << taro_p << ' ' << hanako_p <<"\n";
    
    return 0;
}


Measured memory_bytes: 3180
n,l = map(int,input().split())
small = 1000
sum = 0
for i in range(1,n+1):
    sum = sum + l + i - 1
    if abs(l+i-1) <= small:
        small = abs(l+i-1)
        
if sum > 0:
    print(sum-small)
else:
    print(sum+small)

Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
set<int> kk;
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        kk.insert(k);
    }

    if(kk.size()==n)
        printf("YES\n");
    else
        printf("NO\n");
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    int a, b, c, x, y;
    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
    printf("%d\n", min(x * a + y * b,min(max(x, y) * c * 2, x > y ? y * c * 2 + (x - y) * a : x * c * 2 + (y - x) * b)));
    return 0;
}


Measured memory_bytes: 256
def main():
    INF = 10 ** 9 + 7
    N, M, *a = map(int, open(0).read().split())
    a = set(a)
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in a else 0
    for i in range(2, N + 1):
        if i not in a:
            dp[i] = (dp[i - 1] + dp[i - 2]) % INF
    print(dp[-1])
    return


main()


Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
int main() { 
  int h,w;
  cin >> h >> w;
  vector<string> mat(h);
  rep(i,h) cin >> mat[i];
  
  int c[h][w];
  int isCheck[h][w];
  queue<P> q;
  rep(i,h)rep(j,w){
    if(mat[i][j] == '#'){
      c [i][j] = 0;
      P p = make_pair(i,j);
      q.push(p);
      isCheck[i][j] = 1;
    }
    else{
      c[i][j] = 10e4;
      isCheck[i][j] = 0;
    }
  }
  int ans = 0;
  while(!q.empty()){
    P p = q.front();
    q.pop();
    int i = p.fi;
    int j = p.se;
    rep(k,4){
      int px = i+dx[k];
      int py = j+dy[k];
      if(px < 0 || px >=h || py < 0 || py >= w) continue;
      if(mat[px][py] == '#') continue;
      int cost = min(c[px][py],c[i][j]+1);
      if(cost < c[px][py] && !isCheck[px][py]){
        P p2 = make_pair(px,py);
        q.push(p2);
        c[px][py] = cost;
        isCheck[px][py] = 1;
      }
    }
    maxs(ans,c[i][j]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 17296
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(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 dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

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

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool graph[101][101];
bool visit[101010];
vector<ll> to[101010];
vector<ll>ball(101010, 1);
vector<bool>flag(101010);

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, m;
	cin >> n >> m;
	flag[0] = true;
	rep(i, m) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		ball[a]--;
		ball[b]++;
		if (flag[a])flag[b] = true;
		if (ball[a] == 0)flag[a] = false;
	}
	ll ans = 0;
	rep(i, n) {
		if (flag[i])ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    
    int k,s; cin >> k >> s;
    int ans = 0;
    
    for(int x=0;x<=k;++x){
        for(int y=0;y<=k;++y){
            int z = s - x - y;
            if(0 <= z && z <= k){
                ans = ans + 1;
            }
        }
        
    }
    
    cout << ans << endl; 
}


Measured memory_bytes: 256
//
// Created by tattsun on 2017/02/16.
//

#include <iostream>

#define MAX_N 101
#define INFTY 20000
#define NIL -1

enum Color {
    White,
    Glay,
    Black,
};

using namespace std;

int n;
int w[MAX_N][MAX_N];
int d[MAX_N], p[MAX_N];
Color color[MAX_N];

int min(int x, int y) {
    if(x < y) return x;
    return y;
}

int solve() {
    d[0] = 0;

    while(true) {
        int u = NIL, c = INFTY;

        for(int i=0; i<n; i++) {
            if(d[i] < c && color[i] != Black) {
                u = i;
                c = d[i];
            }
        }

        if(u == NIL)
            break;

        color[u] = Black;

        for(int i=0; i<n; i++) {
            if(color[i] != Black && w[u][i] != INFTY) {
                if(d[i] > w[u][i]) {
                    d[i] = w[u][i];
                    p[i] = u;
                    color[i] = Glay;
                }
            }
        }
    }


    int tc = 0;
    for(int i=0; i<n; i++) {
        if(p[i] != NIL)
            tc += w[i][p[i]];
    }
    return tc;
}

int main() {
    for (int i = 0; i < MAX_N; i++) {
        d[i] = INFTY;
        p[i] = NIL;
        color[i] = White;
        for (int j = 0; j < MAX_N; j++)
            w[i][j] = INFTY;
    }

    int p;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> p;
            w[i][j] = (p == -1) ? INFTY : p;
        }
    }

    cout << solve() << endl;
}

Measured memory_bytes: 3056
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int x,y,gx,gy;
    cin>>x>>y>>gx>>gy;
    string s;
    for (int i=y;i<gy;i++) s+= (char)'U';
    for (int i=x;i<gx;i++) s+= (char)'R';
    for (int i=gy;i>y;i--) s += (char)'D';
    for (int i=gx;i>x;i--) s += (char)'L';
    s += (char)'L';

    for (int i=y;i<=gy;i++) s+= (char)'U';
    for (int i=x;i<=gx;i++) s+= (char)'R';
    s += (char)'D'; s += (char)'R'; 
    for (int i=gy;i>=y;i--) s += (char)'D';
    for (int i=gx;i>=x;i--) s += (char)'L';
    s += (char)'U';
    cout << s << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)

int main() {
	llint a, b;
	cin >> a >> b;
	llint lcm;
	lcm = a * b / GCD(a, b);
	cout << lcm << endl;
	return 0;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min, __gcd, substring, erase, push_back,stoll、stoi

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class Main {

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

	public void run() throws Exception {
		FastIO file = new FastIO();
		int n = file.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = file.nextInt();
		}
		int count = 0;
		for (int i = 1; i < n - 1; i++) {
			if (a[i] >= a[i - 1] && a[i] <= a[i + 1]) {
				count++;
			}
			else if (a[i] <= a[i - 1] && a[i] >= a[i + 1]) {
				count++;
			}
		}
		System.out.println(count);
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, p / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, p / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"

int main(){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if((x+r>w||x-r<0)||(y-r<0||y+r>h)) cout << "No" << endl;
    else COUT("Yes");
    return 0;
}



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

int A[25][25], B[25];

int main(){
    int n, m, c;
    scanf("%d%d%d", &n, &m, &c);
    for(int i = 0; i < m; i++){
        scanf("%d", &B[i]);
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d", &A[i][j]);
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int dot = 0;
        for(int j = 0; j < m; j++){
            dot += A[i][j] * B[j];
        }
        dot += c;
        if(dot > 0) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && a!=c)
    cout<<"Yes";
  else if(b==c && a!=c)
    cout<<"Yes";
  else if(a==c && b!=c)
    cout<<"Yes";
  else
    cout<<"No";
}


Measured memory_bytes: 256