akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

	int solve(char[] a, char[] b) {
		if (Arrays.equals(a, b)) {
			return 0;
		}

		boolean bZero = true;
		for (char c : b) {
			bZero &= c == '0';
		}

		if (bZero) {
			return -1;
		}

		int n = a.length;

		int[] diff = new int[n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {

				if (b[(j + i) % n] != a[j]) {
					diff[i]++;
				}
			}
		}

		boolean[][] bad = new boolean[n][n];

		for (int i = 0; i < n; i++) {
			if (a[i] == '1') {

				if (b[i] == '1') {
					continue;
				}

				int pos = 0;
				while (b[(i + pos) % n] == '0') {
					pos++;
				}

				int neg = 0;
				while (b[(i + n - neg) % n] == '0') {
					neg++;
				}

				// x >= pos or y >= neg
				bad[pos - 1][neg - 1] = true;
			}
		}

		for (int i = n - 1; i >= 0; i--) {
			for (int j = n - 1; j >= 0; j--) {
				if (bad[i][j]) {
					if (i > 0) {
						bad[i - 1][j] = true;
					}
					if (j > 0) {
						bad[i][j - 1] = true;
					}
				}
			}
		}

		int ret = Integer.MAX_VALUE;

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

			boolean isFirst = true;

			for (int neg = 0; pos + neg < n; neg++) {

				if (bad[pos][neg]) {
					continue;
				}

				if (isFirst) {

					for (int end = -neg; end <= pos; end++) {

						int path = getPath(0, -neg, pos, end);
						ret = Math.min(ret, path + diff[(end + n) % n]);

					}
					isFirst = false;

				} else {
					int end = -neg;
					{

						int path = getPath(0, -neg, pos, end);
						ret = Math.min(ret, path + diff[(end + n) % n]);

					}
				}

			}

		}
		
		return ret;

	}
	
	void submit() {
		char[] a = nextToken().toCharArray();
		char[] b = nextToken().toCharArray();
		
		out.println(solve(a, b));
	}

	int getPath(int from, int c1, int c2, int to) {
		return Math.min(getOrderedPath(from, c1, c2, to),
				getOrderedPath(from, c2, c1, to));
	}

	int getOrderedPath(int a, int b, int c, int d) {
		return Math.abs(b - a) + Math.abs(c - b) + Math.abs(d - c);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

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

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

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

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

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


Measured memory_bytes: 26464
#include<iostream>
using namespace std;
int main()
{
    int n,loc,j,c=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i){
        cin>>a[i];
	}
    for (int i=0;i<n;i++){
        loc=i;
        for (j=i;j<n;j++)
        {
            if (a[loc]>a[j])
                    loc=j;
        }
        if(loc!=i)
        {
            int temp=a[i];
            a[i]=a[loc];
            a[loc] =temp;
            c++;
        }
    }
    for(int i=0;i<n-1;i++){
        cout<<a[i]<<" ";
    }
    cout<<a[n-1]<<endl<<c<<endl;
    return 0;

}



