akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
#include<unordered_map>
#include<assert.h>
#include<time.h>
#include<stdlib.h>
#include<random>
#include<queue>
using namespace std;
using lld = long long int;
using pll = pair<lld, lld>;
using lf = double;
using pff = pair<lf, lf>;
using pif = pair<int, lf>;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using piii = pair<int, pii>;
#define M 998244353
int n, m;
int b[1000009];
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	//scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%d %d", &j, &k);
			if (j == k) {
				b[i] = 1;
			}
		}
		bool valid = false;
		for (i = 2; i < n; i++) {
			if (b[i] == 1 && b[i - 1] == 1 && b[i - 2] == 1) {
				valid = true;
			}
		}
		printf("%s\n", valid ? "Yes" : "No");
	}
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &i:a)cin >> i;
	sort(a.begin(),a.end());
	int sum = 0;
	for(auto &i:a)sum+= i;
	for(int i =0;i<n;i++)
	{
		if(sum%10)
		{
			cout<<sum<<endl;
			return 0;
		}
		if(a[i]%10)sum-=a[i];
	}
	if(sum%10)cout<<sum<<endl;
	else cout<<0<<endl;
	
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int f[100010];
int w[100010];
int main(){
    int i, j, k;
    int n, t, m;
    int mif, miw;
    mif = miw = 1e9;
    cin >> n >> m >> k;
    for(i = 1; i <= n; i++) cin >> f[i], mif = min(mif, f[i]);
    for(i = 1; i <= m; i++) cin >> w[i], miw = min(miw, w[i]);
    int ans = mif + miw;
    for(i = 1; i <= k; i++) {
        int l, r, sub;
        cin >> l >> r >> sub;
        ans = min(ans, f[l]+w[r]-sub);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, mut h) = (v[0] as usize, v[1]);
    let mut a = vec![];
    let mut b = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        a.push(v[0]);
        b.push(v[1]);
    }
    let mut a_max = *a.iter().max().unwrap();
    b.sort();
    b.reverse();
    let mut ans = 0;
    for i in 0..n {
        if b[i] < a_max {
            break;
        }
        h -= b[i];
        ans += 1;
        if h <= 0 {
            println!("{}", ans);
            return;
        }
    }
    ans += (h + a_max - 1) / a_max;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int x[100010];
