akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long           ll;
typedef pair<ll, ll>        P;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
const ll                    INF = 2e9;
const ll                    INF_LL = 1LL<<60;
const ll                    MOD = 998244353;

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll N;
	cin >> N;
	vector<ll> a(N);
	REP(i, N) {
		cin >> a[i];
		a[i]--;
	}
	
	vector<ll> b;
	while (!a.empty()) {
		ll idx = INF;
		REP(i, a.size()) {
			if (a[i] == i)	idx = i;
		}
		if (idx == INF) {
			cout << -1 << endl;
			return;
		}
		b.emplace_back(a[idx] + 1);
		a.erase(a.begin() + idx);
	}

	reverse(ALL(b));
	for (auto one : b) {
		cout << one << endl;
	}
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> B(M);
  for (int i = 0; i < M; i++) cin >> A.at(i) >> B.at(i);

  vector<int> cities(N, 0);
  for (int i = 0; i < N; i++) {
    for (int a : A)
      if (a == i + 1) cities.at(i)++;
    for (int b : B)
      if (b == i + 1) cities.at(i)++;
  }
  for (int c : cities) cout << c << endl;
}


Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
count=0
pre=[arr[0]]
for i in range(1,len(arr)):
	pre.append((pre[-1]+arr[i]))
ans=0
for i in range(len(arr)-1,0,-1):
	ans+=(pre[i-1]*arr[i])
print(ans%((10**9)+(7)))

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<vector<int>> m(n, vector<int>(n, -1));
    int x = n / 2, y = n / 2 + 1;
    for (int i = 1; i <= n * n; ++i, ++x, ++y) {
      x %= n;
      y %= n;
      while (~m[y][x]) {
        y = (y + 1) % n;
        x = (x - 1 + n) % n;
      }

      m[y][x] = i;
    }

    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        printf("%4d", m[i][j]);
      }
      puts("");
    }
  }
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S=="hi" || S=="hihi" || S=="hihihi" || S=="hihihihi" || S=="hihihihihi") {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
  
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        x:usize,a:usize,
    }
    if x < a {
        println!("{}", 0);
    } else {
        println!("{}", 10);
    }
}


Measured memory_bytes: 2196
import java.util.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		int a = 0;
		int b = 0;
		int c = 0;
		int d = 0;

		for (int i = 0; i < n; i++) {
			s[i] = sc.next();

			if (s[i].equals("AC")) {
				a++;
			} else if (s[i].equals("WA")) {
				b++;
			} else if (s[i].equals("TLE")) {
				c++;
			} else {
				d++;
			}
		}
		System.out.println("AC x " + a);
		System.out.println("WA x " + b);
		System.out.println("TLE x " + c);
		System.out.println("RE x " + d);
		sc.close();
	}

}