Measured memory_bytes: 3132
#include<stdio.h>
int main(){
	long long h,k,f,s,ans;
	scanf("%lld%lld",&h,&k);
	if(h==1||k==1){
		printf("1");
		return 0;
	}
	long long area=h*k;
	if(area%2==0) ans=area/2;
	else{
		ans=(area-k)/2+(k+1)/2;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500*i + 100*j + 50*k == X:
                count += 1

print(count)

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

int main()
{
  string a,b,e;
  int c,d;
  cin >>a>>b>>c>>d>>e;
  if(a==e)cout<<c-1<<" "<<d<<endl;
  else cout<<c<<" "<<d-1<<endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
slime = str(input())
ans_list = []
previous_slime = ""
#print(slime)
for i in range(N):
  #print(slime[i])
  if slime[i] != previous_slime:
    ans_list.append(slime[i])
    previous_slime = slime[i]

print(len(ans_list))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Monoidapris = tuple<int, int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

template <typename Monoid>
class SegmentTree{
    private:
        using Func = function<Monoid(Monoid, Monoid)>;
        int n; // 最下段の数
        vector<Monoid> segmentTree; // セグ木本体
        const Func f; // 二項演算
        const Monoid identityElement; // モノイドの単位元
        Monoid operator[](const int &k) const{
            return segmentTree[k + n];
        }
    public:
        SegmentTree(vector<Monoid> vec, const Func f, const Monoid identityElement);
        void Update(int x, Monoid val);
        Monoid Query(int a, int b, int k = 0, int l = 0, int r = -1); // 使う時は区間[a, b)のみ指定すれば良い
};

template <typename Monoid>
SegmentTree<Monoid>::SegmentTree(vector<Monoid> vec, const Func f, const Monoid identityElement) :
    f(f), identityElement(identityElement)
    {
        int sz = vec.size();
        n = 1;
        while(n < sz) n *= 2;
        segmentTree.assign(2*n-1, identityElement);
        for(int i = 0; i < sz; i++) segmentTree[i+n-1] = vec[i];
        for(int i = n-2; i >= 0; i--) segmentTree[i] = f(segmentTree[2*i+1], segmentTree[2*i+2]);
    }

template <typename Monoid>
void SegmentTree<Monoid>::Update(int x, Monoid val){
    x += n - 1;
    segmentTree[x] = val;
    while(x > 0){
        x = (x - 1) / 2;
        segmentTree[x] = f(segmentTree[2*x+1], segmentTree[2*x+2]);
    }
}

template <typename Monoid>
Monoid SegmentTree<Monoid>::Query(int a, int b, int k, int l, int r){
    if(r < 0) r = n;

    if(r <= a || b <= l) return identityElement;

    if(a <= l && r <= b) return segmentTree[k];

    int vl = Query(a, b, 2*k+1, l, (l+r)/2);
    int vr = Query(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
}

/*************** using variables ***************/
int n, q;
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> q;
    const int _INT_MAX = pow(2, 31) - 1;
    vector<int> a(n, _INT_MAX);
    SegmentTree<int> st(a, [](int a, int b){return min(a, b);}, _INT_MAX);
    REP(i, q){
        int com, x, y;
        cin >> com >> x >> y;
        if(com == 0) st.Update(x, y);
        else cout << st.Query(x, y+1) << endl;
    }
}



Measured memory_bytes: 4652
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

int main(int argc, const char* argv[]) {
  u64 n, q;
  cin >> n >> q;
  char s[n+1];
  cin >> s;
  
  u64 a[n] = {0};
  for(u64 i = 1; i < n; ++i) {
    if(s[i-1] == 'A' && s[i] == 'C') {
      a[i] = a[i-1] + 1;
    } else {
      a[i] = a[i-1];
    }
  }
  
  /*
  for(u64 i = 0; i < n; ++i) {
    cout << a[i] << " ";
  }
  cout << endl;
  */
  
  for(u64 i = 0; i < q; ++i) {
    u64 ans = 0;
    u64 l, r;
    cin >> l >> r;
    
    cout << a[r-1] - a[l-1] << endl;
  }
        
  return 0;
}


Measured memory_bytes: 1664
# # https://atcoder.jp/contests/dp/tasks/dp_d
# def main():

#     N, W = map(int, input().split())
#     wv = [list(map(int, input().split())) for _ in range(N)]
#     w = [wv[0] for _ in range(N)]
#     v = [wv[1] for _ in range(N)]
#     # dp_v[i][limited_w]:
#     # 重さ制限がlimited_wで、０からi-1番目までの品物を選んだときの価値の最大値
#     dp_v = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

#     for i in range(N):
#         for weight in range(W + 1):
#             # 重さ制限weightのもとで品物iを選べるなら選び、価値を更新
#             if weight >= w[i]:
#                 dp_v[i + 1][weight] = max(dp_v[i][weight - w[i]] + v[i], dp_v[i][weight])
#             else:
#                 dp_v[i + 1][weight] = max(dp_v[i + 1][weight], dp_v[i][weight])


# if __name__ == '__main__':
#     main()

def main():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]
    w = [wv[i][0] for i in range(N)]
    v = [wv[i][1] for i in range(N)]
    vdp = [[0 for _ in range(W+1)] for _ in range(N+1)]

    for i in range(N):
        for weight in range(W+1):
            # 品物iを（選べるなら）選ぶ
            if weight >= w[i]:
                vdp[i+1][weight] = max(vdp[i][weight - w[i]] + v[i],
                                       vdp[i][weight])
            # 品物iを選ばない
            vdp[i+1][weight] = max(vdp[i+1][weight], vdp[i][weight])
    print(vdp[N][W])


if __name__ == '__main__':
    main()


Measured memory_bytes: 171528
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const ll INF = (ll)1e18 + 228;
const int N = 2005;

using namespace std;

int n, x, a[N], b[N];

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	scanf("%d%d", &n, &x);
	forn(i, n)
	{
		scanf("%d", &a[i]);
	}
	//~calc_dp
	ll ans = INF;
	forn(i, n)
		b[i] = a[i];
	for (int i = 0; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			b[j] = min(b[j], a[(j + i - 1) % n + 1]);
		}		
		ll res = 1ll * x * i;
		for (int j = 1; j <= n; j++)
			res += b[j];
		ans = min(ans, res);
	}
	cout << ans << endl;

	return 0;
}



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

