akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN, "%d", $N);
$hoge = trim(fgets(STDIN));
$h = explode(" ", $hoge);

$f = [];
$f[0] = 0;
$f[1] = abs($h[1] - $h[0]);

for ($i = 2; $i < $N; $i++) {
    $f[$i] = min($f[$i-1] + abs($h[$i-1]-$h[$i]), $f[$i-2] + abs($h[$i-2]-$h[$i]));
}

echo $f[$N-1]."\n";

Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;cin >> S;
    int A = S.size();
    REP(i,A){
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
	using namespace std;
	int main()
	{
		int n;
		cin >> n;
		int x = 0;
		for (int i = 1; i <= 9; i++)
		{
			for (int j = 1; j <= 9; j++)
			{
				if (n == i * j)
				{
					cout << "Yes" << endl;
					x++;
					break;
				}
			}
			if (x == 1)
			{
				break;
			}
		}
		if (x == 0)
		{
			cout << "No" << endl;
		}
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    ll k;
    cin>>k;
    int cur = 7;

    for(int i = 1; i<= 1000001; i++){
        cur%= k;
        if(cur==0){
            cout<<i<<"\n";
            return 0;
        }
        cur *= 10;
        cur += 7;
    }
    cout<<-1<<"\n";
}


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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

// ll fact[nax], invfact[nax];

// void pre()
// {
// 	fact[0] = 1;
// 	forn(i, 1, nax)
// 	{
// 		fact[i] = mult(fact[i - 1], i);
// 	}

// 	invfact[nax - 1] = mypow(fact[nax - 1], mod - 2);

// 	ford(i, nax, 1)
// 	{
// 		invfact[i - 1] = mult(invfact[i], i);
// 	}
// }

// ll ncr(ll n, ll r)
// {
// 	if (r > n)
// 		return 0;

// 	ll ans = mult(fact[n], mult(invfact[n - r], invfact[r]));

// 	return ans;
// }

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll n,k;
		cin>>n>>k;

		ll ans = 0;
		while(n>0)
		{
			n/=k;
			ans++;
		}

		cout<<ans;
	}

	return 0;
}

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


using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;


#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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


int a[10010][10010], b[1000];
int dp[10010][3];
 

int main()
{
    ll N; cin >> N;
    
    vector<int> A(100000*2+100);
    rep(i,N){
        A[i] = 0;
    }
    for(ll i = 2; i <= N; i++){
        ll B;
        cin >> B;
        A[B] += 1;
    }

    for(int i = 1; i <= N; i++){
        cout << A[i] << endl;
    }
    return 0;
}


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

struct Unionfind {
  // tree number
  vector<int> par;
  // tree rank
  vector<int> treerank;
  // constructor
  Unionfind(int n = 1) { stree(n + 1); }
  // make and initialization
  void stree(int n = 1) {
    par.assign(n, -1);
    treerank.assign(n, 0);
  }
  // search root
  int root(int x) {
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }

  // add
  // already added, return 0
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return 0;
    if(treerank[x] > treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) ++treerank[y];
    par[y] -= size(x);
    par[x] = y;
    return 1;
  }
  int size(int x) { return -par[root(x)]; }
};

int n, m, ans = 0;
vector<int> p;
Unionfind uf;