signed main(){
	int n;
	cin>>n;
	f(i,n){
		cin>>x[i];
	}
	for(int i=n-2;i>=0;i--){
		if(x[i]-x[i+1]>=2){
			puts("No");
			return 0;
		}
		if(x[i]-x[i+1]==1){
			x[i]--;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll x, k, d;
    cin >> x >> k >> d;
    ll cnt = abs(x) / d;
    ll ans = 0;
    if(k <= cnt) {
        ans = abs(x) - d * k;
    }
    else if((k - cnt) % 2 == 0) {
        ans = abs(x) - d * cnt;
    }
    else {
        ans = abs(x) - d * (cnt + 1);
    }
    cout << abs(ans) << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

int main() {
    int N;
    cin >> N;
    int mi = 1000000, ma = 0;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        mi = min(a, mi);
        ma = max(a, ma);
    }
    cout << ma - mi << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s+=sc.next();
        s+=sc.next();
        System.out.println( s.charAt(0)+""+s.charAt(4)+""+s.charAt(8) );
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>


using std::cout;
using std::cin;
using namespace std;

void oneCase () {
    std::string s;
    std::getline(std::cin, s);
    map<string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;
    std::cout << mp[s] << "\n";
}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;
int main() {
	int x,y;
	cin >> x >> y;
	bool can = false;
	if(y>=x*2&&y<=4*x)
		if(y%2==0)
			can = true;
	if(can)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s1 = scan.next();
        String s2 = scan.next();
        String s3 = scan.next();
        StringBuilder sb = new StringBuilder();
        sb.append(s1.toCharArray()[0]);
        sb.append(s2.toCharArray()[0]);
        sb.append(s3.toCharArray()[0]);
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

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

  vector<ll> x(n);
  vector<ll> y(m);
  rep(i, n) {
    cin >> x.at(i);
  }
  rep(i, m) {
    cin >> y.at(i);
  }

  n--;
  m--;
  ll sumx = 0;
  ll sumy = 0;
  for(ll i=0; i<n; i++) {
    ll mul = ((n-i)*(i+1))%mod;
    sumx += (x.at(i+1)-x.at(i))*mul%mod;
    sumx %= mod;
  }
  for(ll i=0; i<m; i++) {
    ll mul = ((m-i)*(i+1))%mod;
    sumy += (y.at(i+1)-y.at(i))*mul%mod;
    sumy %= mod;
  }
  cout << (sumx*sumy)%mod << endl;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,d;
  cin >> n>>d;
  int x[n][d];
  for(int i=0;i<n;i++) for(int j=0;j<d;j++) cin >> x[i][j];
  double s1=0;
  int s2;
  int count=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=0;k<d;k++){
        s1+=pow(x[i][k] - x[j][k],2);
      }
      s2 = (int)sqrt(s1);
      s1 = sqrt(s1);
      if(s1-(double)s2 == 0.) count++;
      s1 = 0;
    }
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<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};

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    map<int, int> mp;
    REP(i, n) mp[a[i]]++;
    int ans = 0;
    for(auto x : mp){
        if(x.second < x.first) ans += x.second;
        else if(x.second > x.first) ans += x.second - x.first;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cstring>
#include <map>
#include <vector>
using namespace std;

#define MAX_N 100001

typedef long long int ll;

bool table[MAX_N];
vector<ll> prime;

void init() {
    memset(table, 1, sizeof(table));
    table[0] = table[1] = false;
    for (int i = 2; i < MAX_N; i++) {
        if (table[i]) {
            prime.push_back(i);
            for (int j = i + i; j < MAX_N; j += i) {
                table[j] = false;
            }
        }
    }
}

map<ll, ll> factor(ll n) {
    map<ll, ll> ret;
    ll m = n;
    for (int i = 0; ; i++) {
        if (prime[i] * prime[i] > n) {
            if (m != 1) ret[m] = 1;
            break;
        }
        while (m % prime[i] == 0) {
            ret[prime[i]]++;
            m /= prime[i];
        }
    }
    return ret;
}

ll power(ll n, ll m) {
    ll ret = 1;
    for (int i = 0; i < m; i++) {
        ret *= n;
    }
    return ret;
}

int main() {
    init();
    ll n;
    while (cin >> n) {
        if (n == 0) break;
        ll s = 1;
        map<ll, ll> pfactor = factor(n);
        for (map<ll, ll>::iterator it = pfactor.begin();
                it != pfactor.end(); it++) {
//            cout << it->first << ' ' << it->second << endl;
            s *= (power(it->first, it->second+1)-1) / (it->first - 1);
        }
//        cout << s << endl;

        string ans;
        if (n + n < s) {
            ans = "abundant number";
        } else if (n + n == s) {
            ans = "perfect number";
        } else {
            ans = "deficient number";
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;

struct BIT
{
	int N;
	vector<int> bit;

	void init(int n)
	{
		N = n;
		bit.assign(n + 1, 0);
	}

	void update(int idx, int val)
	{
		while(idx <= N)
		{
			bit[idx] += val;
			idx += idx & -idx;
		}
	}

	void updateMax(int idx, int val)
	{
		while(idx <= N)
		{
			bit[idx] = max(bit[idx], val);
			idx += idx & -idx;
		}
	}

	int pref(int idx)
	{
		int ans = 0;
		while(idx > 0)
		{
			ans += bit[idx];
			idx -= idx & -idx;
		}
		return ans;
	}

	int rsum(int l, int r)
	{
		return pref(r) - pref(l - 1);
	}

	int prefMax(int idx)
	{
		int ans = -2e9;
		while(idx > 0)
		{
			ans = max(ans, bit[idx]);
			idx -= idx & -idx;
		}
		return ans;
	}
};


const int M=502;
vector<int>vec[M];
int ses[100009];
vector<pi>yo[M];
vector<pi>abr_yo[M];
BIT Magic;
 main()

{
    fast
    int n,m,q;
    cin>>n>>m>>q;
    Magic.init(503);
    f(i,1,m)
    {
        int l,r;
        cin>>l>>r;
        vec[l].pb(r);
    }
    f(i,1,q)
    {
        int l,r;
        cin>>l>>r;
        yo[l].pb(mp(r,i));
        abr_yo[r].pb(mp(l,i));
    }
    f(i,1,500)
    {
       for(auto x:yo[i])
       {
           int idx=x.si;
           int rgt=x.fi;
           int lft=i;
           ses[idx]=-Magic.rsum(lft,rgt);
       }
       for(auto x:vec[i])
       {
           Magic.update(x,1);
       }
    }
    Magic.init(503);
    f(i,1,500)
    {
        for(auto x:vec[i])
       {
           Magic.update(x,1);
       }
       for(auto x:abr_yo[i])
       {
           int idx=x.si;
           int lft=x.fi;
           int rgt=i;
           ses[idx]+=Magic.rsum(lft,rgt);
       }

    }
    f(i,1,q)
    {
        cout<<ses[i]<<endl;
    }
     cout<<endl;
    return 0;

}





































Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(const pair<string, int>& x, const pair<string, int>& y)
{
	if (x.first.size() == y.first.size()){
		return x.first < y.first;
	}
	return x.first.size() < y.first.size();
}

int main()
{
	map<string, int> m;
	string pn;
	int n, c;

	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		cin >> pn >> c;

		if (m.count(pn)) m[pn] += c;
		else m.insert(make_pair(pn, c));
	}

	vector< pair<string, int> > v;

	for (map<string, int>::iterator it = m.begin(); it != m.end(); it++){
		v.push_back(*it);
	}

	sort(v.begin(), v.end(), cmp);

	for (vector< pair<string, int> >::iterator it = v.begin(); it != v.end(); it++){
		cout << it->first << " " << it->second << endl;
	}

	return (0);
}

Measured memory_bytes: 1284
N = int(input())

X = [list(map(int,input().split())) for _ in range(N)]
X.sort(key=lambda X:-X[2])

count = 0
for i in range(101):
	for j in range(101):
		H = X[0][2] + abs(i-X[0][0]) + abs(j-X[0][1])

		for k in range(N):
			if X[k][2] == max(H-abs(i-X[k][0])-abs(j-X[k][1]),0):
				count += 1
		
		if count == N:
			print(i,j,H)
			break
		count = 0

Measured memory_bytes: 3064
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 500000;
ll mx[MAX_N];

int main() {
    fastio();

    string s;
    cin >> s;
    ll cur = 0;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '<') {
            cur++;
        } else {
            cur = 0;
        }

        chmax(mx[i + 1], cur);
    }

    cur = 0;

    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == '>') {
            cur++;
        } else {
            cur = 0;
        }

        chmax(mx[i], cur);
    }

    cout << accumulate(mx, mx + s.size() + 1, 0LL) << endl;

    return 0;
}


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