Measured memory_bytes: 65988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string stra,strb;
    cin>>stra;
    cin>>strb;
    sort(stra.begin(),stra.end());
    sort(strb.begin(),strb.end(),greater<char>());
    if(stra>=strb) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	string S;
	cin >> S;
	ll ans = 0;
	int  k = 1,q=0;
	set<int> Q;
	map<int, ll> K;
	fx(S.size()) {
		q = (k * (S[S.size() - 1 - x] - '0') + q) % 2019;
		k = (k * 10) % 2019;
		Q.insert(q);
		K[q]++;
	}
	for (int k : Q) {
		ll p = K[k];
		ans += p * (p - 1) / 2;
	}
	ce(ans+K[0])

    return 0;
}



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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N;
    cin >> N;
    vector<int> A(N + 1);
    vector<int> B(N);
    rep(i, N+1){
        cin >> A[i];
    }
    rep(i, N){
        cin >> B[i];
    }
    ll ans = 0;
    rep(i, N){
        if(A[i] > B[i]){
            ans += B[i];
        }else{
            ans += A[i];
            B[i] -= A[i];
            if(A[i+1] > B[i]){
                ans += B[i];
                A[i+1] -= B[i];
            }else{
                ans += A[i + 1];
                A[i + 1] = 0;
            }
        }
    }
    cout << ans << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int x = a * 100 + b * 10 + c;
	if (x % 4 == 0){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

const int INF = 1e8;

class Tree {
	int n;
	void bfs(int s, vector<int>& dis, vector<int>& pre) {
		queue<int> q;
		dis[s] = 0;
		q.emplace(s);

		while (not q.empty()) {
			int u = q.front();
			q.pop();
			for (auto e : g[u]) {
				if (dis[e.first] == INF) {
					dis[e.first] = dis[u] + e.second;
					pre[e.first] = u;
					q.emplace(e.first);
				}
			}
		}
	}

  public:
	vector<vector<pair<int, int>>> g;
	vector<int> path;
	Tree(int n) : n(n), g(n) {}
	void addEdge(int a, int b, int c = 1) {
		g[a].emplace_back(b, c);
		g[b].emplace_back(a, c);
	}
	int diameter() {
		vector<int> pre(n, -1), dis(n, INF);
		bfs(0, dis, pre);

		int maxi = 0, tgt = 0;
		rep(i, n) {
			if (dis[i] == INF) continue;
			if (maxi < dis[i]) {
				maxi = dis[i];
				tgt = i;
			}
		}

		pre = vector<int>(n, -1);
		dis = vector<int>(n, INF);
		bfs(tgt, dis, pre);
		maxi = 0; // tgt$B$+$i:G$b1s$$@\E@$N5wN%(Bmaxi
		rep(i, n) {
			if (dis[i] == INF) continue;
			if (maxi < dis[i]) {
				maxi = dis[i];
				tgt = i;
			}
		}

		int pos = tgt;
		while (pre[pos] != -1) {
			path.emplace_back(pre[pos]);
			pos = pre[pos];
		}
		return maxi;
	}
	pair<int, int> center() {
		if (path.empty()) diameter();

		assert(path.size() == 0 and "path is empty");
		if (path.size() % 2 == 0) {
			return make_pair(path[path.size() / 2 - 1], path[path.size() / 2]);
		} else {
			return make_pair(path[path.size() / 2], -1);
		}
	}
};

signed main() {
	int n;
	cin >> n;
	Tree tree(n);
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		tree.addEdge(a, b);
	}
	auto c = tree.diameter();
	c++;
	if(c==1){
		cout << "First" << endl;
	}else if((c-2)%3==0){
		cout << "Second" << endl;
	}else{
		cout << "First" << endl;
	}
}