int main() {
  cin >> n >> m;
  uf = Unionfind(n);
  p.assign(n, 0);
  for(int i = 0; i < n; ++i) {
    cin >> p[i];
    --p[i];
  }
  for(int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    uf.uni(--x, --y);
  }
  for(int i = 0; i < n; ++i)
    if(uf.issame(i, p[i])) ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
//g++ -std=c++11 -Wall test.cpp -o test -lm -g -O2
#include <bits/stdc++.h>
using namespace std;
#define sws                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define qi queue<int>
#define si stack<int>
#define s string
#define ll long long;

int main()
{
    sws;
    int age;
    cin >> age;
    if (age == 3 or age == 5 or age == 7)
        cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            try:
                if isCLKWISE(phU) : break
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            try:
                if isCLKWISE(phL) : break
            except IndexError : break
      
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(y) for y in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

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

int main() {
	int N, K;
	cin >> N >> K;
	int ans = 1;
	for (int i = 0;i < N;++i) {
		ans = min(ans * 2, ans + K);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))	
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)	
#define FloorN(x, n)	((x)-(x)%(n))			
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long			ll;
typedef unsigned long long	ull;
typedef pair<ll, ll>		P;
typedef vector<ll>			VLL;
typedef vector<VLL>			VVLL;
typedef vector<VVLL>		VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
template<class T>
class UnionFind
{
private:
	vector<T> parentNo;
	vector<T> parentRank;
	vector<T> parentSize;

public:
	// コンストラクタ
	UnionFind(int n)
	{
		parentNo.resize(n);
		parentRank.resize(n, 0);
		parentSize.resize(n, 1);
		for (int i = 0; i < n; i++) {
			// 始めは全部ROOT
			parentNo[i] = i;
		}
	}

	int root(T x)
	{
		if (parentNo[x] == x) {
			return x;
		} else {
			T rootParentNo = root(parentNo[x]);
			parentNo[x] = rootParentNo;
			return rootParentNo;
		}
	}

	bool same(T x, T y)
	{
		return root(x) == root(y);
	}

	int size(T x)
	{
		return parentSize[root(x)];
	}

	void unite(T xc, T yc)
	{
		T xr = root(xc);
		T yr = root(yc);
		if (xr == yr) {
			return;
		}
		if (parentRank[xr] < parentRank[yr]) {
			parentNo[xr] = yr;
			parentSize[yr] += parentSize[xr];
		} else {
			parentNo[yr] = xr;
			parentSize[xr] += parentSize[yr];
			if (parentRank[xr] == parentRank[yr]) {
				parentRank[xr]++;
			}
		}
	}
};

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	
	vector<vector<int>> frnd(N);
	vector<int> A(M), B(M);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		A[i] = a;
		B[i] = b;
		frnd[b].emplace_back(a);
		frnd[a].emplace_back(b);
	}

	vector<vector<int>> Block(N);
	REP(i, K) {
		int c, d;
		cin >> c >> d;
		c--; d--;
		Block[c].emplace_back(d);
		Block[d].emplace_back(c);
	}

	UnionFind<int> uFind(N + 1);
	REP(i, M) {
		uFind.unite(A[i], B[i]);
	}
		
	REP(i, N) {
		int ansOne = uFind.size(i);
		ansOne--;
		ansOne -= frnd[i].size();
		for (auto blkOne : Block[i]) {
			if (uFind.same(i, blkOne)) {
				ansOne--;
			}
		}
		cout << ansOne << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 13816
#include <bits/stdc++.h>
using namespace std;
 
// Type alias
using ll=long long;
using ld=double;
using innt=long long;
 
// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl
 
#define ALL(a) a.begin(),a.end()
 

ll memo[40][10] = {};

int count_zero(int keta, int start){
  if(keta == 1){
    return 1;
  }

  if(memo[keta][start])
    return memo[keta][start];

  if(keta == 2 && (start == 0 || start == 9)){
    memo[2][0] = 2;
    memo[2][9] = 2;
    return 2;
  }
  if(keta == 2){
    memo[2][1] = 3;
    memo[2][2] = 3;
    memo[2][3] = 3;
    memo[2][4] = 3;
    memo[2][5] = 3;
    memo[2][6] = 3;
    memo[2][7] = 3;
    memo[2][8] = 3;
    return 3;
  }

  if(start == 0){
    memo[keta][start] = count_zero(keta - 1, 0) + count_zero(keta - 1, 1);
    return memo[keta][start];
  }
  if(start == 9){
    memo[keta][start] = count_zero(keta - 1, 8) + count_zero(keta - 1, 9);
    return memo[keta][start];
  }

  memo[keta][start] = count_zero(keta - 1, start - 1) + count_zero(keta - 1, start) + count_zero(keta - 1, start + 1);
  return memo[keta][start];
} 
 
int count(int keta){
  if(keta == 1){
    return 10;
  }

  int res = 0;
  REP(i, 1, 9){
    res += count_zero(keta - 1, i-1) + count_zero(keta - 1, i) + count_zero(keta - 1, i+1);
  }
  res += count_zero(keta - 1, 8);
  res += count_zero(keta - 1, 9);
  return res;
}

void kazu_zero(int keta, int mae, int t){
  //cout << "kazu_zero(" << keta << "," << mae << "," << t << ");" << endl;
  if(keta == 1 && mae == 0){
    cout << mae + t;
    return;
  }

  if(keta == 1){
    cout << mae + t - 1;
    return;
  }

  int i = mae - 1;
  while(true){
    if(i < 0 || i > 9){
      i++;
      continue;
    }

    int u = count_zero(keta, i);
    if(t - u < 0){
      cout << i;
      break;
    }

    t -= u;
    i++;
  }

  kazu_zero(keta - 1, i, t);
  return;
}

void kazu(int keta, int t){
  //cout << "kazu(" << keta << "," << t << ");" << endl;
  if(keta == 1){
    cout << t;
    return;
  }
  
  int i = 1;
  while(true){
    int u = count_zero(keta, i);
    if(t - u < 0){
      cout << i;
      break;
    }
    t -= u;
    i++;
  }

  kazu_zero(keta - 1, i, t);
  return;
}

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

  int keta = 1;
  while(true){
    int t = count(keta);
    if(K - t < 0){
      break;
    }else{
      K -= t;
    }
    keta++;
  }
  //cout << keta << "," << K << endl;

  kazu(keta, K);
  cout << endl;
}
 