void solve(long long T, long long X){
	printf("%.10Lf\n",T/(long double)(X));
}

int main(){
    long long T;
    scanf("%lld",&T);
    long long X;
    scanf("%lld",&X);
    solve(T, X);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

mint dp[10010][2][110];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	int d;
	cin>>d;
	dp[0][0][0]=1;
	rep(i,n)rep(j,2)rep(k,d){
		int now=(int)s[i]-'0';
		for(int l=0;l<=(j?9:now);l++){
			dp[i+1][j|(l<now)][(k+l)%d]+=dp[i][j][k];
		}
	}
	mint ans=dp[n][0][0]+dp[n][1][0]-1;
	cout<<ans.x<<endl;
}

Measured memory_bytes: 17536
n = int(input())
h = [int(_) for _ in input().split()]

if  n == 1:
    print(h[0])
else:
    ans = h[0]
    for i in range(n-1):
        if h[i+1] > h[i]:
            ans += h[i+1] - h[i]
    print(ans)

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

Int par[100001];
Int sz[100001];

Int root(Int x) {
    if (x == par[x]) return x;
    return par[x] = root(par[x]);
}

void unite(Int x, Int y) {
    Int rx = root(x);
    Int ry = root(y);
    if (rx == ry) return;
    par[ry] = rx;
    sz[rx] += sz[ry];
}