int main() {

    vector<int> v(32);

    int n;

    cin >> n;

    while(n--) {

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

        v[31] = 0;

        queue<vector<int> > q;

        q.push(v);

        while(1){

            vector<int> tmpv = q.front();

            q.pop();

            if(tmpv[31] == 8){
                cout << 8 << endl;
                break;
            }

            bool check = true;

            for(int i=1;i<=9;i++){
                if(tmpv[1] != tmpv[i]){
                    check = false;
                    break;
                }
            }

            if(check) {
                for (int i = 10; i <= 12; i++) {
                    if (tmpv[10] != tmpv[i]) {
                        check = false;
                        break;
                    }
                }
            }

            if(check) {
                for (int i = 13; i <= 15; i++) {
                    if (tmpv[13] != tmpv[i]) {
                        check = false;
                        break;
                    }
                }
            }

            if(check) {
                for (int i = 16; i <= 18; i++) {
                    if (tmpv[16] != tmpv[i]) {
                        check = false;
                        break;
                    }
                }
            }

            if(check) {
                for (int i = 19; i <= 21; i++) {
                    if (tmpv[19] != tmpv[i]) {
                        check = false;
                        break;
                    }
                }
            }

            if(check) {
                for (int i = 22; i <= 30; i++) {
                    if (tmpv[22] != tmpv[i]) {
                        check = false;
                        break;
                    }
                }
            }

            if(check){
                cout << tmpv[31] << endl;
                break;
            }

            tmpv[31]++;

            vector<int> bv = tmpv;

            swap(tmpv[3],tmpv[22]);
            swap(tmpv[6],tmpv[25]);
            swap(tmpv[9],tmpv[28]);
            swap(tmpv[13],tmpv[15]);
            swap(tmpv[12],tmpv[19]);

            q.push(tmpv);

            tmpv = bv;

            swap(tmpv[1],tmpv[24]);
            swap(tmpv[4],tmpv[27]);
            swap(tmpv[7],tmpv[30]);
            swap(tmpv[16],tmpv[18]);
            swap(tmpv[10],tmpv[21]);

            q.push(tmpv);
            tmpv = bv;

            swap(tmpv[7],tmpv[22]);
            swap(tmpv[8],tmpv[23]);
            swap(tmpv[9],tmpv[24]);
            swap(tmpv[10],tmpv[12]);
            swap(tmpv[13],tmpv[18]);

            q.push(tmpv);
            tmpv = bv;

            swap(tmpv[1],tmpv[28]);
            swap(tmpv[2],tmpv[29]);
            swap(tmpv[3],tmpv[30]);
            swap(tmpv[15],tmpv[16]);
            swap(tmpv[19],tmpv[21]);

            q.push(tmpv);

        }

    }


    return 0;
}

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

main() {
    int T,X; cin >> T >> X;
    cout << fixed << setprecision(4) << (double)T/X << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n,k;
  scanf ("%d %d\n",&n,&k);
  
  int* arr = calloc (n+1,sizeof(int));
  arr[0] = 1;
  
  for (int i=0;i<k;i++)
  {
      int d,curr;
      scanf ("%d\n",&d);
      for (int j=0 ; j<d ; j++)
      {
          scanf ("%d ",&curr);
          arr[curr] = 1;
      }
      scanf ("\n");
  }
  
  int cnt=0;
  
  for (int i=1;i<n+1;i++)
  {
      if (arr[i] == 0) cnt++;
  }
  
  printf ("%d\n",cnt);
  return 0;
} 

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define lld unsigned long long int
#define MAX 2005
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
using namespace std;

int k, n;
char c[MAX];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    if(k==n || k==1)n=0;
    else{
        n-=k;
    }
    cout<<n<<endl;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

fn main() {
    let x: usize = input();
    let y: usize = input();
    let z: usize = input();
    let k: usize = input();
    let mut a: Vec<i64> = (0..x).map(|_| input()).collect();
    let mut b: Vec<i64> = (0..y).map(|_| input()).collect();
    let mut c: Vec<i64> = (0..z).map(|_| input()).collect();

    a.sort_by_key(|a| -a);
    b.sort_by_key(|b| -b);
    c.sort_by_key(|c| -c);

    let mut q = std::collections::BinaryHeap::new();
    for &a in &a {
        for &b in &b {
            for &c in &c {
                if q.len() < k {
                    q.push(Reverse(a + b + c));
                } else {
                    let Reverse(w) = q.pop().unwrap();
                    if w < a + b + c {
                        q.push(Reverse(a + b + c));
                    } else {
                        q.push(Reverse(w));
                        break;
                    }
                }
            }
        }
    }

    let mut ans = Vec::from(q);
    ans.sort();
    with_stdout_lock(|mut w| {
        for Reverse(a) in ans {
            writeln!(w, "{}", a).unwrap();
        }
    });
}