int main(){
  // FastIO
  //ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}





















Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <stack>
#include <cmath>

using namespace std;

string s;

string func(string s) {
    stack<char> st;
    string t = "";
    for (int i = 0; i < s.size(); i++) {
        if (isalpha(s[i]) || isdigit(s[i])) {
            t += s[i];
            while (st.size() && st.top() == '-') t += st.top(), st.pop();
        }
        else if (s[i] != ')') st.push(s[i]);
        else {
            while (st.top() != '(') t += st.top(), st.pop();
            st.pop();
            while (st.size() && st.top() == '-') t += st.top(), st.pop();
        }
    }
    return t;
}

string func2(string s, int p, int q, int r) {
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'P') s[i] = '0'+p;
        if (s[i] == 'Q') s[i] = '0'+q;
        if (s[i] == 'R') s[i] = '0'+r;
    }
    return s;
}

int solve(string s) {
    stack<int> st;
    for (int i = 0; i < s.size(); i++) {
        if (isdigit(s[i])) st.push(s[i]-'0');
        if (s[i] == '-') {
            int a = st.top(); st.pop();
            a = 2 - a;
            st.push(a);
        }
        if (s[i] == '+') {
            int a = st.top(); st.pop();
            int b = st.top(); st.pop();
            a = max(a, b);
            st.push(a);
        }
        if (s[i] == '*') {
            int a = st.top(); st.pop();
            int b = st.top(); st.pop();
            a = min(a, b);
            st.push(a);
        }
    }
    if (st.top() == 2) return 1;
    else return 0;
}