int main() {
    Int n, m, k;
    cin >> n >> m >> k;
    vector<Int> res(n, n - 1);
    for (Int i = 0; i < n; i++) {
        par[i] = i;
        sz[i] = 1;
    }
    vector<Int> a(m), b(m), c(k), d(k);
    for (Int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        unite(a[i], b[i]);
    }
    for (Int i = 0; i < k; i++) {
        cin >> c[i] >> d[i];
        c[i]--;
        d[i]--;
    }
    for (Int i = 0; i < n; i++) {
        res[i] = sz[root(i)] - 1;
    }
    for (Int i = 0; i < m; i++) {
        res[a[i]]--;
        res[b[i]]--;
    }
    for (Int i = 0; i < k; i++) {
        if (root(c[i]) != root(d[i])) continue;
        res[c[i]]--;
        res[d[i]]--;
    }
    // for (Int i = 0; i < n; i++) {
    //     cout << sz[root(i)] <<  " ";
    // }
    // cout << endl;
    for (Int i = 0; i < n; i++) {
        cout << res[i]  << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

struct mod {
    static const ll p = 1e9 + 7;
    ll val;
    mod() : val(0) {}
    mod(ll val) : val(val % p) {}
    mod operator+(mod o) { return mod(val + o.val); }
    mod operator-(mod o) { return mod(val - o.val + p); }
    mod operator*(mod o) { return mod(val * o.val); }
    mod operator/(mod o) { return mod(*this * pow(o, p - 2)); }
    static mod pow(mod a, mod b) {
        mod res = 1;
        for (; b.val; b.val >>= 1, a = a * a)
            if (b.val & 1) res = res * a;
        return res;
    }
    friend istream& operator>>(istream& i, mod& m) {
        i >> m.val;
        m.val %= mod::p;
        if (m.val < 0) m.val += mod::p;
        return i;
    }
    friend ostream& operator<<(ostream& o, mod m) { return o << m.val; }
};

ll sumft(ll a, ll b) { return (b + 1) * b / 2 - (a - 1) * a / 2; }

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

    ll n, k;
    cin >> n >> k;
    mod ans;

    for (ll i = k; i <= n + 1; ++i) {
        ll plus = sumft(n - i + 1, n) - sumft(0, i - 1) + 1;
        dout << i << ": " << plus << endl;
        ans = ans + plus;
    }

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


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

bool draw(vector<string> &map, int i, int j){
    if (i-1 >= 0){
        if (map.at(i-1).at(j) == '#'){
            return false;
        }
    }

    if (i+1 <= map.size()-1){
        if (map.at(i+1).at(j) == '#'){
            return false;
        }
    }

    if (j-1 >= 0){
        if (map.at(i).at(j-1) == '#'){
            return false;
        }
    }

    if (j+1 <= map.at(0).size()-1){
        if (map.at(i).at(j+1) == '#'){
            return false;
        }
    }

    return true;
}

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

    vector<string> map(h);
    for (int i = 0; i<h; i++){
        cin >> map.at(i);
    }

    for (int i = 0; i<h; i++){
        for (int j = 0; j<w; j++){
            if (map.at(i).at(j) == '#'){
                if (draw(map, i, j)){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
N = int(input())
B = [int(i) for i in input().split(' ')]
A = 0
for i in range(N):
    if i == 0:
        A += B[i]
    elif i == N - 1:
        A += B[i - 1]
    else:
        A += min(B[i-1], B[i])
print(A)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,x,i,b;
	int a[128];
	b=0;
	cin >> n;
	cin >> d >> x;
	for(i=1;i<=n;i++){
		cin >> a[i];
	}
	for(int j=1;j<=n;j++){
		for(int k=1;k<=d;k=k+a[j]){
			b++;
		}
	}
	cout << b+x << endl;
	return 0;
}

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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, begin, end) for(int (i) = (begin); (i) < (end); (i)++)

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    stack<char> st;
    string s;
    cin >> s;
    for(auto c: s) {
        if(c == '0') {
            st.push(c);
        } else if(c == '1') {
            st.push(c);
        } else {
            if(st.size() > 0) {
                st.pop();
            }
        }
    }

    string ans = "";
    while(!st.empty()) {
        ans += st.top();
        st.pop();
    }
    reverse(ALL(ans));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
	int arrays[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int a;
	cin >> a;
	cout << arrays[a-1] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String linesum = "";
		while(in.hasNext()){
			String line = in.nextLine();
			linesum = linesum + line;
		}//?????°???????????¬????????????????????????
		char[] alpha = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
		int[] alphabet = new int[26];
		char[] word = new char[linesum.length()];
		for(int i = 0; i < 26; i++){
			alphabet[i] = 0;
		}
		for(int i = 0; i < linesum.length(); i++){
			word[i] = linesum.toLowerCase().charAt(i);
			for(int j = 0; j < 26; j++){
				if(word[i] == alpha[j]){
					alphabet[j]++;
				}
			}
		}
		for(int i = 0; i < 26; i++){
			System.out.println(alpha[i] + " : " + alphabet[i]);
		}
	}
}

Measured memory_bytes: 32644
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);*/
//        string temp = ReadLine();
        int a = int.Parse(ReadLine());
        int b = a;
        for(int i=0;i<=a;i++){
            int cc = 0;
            int t = i;
            while(t>0){ cc+=t%6; t/=6; }
            
            t = a-i;
            while(t>0){ cc+=t%9; t/=9; }
            
            if(b > cc)  b=cc;
        }
        WriteLine(b);
    }
}