Measured memory_bytes: 21064
#include<iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	string ans;
	for (int i = 0;i < s.length();i++) {
		if (s[i] == '0') {
			ans += "0";
		}
		if (s[i] == '1') {
			ans += "1";
		}
		if (s[i] == 'B') {
			if (ans.length() >= 1) {
				ans = ans.substr(0, ans.length() - 1);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3040
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int n, k; cin >> n >> k;

	int ans = 1;

	rep(i, n) {
		if (ans * 2 > ans + k) ans += k;
		else ans *= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
typedef pair<int,int> P;

int main(){
	int h,w;
	cin >> h>>w;
	char a;
	vector<P> v;
	rep(i,h){
		rep(j,w){
			cin >> a;
			if (a == '#'){
				v.push_back(P(i,j));
			}
		}
	}
	bool flag = 0;
	rep(i,v.size()-1){
		if (((v[i].first+1==v[i+1].first)&&(v[i].second==v[i+1].second))||((v[i].first==v[i+1].first)&&(v[i].second+1==v[i+1].second))){
			continue;
		}
		else {
			flag = 1;
			break;
		}
	}
	if (flag){
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" <<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

money = 100000

for s in sys.stdin:
  count = 0
  d = int(s)
  for i1 in range(10):
    if i1 > d:
      pass
    for i2 in range(10):
      if i1 + i2 > d:
        pass
      for i3 in range(10):
        if i1 + i2 + i3 > d:
          pass
        for i4 in range(10):
          if i1 + i2 + i3 + i4 > d:
            pass
          if i1 + i2 + i3 + i4 == d:
            count += 1
  print count

Measured memory_bytes: 4208
/**Coder Khỏe ♥♥♥ Code Vui**/
#include<bits/stdc++.h> 
  
using namespace std; 
  
#define ii pair<int, int> 
#define li pair<long long, int> 
#define si pair<string, int> 
#define is pair<int, string> 
#define ci pair<char, int> 
#define ic pair<int, char> 
#define iii pair<pair<int, int>, int> 
#define fi first 
#define se second 
#define FOR(i,x,y) for (int i=x; i<=y; i++) 
#define FOD(i,x,y) for (int i=x; i>=y; i--) 
  
const int oo=1e9+9; 
const int nmax=1e6+9; 
const int cot[4]={0, 0, -1, 1}; 
const int dong[4]={-1, 1, 0, 0}; 
long long k; 
long long a[59]; 
//------------------------------------------ 
int main() 
{ 
    ios::sync_with_stdio(false); cin.tie(0); 
    //freopen("text.inp",  "r", stdin); 
    //freopen("text.out", "w", stdout); 
    cin>>k; 
    FOR(i,1,50) 
        a[i]=49+k/50; 
    k%=50; 
    FOR(i,1,k) 
    { 
        a[i]+=50+1; 
        FOR(j,1,50) a[j]--; 
    } 
    cout<<50<<endl; 
    FOR(i,1,50) 
    { 
        cout<<a[i]<<' '; 
    } 
    return 0; 
} 
/**NXKhang ♥ VNgHT**/

Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())
c1=a*a*b/2
if x==a*a*b:
    print(0.0)
    exit(0)
if x>c1:
    ans=math.atan((a*a*a)/((2*a*a*b)-(2*x)))
    ans=math.degrees(ans)
    print(90-ans)
else:
    ans=math.atan((2*x)/(a*b*b))
    ans=math.degrees(ans)
    print(90-ans)

Measured memory_bytes: 38384
import java.util.*;
import java.util.regex.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int n = sc.nextInt();
        int[] t = new int[n+1];
        int[] x = new int[n+1];
        int[] y = new int[n+1];
        // 初期値
        t[0] = 0;
        x[0] = 0;
        y[0] = 0;
        // 入力値
        for (int i = 1; i <= n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        int dt, dist, diff;
        for (int i = 0; i < n; i++) {
            // dt = t[i+1] - t[i];
            // dist = Math.abs(x[i+1] - x[i]) + Math.abs(y[i+1] - y[i]);
            // if (dt < dist || (dist % 2 != dt % 2)) {
            //     // 出力
            //     System.out.println("No");
            //     return;
            // }
            diff = Math.abs(x[i+1] - x[i]) + Math.abs(y[i+1] - y[i]) - t[i+1] + t[i];
            if ((diff % 2 != 0) || diff > 0) {
                // 出力
                System.out.println("No");
                return;
            }
        }

        // 出力
        System.out.println("Yes");
    }
}


Measured memory_bytes: 90152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 2000005
#define INF 2000000010
int n = 0;
int a[N];
void swap(int *a, int *b){
    int t;
    t = *a;
    *a= *b;
    *b = t;
}
void maxHeapify(int i){
    int l = 2*i;
    int r = 2*i+1;
    int maxi = i;
    if(l <= n && a[l] > a[maxi]){
        maxi = l;
    }
    if(r <= n && a[r] > a[maxi]){
        maxi = r;
    }
    if(maxi != i){
        swap(&a[i], &a[maxi]);
        maxHeapify(maxi);
    }
}
void insert(int key){
    a[++n] = key;
    int temp = n;
    while(temp > 1 && a[temp/2] < key){
        swap(&a[temp], &a[temp/2]);
        temp /= 2;
    }
}
int extract(){
    int res = a[1];
    a[1] = a[n--];
    maxHeapify(1);
    return res;
}
int main(){
    char s[10];
    int k;
//    insert (120);
//    insert (88);
//    insert (3);
//    insert (999999999);
//    insert (7);
//    extract();
//    insert (100);
//    insert (21);
//    insert (100);
//    insert (100);
//    insert (10);
//    extract();
//    insert (100);
//    extract();
//    insert (777);
//    insert (100);
//    extract();
//    extract();
//    extract();
//    extract();
//    extract();
//    insert (120);
//    extract();
//    extract();
    while(scanf("%s", s), strcmp(s, "end")){
        if(s[0] == 'i'){
            scanf("%d", &k);
            insert(k);
        }else if(s[0] == 'e'){
            int p = extract();
            printf("%d\n", p);
        }
    }
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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;

	vector<int> A;
	int temp = 0;
	for(int i=0; i<N; i++){
		cin >> temp;
		A.push_back(temp);
	}

	vector<int> B;
	temp = 0;
	for(int i=0; i<N; i++){
		cin >> temp;
		B.push_back(temp);
	}

	vector<P> val;
	REP(i,N){
		val.push_back(make_pair(B[i],A[i]));
	}
	sort(val.begin(),val.end());

/*	REP(i,N){
		cout << val[i].second << "," << val[i].first << "\n";
	}
*/

	REP(i,N){
		A[i] = val[i].second;
		B[i] = val[i].first;	
	}

	REP(i,N){
		val[i] = make_pair(A[i],i);
	}
	sort(val.begin(),val.end());

	REP(i,N){
		if(val[i].first > B[i]){
			cout << "No" << "\n";
			return 0;
		}
	}
	bool flg = false;
	REP(i,N-1){
		if(val[i+1].first <= B[i]){
			flg = true;
			break;
		}
	}
	if(flg == true){
		cout << "Yes" << "\n";
		return 0;
	}

	int now = 0;
	while(N-1 > 0){
		now = val[now].second;
		if(now == 0){
			cout << "Yes" << "\n";
			return 0;
		}
		N--;
	}
	cout << "No" << "\n";
	return 0;


return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    int n;
    cin >> n;
    vector<int>l(n);
    ll ans  = 0;
    rep(i, n) cin >> l[i];
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            for (int k = j + 1; k < n; k++) {
                if ((l[i] != l[j]) && (l[i] != l[k]) && (l[k] != l[j])){
                    if ((l[i] + l[j] > l[k]) && (l[i] + l[k] > l[j] )&& (l[k] + l[j] > l[i])) {
                        ans++;
                        //cout << i <<',' << j << ',' << k << endl;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	string A, B, C;
	cin >> A >> B >> C;
	char h = 'a';
	int i=0, j=0, k=0;
	while (1) {
		switch (h) {
			case 'a':
				h = A[i];
				i++;
				if (i == A.size()+1) {
					cout << 'A' << endl;
					return 0;
				}
				break;
			case 'b':
				h = B[j];
				j++;
				if (j == B.size()+1) {
					cout << 'B' << endl;
					return 0;
				}
				break;
			case 'c':
				h = C[k];
				k++;
				if (k == C.size()+1) {
					cout << 'C' << endl;
					return 0;
				}
				break;
		}
	}
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a=n/100;
    int b=(n/10)%10;
    int c=n%10;
    if(a==7||b==7||c==7) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3588
N = int(input())
H = list(map(int,input().split()))
ans = "Yes"
bef = 0
for i in range(N):
    if i==0:
        bef=H[i]-1
        continue
    if H[i]>bef:
        bef=H[i]-1
    elif H[i]<bef:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 14252
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    long sum = 0;
    
    scanf("%d",&N);
    
    for(int i = 1; i <= N; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    
    printf("%ld\n",sum);
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define INF INT_MAX
#define MIN INT_MIN
int d[200000];
int main(void){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> d[i];
	int mn = INF, mx = MIN;
	for(int i = 1; i < n; i++){
		mn = min(mn, d[i - 1]);
		mx = max(mx, d[i] - mn);
	}
	cout << mx << endl;
	return 0;
}


Measured memory_bytes: 3884
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 1005
#define ll long long
#define ld double
#define mod 1000000007
using namespace std;	
int a[maxn], b[maxn];
int tp[2][maxn * maxn];
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]), 
		tp[0][a[i]] = 1;
	for(int j = 0; j < m; j++)
		scanf("%d", &b[j]), 
		tp[1][b[j]] = 1;
	int pl1 = n, pl2 = m;
	sort(a, a + n),
	sort(b, b + m);	
	ll ans = 1;
	for(int i = 0; i < n - 1; i++)
		if(a[i] == a[i + 1]) ans = 0;
	for(int i = 0; i < m - 1; i++)
		if(b[i] == b[i + 1]) ans = 0;

	for(int s = n * m; s >= 1; s--)
	{
		while(pl1 && a[pl1 - 1] >= s) pl1--;
		while(pl2 && b[pl2 - 1] >= s) pl2--;
		int nt = (n - pl1) * (m - pl2) - (n * m - s);
		if(nt <= 0) ans = 0;
		if(tp[0][s] && tp[1][s]) nt = 1;
		else if(tp[0][s]) nt = m - pl2;
		else if(tp[1][s]) nt = n - pl1;
		ans = ans * nt % mod;
	}
	printf("%lld\n", ans);
	return 0;
} 
/*
bbbbbb
bababa

*/

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << a * b << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    string s;
    cin >> s;
    int n = s.size();
    for(int i=0; i<n; i++){
        if(i%2 && s[i] == 'R'){
            cout << "No";
            return 0;
        }
        if(i%2 == 0 && s[i] == 'L'){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	type pair struct{ l, r, i int }

	n, q := r(), r()
	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		a[i] = r()
	}
	qs := make([]pair, q)
	for i := range qs {
		qs[i] = pair{r(), r(), i}
	}
	sort.Slice(qs, func(i, j int) bool { return qs[i].r < qs[j].r })

	tree := make([]int, n+1)
	add := func(i int, val int) {
		for ; i <= n; i += i & -i {
			tree[i] += val
		}
	}
	sum := func(i int) (res int) {
		for ; i > 0; i &= i - 1 {
			res += tree[i]
		}
		return
	}
	query := func(l, r int) int { return sum(r) - sum(l-1) }

	ans := make([]int, q)
	posR := make([]int, n+1)
	i := 1
	for _, q := range qs {
		for ; i <= q.r; i++ {
			if p := posR[a[i]]; p > 0 {
				add(p, -1)
			}
			add(i, 1)
			posR[a[i]] = i
		}
		i = q.r + 1
		ans[q.i] = query(q.l, q.r)
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 35964
#include<stdio.h>
int main()
{
	int x[10000],i,a;
	i=1;
	a=2;
	while(1){
		scanf("%d",&x[i]);
		a=x[i];
		i++;
		if(a==0){
			i=1;
			break;
		}
	}while(1){
		printf("Case %d: %d\n",i,x[i]);
		i++;
		if(x[i]==0){
			break;
		}
	}
return 0;
}

Measured memory_bytes: 2656
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;
    cin >> n;
    ll t = n;
    vector<int> v;
    while(t > 0){
        v.PB(t % 10);
        t /= 10LL;
    }
    reverse(ALL(v));
    int ans = accumulate(ALL(v), 0);
    int sum = 0;
    for(int i = 0; i < SZ(v); i++){
        if(v[i] > 0){
            v[i] -= 1;
            sum += v[i++];
            while(i < SZ(v)){
                sum += 9;
                i++;
            }
            break;
        }
        sum += v[i];
    }
    cout << max(ans, sum);
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
N = gets.to_i
H = gets.split.map(&:to_i)

min = H[0]
isFail = false
(1...N).each do |i|
  if (min - H[i]) > 1
    isFail = true
    break
  end
  min = H[i] if min < H[i]
end

if isFail
  puts 'No'
else
  puts 'Yes'
end

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    vector<int> P(N), Q(N);
    vector<int> v(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    rep(i,N) v[i] = i+1;
    sort(v.begin(), v.end());
    int a, b;
    int cnt = 0;
    do{
        cnt++;
        if(v == P) a = cnt;
        if(v == Q) b = cnt;
    }while(next_permutation(v.begin(), v.end()));
    cout << abs(a - b) << endl;
}

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

using namespace std;

int main(){
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  if( a==b && a!=c ){
    cout << "Yes" << endl;
    return 0;
  }
  if( a==c && a!=b ){
    cout << "Yes" << endl;
    return 0;
  }
  if( b==c && b!=a ){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;


  return 0;
}


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

int main(void)
{
	set<char> nums1;
	const char a[] = {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b',' '};
	for(int i=0; a[i]!=' '; i++)
	{ 
		nums1.insert(a[i]);
	}
	
	string c;
	int count=0,flag1=0,flag2;
	
	for(;;)
	{
		count=0;
		cin >> c;
		if(c=="#") break;
		for(int i=0; i<c.size(); i++)
		{
			if(nums1.find(c[i])==nums1.end())
			{
				flag2=0;
			}
			else
			{
				flag2=1;
			}
			
			if(flag1!=flag2 && i!=0) count++;
			flag1=flag2;
		}
		
		cout  << count << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1192
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

A_set = set(A)
a = Counter(A)
ruiseki = 0
for i in A_set:
    count = a[i]
    ruiseki += count*(count-1)/2
    
for i in range(N):
    b = A[i]
    front = a[b] * (a[b]-1) / 2
    later = (a[b]-1) * (a[b]-2) / 2
    ans = ruiseki - front + later
    print(int(ans))

Measured memory_bytes: 28732
#include <bits/stdc++.h>
using namespace std;
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 a, p;

int main() {
    cin >> a >> p;
    cout << (a*3+p) / 2 << endl;
}

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

using namespace std;

using int64 = long long;

int main()
{
  int N, P[200000];
  cin >> N;
  N *= 2;
  for(int i = 0; i < N; i++) cin >> P[i];
  sort(P, P + N);
  double ret = 0;
  for(int i = 0; i < N; i++) ret += 1.0 * i * P[i];
  cout << fixed << setprecision(15) << ret / (N - 1) << endl;
}

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

string dice[8];
bool use[8];
string cube[8];

char trans(char a){
  if('a'<=a && a<='z')return a-32;
  else return a+32;
}

bool rec(int times){
  if(times == 8)return true;
  for(int i=0;i<8;i++){
    if(!use[i]){
      bool f = true;
      char ex;
      if(times%2){
	bool f2 = false;
	ex = trans(cube[times-1][5]);
	for(int j=0;j<6;j++)
	  if(dice[i][j]==ex)f2 = true;
	f &= f2;
      }

      if(times%4>=2){
	bool f2 = false;
	ex = trans(cube[times-2][3]);
	for(int j=0;j<6;j++)
	  if(dice[i][j]==ex)f2 = true;
	f &= f2;
      }
      if(times>=4){
	bool f2 = false;
	ex = trans(cube[times-4][4]);
	for(int j=0;j<6;j++)
	  if(dice[i][j]==ex)f2 = true;
	f &= f2;
      }
      if(f){
	use[i] = true;
	string tmp = dice[i];
	for(int l=0;l<3;l++){
	  if(l==1){
	    swap(tmp[0],tmp[5]);
	    swap(tmp[1],tmp[4]);
	  }
	  if(l==2){
	    swap(tmp[0],tmp[5]);
	    swap(tmp[2],tmp[3]);
	  }
	  for(int j=0;j<3;j++){
	    swap(tmp[0],tmp[1]);
	    swap(tmp[1],tmp[2]);
	    swap(tmp[5],tmp[4]);
	    swap(tmp[4],tmp[3]);
	    for(int k=0;k<4;k++){
	      swap(tmp[1],tmp[2]);
	      swap(tmp[2],tmp[4]);
	      swap(tmp[4],tmp[3]);

	      //if(!i && !times)cout << tmp << endl;
	      f = true;
	      if(times%2){
		if(trans(tmp[0])!=cube[times-1][5])f = false;
	      }
	      if(times%4>=2){
		if(trans(tmp[2])!=cube[times-2][3])f = false;
	      }
	      if(times>=4){
		if(trans(tmp[1])!=cube[times-4][4])f = false;
	      }
	      if(f){
		cube[times] = tmp;
		if(rec(times+1))return true;
	      }
	    }
	  }
	}
	use[i] = false;
      }
    }
  }

  return false;
}

int main(){
  for(;;){
    cin >> dice[0];
    if(dice[0] == "0")break;
    for(int i=1;i<8;i++)cin >> dice[i];
    for(int i=0;i<8;i++)use[i] = false;

    if(rec(0))cout << "YES\n";
    else cout << "NO\n";
    //for(int i=0;i<8;i++)cout << cube[i] << endl;
  }
}

Measured memory_bytes: 896
fun main(args : Array<String>) {
    val (A, B, K) = readLine()!!.split(" ").map { it.toInt() }

    println(
            (100 downTo 1).filter {
                it <= A && it <= B &&
                A.mod(it) == 0 && B.mod(it) == 0
            }.get(K - 1)
    )
}

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

int t[100050];

int main(){
	map<int,int> mp;

	int n, m, x;
	int k = 0, a = 1, b = 1;
	scanf("%d%d", &n, &m);
	while(n--){
		scanf("%d", &x);

		if(mp[x] == 0){
			if(k < m){
				++k;
			}
			else{
				while(t[a] < 0) ++a;
				mp[t[a]] = 0;
				t[a++] = -1;
			}
		}
		else{
			t[mp[x]] = -1;
		}
		
		mp[x] = b;
		t[b++] = x;
	}

	while(--b >= a){
		if(t[b] >= 0) printf("%d\n", t[b]);
	}
}

Measured memory_bytes: 6104
# -*- coding: utf-8 -*-

from collections import Counter 

N = int(input())
AN = list(map(int, input().split()))

# 各数値ごとに数を集計
AN_dict = Counter(AN)

ans = 0
for key, value in AN_dict.items():
    tmp = 0
    # その数、+1、-1した数の合計を調べて、最大になるものを選ぶ
    tmp += value
    if key-1 in AN_dict:
        tmp += AN_dict[key-1]
    if key+1 in AN_dict:
        tmp += AN_dict[key+1]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 14564
h, w = map(int, input().split())

white = 0
a = [[] for _ in range(h + 2)]
a[0] = [ '#' for _ in range(w + 2)]
a[h + 1] = [ '#' for _ in range(w + 2)]
for i in range(h):
    a[i + 1] = ['#'] + list(input()) + ['#']
    white += a[i + 1].count('.')

a[1][1] = '.'
a[h][w] = '.'

res = [[1,1]]
ans = 1
while 1:
    ans += 1
    temp = []
    for i, j in res:
        if a[i + 1][j] == '.':
            temp.append([i + 1, j])
        if a[i][j + 1] == '.':
            temp.append([i, j + 1])
        if a[i - 1][j] == '.':
            temp.append([i - 1, j])
        if a[i][j - 1] == '.':
            temp.append([i, j - 1])
        a[i][j] = '#'
    if len(temp) == 0:
        print('-1')
        exit()
    res = list(map(list, set(map(tuple, temp))))
    if [h, w] in res:
        break

print(white - ans)

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

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

		int[] colors = new int[100];

		for (int i = 0; i < 3; i++) {
			int color = sc.nextInt();
			colors[color - 1] = 1;
		}

		int sum = 0;

		for (int i = 0; i < colors.length; i++) {
			sum += colors[i];
		}

		System.out.println(sum);

		sc.close();

	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());

    int m = a[0];
    for(int i = 1; i < n; ++i)  m -= a[i];

    int cnt = 0;
    for(int i = 1; i < n - 1; ++i){
        int foo = m;
        foo += a[i] * 2;
        if(foo >= m){
            m = foo;
            ++cnt;
        }
        else    break;
    }

    cout << m << endl;
    for(int i = 0; i < cnt; ++i){
        cout << a[n - 1] << ' ' << a[i + 1] << '\n';
        a[n - 1] -= a[i + 1];
    }
    for(int i = cnt + 1; i < n; ++i){
        cout << a[0] << ' ' << a[i] << '\n';
        a[0] -= a[i];
    }
}

Measured memory_bytes: 2304
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

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

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

//	for priority queue
//	priority_queue<ipair, vector<ipair>, greater<ipair>>
using ipair = pair<int, pair<int, int>>;
bool operator>(const ipair a, const ipair b) { return a.first > b.first; };
bool operator<(const ipair a, const ipair b) { return a.first < b.first; };

int main()
{
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v < w)
	{
		printf("NO");
		return 0;
	}
	ll c = b > a ? b - a : a - b;
	ll u = v - w;

	if (u * t >= c)
		printf("YES");
	else
		printf("NO");
	return 0;
}


Measured memory_bytes: 3172
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
ll N, M;
int A[100001];

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

  cin >> N >> M;
  if (N==1){
    if (M==1) cout << 1 << "\n";    
    else cout << M-2 << "\n";
    return 0;
  }
  if (M==1){
    if (N==1) cout << 1 << "\n";    
    else cout << N-2 << "\n";
    return 0;
  }
  if (M==2 || N==2){
    cout << 0 << "\n";
    return 0; 
  }
  cout << (N-2)*(M-2) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;
int main (){
    int N;
    cin >> N;
    vector<ll> a(N+1);

    for (int i=1;i<=N;i++){
        cin >> a[i];
    }

    int ans=0;
    int v=1;
    int r =0;
    bool f=false;
    for(int i=1;i<=N;i++){

        if(a[i] == v){
            f=true;
            ans += i - r - 1;
            r = i;
            v += 1;
        }
       

    }

    ans += N - r;

    if(f){
        cout << ans;
    }
    else cout << "-1";

}

Measured memory_bytes: 1792
import copy

N = int(input())

p = [int(i) for i in input().split()]

ans = 0
for i in range(1, N-1):
	t = copy.deepcopy(p[i])
	s = copy.deepcopy(p[i-1:i+2])
	
	if t == sorted(s)[1]:
		ans += 1

print(ans)

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

int main() {
  int n,k;
  cin>>n>>k;
  n--;
  k--;
  vector<int>s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  int ans=n/k;
  if(n%k!=0) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll l,r;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,k,s;
    cin>>n>>k>>s;
    if (s!=1e9)
    {
        rep (i,0,k)
        {
            cout<<s<<" ";
        }
        rep (i,0,n-k)
        {
            cout<<s+1<<" ";
        }
        return 0;
    }
    else
    {
        rep (i,0,k)
        {
            cout<<s<<" ";
        }
        rep (i,0,n-k)
        {
            cout<<s-1<<" ";
        }
        return 0;
    }


    // ll c=2*s;
    // ve <abc> arr;
    // rep (i,1,s+1)
    // {
    //     ll a1=(i)*(i+1)-2*s;
    //     ld b1=1+4*a1;
    //     if (sqrt(b1)!=floor(sqrt(b1)))
    //     {
    //         cc;
    //     }
    //     ll b2=sqrt(b1);
    //     if ((1+b2)%2!=0)
    //     {
    //         cc;
    //     }
    //     ll b3=(1+b2)/2;
    //     abc x1;
    //     x1.l=b3;
    //     x1.r=i;
    //     arr.pb(x1);
    // }

    // for (auto x: arr)
    // {
    //     cout<<x.l<<" "<<x.r<<"\n";
    // }
    // ll n1=arr.size();
    // // rep (i,0,)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
 int n; cin >> n;
 int s = 0;
 int t[n]; for(int i=0;i<n;i++) {cin >> t[i]; s+= t[i];}
 int m; cin >> m;
 for(int i=0;i<m;i++){
  int p, x; cin >> p >> x;
  cout << s + x - t[p-1] << endl;
 } 
 return 0;
}

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

int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  int ans;
  if(n<=k)ans=n*x;
  else ans=k*x+(n-k)*y;
  cout << ans << endl;
  return 0;
}

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

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long LL;

template <typename T, typename TT> ostream & operator << (ostream &out, pair<T, TT> t) { return out << "(" << t.X << "," << t.Y << ")";}
template <typename T> ostream & operator << (ostream &out,vector<T> t) { out << "["; for (auto x:t) out << x << " "; out << "]"; return out;}
template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
template <typename T> void read(T & x) 
{
	int f = 1; char ch; x = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); x *= f;
}

const int NX = 100010;
int n, m, e, label[NX]; LL cnt[3]; 
vector<pair<int, int> > edge[NX];
bool vis[NX], ok;

void dfs(int x, int d)
{
	vis[x] = true; 
	++cnt[label[x] = d]; 
	for (pair<int, int> p : edge[x])
	{
		int y = p.first; ++e;
		if(vis[y])
		{
			if(label[y] != (d + p.second + 3) % 3)
				ok = false;
		} else {
			dfs(y, (d + p.second + 3) % 3);
		}
	}
}

int main() {
	read(n); read(m);
	for (int i = 1; i <= m; i++)
	{
		int u, v; read(u); read(v);
		edge[u].pb(mp(v, 1));
		edge[v].pb(mp(u, -1));
	}
	
	LL ans = 0;
	for (int i = 1; i <= n; i++)
		if(!vis[i]){
			memset(cnt, 0, sizeof(cnt));
			ok = true; e = 0;
			dfs(i, 0);
			
			if(ok)
			{
				if(*min_element(cnt, cnt + 3) > 0)
				{
					ans +=    cnt[0] * cnt[1]
							+ cnt[1] * cnt[2]
							+ cnt[2] * cnt[0];
				}
				else 
					ans += (e >> 1);
			} else {
				LL m = cnt[0] + cnt[1] + cnt[2];
				ans += m * m;	
			}
		}
	cout << ans << "\n";
	return 0;
}





Measured memory_bytes: 10880
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	string s,t;
	int count{0};
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			count++;
		}
	}
	cout<<count<<endl;
}


Measured memory_bytes: 3800
N, M = map(int, input().split())

ks = []
switch_to_light = [[] for _ in range(N)]

for i in range(M):
    t = list(map(int, input().split()))
    ks.append(list(map(lambda x: x - 1, t[1:])))
for i, k in enumerate(ks):
    for ss in k:
        switch_to_light[ss].append(i)

# print(ks)
# print(switch_to_light)

p = tuple(map(int, input().split()))
# print(p)

ans = 0
for i in range(1 << N):
    # print(bin(i).zfill(N))
    cnt = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            # スイッチjがON
            for light_idx in switch_to_light[j]:
                # print(light_idx, j, cnt)
                cnt[light_idx] += 1
    flg = True
    for j in range(M):
        if cnt[j] % 2 != p[j]:
            flg = False
            break
    if flg:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int H, W;
char s[20][20];
int d[20][20][20][20];
bool used[20][20];
int dh[4] = {-1, 1, 0, 0};
int dw[4] = {0, 0, -1, 1};

bool isIn(int h, int w){
    return (h >= 0 && h < H && w >= 0 && w < W);
}

void clear(){
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            used[i][j] = false;
        }
    }
}

int ans = 0;
typedef pair<int, int> P_;
typedef pair<P_, int> P;

void bfs(int sh, int sw, int d){
    queue<P> que;
    que.push(P(P_(sh, sw), 0));
    used[sh][sw] = true;
    while(!que.empty()){
        P top = que.front();
        que.pop();
        int h = top.first.first;
        int w = top.first.second;
        int d = top.second;
        used[h][w] = true;
        ans = max(ans, d);
        for(int i = 0; i < 4; i++){
            if(isIn(h+dh[i], w+dw[i]) && !used[h+dh[i]][w+dw[i]] && s[h+dh[i]][w+dw[i]] == '.') {
                used[h+dh[i]][w+dw[i]] = true;
                que.push(P(P_(h+dh[i], w+dw[i]), d+1));
            }
        }
    }
    
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            clear();
            if(s[i][j] == '.') bfs(i, j, 0);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main(void) {
	string s; cin >> s;
	const int sz = s.length();
	if (sz & 1) {
		cout << "No" << endl;
		return 0;
	}
	int ptr = 0;
	while (ptr < sz) {
		string sub = s.substr(ptr, 2);
		if (sub != "hi") {
			cout << "No" << endl;
			return 0;
		}
		ptr += 2;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	int ans=m;
	int in,out;
	rep(i,n){
		cin>>in>>out;
		m=m+in-out;
		ans=max(ans,m);
		if(m<0){
			ans=0;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160