int main(void){
    while (cin>>s && s != ".") {
        s = func(s);
        int ans = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    string t = s;
                    t = func2(t, i, j, k);
                    ans += solve(t);
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;
 
class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long[] b = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long[] c = Console.ReadLine().Split().Select(long.Parse).ToArray();
        Array.Sort(a);
        Array.Reverse(a);
        Array.Sort(b);
        Array.Reverse(b);
        Array.Sort(c);
        Array.Reverse(c);
        foreach(long i in solve(a,b,c, Math.Min(s[0],3000), Math.Min(s[1], 3000), Math.Min(s[2], 3000), s[3])) {
            Console.WriteLine(i);
        }
    }
    static long[] solve(long[] a, long[] b, long[] c, int x, int y, int z, int k) {
        List<long> l = new List<long>();
        for(int i = 0; i < x; i ++) {
            for(int j = 0; j < y; j ++) {
                l.Add(a[i] + b[j]);
            }
        }
        l.Sort();
        l.Reverse();
      	List<long> r = new List<long>();
        for(int i = 0; i < Math.Min(k,x*y); i ++) {
            for(int j = 0; j < z; j ++) r.Add(l[i]+c[j]);
        }
        r.Sort();
        r.Reverse();
        return r.Where((s,t) => t < k).ToArray();
    }
}

Measured memory_bytes: 63260
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;

/*printf("? %c %c\n",x,y);
		fflush(stdout);
		char ret;scanf(" %c", &ret);
		*/
int main(void){
	int i,j,k,N=200,chousei=4,a,b;
	vector<pair<int,int>> kotae;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j+=chousei){
			printf("? ");
			for(k=0;k<N;k++){
				if(k==i||(j<=k&&k<j+chousei)){a=1;} else{a=0;}
				printf("%d",a);
			}
			printf("\n");
			fflush(stdout);
			scanf("%d",&a);
			if(a!=0){
				for(k=j;k<min(j+chousei,N);k++){
					printf("? ");
					for(int l=0;l<N;l++){
						if(l==i||k==l){b=1;} else{b=0;}
						printf("%d",b);
					}
				printf("\n");
				fflush(stdout);
				scanf("%d",&b);
				if(b!=0){kotae.pub(mp(i,k));}
				}
			}
		}
	}
	printf("!");
	for(i=0;i<kotae.size();i++){
		printf(" (%d,%d)",kotae[i].first,kotae[i].second);
		
	}
	printf("\n");
	fflush(stdout);
	return 0;
}



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

#define MAX 1000000001
#define SIZE 500001

int S[SIZE];
int count = 0;
int n;

void print(){
    for(int i = 0; i < n; i++){
        if(i != 0)  cout << " ";
        cout << S[i];
    }
    cout << endl;
    cout << count << endl;
}

void merge(int A[], int left, int mid, int right){
    int n1 = mid-left;
    int n2 = right-mid;
    int L[n1+1];
    int R[n2+1];
    for(int i = 0; i < n1; i++) L[i] = A[left+i];
    for(int i = 0; i < n2; i++) R[i] = A[mid+i];
    L[n1] = MAX;
    R[n2] = MAX;

    int li = 0;
    int ri = 0;

    for(int i = left; i < right; i++){
        if(L[li] <= R[ri]){
            A[i] = L[li];
            li++;
        }else{
            A[i] = R[ri];
            ri++;
        }
        count++;
    }
}