Measured memory_bytes: 13140
n = int(input())
a = [int(x) for x in input().split()]
res = "APPROVED"
for i in range(n):
  if a[i] % 2 == 0:
    if a[i] % 3 != 0 and a[i] % 5 != 0:
      res = "DENIED"
print(res)

Measured memory_bytes: 9180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);


int main(void) {

	int    N;
	long long   a,b,c,tmp = 0;
	int s,l;

	i_cin(N);
	for (a = 1; a < (N+1); a++) {
		for (b = 1; b < (N+1); b++) {
			for (c = 1; c <(N+1); c++) {
				tmp += (long long)_gcd(_gcd(a,b), c);
			}
		}
	}
	ll_cout(tmp); return 0;	
}
	

int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}

	return 0;
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}


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

using ll = long long;

#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_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

ll A, B, C, K;

int main() {
  cin.tie(0);cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>A>>B>>C>>K;
  
  cout<<(K%2?B-A:A-B)<<endl;
  
  return 0;
}


Measured memory_bytes: 888
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

n = k()

for i in range(1,n+1):
    if len(str(i))%2 == 1:
        count += 1

print(count)


Measured memory_bytes: 10100
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <math.h>

int main(void){
    using namespace std;
    long long a;
    
    long long b;

    cin >> a;
    long long a_l[a];
    long long n_l[a];

    long long num = 200;

    for(int i=0; i<a; i++){
        long long n = 0;
        cin >> b;
        for(int j=0; b%2==0; j++){
            n += 1;
            b = b/2;
        }
        if (num > n){
            num = n;
        }
    }


    long long min_n;

    //cout << num << " " << l_a << endl;
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

vector<vi> g;

bool check(vector<set<int>> s, vi color, int u, int c){
	int v = g[u][0];
	color[u] = c;
	if(color[u] == color[v]){
		return false;
	}
	s[v].erase(color[u]);
	u = v;
	
	while(color[u] == -1){
		int v = g[u][0];
		color[u] = *s[u].begin();
		if(color[u] == color[v]){
			return false;
		}
		s[v].erase(color[u]);
		u = v;
	}
	if(color[u] != *s[u].begin()) return false;
	return true;
}

bool solve(){
	cin >> n;
	g.resize(n);
	vi deg(n);
	vector<set<int>> s(n);
	REP(i, n) s[i].insert(0);
	REP(i, n) s[i].insert(1);
	REP(v, n){
		int u;
		cin >> u; u--;
		g[v].pb(u);
		deg[u] ++;
		int t = s[u].size();
		s[u].insert(t);
	}
	vi color(n, -1);
	queue<int> q;
	REP(i, n)if(deg[i] == 0){
		q.push(i);
	}
	while(!q.empty()){
		int u = q.front(); q.pop();
		color[u] = *s[u].begin();
		for(int v : g[u]){
			if(-- deg[v] == 0) q.push(v);
			s[v].erase(color[u]);
		}
	}
	int u = -1;
	REP(v, n)if(deg[v] && (u == -1 || *s[u].begin() < *s[v].begin())) u = v;
	auto it = s[u].begin();
	if(check(s, color, u, *it)) return true;
	if(check(s, color, u, *(++it))) return true;
	
	return false;
}

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cout << (solve() ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


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

#define ll long long int
#define f(i,n) for(ll i = 0; i < n ; i++)
#define fn(i,n) for(ll i = 1; i <= n ; i++)
#define F first 
#define pb push_back
#define S second
using namespace std;
ll dp[3005][3005];

ll mn = INT_MAX;
void sol(string s1, string s2, ll n , ll m)
{
    
   ll dp[n+1][m+1] = {};
    
    fn(i,n)
    {
      for(ll j = 1 ; j <= m ; j++)
      {
        if(s1[i-1] == s2[j-1])
         dp[i][j] = 1 + dp[i-1][j-1];

        else
         dp[i][j] = max(dp[i-1][j],  dp[i][j-1]);
      }
    }
    //cout<<dp[n][m]<<endl;
string s;
       ll i = n, j = m;
       while(i > 0 && j > 0)
         {
            if(s1[i-1] == s2[j-1])
            {
              s.pb(s1[i-1]);
              i--;j--;
            }
            else
            {
              if(dp[i][j-1] > dp[i-1][j])
                j--;
              else
                i--;

            }
         } 
         reverse(s.begin(),s.end());
         cout<<s;
}


 
int main()
{

     #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif
     
         //ll n;
          memset(dp,-1,sizeof(dp));
         //cin>>n>>W;
         //ll p[n],w[n];
        
         string s1,s2; cin>>s1>>s2;
         ll n = s1.length();
         ll m = s2.length();
         //f(i,10) dp[i] = 100;
         //memset(dp,-1,sizeof(dp));
         sol(s1,s2,n,m);
         
         
         
         //cout<<dp[0][3]<<endl;
         
        
         
   return 0;
}


Measured memory_bytes: 144476
def cumsum(a):
    s = [0]
    for i in range(len(a)):
        s.append(s[i]+a[i])
    return s

n,k = map(int, input().split())
p = list(map(int, input().split()))
ex = [0]*n
for i in range(len(p)):
    ex[i] = (1 + p[i]) / 2
ex_list = cumsum(ex)
ans = 0
for i in range(n-k+1):
    ans = max(ans, ex_list[i+k] - ex_list[i])
print(ans)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define il inline
#define gc getchar()
#define mp make_pair
#define ri register int
#define rc register char
#define rb register bool
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)

const int N=1e6+10;
int n,m,d;
string str;

il int read()
{
	rc ch=gc;ri x=0;rb y=1;
	while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
	if(ch=='-')ch=gc,y=0;
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
	return y?x:-x;
}

int main()
{
	n=read();m=read();d=read();str=" RGBY";
	rp(i,0,n-1){rp(j,0,m-1){ri x=(m+i+j)/d%2,y=(m+i-j)/d%2;printf("%c",str[2*x+y+1]);}printf("\n");}
	return 0; 
}

Measured memory_bytes: 512
package main

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

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n-1)
}