#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
struct Reverse<T>(T);
impl<T: Ord> Ord for Reverse<T> {
    fn cmp(&self, other: &Reverse<T>) -> std::cmp::Ordering {
        other.0.cmp(&self.0)
    }
}
impl<T: PartialOrd> PartialOrd for Reverse<T> {
    fn partial_cmp(&self, other: &Reverse<T>) -> Option<std::cmp::Ordering> {
        other.0.partial_cmp(&self.0)
    }
}


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

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


  int A[n+1][m+1];
  int b[m+1];
  int t;

  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      cin >> t;
      A[i][j] = t;
    }
  }

  for (int j = 1; j <= m; j++){
    cin >> t;
    b[j] = t;
  }

  //int c[n] = {};
  for (int i = 1; i <= n; i++){
    t = 0;

    for (int j = 1; j <= m; j++){
      t += A[i][j] * b[j];
    }
    cout << t << endl;
  }

  return 0;
}

Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


int main()
{
    int n;
    cin >> n;
    vector<long long int>a(n), b(n);

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

    long long int x = 0, y = 0;

    for (int i = 0; i < n; i++) {
        x += b[i] - a[i];
    }
    long long int r = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > b[i])r += a[i] - b[i];
        else if (a[i] < b[i])r -= (b[i] - a[i]) / 2;
    }
    if (r<=0)cout << "Yes" << endl;
    else cout << "No" << endl;



    return 0;

}

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

#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 EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

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

  EACH(n,0,N) {
    EACH(m,0,M) {
      if (n*M + m*(N-2*n) == K) {
        Yes();
        return 0;
      }
    }
  }

  No();

  return 0;
}



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

int main(){
  char s[258] = {}, tmp[258] = {};
  int m, h, i, l;
  while(scanf("%s", s) && s[0] != '-'){
    scanf("%d", &m);
    while(m--){
      scanf("%d", &h);
      strcpy(tmp, s + h);
      s[h] = '\0';
      strcat(tmp, s);
      strcpy(s, tmp);
    }
    puts(s);
  }
  return 0;
}


Measured memory_bytes: 2132
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
// const int N = ;
#define singleCase
// #define multipleCase
int n,a,b;

void work() {
   in(n); in(a); in(b);
   puts((b - a - 1) & 1 ? "Alice" : "Borys");
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
long long n, m, a[1000005];
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      cin >> n >> m;
      while(m--)
      {
            int temp;
            cin >> temp;
            n-=temp;
      }if (n>=0)cout << n << endl;
      else cout << -1 << endl;
      return 0;
}


Measured memory_bytes: 3644
inf = 10**20
n = int(input())
arr = []
s = 0
m = inf
for _ in range(n):
    a,b = ([int(x) for x in input().split()])
    if a > b and m > b:
        m = b
    s += a
if m == inf:
    print(0)
else:
    print(s - m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define lli long long int
#define MAX 1000000000
using namespace std;

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

    int k, a, b;
    bool flag = false;
    cin>>k>>a>>b;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            flag = true;
            break;
        }
    }
    if(flag)
        cout<<"OK";
    else
        cout<<"NG";
    return 0;
}


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

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

using namespace std;

#define MAX (23*60*60+59*60+59+1)
int arr[MAX];

int main() {
  int n;
  while( cin >> n, n ) {
    memset(arr,0,sizeof arr);
    int h,m,s;
    rep(i,n) {
      scanf("%d:%d:%d",&h,&m,&s);
      arr[h*60*60+m*60+s] += 1;
      scanf("%d:%d:%d",&h,&m,&s);
      arr[h*60*60+m*60+s] += -1;
    }
    int maxi = arr[0];
    REP(i,1,MAX) {
      arr[i] += arr[i-1];
      maxi = max(maxi,arr[i]);
    }
    cout << maxi << endl;
  }
  return 0;
}



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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int K = nextInt();




		System.out.println((K/2)*((K+1)/2));

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21332
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
double toRad(int deg){
	return deg/180.0*M_PI;
}
main(){
	double x=0,y=0;
	int len,deg=90;
	double rad=toRad(deg);
	while(1){
		int tdeg;
		scanf("%d,%d",&len,&tdeg);
		if(len==tdeg && len==0){
			break;
		}
		double tx=len*cos(rad);
		double ty=len*sin(rad);
		x+=tx;
		y+=ty;
		deg-=tdeg;
		rad=toRad(deg);
	}
	cout<<(int)x<<endl<<(int)y<<endl;
}