void mergeSort(int A[], int left, int right){
    if(left+1 < right){
        int mid = (left+right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> S[i];
    mergeSort(S,0,n);
    print();
    return 0;
}



Measured memory_bytes: 6964
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define lb lower_bound
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int N, a[100010];
V n;

void solve()
{
    FOR(i, 0, N)
    {
        auto it = lb(all(n), a[i]);
        if (it == n.begin()) {
            n.insert(it,a[i]);
        } else {
            it--;
            *it = a[i];
        }
    }
    cout << (int)n.size() << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N)
    cin >> a[i];
    solve();
    return 0;
}


Measured memory_bytes: 2296
#include <iostream>
using namespace std;
int main(void){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int y=ty-sy,x=tx-sx;
    for(int i=0;i<y;i++)cout<<'U';
    for(int i=0;i<x;i++)cout<<'R';
    for(int i=0;i<y;i++)cout<<'D';
    for(int i=0;i<=x;i++)cout<<'L';
    for(int i=0;i<=y;i++)cout<<'U';
    for(int i=0;i<=x;i++)cout<<'R';
    cout<<"DR";
    for(int i=0;i<=y;i++)cout<<'D';
    for(int i=0;i<=x;i++)cout<<'L';
    cout<<"U\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3088
#define _USE_MATH_DEFINES

#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

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

	string ideal;
	int red_cnt = 0;
	int white_cnt = 0;
	for (int i=0; i<n; i++) {
		if (s[i] == 'R') {
			red_cnt++;
		} else {
			white_cnt++;
		}
	}
	int diff = 0;
	for (int i=0; i<red_cnt;i++) {
		if (s[i] != 'R') {
			diff++;
		}
	}
	for (int i=red_cnt; i<(int)s.size(); i++) {
		if (s[i] != 'W') {
			diff++;
		}
	}
	cout << diff/2 << endl;
}

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

bool went[410][410];
char m[410][410];
int h, w;
ll white = 0;
ll black = 0;

void dfs(int y, int x) {
  went[y][x] = true;

  if (m[y][x] == '.') {
    white++;
    for (int i = 0; i < 4; i++) {
      if (0 <= y + dy[i] && y + dy[i] < h && 0 <= x + dx[i] && x + dx[i] < w) {
        if (!went[y + dy[i]][x + dx[i]] && m[y + dy[i]][x + dx[i]] == '#') {
          dfs(y + dy[i], x + dx[i]);
        }
      }
    }
  } else {
    black++;
    for (int i = 0; i < 4; i++) {
      if (0 <= y + dy[i] && y + dy[i] < h && 0 <= x + dx[i] && x + dx[i] < w) {
        if (!went[y + dy[i]][x + dx[i]] && m[y + dy[i]][x + dx[i]] == '.') {
          dfs(y + dy[i], x + dx[i]);
        }
      }
    }
  }
}

int main() {
  cin >> h >> w;

  for (int i = 0; i < h; i++) cin >> m[i];

  ll ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (m[i][j] == '#' && went[i][j] == 0) {
        white = 0;
        black = 0;
        dfs(i, j);
        ans += white * black;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

const int N = 1e5+5;
int n, h[N];
int c[N];

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> h[i];
  c[0] = 0;
  c[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; ++i) {
    c[i] = min(
      c[i-1] + abs(h[i] - h[i-1]),
      c[i-2] + abs(h[i] - h[i-2])
    );
  }
  cout << c[n-1] << nl;

  return 0;
}



Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
using namespace std;

signed main()
{
	int N, M;
	cin >> N >> M;
	int c[100] = { 0 };
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		c[a - 1]++;
		c[b - 1]++;
	}
	for (int i = 0; i < N; i++)
	{
		cout << c[i] << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main() {
    int a,b;
    int ans = 0;

    cin >> a >> b;
    if(a >= 6 && a <= 12) {
        ans = b/2;
    }
    if(a >= 13) {
        ans = b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int n;
  	scanf("%s", &n);
    bool yes = true;
  	for(int i = 0; i < n; i++){
    	int x;
      	scanf("%d", &x);
      	if(x % 2 == 0 && x%3 !=0 && x%5!=0){
        	yes = false;
        }
    }
  	if(yes) {
      	puts("APPROVED");
    }else {
    	puts("DENIED");
    }
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


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



Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    string S;
    cin >> S;
    bool postal = true;
    rep(i,A){
        if(S[i] != '0' && S[i] != '1' && S[i] != '2' && S[i] != '3' && S[i] != '4' && S[i] != '5' && S[i] != '6' && S[i] != '7' && S[i] != '8' && S[i] != '9'){
            postal = false;
        }
    }
    if(S[A] != '-'){
        postal = false;
    }
    for(int i = A + 1; i < A + B + 1; i++){
        if(S[i] != '0' && S[i] != '1' && S[i] != '2' && S[i] != '3' && S[i] != '4' && S[i] != '5' && S[i] != '6' && S[i] != '7' && S[i] != '8' && S[i] != '9'){
            postal = false;
        }
    }
    if(postal){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [input() for _ in range(h)]

for i in range(h):
  l = ""
  for j in range(w):
    if s[i][j] == "#":
      l += "#"
    else:
      x = 0
      for dh in [-1, 0, 1]:
        for dw in [-1, 0, 1]:
          if 0 <= i + dh < h and 0 <= j + dw < w and s[i + dh][j + dw] == "#":
            x += 1
      l += str(x)
  print(l)

Measured memory_bytes: 3064
use std::io;
fn main() {
    let mut l1 = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut l1).unwrap();
    let mut iter = l1.split_whitespace();
    let v1: i32 = iter.next().unwrap().parse().unwrap();
    let mut result = 0_u128;
    let mut count = 1_u128;
    while (count <= (v1 as u128)) {
        if count % 3 == 0 {
            count = count + 1_u128;
            continue;
        }
        if count % 5 == 0 {
            count = count + 1_u128;
            continue;
        }
        result = result + count;
        count = count + 1_u128;
    }
    println!("{}", result);
}


Measured memory_bytes: 2144
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int>ary;
	for (int i = 0;i < n;i++)
	{
		int num;
		cin >> num;
		ary.push_back(num);
	}
	int oper;
	cin >> oper;
	while (oper--)
	{
		int head, end;
		cin >> head >> end;
		int find;
		cin >> find;
		int nu = count(&ary[head], &ary[end-1], find);
		if (ary[end - 1] == find)nu++;
		cout << nu << endl;
	}
}


Measured memory_bytes: 3144
#include <iostream>
using namespace std;
int main() {
	int n, l, i=0;
  	string check = "APPROVED";
  
  	cin >> n;
  	int arry[n];
  while(cin >> l) {
   arry[i] = l;
    i++;
  }

  for(i = 0; i < n; i++) {
	if(arry[i] % 2 == 0) {
    	if(arry[i] % 3 != 0 && arry[i] % 5 != 0) {
          check = "DENIED";
        }
    }
  }
  
  cout << check << endl;
	return 0;
}

Measured memory_bytes: 256
N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
if A[-1] < K:
    print("IMPOSSIBLE")
    exit()
if K in A:
    print("POSSIBLE")
    exit()
from fractions import gcd
n = A[0]
for i in range(1,N):
    n = gcd(A[i],n)
if K % n == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 14100
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
print(n-m if m != 1 else 0)


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

const long long MOD = 1000000007;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll H, ll W, std::vector<std::vector<char>> a) {
  vector<vector<ll>> dp(H + 1, vector<ll>(W + 1, 0));
  dp.at(1).at(1) = 1;
  rep(i, H) {
    rep(j, W) {
      if (a.at(i).at(j) == '#') {
        dp.at(i + 1).at(j + 1) = 0;
        continue;
      }
      chmax(dp.at(i + 1).at(j + 1),
            (dp.at(i + 1).at(j) + dp.at(i).at(j + 1)) % MOD);
    }
  }

  cout << dp.at(H).at(W) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll H, W;
  cin >> H;
  cin >> W;
  std::vector<std::vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    string s;
    std::cin >> s;
    for (int j = 0; j < W; j++) a.at(i).at(j) = s.at(j);
  }
  solve(H, W, std::move(a));
  return 0;
}


Measured memory_bytes: 12020
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

use std::collections::{HashMap, BinaryHeap};

fn main() {
    input! {
        n: usize,
        m: usize,
        students: [(i32, i32); n],
        check_points: [(i32, i32); m],
    }

    for student in students {
        let mut diffs = BinaryHeap::new();
        let mut diff_map: HashMap<i32, BinaryHeap<i32>> = HashMap::new();

        for (i, point) in check_points.iter().enumerate() {
            let diff = diff(&student, point);
            let v = diff_map.entry(-diff).or_insert(BinaryHeap::new());
            v.push(i as i32 * -1);
            diffs.push(-diff);
        }

        let min = diffs.pop().unwrap();
        let mut indexes = diff_map.get_mut(&min).unwrap();
        println!("{}", indexes.pop().unwrap() * -1 + 1);
    }
}

fn diff(&(s_x, s_y): &(i32, i32), &(c_x, c_y): &(i32, i32)) -> i32 {
    (s_x - c_x).abs() + (s_y - c_y).abs()
}

Measured memory_bytes: 4352
a,b,c = map(int,input().split())

if a != b == c:
	print(2)

if a == b != c:
	print(2)
	
if a == c != b:
	print(2)

if a == b == c:
	print(1)
	
if a != b != c and a != c:
	print(3)

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		br.close();

		int[][] cnt = new int[10][10];
		for (int i = 1; i <= n; i++) {
			String s = String.valueOf(i);
			int a = s.charAt(0) - '0';
			int b = s.charAt(s.length() - 1) - '0';
			cnt[a][b]++;
		}

		long ans = 0;
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				long val = (long) cnt[i][j] * cnt[j][i];
				ans += val;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 32212
import math
n = int(input())
n_3 = math.floor(n/3)
n_5 = math.floor(n/5)
n_15 = math.floor(n/15)
s_all = n*(n+1)/2
s_3  = 3*n_3*(n_3+1)/2
s_5  = 5*n_5*(n_5+1)/2
s_15 = 15*n_15*(n_15+1)/2
print(int(s_all-(s_3+s_5-s_15)))

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
#define rep(i,N) for(int i=0;i<(int)N;++i)
//cout << fixed << setprecision(20) << *** << endl;
typedef long long ll;
using namespace std;
int main()
{
	vector<int> vec(3,0);
	ll ANS=0;
	cin>>vec[0]>>vec[1]>>vec[2];
	sort(vec.begin(),vec.end());
	if(vec[0]==vec[1]&&vec[1]==vec[2]){
		cout<<"0"<<endl;
	}
	else{
		ANS=ANS+vec[2]-vec[1];
		vec[0]=vec[0]+vec[2]-vec[1];
		vec[1]=vec[2];
		for(;;){
			if(vec[0]<vec[2]){
				vec[0]=vec[0]+2;
				ANS++;
			}
			else{
				break;
			}
		}
		ANS=ANS+vec[0]-vec[2];
		cout<<ANS<<endl;
	}

}

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

const int MOD = 2019;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  reverse(begin(S), end(S));

  vector<int> v(2020, 0);
  int curr = 0;
  int p = 1;
  v[0]++;
  for (int i = 0; i < N; ++i) {
    curr = (curr + (S[i] - '0') * p) % MOD;
    p = p * 10 % MOD;
    v[curr]++;
  }

  long long ans = 0;
  for (const auto& x: v) {
    ans += x * (x - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a));
    cout << abs(a[0] - a[a.size() - 1]) << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
void solve(){
	int n;
	cin>>n;
	cout<<setprecision(10)<<pow((ll)sqrt(n), 2)<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    //my-code
    int N, M; cin >> N >> M;
    vi A(M); REP(i, M) cin >> A[i];
    ll ans = N;
    REP(i, M) ans -= A[i];
    if (ans < 0) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3672
dx=[0,0,1,-1]
dy=[1,-1,0,0]

def dfs(y,x,cnt):
    global maxInt
    maxInt=max(maxInt,cnt)
    Ice[y][x]=0
    for i in range(4):
        mx=x+dx[i]
        my=y+dy[i]
        if mx<0 or m<=mx or my<0 or n<=my:
            continue
        if Ice[my][mx]==1:
            dfs(my,mx,cnt+1)
            Ice[my][mx]=1

while True:
    m=input()
    n=input()
    if n==m==0:break
    maxInt=0
    Ice=[map(int,raw_input().split()) for i in range(n)]
    for y in range(n):
        for x in range(m):
            if Ice[y][x]==1:
                dfs(y,x,1)
                Ice[y][x]=1
    print maxInt

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;
 
int main() {
  string s;
  cin >> s;
  cout << s.substr(0,3) << endl;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<ll, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int d, n;
  n = 26;
  cin >> d;
  vi c(n);
  rep(i, n) cin >> c[i];
  vvi s(d, vi(n));
  rep(i, d) rep(j, n) cin >> s[i][j];
  vi l(n, -1);
  vector<vector<P>> g(d, vector<P>(n));
  vi ans(d);
  rep(i, d) {
    rep(j, n) {
      g[i][j].first = s[i][j];
      g[i][j].second = j;
      rep(k, n) {
        if (j != k) g[i][j].first -= (ll)c[k] * (i - l[k]);
      }
    }
    sort(g[i].rbegin(), g[i].rend());
    // dump(g[i]);
    int mi = g[i][0].second;
    l[mi] = i;
    ans[i] = mi;
  }
  auto score = [&] (vi& sel) {
    ll sc = 0;
    l.assign(n, -1);
    rep(i, d) {
      sc += s[i][sel[i]];
      l[sel[i]] = i;
      rep(k, n) sc -= (ll)c[k] * (i - l[k]);
    }
    return sc;
  };
  ll msc = score(ans);
  dump(msc, ans);
  rep(k, 20) {
    rep(i, d) {
      for (int j = 1; j < n; j++) {
        vi sel = ans;
        sel[i] = g[i][j].second;
        ll ss = score(sel);
        dump(i, ss, sel);
        if (msc < ss) {
          ans = sel;
          msc = ss;
        }
      }
    }
  }
  rep(i, d) cout << ans[i] + 1 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3852
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [x, y] = input.trim().split(" ").map(Number);
  const g1 = [1, 3, 5, 7, 8, 10, 12];
  const g2 = [4, 6, 9, 11];
  const g3 = [2];
  return (g1.includes(x) && g1.includes(y)) ||
    (g2.includes(x) && g2.includes(y)) ||
    (g3.includes(x) && g3.includes(y))
    ? "Yes"
    : "No";
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29552
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int k = sc.nextInt();
			int [] data = new int[n];
			HashMap<Integer, Integer> map = new HashMap();
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
				if(map.containsKey(data[i])){
					map.put(data[i], map.get(data[i]) + 1);
				}
				else{
					map.put(data[i], 1);
				}
			}
			ArrayList<Integer[]> data2 = new ArrayList<>();
			for(int key: map.keySet()){
				data2.add(new Integer[]{key, map.get(key)});
			}
			Collections.sort(data2, new Comparator<Integer[]>() {
				@Override
				public int compare(Integer[] o1, Integer[] o2) {
					if(o1[1] < o2[1]) return -1;
					if(o1[1] > o2[1]) return 1;
					return 0;
				}
			});
			long sum = 0;
			for(int i = 0 ; i < Math.max(data2.size() - k, 0); i++){
				sum += data2.get(i)[1];
			}
			
			System.out.println(sum);
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int,int> P;




int main() {
    int n; cin >> n;
    vector<int> b(n-1);
    vector<int> a(n, INT_MAX);

    rep(i, n-1) cin >> b[i];

    int ans = 0;
    for(int i=n-2; i >= 0; i--) {
        a[i+1] = min(a[i+1], b[i]);
        a[i] = min(a[i], b[i]);
    }

    rep(i, n) ans += a[i];

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


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main(){

    input!{
        n: usize,
        m: usize,
        a: [usize;m],
    }

    let mut stair: Vec<bool> = vec![true;n];
    for i in 0..m {
        stair[a[i]] = false;
    }
    let mut dp: Vec<usize> = vec![0;n+1];
    dp[0] = 1;
    for now in 0..n {
        for next in now+1..std::cmp::min(now+2,n)+1 {  
            if stair[now] {
                dp[next] += dp[now];
                dp[next] %= 1000000007;
            }
        }
    }

    println!("{}", dp[n]);
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    set<int> s;
    rep(i, n) {
        int a;
        cin >> a;
        if (!s.count(a)) s.insert(a);
        else s.erase(a);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 4992