func combination(n int, k int) int {
	return permutation(n, k) / factorial(k)
}

func proc(r io.Reader, w io.Writer) {
	var n int
	var s string
	fmt.Fscanf(r, "%d", &n)
	arr := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(r, "%s", &s)
		runes := []rune(s)
		ints := make([]int, 10)
		for j := 0; j < 10; j++ {
			ints[j] = int(runes[j] - 'a')
		}
		sort.Ints(ints)
		for j := 0; j < 10; j++ {
			runes[j] = rune('a' + ints[j])
		}
		arr[i] = string(runes)
	}
	sort.Strings(arr)
	res := 0
	cnt := 0
	s = arr[0]
	for i := 1; i < n; i++ {
		if arr[i] == s {
			cnt++
		} else {
			res += permutation(cnt+1, 2) / 2
			cnt = 0
			s = arr[i]
		}
	}
	res += permutation(cnt+1, 2) / 2
	fmt.Fprintf(w, "%d ", res)
}

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


Measured memory_bytes: 6528
a,b,c = map(int,input().split())
if a==5 and b==5 and c==7:
    print('YES')
elif  a==5 and b==7 and c==5:
    print('YES')
elif a==7 and b==5 and c==5:
    print('YES')
else:
    print('NO')
    

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


int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p.at(i);
	}
	sort(p.begin(), p.end());
	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += p.at(i);
	}
	cout << sum << endl;

}