Measured memory_bytes: 1212
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b, c, d = input_int_list()
    S = input()

    for i in range(a - 1, max(c, d) - 1):
        if S[i] == S[i + 1] == "#":
            print("No")
            quit()
    if c < d:
        print("Yes")
        quit()
    if c > d:
        for i in range(b - 2, d - 1):
            if S[i: i + 3] == "...":
                print("Yes")
                quit()
        print("No")
        quit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 73496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var keta = int.Parse(nm[0]);
            var time = int.Parse(nm[1]);
            var info = new string[time][];
            var result = "-1";
            var flag = true;
            for(int i = 0; i < time; i++)
            {
                info[i] = Console.ReadLine().Split(' ');
            }
            var num = new char[keta];
            for(int i = 0; i < keta; i++)
            {
                num[i] = 'e';
            }
            for(int i = 0; i < time; i++)
            {
                if (num[int.Parse(info[i][0]) - 1] == 'e')
                {
                    var tmp = info[i][1].ToCharArray();
                    num[int.Parse(info[i][0]) - 1] = tmp[0];
                }
                else
                {
                    var tmp = info[i][1].ToCharArray();
                    if (num[int.Parse(info[i][0]) - 1] != tmp[0])
                    {
                        flag = false;
                        break;
                    }
                }
                if(num[0] == '0')
                {
                    flag = false;
                    break;
                }
            }
            if(keta != 1 && num[0] == 'e') { num[0] = '1'; }
            if (keta == 1 && num[0] == '0'|| keta == 1 && num[0] == 'e')
            {
                flag = true;
                num[0] = '0';
            }
            for (int i = 1; i < keta ; i++)
            {
                if(num[i] == 'e') { num[i] = '0'; }
            }
            if (flag == true) { result = new string(num); }
            Console.WriteLine(result);
            //Console.ReadKey();
        }
    }
}

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

ll d[55];
ll f(int n, ll x){
  if(n >= x) return 0;
  if(n == 0) return 1;
  ll maxnum = ((ll)4<<n)-3;
  //cout << "n=" << n << " x:" << x << " maxnum:"<< maxnum << endl;
  if(x >= maxnum -1){
    if(d[n] != 0) return d[n];
    else return d[n] = f(n-1, maxnum/2-1) *2 +1;
  }
  else if(x >= maxnum/2+1){
    return f(n-1, x -maxnum/2-1) +1 +f(n-1, maxnum/2-1);
  }
  else{
    return f(n-1, x-1);
  }
}

int main(){
  int n;
  ll x;
  cin >> n >> x;
  cout << f(n,x) << endl;
}

Measured memory_bytes: 3636
N = int(input())
H = list(map(int, input().split()))

ans = 0
cnt = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt
        cnt = 0    
if ans < cnt:
    ans = cnt
print(ans) 

