akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AUTHOR : SHASHANK *
* NICK : lance_lot *
* INSTITUTION : BIT MESRA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;

int main() {
fast;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    ll dp[n];
    for(ll i = 0;i < n;i++) {
        cin>>arr[i];
        dp[i] = inf;
    }
    dp[0] = 0;
    for(ll i = 1;i < n;i++) {
        for(ll j = i-1;j >= max(0LL,i-k);j--) {
            dp[i] = min(dp[i],abs(arr[i]-arr[j])+dp[j]);
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



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

	int N, M;
	cin >> N >> M;
	if (N == M)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int ch, cw;
    cin >> ch >> cw;
    ch--; cw--;
    int dh, dw;
    cin >> dh >> dw;
    dh--; dw--;
    vector<string> ss(h); cin >> ss;
    vector<pair<int, int>> stack;
    vector<pair<int, int>> nexts;
    stack.emplace_back(ch, cw);
    ss[ch][cw] = 'o';
    int ans = 0;
    while(ss[dh][dw] == '.'){
        auto add = [&](int y, int x){ 
            if(y < 0 || h <= y || x < 0 || w <= x){ return; }
            if(ss[y][x] != '.'){ return; }
            ss[y][x] = 'o';
            stack.emplace_back(y, x);
        };
        if(stack.empty()){
            ans++;
            for(auto& p : nexts){
                for(int i = -2; i <= 2; i++){
                    for(int j = -2; j <= 2; j++){
                        add(p.first + i, p.second + j);
                    }
                }
            }
            nexts.clear();
            if(stack.empty()){
                break;
            }
        }
        auto p = stack.back();
        nexts.push_back(p);
        stack.pop_back();
        add(p.first + 1, p.second);
        add(p.first, p.second + 1);
        add(p.first - 1, p.second);
        add(p.first, p.second - 1);
    }
    cout << (ss[dh][dw] == '.' ? -1 : ans) << '\n';
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    int ret = 0;
    for(int a = 1;a <= n;a++)for(int b = 1;a*b <= n;b++){
        int c = n-a*b;
        if(c <= 0 )continue;
        ret++;
    }
    cout << ret << endl;
    return 0;
}

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

#define ll long long

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

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

int main(){
    int n;
    cin >>n;
    ll ans=0;
    cin >> ans;
    for(int i=1;i<n;i++){
        ll t=0;
        cin>>t;
        ans=lcm(max(ans,t),min(ans,t));
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MOD 1000000007
using namespace std;
typedef long long ll;
//vector<vector<int>> vec(i, vector<int>(j));

vector<int> input(int N) {
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    return vec;
}

void Main() {
    int n,d,x,ans;
    cin >> n>>d>>x;
    ans = 0;
    vector<int> A=input(n);
    int cnt=0;
    int days;
    for (int i = 0; i < n; i++)
    {
        int loop;
        loop = (d-1)/A[i];
        ans += (1+loop);
    }
    cout << ans+x<<endl;
}

int main() {
	Main();
	return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

int main()
{
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;

    ll x = min(a,min(min(min(b,c),d),e));
    ll ans = 5;
    if(n % x == 0) ans+=(n/x - 1);
    else ans+=n/x;

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

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

using namespace std;

int main(void){
	int i, len;
	string encrypted, tmp, decoded;

	while(getline(cin, encrypted)){
		len = encrypted.size();
	
		while(encrypted.find("this") == string::npos &&
			  encrypted.find("that") == string::npos &&
			  encrypted.find("the")  == string::npos){
			for(i=0;i<len;i++){
				if(encrypted[i] >= 97 && encrypted[i] <=122){ //isAlphabet(encrypted[i]);
					encrypted[i] += 1;
					if(encrypted[i] == 123) encrypted[i] = 97;//z->a
				}
			}
		}
	
		cout << encrypted << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int i = 0;
  while (1){
  	i++;
    if(8*i/100==a && i/10==b){cout << i;break;}
    if(i > 10000){cout <<-1;break;}
  }
  return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
signed main(){
	int n,l;
	cin>>n>>l;
	if(l>=0){
		c((l*2+n-1)*n/2-l)
	}
	else{
		if(n+l>0){
			c((l*2+n-1)*n/2)
		}
		else{
			c((l*2+n-1)*n/2-(n+l-1))
		}
	}
}						

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, p, res; cin >> n >> p, n; cout << res << endl){
        res = 0;
        int rest = p;
        vi s(n);

        while(1){
            if(rest != 0){
                s[res]++;
                rest--;

                if(rest == 0 && s[res] == p){
                    break;
                }
            }
            else{
                rest += s[res];
                s[res] = 0;
            }
            res = (res + 1) % n;
        }
    }

	return 0;
}

Measured memory_bytes: 1196
#include<iostream>

using namespace std;

int main() {
	int s;
	cin >> s;

	int sum = 1;
	while (1) {
		if (s == 4 || s == 2 || s == 1)break;
		if (s % 2 == 0)s /= 2;
		else s = s * 3 + 1;
		sum++;
	}

	cout << sum + 3 << endl;

	return 0;
}

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

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

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    auto v = map<string, ll>();

    REP(i, n) {
        int    q;
        string k;
        cin >> q >> k;
        if (q == 0) {
            int x;
            cin >> x;
            v[k] = x;
        } else if (q == 1) {
            auto it = v.find(k);
            if (it != v.end()) {
                cout << it->second << endl;
            } else cout << 0 << endl;
        } else if (q == 2) {
            v.erase(k);
        } else if (q == 3) {
            string L = k, R;
            cin >> R;
            for (auto it = v.lower_bound(L); it != v.end() && it->first <= R; ++it) {
                cout << it->first << " " << it->second << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 25896
H, W, K = map(int, input().split())
MOD = 10 ** 9 + 7


def transition(w):
    X = [1, 2, 3, 5, 8, 13, 21, 34]
    if w >= 0:
        return X[w]
    else:
        return 1


# h行w列に到達する方法
dp = [[0] * W for h in range(H + 1)]
dp[0][0] = 1

for h in range(H):
    for w in range(W):
        # 真下へ
        dp[h + 1][w] += dp[h][w] * (transition(w - 1) * transition(W - w - 2))
        dp[h + 1][w] %= MOD

        # 右下へ
        if w + 1 < W:
            dp[h + 1][w + 1] += dp[h][w] * (transition(w - 1) * transition(W - w - 3))
            dp[h + 1][w + 1] %= MOD

        # 左下へ
        if w - 1 >= 0:
            dp[h + 1][w - 1] += dp[h][w] * (transition(w - 2) * transition(W - w - 2))
            dp[h + 1][w - 1] %= MOD

print(dp[H][K - 1])


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

int main() {
    int n, k; scanf("%d%d", &n, &k);
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    set<int> s;
    int ans = 1;
    for (int i = 0; i < k; i++) {
        s.insert(arr[i]);
    }
    for (int i = k; i < n; i++) {
        int old_e = arr[i - k];
        int new_e = arr[i];
        if (old_e != *s.begin() || new_e < *s.rbegin()) {
            ans++;
        }
        s.erase(old_e);
        s.insert(new_e);
    }
    int l = 0;
    int r = 0;
    int patch = 0;
    for (int i = 1; i < n; i++) {
        if (arr[i] > arr[r]) {
            r = i;
        } else {
            if (r - l + 1 >= k) {
                patch += 1;
            }
            l = i;
            r = i;
        }
    }
    if (r - l + 1 >= k) {
        patch += 1;
    }
    if (patch) {
        ans -= patch - 1;
    }

    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int n, l;
  cin>>n>>l;
  string s[n];
  for (int i=0; i<n; i++) cin>>s[i];
  sort(s, s + n);
  for (int i=0; i<n; i++) cout<<s[i];
  cout<<endl;
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())

if x < a*a*b/2:
    tan = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan))
    print(90-deg)
elif x == a*a*b:
    print(0)
else:
    i = a**3
    j = 2*(a*a*b-x)
    tan = i/j
    deg = math.degrees(math.atan(tan))
    print(90-deg)

    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define inf 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }
    sort(h.begin(), h.end(), greater<int>());
    rep(i,min(k,n)){
        h[i] = 0;
    }
    ll ans = 0;
    rep(i,n){
        ans += h[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int result = 0;
		for (int i = 1; i <= 9; i++)
			for (int j = 1; j <= 9; j++) {
				result += num(N, i, j) * num(N, j, i);
			}
		System.out.println(result);
	}

	static int num(int max, int head, int tail) {
		int result = 0;

		for (int i = 1; i <= max; i++)
			if (i % 10 == tail && head(i) == head)
				result++;

		return result;
	}

	static int head(int i) {
		while (i > 9) {
			i /= 10;
		}
		return i;
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n;
ll a[300000];
int main(){
	cin >> n;
	REP(i,n) {
		cin >> a[i];
	}

	ll mini = 1000000000000;

	ll p = a[0];
	ll sum = 0;
	REP(i,n)
		sum += a[i];

	FOR(i,1,n) {
		mini = min(mini,abs(sum - p - p));
		p += a[i];
	}
	cout << mini << endl;
	return 0;
}


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


public class Main {
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			double a = sc.nextDouble();
			
			double s = a;
			
			for(int i=2; i<=10; ++i){
				a = i%2==0 ? a*2. : a/3.;
				s += a;
			}
			
			System.out.println(s);
		}
		
		sc.close();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int k = ri();
	int a[n], b[m];
	for (auto &i : a) i = ri();
	for (auto &i : b) i = ri();
	int res = *std::min_element(a, a + n) + *std::min_element(b, b + m);
	for (int i = 0; i < k; i++) {
		int x = ri() - 1;
		int y = ri() - 1;
		int c = ri();
		res = std::min(res, a[x] + b[y] - c);
	}
	printf("%d\n", res);
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>p(N);
    ll cnt = 0;
    rep(i,N){
        cin>>p[i];
        if(p[i]!=(i+1)){
            cnt++;
        }
    }

    if(cnt<=2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


    
    


    return 0;
    

}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int main() {
    string o, e;
    cin >> o >> e;

    int i, j;
    i = j = 0;
    int c = 1;
    while(i < o.size() || j < e.size()) {
        if (c == 1) {
            cout << o[i++];
        } else {
            cout << e[j++];
        }
        c = (c + 1) % 2;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int n;
	cin >> n;
	cout << n / 2 + n % 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL H, N; cin >> H >> N;
		UL D = 0;
		rep(i, N) {
			UL a; cin >> a;
			D += a;
		}
		cout << (H<=D ? "Yes":"No") << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int x[28],y,i;
    for(i=0;i<28;i++)
    {
        scanf("%d",&x[i]);
    }
    for(y=1;y<31;y++)
    {
        for(i=0;i<28;i++)
        {
            if(x[i]==y)
            {
            break;
            }
            else if(x[i]!=y&&i==27)
            {
                printf("%d\n",y);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<vector>
#include<stdlib.h>

#define SZ(v) ((int)v.size())
#define pb push_back
using namespace std;
typedef vector<int> VI;

const int N=200005;
VI li[N],id;
char s[N];
int n,m,L,ec,sum,mark[N];

void markit(){
    for(int i=0;i<<2<id.size();i++){
        for(int j:{0,1})for(int k:{0,1})mark[id[i<<2|j<<1|k]]=ec+k+1;
        ec+=2;
    }
}
void output(){
    puts("Yes");
    for(int i=0;i<L;i++){
        if(!mark[i])mark[i]=ec<0?-ec:++ec,ec=-ec;
        printf("%d ",mark[i]);
    }
    exit(0);
}

int main(){
    scanf("%d",&n);scanf("%s",s+1);s[0]='1';L=n<<1;
    for(int i=0,j;i<L;i++)if(s[i]=='0'&&s[(i+1)%L]=='1'){
        for(li[m].pb(i),j=(i+1)%L;s[j]=='1';j=(j+1)%L)li[m].pb(j);
        m++;
    }
    if(!m){
        if(~n&1){
            for(int i=0;i<L;i++)id.pb(i);
            markit();output();
        }else puts("No"),exit(0);
    }
    for(int i=0;i<m;i++)sum+=SZ(li[i])-2;
    if(sum&1)puts("No"),exit(0);
    if(sum&2){
        for(int i=0;i<m;i++)if(SZ(li[i])>2)li[m-1].swap(li[i]);
        for(int i=0;i<m-1;i++)if(SZ(li[i])>2){
            VI&a=li[i],&b=li[m-1];
            int la=SZ(a)-1,lb=SZ(b)-1,ea=a[la],eb=b[lb];
            mark[a[la-1]]=mark[b[lb-1]]=++ec;
            a.pop_back();b.pop_back();a.pop_back();b.pop_back();a.push_back(eb);b.push_back(ea);
            sum-=2;
            break;
        }
        if(sum&2)puts("No"),exit(0);
    }
    for(int i=0;i<m;i++){
        mark[li[i][0]]=ec+1+i;
        mark[li[i][SZ(li[i])-1]]=ec+1+(i+1)%m;
        for(int j=1;j<SZ(li[i])-1;j++)id.pb(li[i][j]);
    }
    ec+=m;markit();output();
    return 0;
}

Measured memory_bytes: 9084
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=pow(10,9)+7;
bool cmp(pair<long double, int > x, pair<long double, int> y){ return x.F<y.F && x.S<y.S; }
const ll maxn=2*1e6+10;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
ll random(ll mn, ll mx){
	return (rand() % (mx - mn + 1)) + mn; 
}
void solve(){
	
	ll a,b;
	cin>>a>>b;
	
	for (int i=1;i<maxn;i++){
		ll x=(i*8)/100;
		ll y=(i*10)/100;
		if (x==a && y==b){
			cout<<i<<endl;
			return;
		}
	}
	cout<<-1<<endl;
	
	
	
	return;
}

int main(){ 
    
    #ifndef ONLINE_JUDGE
  		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	//T{ solve(); }
	solve();
	
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)
 
int n, m;
 
int main(int argc, char **argv) {
	cin >> n >> m;
	cout << ((n - 1) * (m - 1)) << endl;
	return 0;
}

Measured memory_bytes: 256
N,T = map(int,input().split());
t = [int(x) for x in input().split()];

end = 0;
ans = 0;
for i in range(N) :
    if end > t[i] :
        ans += t[i] + T - end;
    else :
        ans += T;
    end = t[i] + T;
    #print(ans,end);

print(ans); 

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;


    string ans;
    int i=0,j=0;
    loop(i,0,n)
    {
        cout<<a[i]<<b[i];
    }

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(q,a,b) for(int q=a,q##_end_=b;q<=q##_end_;++q)
#define dep(q,a,b) for(int q=a,q##_end_=b;q>=q##_end_;--q)
#define mem(a,b) memset(a,b,sizeof a )
#define debug(a) cerr<<#a<<' '<<a<<"___"<<endl
using namespace std;
void in(int &r) {
	static char c;
	r=0;
	while(c=getchar(),!isdigit(c));
	do r=(r<<1)+(r<<3)+(c^48);
	while(c=getchar(),isdigit(c));
}
const int mn=100005;
char as[mn];
int cnt[27],n;
const int mod=1e9+7;
int main(){
	scanf("%d%s",&n,as+1);
	rep(q,1,n)++cnt[as[q]-'a'];
	long long s=1;
	rep(q,0,25)s=1LL*(cnt[q]+1)*s%mod;
	printf("%lld\n",s-1);
    return 0;
}

Measured memory_bytes: 384
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}, dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	vector<string> a(h);
	rep(i, h) cin >> a[i];
	rep(i, h) {
		rep(j, w) {
			if (a[i][j] == '#') {
				printf("#");
				continue;
			}
			int cnt = 0;
			rep(k, 8) {
				int nx = i + dx[k], ny = j + dy[k];
				if (nx < 0 or h <= nx or ny < 0 or w <= ny) continue;
				if (a[nx][ny] == '#') cnt++;
			}
			printf("%d", cnt);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    h = int(input())
    attack = 0
    cnt = 0
    while h >= 2:
        h //= 2
        cnt += 1
    for i in range(cnt+1):
        attack += 2 ** i          
    print(attack)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<cstring>
using namespace std;

int a[100005];
signed main() {
	int b, c; cin >> b >> c;
	for (int d = 0; d < b; d++) {
		int e, f; scanf("%d%d", &e, &f);
		a[e]++; a[f]--;
	}
	int k = 0, Max = 0;
	for (int i = 0; i < 100005; i++) {
		k += a[i];
		Max = max(Max, k);
	}
	cout << Max << endl;
}

Measured memory_bytes: 3548
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main() {
    
    ll alpha[26]={0};
    int n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,s.size())alpha[s[i]-'a']++;

    ll ans=1;
    rep(i,26){
        ans*=alpha[i]+1;
        ans%=MOD;
    }
    ans--;
    fin(ans);

}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define BPhuong "vsteps"
#define maxn 1009
#define maxm
#define bit(x, i) ((x>>i)&1)
#define fid(i,a,b) for(int i = a; i>=b; i--)
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<int, int>
#define ll long long
#define f first
#define se second
#define pb push_back
using namespace std;
int n, m, q[maxn],t, mod;
char  a[maxn][maxn];
int f[maxn][maxn];
void nhap(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    srand(time(NULL));
    cin >> n >> m;
    mod = 1e9+7;
    fi(i, 1, n)
        fi(j, 1, m) cin >> a[i][j];
}
void xuli(){
    f[1][1] = 1;
    fi(i, 1, n){
        fi(j, 1, m){
            if(a[i][j] == '#') f[i][j] = 0;
            else{
                if(i>1 && j == 1) f[i][j] = f[i-1][j];
                if(i==1 && j >1) f[i][j] = f[i][j-1];
                if( i > 1 && j > 1) f[i][j] = f[i][j-1] + f[i-1][j];
            }
            f[i][j]%=mod;
        }
    }
    cout << f[n][m];
}
int main(){
    nhap();
    xuli();
}


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

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  sort(an.begin(),an.end());
  int ansx = an.back();
  auto it = lower_bound(an.begin(),an.end(), ansx/2);
  int ansy = *it;
  --it;
  if(abs(ansx - ansy*2) >= abs(ansx - *it*2)) ansy = *it;
  cout << ansx << " " << ansy << endl;
}

Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main(){
    unsigned population,kinds;
    cin >> population >> kinds;
    unsigned sweets[kinds];
    unsigned people[population];
    for(unsigned i = 0; i < population; i++) {
        people[i] = 0;
    }
    for(unsigned i = 0; i < kinds; i++) {
        cin >> sweets[i];
        for(unsigned k = 0; k < sweets[i]; k++) {
            unsigned box;
            cin >> box;
            people[box-1]++;
        }
    }
    unsigned counter=0;
    for(unsigned i = 0; i < population; i++) {
        if(people[i] == 0) 
            counter++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
int main() 
{
     int n;
     cin>>n;
     if(n>0&&n<=99)
     {
         if(n<10)
            cout<<n;
        else
            cout<<"9";
     }
     else if(n>99&&n<=999)
     {
         cout<<n-90;
     }
     else if(n>999&&n<=9999)
     {
         cout<<"909";
     }
     else if(n>9999&&n<=99999)
     {
         cout<<n-9090;
     }
     else if(n==100000)
        cout<<"90909";
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;


ll d[100001];
bool color[100001];
vector<pair<ll,ll>> V[100000];


void  dfs(ll s) {


	FOR(i, 0, V[s].size()) {

		pair<ll, ll>P = V[s][i];
		
		if (color[P.first] ==false) {
			color[P.first] = true;
			d[P.first] = d[s] + P.second;
			dfs(P.first);
		}

	}
	return;
}


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

	ll N;
	cin >> N;

	FOR(i, 0, N-1) {
		ll u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		pair<ll,ll> P(u, w);
		pair<ll,ll> PP(v, w);
		V[u].push_back(PP);
		V[v].push_back(P);
	}
	color[0] = true;
	dfs(0);
	FOR(i, 0, N) {
		if (d[i] % 2)cout << 0 << endl;
		else cout << 1 << endl;
	}



	return 0;
}


Measured memory_bytes: 10240
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

deque<ll> data;
ll n;

/* add your algorithm here */

int main() {
  cin >> n;
  ll a;
  if (n % 2) {
    for (int i = 0; i < n; ++i) {
      cin >> a;
      if (i % 2 == 1) {
        data.push_back(a);
      } else {
        data.push_front(a);
      }
    }
  } else {
    for (int i = 0; i < n; ++i) {
      cin >> a;
      if (i % 2 == 0) {
        data.push_back(a);
      } else {
        data.push_front(a);
      }
    }
  }

  for (auto itr : data) {
    cout << itr << " ";
  }

  cout << endl;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    ll i,j,n;
    string s,t;
    cin>>s>>t;
    n = sz(s);
    ll ans = 0;
    for(i=0;i<n;i++)
    {
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans;
}

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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";

int dx[] = { 0,0,1,-1,-1,-1,1,1 };
int dy[] = { 1,-1,0,0,-1,1,1,-1 };



template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};



#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

long long get(long long n){

    return (n*(n-1ll))/2ll;
}

void solve()
{
    int n;
    cin>>n;

    map<int,int> mp;
    vector<int> items;

    for(int i=0;i<n;i++){
        int it;
        cin>>it;
        mp[it]++;
        items.push_back(it);
    }

    long long ans=0;

    for(auto i:mp){
        ans+=get(i.second);
    }

    for(int i=0;i<n;i++){

        long long it=mp[items[i]];
        long long res=ans-get(it)+get(it-1);
        cout<<res<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 8312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];
    ll ans = 0;
    reps(i, 1, n - 1) {
        if (
            ((p[i] > p[i - 1]) && (p[i] < p[i + 1])) ||
            ((p[i] < p[i - 1]) && (p[i] > p[i + 1]))
        ) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int[] arr = new int[count];
        for (int i = 0; i < count; ++i) {
            arr[i] = scanner.nextInt();
        }

        long[][] dp = new long[count + 1][count + 1];
        for (int piles = 1; piles <= count; ++piles) {
            for (int start = 0; start + piles <= count; ++start) {
                if ((count - piles) % 2 == 0) {
                    dp[piles][start] = Math.max(
                            dp[piles - 1][start + 1] + arr[start],
                            dp[piles - 1][start] + arr[start + piles - 1]);
                } else {
                    dp[piles][start] = Math.min(
                            dp[piles - 1][start + 1] - arr[start],
                            dp[piles - 1][start] - arr[start + piles - 1]);
                }
            }
        }

        System.out.println(dp[count][0]);
    }
}


Measured memory_bytes: 129612
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	REP(X, N + 1) {
		if (X * 108LL / 100 == N) {
			cout << X << "\n";
			return 0;
		}
	}
	cout << ":(\n";

	return 0;
}


Measured memory_bytes: 256
x,y,z,k = map(int,input().split())

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

tem = []

for i in range(x):
    for j in range(y):
        tem.append(a[i]+b[j])

tem.sort()
if(x*y > k):
    tem2 = tem[x*y-k-1:]
else:
    tem2 = tem
ans = []
for i in range(len(tem2)):
    for j in range(z):
        ans.append(tem2[i]+c[j])

ans.sort()
dd = len(tem2)*z
for i in list(reversed(range(dd-k,dd))):
    print(ans[i])

Measured memory_bytes: 147948
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int r;
    cin>>r;

    cout<<3*r*r<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
LL a[5001];
bool check[5001];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    for(int i = 0; i < N; ++i)
        cin >> a[i];
    
    int ans = 0;
    sort(a, a + N, greater<int>());
    for(int i = 0; i < N; ++i){
        LL sum = 0;
        for(int j = i; j < N; ++j){
            sum += a[j];
            if(sum >= K){
                ans = max<LL>(ans, j + 1);
                sum -= a[j];
            }
        }
    }
    cout << N - ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
struct UnionFind{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int root(int x) {
    if (x == par[x]) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sizes[root(x)];
  }
};
int main(){
	int N,M;
	int A[100001],B[100001];
	ll ans[100001];
	scan(N);scan(M);
	UnionFind uf(N);
	rep(i,M){
		scan(A[i]);scan(B[i]);
		A[i]--; B[i]--;
	}
	ans[M-1]=(ll)N*(N-1)/2;
	for(int i=M-1;i>0;i--){
		if(uf.root(A[i])!=uf.root(B[i])) ans[i-1]=ans[i]-(ll)uf.size(A[i])*uf.size(B[i]);
		else ans[i-1]=ans[i];
		uf.unite(A[i],B[i]);
	}
	rep(i,M){
		prin(ans[i]);
	}

	return 0;
}


Measured memory_bytes: 3712
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#define P 1000000007

using namespace std;

typedef long long ll;

ll powmod(ll x, ll y = P - 2, ll p = P) {
    ll ans = 1;
    while(y) {
        if(y & 1) ans = ans * x % p;
        x = x * x % p;
        y >>= 1;
    }
    return ans;
}

const int m10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};

int S, K[30000010];

ll Solve1(int x) {
    int tmp = S / x;
    if(x <= 8 && tmp > m10[x] - m10[x - 1]) return 0;
    return powmod(10, x) - powmod(10, x - 1) - tmp + 1;
}

void add(ll &x, ll y) {
    x = (x + y) % P;
}

int main() {
    scanf("%d", &S);
    ll ans = 0;
    for(int i = 1; i <= sqrt(S); i++) if(S % i == 0) {
        add(ans, Solve1(i));
        if(i * i != S) add(ans, Solve1(S / i));
    }
    for(int i = S; i >= 1; i--) {
        int tmp = S / i;
        int s = S % i;
        if(!s) continue;
        if(tmp <= 8 && m10[tmp] - m10[tmp - 1] < i - s) continue;
        if(tmp <= 7 && m10[tmp + 1] - m10[tmp] < s) continue;
        ans = (ans + 1) % P;
    }
    for(int i = 1; i <= 30000000; i++) K[i] = K[i / 10] + 1;
    int nw = 0, t = 1;
    for(int i = 1; i <= 30000000; i++) {
        nw += K[i];
        while(nw > S) {
            nw -= K[t];
            t++;
        }
        if(nw == S && K[i] - K[t] > 1) ans = (ans + 1) % P;
    }
    printf("%lld\n", (ans % P + P) % P);
    return 0;
}

Measured memory_bytes: 117504
def main():
    S = input()
    N = len(S)
    K = int(input())

    if K == 1:
        print(cnt(S))
        return
    if K == 2:
        print(cnt(S*2))
        return
    i = 0
    j = 0
    while True:
        if S[i] != S[(j-1) % N]:
            break
        i += 1
        j = (j + 1) % N
        if i >= N:
            i = -1
            break
    if i == -1:
        print(K * N // 2)
        return
    start = S[:i]
    end = S[j:]
    mid = S[i:] + S[:j]
    # print(start)
    # print("1")
    # print(end)
    # print("w")
    # print(mid)
    print(cnt(start) + cnt(mid) * (K-1) + cnt(end))


def cnt(S):
    prev = "あ"
    cnt = 0
    for c in S:
        if c == prev:
            cnt += 1
            prev = "あ"
        else:
            prev = c
    return cnt
main()

Measured memory_bytes: 3064