Measured memory_bytes: 3588
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N%1000 == 0){
            System.out.println(0);
        }else{
            System.out.println(1000 - N%1000);
        }
    }
}


Measured memory_bytes: 35660
#include <iostream>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#include <algorithm>
#include <bits/stdc++.h>
#define MOD 1000000000
#define ll long long
#define mm(arr) memset(arr, 1, sizeof(arr))
#define scanArray(a,n) for(ll i = 0; i < n; i++){cin >> a[i];}
#define PI 3.141592653589793
using namespace std;
int main(){
FAST
int n,m; cin >> n >> m;
int a[n];
int sum2=0;
for(int i =0; i<m; i++){
    cin >> a[i];
    sum2+=a[i];

}
if(n>=sum2){
    cout << n-sum2<< endl;
}
else{
    cout << "-1" << endl;
}

return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string s;
	cin>>s;
	
	int i=0;
	int j=s.size()-1;
	int cnt=0;
	while(i<=j){
		if(s[i++]!=s[j--]) cnt++;
	}
	
	cout<<cnt<<endl;
}


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

class Vector2{
public:
	Vector2() : x( 0 ), y( 0 ){}
	Vector2( Vector2& a ){
		x = a.x;
		y = a.y;
	}
	Vector2( Vector2& a, Vector2& b ){
		x = b.x - a.x;
		y = b.y - a.y;
	}

	double cross( Vector2& a ){
		return ( x * a.y ) - ( y * a.x );
	}

	double x, y;
};