Measured memory_bytes: 15020
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  long long N,A,B;
  long long X[100000];
  cin>>N>>A>>B;
  FOR(i,0,N){
    cin>>X[i];
  }
  long long sum=0;
  FOR(i,0,N-1){
    if(abs(X[i]-X[i+1])*A>=B){
      sum+=B;
    }else{
      sum+=abs(X[i]-X[i+1])*A;
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int a[maxn],p[maxn];
char s[maxn];


int main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    vector<int> st;
    for(int i=1;i<=n;i++){
        if(s[i]=='R'){
            st.push_back(i);
        }
        else{
            for(int j:st){
                p[j]=i;
            }
            st.clear();
        }
    }
    for(int i=n;i>=1;i--){
        if(s[i]=='L'){
            st.push_back(i);
        }
        else{
            for(int j:st){
                p[j]=i;
                st.clear();
            }
        }
    }
   /* for(int i=1;i<=n;i++){
        printf("%d ",p[i]);
    }*/
    for(int i=1;i<=n;i++){
        if(p[i]>i){
            int len=p[i]-i;
            a[p[i]-(len%2)]++;
        }
        else{
            int len=i-p[i];
            a[p[i]+(len%2)]++;
        }
    }
    for(int i=1;i<=n;i++){
        printf("%d ",a[i]);
    }
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 1400
#include <iostream>
#include <stdio.h>
#include <cmath>
#define PI 3.14159265358979323846
using namespace std;

int main(void){
	int a,b,x;
  	cin >> a >> b >> x;
  	double s = (double)x/a,k=(double)a*b/2;
  	if(s>k){
    	double n = (double)2*x/(a*a)-b;
			printf("%.10f\n",atan((b-n)/a)/PI*180);
    }else if(s<k){
    	double n = (double)2*x/a/b;
			printf("%.10f\n",atan(b/n)/PI*180);
    }else{
			printf("%.10f\n",atan((double)b/a)/PI*180);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e6 + 2; int n;
char a[maxN];

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    scanf(" %s", a);
    DEBUG {
      int x[n][n];
      for (int j = 0; j < n; j++)
      {
        printf("%c%c", a[j], j < n - 1 ? ' ' : '\n');
        x[0][j] = a[j] - '0';
      }

      for (int i = 1; i < n; i++)
      {
        for (int j = 0; j < i; j++) printf(" ");
        for (int j = 0; j < n - i; j++)
        {
          x[i][j] = abs(x[i - 1][j] - x[i - 1][j + 1]);
          printf("%d%c", x[i][j], j < n - i - 1 ? ' ' : '\n');
        }
      }
      printf("----------\n");
    }

    int x[n]; for (int i = 0; i < n; i++) x[i] = a[i] - '1';
    int answer = 0;
    for (int i = 0; i < n; i++)
      if (((n - 1) & i) == i)
        answer ^= x[i];
    if (answer & 1)
      printf("1\n");
    else
    {
      bool hasOne = false;
      for (int i = 0; i < n; i++)
        if (x[i] == 1)
          hasOne = true;
      if (hasOne) printf("0\n");
      else
      {
        for (int i = 0; i < n; i++) x[i] >>= 1;
        answer = 0;
        for (int i = 0; i < n; i++)
          if (((n - 1) & i) == i)
            answer ^= x[i];
        if (answer & 1)
          printf("2\n");
        else
          printf("0\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
set<string> st;
map<string, vector<string> > mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n)
	{
		string s, t = "";
		cin >> s;
		bool flag = false;
		int pos = 0;
		st.clear();
		mp.clear();
		while(1)
		{
			if(s[pos] == '.')
			{
				st.insert(t);
				t = "";
				break;
			}
			if(s[pos] == ':')
			{
				flag = true;
				t = "";
			}
			else if(s[pos] == ',')
			{
				st.insert(t);
				t = "";
			}
			else
				t += s[pos];
			pos++;
		}
		for(int i = 0; i < n - 1; i++)
		{
			cin >> s;
			pos = 0;
			string group = "";
			t = "";
			flag = false;
			while(1)
			{
				if(s[pos] == '.')
				{
					mp[group].push_back(t);
					break;
				}
				if(flag == false)
				{
					if(s[pos] == ':')
						flag = true;
					else
						group += s[pos];
				}
				else
				{
					if(s[pos] == ',')
					{
						mp[group].push_back(t);
						t = "";
					}
					else
					{
						t += s[pos];
					}
				}
				pos++;
			}
		}
		flag = true;
		while(flag)
		{
			flag = false;
			for(auto itr = mp.begin(); itr != mp.end(); itr++)
			{
				auto group = itr->first;
				if(st.find(group) == st.end())
					continue;
				st.erase(group);
				auto vec = itr->second;
				for(int i = 0; i < vec.size(); i++)
				{
					//cout << vec[i] << endl;
					st.insert(vec[i]);
				}
				flag = true;
			}
		}
		cout << st.size() << endl;
	}
	return 0;
}



Measured memory_bytes: 3336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long X = scan.nextLong();
		int answer = 0;
		double money = 100;

		while (money < X) {
			money *= 1.01;
			money = Math.floor(money);
			answer++;
		}

		System.out.println(answer);

	}
}

Measured memory_bytes: 35720
#include <stdio.h>
int gcc(int a, int b)
{
	if(a%b==0)
      return b;
    return gcc(b, a%b);
}
int main(void)
{
	int i, j, k, num, m;
	long int sum=0;
	scanf("%d", &num);
	for(i=1;i<=num;i++)
		for(j=1;j<=num;j++)
			for (k = 1; k <= num; k++) {
				sum += gcc(i, gcc(j,k));
			}
	printf("%ld\n", sum);
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  int  A,B,C,D,a,b;
  cin >> A >> B >> C >> D;
  
  if(A < B) a = A;
  else a = B;
  
  if(C < D) b = C;
  else b = D;
  
  cout << a + b << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n,k,a[1005];
int main()
{
  scanf("%d%d",&n,&k);
  for(int i=1;i<=n;++i) scanf("%d",&a[i]);
  sort(a+1,a+1+n);
  int ans=0;
  for(int i=1;i<=k;++i) ans+=a[i];
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 1700
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner scanner = new Scanner(System.in);

		int save = 0;

		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int z = scanner.nextInt();

		save = x;
		x = y;
		y = save;

		save = z;
		z = x;
		x = save;
		
		System.out.println(x + " " + y + " " + z);

		scanner.close();

	}

}

Measured memory_bytes: 39564
n = int(input())
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
c_lst = list(map(int, input().split()))

ans = 0
for i in range(n):
  a = a_lst[i]
  ans += b_lst[a-1]
  if i<n-1 and a_lst[i+1] == a+1:
    ans += c_lst[a-1]
print(ans)

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

int main()
{
  int n;
  cin>>n;
  vector<int>a(n),b(n),c(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i]>>b[i]>>c[i];
  }
  
  int dp[n][3];
  memset(dp,0,sizeof(dp));
  dp[0][0]=a[0],dp[0][1]=b[0],dp[0][2]=c[0];
  
  for(int i=1;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      	for(int k=0;k<3;k++)
        {
        	if(j!=k)
            {
            	if(j==0) 
                  dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i]);
              	else if(j==1)
                  dp[i][j]=max(dp[i][j],dp[i-1][k]+b[i]);
              	else
                  dp[i][j]=max(dp[i][j],dp[i-1][k]+c[i]);   	
            }
        }
    }
  }
  int ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  cout<<ans;
  return 0;
}

Measured memory_bytes: 2560
H, W, K = map(int, input().split())
S = [input() for h in range(H)]

# 横の割り方を全通り試す(2**(H-1))
ans = float('inf')
for i in range(2**(H-1)):
    _ans = bin(i).count('1')
    chocos = [list(map(int, S[0]))]
    for j in range(H-1):
        if i >> j & 1:
            chocos.append(list(map(int, S[j+1])))
        else:
            for w in range(W):
                chocos[-1][w] += int(S[j+1][w])
    
    ns = len(chocos)
    nums = [0] * ns
    is_next = False
    for w in range(W):
        for j in range(ns):
            nums[j] += chocos[j][w]
            if chocos[j][w] > K:
                _ans = float('inf')
            if nums[j] > K:
                _ans += 1
                is_next = True
                break
        
        if is_next:
            for j in range(ns):
                nums[j] = chocos[j][w]
            is_next = False
    
    ans = min(ans, _ans)

print(ans)

Measured memory_bytes: 53596
#include<iostream> 
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main()
{
	int n,tmp;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>tmp;	
		a[tmp]=i;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<' ';
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 1152
N=int(input())
S=input()
code=list(set(list(S)))
ans=0
for i in code:
    for j in code:
        for k in code:
            count=0
            for s in S:
                if count==0:
                    if s==i:
                        count+=1
                elif count==1:
                    if s==j:
                        count+=1
                elif count==2:
                    if s==k:
                        count+=1
                if count==3:
                    ans+=1
                    break
print(ans)

Measured memory_bytes: 9400
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main() {
	int n; scanf("%d", &n);
	int ans=0;
	for(int i=1; i<=n; i++) {
		int t; scanf("%d", &t);
		if(t%2==1 && i%2==1) ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1728
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] l = new int[3];
        for(int i = 0;i < 3;i++)    l[i] = sc.nextInt();
        Arrays.sort(l);
        if(l[0] == l[2]){
            System.out.println(0);
            return;
        }
        if((l[1]-l[0])%2 == 0)    System.out.println((2*l[2]-l[1]-l[0])/2);
        else    System.out.println((2*l[2]-l[1]-l[0]-1)/2+2);
    }
}

Measured memory_bytes: 23764
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();

    int times = n/x;
    if(n % x != 0){
      times++;
    }
    
    System.out.println(times * t);

    return;

  }
}

Measured memory_bytes: 35708
let N = Int(readLine()!)!

let a = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }
let b = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }
let c = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }

var ret = 0

for i in 0..<a.count {
  ret += b[a[i] - 1]
  if (i != 0) && (a[i] == a[i - 1] + 1) {
    ret += c[a[i - 1] - 1]
  }
}

print(ret)