int main(){
	Vector2 a, b, c, d;
	char s;

	while ( cin >> a.x >> s >> a.y >> s >> b.x >> s >> b.y >> s
				>> c.x >> s >> c.y >> s >> d.x >> s >> d.y ){

		Vector2 ab( a, b ), bc( b, c ), cd( c, d ), da( d, a );
		double ap, bp, cp, dp;

		ap = da.cross( ab );
		bp = ab.cross( bc );
		cp = bc.cross( cd );
		dp = cd.cross( da );

		if ( ( ap > 0 && bp > 0 && cp > 0 && dp > 0 ) || ( ap < 0 && bp < 0 && cp < 0 && dp < 0 ) ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 0
sx,sy,tx,ty = map(int, input().strip().split(' '))
print('U'*(ty-sy)+'R'*(tx-sx+1)+'D'*(ty-sy+1)+'L'*(tx-sx+1)+'UL'+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'*(ty-sy+1)+'L'*(tx-sx))


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

using namespace std;

#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 FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;} 

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int k,s;
   cin >> k >> s;
   int ans = 0;
   for(int i=0;i<=k;i++){
      if(i>s)break;
      for(int j=0;j<=k;j++){
         if(i+j > s)break;
         int z = s-i-j;
         if(z>=0 && z<=k)ans++;
      }
   }
   cout << ans << endl;
   return 0;
}

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

A = int(input())
B = int(input())
C = int(input())
X = int(input())

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

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int A, B;
char ans[112][112];

int main()
{
	in >> A >> B;
	rep(i, 100) rep(j, 100) ans[i][j] = (i < 50 ? '#' : '.');
	--A; --B;
	for (int i = 0; i < 49; i += 2)
	{
		if (A == 0) break;
		for (int j = 0; j < 100; j += 2)
		{
			if (A == 0) break;
			ans[i][j] = '.';
			--A;
		}
	}
	for (int i = 51; i < 100; i += 2)
	{
		if (B == 0) break;
		for (int j = 0; j < 100; j += 2)
		{
			if (B == 0) break;
			ans[i][j] = '#';
			--B;
		}
	}
	out << 100 << " " << 100 << std::endl;
	rep(i, 100) out << ans[i] << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main(){
	int A, B; 
	cin >> A >> B; 
	if(A > B) cout << 2 * A - 1 << endl; 
	else if(A == B) cout << A + B << endl; 
	else if(A < B) cout << 2 * B - 1 << endl; 
}

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

signed main(){
	int n,p[200];
	vector<int> ans;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> p[i];
	for(int i = 0;i <= n;i++){
		for(int j = 0;j < n;j++){
			bool flag = true;
			for(int k = 0;k < n;k++){
				if(p[k] != k) flag = false;
			}
			if(flag){
				cout << ans.size() << endl;
				for(int v : ans) cout << v << endl;
				return 0;
			}
			if(j != n - 1 && p[0] < p[n - 1]){
				ans.push_back(n - 1);
				swap(p[0],p[n - 1]);
			}
			ans.push_back(1);
			for(int k = 1;k < n;k++) swap(p[k],p[k - 1]);
		}
	}
	return 0;
}

Measured memory_bytes: 764
N = int(input())
A = list(map(int, input().split()))

ans = 0
tmp = A[0]
end = 0

# ^ = XOR演算子
for start in range(N):

    while end < N - 1 and (tmp ^ A[end + 1] == tmp + A[end + 1]):
        end += 1
        tmp += A[end]

    ans += (end - start + 1)
    tmp -= A[start]

    if start == end and end < N - 1:
        end += 1
        tmp += A[end]

print(ans)


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

int Q;

bool ok(long int n, int c) {
	if (n < 10) {
		cout << c << endl;
		return true;
	}
	return false;
}

int mul(long int n) {
	int t,r = 0;
	int dig = (int)log10(n);
	for (int i = 1; i < dig + 1; i++) {
		t = (n / (int)pow(10,i)) * (n % (int)pow(10,i));
		if (t > r) {
			r = t;
		}
	}
	return r;
}

int main(){
	long int N;
	int c;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> N;
		c = 0;
		while (!ok(N, c)) {
			if (c > 10000) {
				cout << -1 << endl;
				break;
			}
			N = mul(N);
			c++;
		}
	}

	return 0;
}

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

int main(){
  int n;
  long long k;
  cin >> n >> k;
  map<int,long long> mp;

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

  for(auto m:mp){
    if(m.second >= k){
      cout << m.first << endl;
      return 0;
    }
    else{
      k-=m.second;
    }
  }
}

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

int main() {
	long long n;cin>>n;
	long long a=1;
	if(n==0){
		cout<<0<<endl;
		return 0;
	}
	vector<long long> v;
	while(abs(a)<=abs(n)){
		a*=-2;
//		cout<<a<<endl;
//		cout<<n<<endl;
		if(n%a!=0){
			n-=a/(-2);
			v.push_back(1);
		}else{
			v.push_back(0);
		}
	}
	for(int i=0;i<v.size();i++){
		cout<<v[v.size()-1-i];
	}
	cout<<endl;
	return 0;
}


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

int main(){
    string s;
    cin>>s;
    int a=1,b=0;
    char c,d;
    c = s[0];
    for(int i=1;i<s.length();i++){
        if(s[i]==c){
            a++;
        }else{
            if(b==0){
                d = s[i];
                b++;
            }
            else
            {
                if(s[i]==d)
                b++;
            }    
        }
    }
    if(a==2 && b==2)
    cout<<"Yes\n";
    else
    {
        cout<<"No\n";
    }
    
    return 0;
}


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

int main() {
    ll N, sum = 0;
    cin >> N;
    int A[N];
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    ll k = sum / (N * (N + 1) / 2);
    if (k * N * (N + 1) / 2 != sum) {
        cout << "NO" << endl;
        return 0;
    }
    int d[N];
    ll cnt = 0;
    rep(i, N) {
        d[i] = A[(i+1)%N] - A[i];
        d[i] -= k;
        if (d[i] % N) {
            cout << "NO" << endl;
            return 0;
        }
        cnt += abs(d[i] / N);
    }
    if (cnt != k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 1024