Measured memory_bytes: 4208
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#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 FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CFennecVsMonster {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;
        vector<int> H(N);
        REP(i, N) cin >> H[i];
        sort(H.begin(), H.end());
        int num = 0;
        REP(i, N - K) num += H[i];
        cout << num << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CFennecVsMonster solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1792
using System.Collections.Generic;
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        getAns(n, line);
    }
    static void getAns(int n, string[] a)
    {
        var hs = new HashSet<string>();
        for (int i = 0; i < n; i++) hs.Add(a[i]);
        Console.WriteLine(hs.Count());
    }
}



Measured memory_bytes: 23224
var
	s,s1 : ansistring;
	i : longint;
begin
	readln(s1);
	s := '';
	for i := length(s1) downto 1 do s := s + s1[i];
	//writeln(s);
	if (pos('C',s) > pos('F',s)) and (pos('C',s) <> 0) and (pos('F',s) <> 0) then writeln('Yes')
	else writeln('No');
end.

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
ans = "Yes"
for i in range(n - 1):
    if h[i] < h[i + 1]:
        if i + 2 < n:
            if h[i + 1] - 1 <= h[i + 2]:
                h[i + 1] -= 1        
    elif h[i] == h[i + 1]:
        continue
    elif h[i] > h[i + 1]:
        if h[i + 1] + 1 == h[i]:
            if i >= 1:
                if h[i] - h[i - 1] > 0:
                    h[i] -= 1
                else:
                    ans = "No"
            elif i == 0:
                h[i] -= 1
        else:
            ans = "No"
print(ans)

Measured memory_bytes: 14400
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;

int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n*2);
    sort(all(a));
    int ans=0;
    rep(i,n*2){
        if(i%2==0)ans+=a[i];
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 205,M=10000008;
int n,y[N],x[N],pr[M],tot,k,fa[N],m;
bool vis[M],vv[N];
vector<int>S,T,v[N];
int dfs(int x)
{
    for(auto i:v[x])
    {
        if(!vv[i])
        {
            vv[i]=1;
            if(!fa[i]||dfs(fa[i]))
            {
                fa[i]=x;
                return 1;
            }
        }
    }
    return 0;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)scanf("%d",&y[i]);
    sort(y+1,y+n+1);
    x[m=1]=y[1];
    if(y[1]+1!=y[2])x[++m]=y[1]+1;
    for(int i=2;i<=n;i++)
    {
        if(y[i]!=y[i-1]+1)x[++m]=y[i];
        if(y[i]!=y[i+1]-1)x[++m]=y[i]+1;
    }
    n=m;vis[1]=1;
    for(int i=2;i<=10000000;i++)
    {
        if(!vis[i])pr[++tot]=i;
        for(int j=1;j<=tot&&i*pr[j]<=10000000;j++)
        {
            vis[i*pr[j]]=1;
            if(i%pr[j]==0)break;
        }
    }
    for(int i=1;i<=n;i++)
        if(x[i]&1)S.push_back(i);
        else T.push_back(i);
    for(auto i:S)for(auto j:T)if(!vis[abs(x[i]-x[j])])v[i].push_back(j);
    for(auto i:S)
    {
        memset(vv,0,sizeof(vv));
        if(dfs(i))k++;
    }
    printf("%d\n",k+(S.size()-k)/2*2+(T.size()-k)/2*2+((S.size()-k)%2)*3);
    return 0;
}


Measured memory_bytes: 14720
//




#include <bits/stdc++.h>
using namespace std;


#define spdio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define pf push_front
#define ppf pop_front()
#define ff first
#define ss second
#define mp make_pair
#define fr(i,j,n) for(ll i=j; i<n; i++)
#define rfr(i,j,n) for(ll i=n-1; i>=j; i--)
#define pll pair<ll,ll>
#define plb pair<ll,bool>
#define psl pair<string,ll>
#define psb pair<string,bool>
#define srt(v) sort((v).begin(),(v).end())
#define ub(v,val) upper_bound((v).begin(),(v).end(),(val))-(v).begin()
#define lb(v,val) lower_bound((v).begin(),(v).end(),(val))-(v).begin()


typedef long double ld;
typedef long long int ll;


//getline(cin,string);
const ll inf = (ll) 1e18 + 19;
const ll mod = (ll) 1e9  +  7;




ll calc(ll n,ll k) {
    ll val=1;
    fr(i,0,k) val*=n;
    return val;
}




void cazz() {
    ll t=1,i=0,j,n;
    //cin>>t;
    while(t--) {
        cin>>n;
        n^=1;
        cout<<n<<"\n";
    }
}




int main() {
    spdio;
	cazz();
	return 0;
}


Measured memory_bytes: 3632