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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    int x; cin >> x;
    
    cout << (x<1200?"ABC":"ARC") << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;

void yes(){
    cout<<"Yes"<<endl;
}

void no(){
    cout<<"No"<<endl;
}

ll dp[2010];
void solve(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vl p(a);
    for(int i=0;i<a;i++){
        cin>>p[i];
    }
    vl q(b);
    for(int i=0;i<b;i++){
        cin>>q[i];
    }
    vl r(c);
    for(int i=0;i<c;i++){
        cin>>r[i];
    }
    sort(all(p));
    for(int i=a-1;i>=a-x;i--){
        r.pb(p[i]);
    }
    sort(all(q));
    for(int i=b-1;i>=b-y;i--){
        r.pb(q[i]);
    }
    sort(all(r));
    ll ans=0;
    for(int i=r.size()-1;i>=r.size()-x-y;i--){
        ans+=r[i];
    }
    cout<<ans<<endl;
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 6256
// {{{
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)x.size())
#define FOR(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
using LL=long long;
using PII=pair<int,int>;
using VI=vector<int>;

#ifdef FEI
template<typename T>
void _dump(const char* s, T&& head) { cerr<<s<<"="<<head<<endl; }
template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
    int c=0;
    while (*s!=',' || c!=0) {
        if (*s=='(' || *s=='[' || *s=='{') c++;
        if (*s==')' || *s==']' || *s=='}') c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1, tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, ##__VA_ARGS__); \
} while(0);

template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<'[';
    for (auto it=b; it!=e; it++) s<<(it==b?"":",")<<*it;
    s<<']';
    return s;
}

template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) { return s<<"("<<p.first<<","<<p.second<<")";}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &x) { return _out(s,ALL(x)); }
template<typename T, size_t N>
ostream& operator <<(ostream &s, const array<T,N> &x) { return _out(s,ALL(x)); }
template<typename T>
ostream& operator <<(ostream &s, const set<T> &x) { return _out(s,ALL(x)); }
template<typename A, typename B>
ostream& operator <<(ostream &s, const map<A,B> &x) { return _out(s,ALL(x)); }
#else
#define dump(...)
#endif

template<typename T>
void _R(T &x) { cin>>x; }
void _R(int &x) { scanf("%d",&x); }
void _R(LL &x) { scanf("%" PRId64,&x); }
void _R(double &x) { scanf("%lf",&x); }
void _R(char &x) { scanf(" %c",&x); }
void _R(char *x) { scanf("%s",x); }

void R(){}
template<typename T, typename... X>
void R(T& head, X&... tail) { _R(head); R(tail...); }
// }}}

int main() {
    int n;
    R(n);
    int ans = 1, pre, up=1, down=1;
    R(pre);
    for (int i=1; i<n; i++) {
        int now;
        R(now);
        if (pre > now) {
            if (!down) {
                ans++;
                up = down = 1;
            }
            else {
                up = 0;
            }
        }
        else if (pre < now) {
            if (!up) {
                ans++;
                up = down = 1;
            }
            else {
                down = 0;
            }
        }

        pre = now;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def s():
 import sys
 r=sys.stdin.readline
 for e in iter(r,'0\n'):
  R=[[]for _ in[0]*-~int(e)]
  for _ in[0]*int(r()):
   a,b=map(int,r().split())
   R[a]+=[b];R[b]+=[a]
  for m in R[1][:]:R[1]+=R[m]
  print(len({*R[1]}-{1}))
s()


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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=2e3+10,MOD=1e9+7;
int n,k,dp[MAXN][MAXN],res;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=2;i<=n;i++) dp[1][i]=1;
	for(int i=2;i<k;i++)
	{
		int pre=dp[i-1][n-i+2];
		for(int j=n-i+1;j>=2;j--)
		{
			(dp[i][j]+=pre)%=MOD;
			(pre+=dp[i-1][j])%=MOD;
			(dp[i][j]+=dp[i-1][j])%=MOD;
		}
	}
	if(k==1) res=1;
	for(int i=2;i<=n;i++)
		(res+=dp[k-1][i])%=MOD;
	for(int i=1;i<=n-k-1;i++)
		(res<<=1)%=MOD;
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 15360
h,w=map(int,input().split())
a=['*'*(w+2)]+['*'+input()+'*' for _ in range(h)]+['*'*(w+2)]
from collections import deque
d=deque()
c=[[0]*w for _ in range(h)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if a[i][j]=='#':
      d.append([i,j])
di=[[0,1],[1,0],[-1,0],[0,-1]]
while d:
  g=d.popleft()
  for i in di:
    x=g[0]+i[0]
    y=g[1]+i[1]
    if a[x][y]=='.':
      if c[x-1][y-1]==0:
        d.append([x,y])
        c[x-1][y-1]=c[g[0]-1][g[1]-1]+1
m=0
for i in range(h):
  for j in range(w):
    m=max(m,c[i][j])
print(m)

Measured memory_bytes: 141020
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int  check(int n)
{
    int c=0;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0){
        if(n/i==i)
        c++;
        else
        c+=2;}
    }
    return c;
}

int main()
{
    int n;
    cin>>n;
    long long int s=0;
    for(int i=1;i<=n-1;i++)
    {
        s+=check(i);
    }
    cout<<s<<"\n";

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int cnt;

void merge(int arr[], int l, int m, int r) {
    int i, j, k;

    int n1 = m - l + 1;  // number of elements in first subarray
    int n2 = r - m;      // number of elements in second subarray

    // create temporary subarrays
    int L[n1];  // array[l..m]
    int R[n2];  // array[m+1..r]

    // copy data to subarrays L and R 
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1 + j];

    // merge the two arrays
    i = 0;    // index of L
    j = 0;    // index of R
    k = l;    // index of merged array
   
    while (i < n1 && j < n2) {
        if (L[i] <= R[j]) {
            arr[k] = L[i];
            i++;
        } else {
            arr[k] = R[j];
            j++;
        }
        k++;
	cnt++;
	
    }
     
    while (i < n1) {
        arr[k] = L[i];
        i++;
        k++;
	cnt++;
    }
    
    while (j < n2) {
        arr[k] = R[j];
        j++;
        k++;
	cnt++;
    }
}

void mergeSort(int array[], int l, int r) {

    if (l < r) {
        // avoids overflow for large l and h
        int m = l + (r - l) / 2;

        mergeSort(array, l, m);
        mergeSort(array, m + 1, r);
        merge(array, l, m, r);
    }

}


int main (void) {

    int n,i,S[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,0,n-1);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1) printf(" ");
    if(i == n-1) printf("\n");
  }
  printf("%d\n",cnt);

  return 0;
}



Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
string xx[]={"7","5","3"};
int n,ans;
int main(){
	cin >> n;
	vector<string> t;
	t.push_back("");
	while(t.size()){
		vector<string> p;
		for (auto y:t){
			for(auto s:xx){
				string k = y+s;
				if(k.find('7')!=k.find('0'))
				if(k.find('5')!=k.find('0'))
				if(k.find('3')!=k.find('0'))
				if(stoi(k)<=n)ans++;
				if(y.size()<8)
				p.push_back(y+s);
			}
		}
		t = p;
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
//#define TEST
bool compare_by_pair(pair<long,long> a, pair<long,long> b) {
    if(a.second !=  b.second){
        return a.second < b.second;
    }
    return a.second == b.second;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N;
    cin >> N;
    vector<pair<long, long>> A(N);
    long a;
    pair<long, long> best = make_pair(0, 0);
    long second_best=0;
    for(size_t i=0;i<N; i++)
    {
        cin >> a;
        if(a >= best.second)
        {
            second_best = best.second;
            best = make_pair(i, a);
        }
        else if(a > second_best) second_best = a;
    }
    for(size_t i=0;i<N; i++)
    {
        if(i != best.first) cout << best.second << endl;
        else cout << second_best << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
 
using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;
using ll=long long;
 
class UFDS
{
private:
    std::vector<int> size, ps;

public:
	int groups = -1;
    UFDS(int N) : size(N + 1, 1), ps(N + 1)
    {
        // ps = {0, 1, 2, 3, ..., N}
        std::iota(ps.begin(), ps.end(), 0);
    }

    int find_set(int x) const
    {
        return x == ps[x] ? x : find_set(ps[x]);
    }

    bool same_set(int x, int y)
    {
        return find_set(x) == find_set(y);        
    }

    void union_set(int x, int y)
    {
        if (same_set(x, y))
            return;

        int p = find_set(x);
        int q = find_set(y);

        if (size[p] < size[q])
            std::swap(p, q);

        ps[q] = p;
        size[p] += size[q];
		groups = max(groups, size[p]);
    }
};
int main()
{
	int n, m; cin >> n >> m;
	UFDS dsu(n);
	for (int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		dsu.union_set(a, b);
	}
	cout << (dsu.groups == -1 ? 1 : dsu.groups) << "\n";
}


Measured memory_bytes: 4840
Y = [-1,0,1,0]; X = [0,-1,0,1]
H, W = gets.split.map(&:to_i)
areas = [] << Array.new(W+2, "@")
black = 0
H.times do
  pre = gets.chomp.split('')
  black += pre.count("#")
  areas << ["@"] + pre + ["@"]
end
areas << Array.new(W+2, "@")
# p black
# areas.each do |area|
#   p area
# end
queue = [] << [1, 1, 0] # [y, x, ０歩目]
while !queue.empty?
  now = queue.shift
  4.times do |i|
    nexy = now[0] + Y[i]
    nexx = now[1] + X[i]
    if nexy == H && nexx == W
      puts H * W - (black + now[2] + 2) # +2 はスタートとゴール分
      exit
    elsif areas[nexy][nexx] == "."
      areas[nexy][nexx] = "b"
      queue.push([nexy, nexx, now[2] + 1])
    end
  end
end
puts -1

Measured memory_bytes: 2172
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
using System.Numerics;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var P = new int[N];
        for (int i = 0; i < N; i++)
        {
            P[i] = int.Parse(ReadLine());
        }
        var K = new int[N];
        for (int i = 0; i < N; i++)//K no増加部分列を調べてみる
        {
            K[P[i]-1] = i;
        }
        int zouka = 0;
        int num = 0;
        for (int i = 0; i < N-1; i++)
        {
            if (K[i] < K[i + 1]) num++;
            else
            {
                zouka = Max(zouka, num);
                num = 0;
            }
        }
        zouka = Max(zouka, num);
        WriteLine(N-zouka-1);

        //

    }
}


Measured memory_bytes: 36224
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAXN = 100000;

ll N, ans=0, tmp=0;
vector<ll> S(MAXN, 0);

bool sosuu(ll num) {
    for(int i=2;i*i<=num;i++) {
        if(num%i==0) {
            return 0;
        }
    }
    return 1;
}

ll judgefunc(ll num) {
    if(sosuu(num)&&sosuu((num+1)/2)) return 1;
    return 0;
}

void prepairfunc() {
    S[1] = 0;
    for(int i=1;i<50000;i++) {
        S[2*i+1] = S[2*i-1] + judgefunc(2*i+1);
    }
}

signed main(){
    prepairfunc();
    cin >> N;
    for(int i=0;i<N;i++) {
        ll l, r;
        cin >> l >> r;
        if(l==1) cout << S[r] << endl;
        else cout << S[r]-S[l-2] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long h, w;
long long sa, sb, sc;
long long sb2, sc2;
long long smin(long long H, long long W, long long S) {
    long long rans = 1e12;
    for(int i = 0; i <= H; ++i) {
        vector<long long> ss;
        vector<long long> ss2;
        sa = i*W;
        if((H-i) % 2 == 0 || W % 2 == 0) {
            sb = sc = (S-sa) / 2;
            sb2 = sc2 = (S-sa) / 2;
        }else {
            sb = (H-i)/2 * W;
            sc = S - sa - sb;
            sb2 = (H-i) * (W/2);
            sc2 = S - sa - sb2;
        }
        ss.push_back(sa); ss.push_back(sb); ss.push_back(sc);
        ss2.push_back(sa); ss2.push_back(sb2); ss2.push_back(sc2);
        sort(ss.begin(), ss.end());
        sort(ss2.begin(), ss2.end());
        chmin(rans, ss.at(2)-ss.at(0));
        chmin(rans, ss2.at(2)-ss2.at(0));
        /*for(int i = 0; i < 3; ++i) {
            cout << ss.at(i) << " " << ss2.at(i) << endl;
        }*/
    }
    return rans;
}

int main() {
    cin >> h >> w;
    long long s = h * w;
    long long sa, sb, sc;
    long long ans = 1e12;
    if(h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
    }else {
        if(h == w) {
            cout << smin(h, w, s) << endl;
        }else {
            cout << min(smin(h, w, s), smin(w, h, s)) << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
        if(((4*x-y)%2==0) &&(4*x-y>=0) && ((y-2*x)%2==0) && (y>=2*x) && (y%2==0))cout<<"Yes";
        else cout<<"No";
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N(22222);
int b[N];
int main() {
	int n;
	scanf("%d", &n);
	for(int i(0); i < n; i++) {
		int x;
		scanf("%d", &x);
		b[x - 1] = i;
	}
	for(int i(0); i < n; i++) {
		printf("%d%c", 1 + i * 20000, i == n - 1 ? '\n' : ' ');
	}
	for(int i(0); i < n; i++) {
		printf("%d%c", 1 + (n - 1 - i) * 20000 + b[i], i == n - 1 ? '\n' : ' ');
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

const int mod = pow(10, 9) + 7;



int main() {
    int N, M;
    cin >> N >> M;

    if(abs(N - M) > 1) {
        cout << 0 << endl;
    } else if(N == M) {
        ll F = 1;
        repi(i, 1, N + 1) {
            F *= i;
            F %= mod;
        }
        cout << ((F * F) % mod * 2) % mod << endl;
    } else {
        ll F = 1;
        ll T;
        int L = max(N, M);
        int S = min(N, M);
        repi(i, 1, L + 1) {
            F *= i;
            F %= mod;
            if(i == S) {
                T = F;
            }
        }
        cout << (F * T) % mod << endl;
    }
}

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        a[i] *= 2;
    }
    ll p = 0;
    for (int i = 0; i < n; ++i)
    {
        if (i % 2 == 0)
            p += a[i];
        else
            p -= a[i];
    }
    p /= 2;
    cout << p << " ";
    for (int i = 0; i < n - 1; ++i)
    {
        p = a[i] - p;
        cout << p << " ";
    }
    return 0;
}


Measured memory_bytes: 2176
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> H >> W;
	vector<vector<int>>a(H+1, vector<int>(W+1));
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> a[i][j];
		}
	}
	vector<vector<int>>b(H + 1, vector<int>(W + 1));
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> b[i][j];
		}
	}
	vector<vector<bitset<25601>>>dp(H + 1, vector<bitset<25601>>(W + 1));
	dp[0][1].flip(12800);
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			dp[i][j] |= dp[i - 1][j] << (abs(a[i][j] - b[i][j]));
			dp[i][j] |= dp[i - 1][j] >> (abs(a[i][j] - b[i][j]));
			dp[i][j] |= dp[i][j - 1] << (abs(a[i][j] - b[i][j]));
			dp[i][j] |= dp[i][j - 1] >> (abs(a[i][j] - b[i][j]));
		}
	}
	int ans = MOD;
	for (int i = 0; i < 25601; i++) {
		if (dp.back().back().test(i)) {
			ans = min(ans, abs(12800 - i));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 21376
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
struct Point { long double px, py; };
struct Line { Point p1, p2; };
Point Minus(const Point& a, const Point& b) { return Point{ a.px - b.px,a.py - b.py }; }
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
long double dst(const Point& a, const Point& b) { return abs(Minus(b , a)); }
long double dst(const Line& a, const Point& b) {
	long double E = dot(Minus(a.p2, a.p1), Minus(b, a.p1));
	long double F = dot(Minus(a.p1, a.p2), Minus(b, a.p2));
	if (E < -1e-7)return abs(Minus(b, a.p1));
	if (F < -1e-7)return abs(Minus(b, a.p2));
	return abs(crs(Minus(a.p2, a.p1), Minus(b, a.p1)) / abs(Minus(a.p2, a.p1)));
}
int contain(vector<Point> v, Point p) {
	bool in = false;
	for (int i = 0; i < v.size(); ++i) {
		Point a = Minus(v[i], p), b = Minus(v[(i + 1) % v.size()], p);
		if (a.py > b.py) swap(a, b);
		if (a.py <= 1e-7 && 1e-7 < b.py)
			if (crs(a, b) < -1e-7) in = !in;
		if (fabs(crs(a, b)) <= 1e-7 && dot(a, b) <= 1e-7) return 1;
	}
	return in ? 2 : 0;
}
int main() {
	while (true) {
		Point r1, r2, r3, r4; long double r;
		cin >> r1.px >> r1.py; if (fabs(r1.px) <= 1e-7 && fabs(r1.py) <= 1e-7)break;
		cin >> r2.px >> r2.py >> r3.px >> r3.py >> r4.px >> r4.py >> r;
		Line l1 = Line{ r1,r2 }, l2 = { r2,r3 }, l3 = { r3,r1 };
		long double c1 = min(dst(l1, r4), min(dst(l2, r4), dst(l3, r4)));
		long double c2 = max(dst(r1, r4), max(dst(r2, r4), dst(r3, r4)));
		//cout << dst(l1, r4) << ' ' << dst(l2, r4) << ' ' << dst(l3, r4) << endl;
		int c4 = contain({ r1,r2,r3 }, r4);
		if (c1 >= r - 1e-7 && c4 != 0) { cout << "a" << endl; }
		else if (c2 <= r + 1e-7) { cout << "b" << endl; }
		else if (c1 <= r + 1e-7) { cout << "c" << endl; }
		else { cout << "d" << endl; }
	}
	return 0;
}

Measured memory_bytes: 3008
N , M = map(lambda x: int(x),input().split())
isAC = ["WA"] * (N+1)
WAcount = [0] * (N+1)
score=0
penalty = 0
for i in range(M):
    p,r = input().split()
    #print(p,r)
    p = int(p)
    #p -= 1
    if isAC[p] =="AC":
        continue
    if r == "WA":
        WAcount[p] += 1
        #print(penalty)
    else:
        isAC[p] = "AC"
        score += 1
        #print(score)
    #print(isAC)
for i in range(N+1):
  if isAC[i]=="AC":
    penalty += WAcount[i]
print(score,penalty)


Measured memory_bytes: 4724
#include <bits/stdc++.h>
 
int main()
{
int a=0,b=0,c=0;
double d=0,e=0;
scanf("%d %d",&a,&b);
d=a;
e=b;
c=a/b;	
a=a%b;
d=d/e;
printf("%d %d %f\n",c,a,d);
return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const int INF = 1e9;

int dp[41][401][401];

int main(){
  int n,ma,mb;
  cin >> n >> ma >> mb;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> val(n);

  rep(i,n){
    cin >> a[i] >> b[i] >> val[i];
  }
  for (int i = 0;i <= n;i++){
    rep(x,401) rep(y,401) dp[i][x][y] = INF;
  }
  dp[0][0][0] = 0;
  rep(i,n+1){
    rep(x,401){
      rep(y,401){
        if (i == 0) continue;
        if (dp[i-1][x][y] != INF){
            dp[i][x+a[i-1]][y+b[i-1]] = min(dp[i][x+a[i-1]][y+b[i-1]],dp[i-1][x][y] + val[i-1]);
            dp[i][x][y] = min(dp[i][x][y],dp[i-1][x][y]);
        }
      }
    }
    //rep(x,15) {
    //  rep(y,15){
    //    if (dp[i][x][y] == INF) cout << "F ";
    //    else cout << dp[i][x][y] << " ";
    //  }
    //  cout << endl; 
    //}
    //cout << endl;
  }
  
  
  int ans;
  ans = INF;
  rep(i,401) rep(j,401){
    if (i == 0 && j == 0) continue;
    if (mb*i == ma*j) ans = min(ans,dp[n][i][j]);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 29388
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ans := 1<<32 - 1
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scan(&m)
		arr[i] = m
	}
	for i := -100; i <= 100; i++ {
		tmp := 0
		for _, ai := range arr {
			tmp += (i - ai) * (i - ai)
		}
		ans = min(ans, tmp)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;
 
int main()
{
    ll a; cin>>a;
    ll total = a + a*a + a*a*a;
    cout<<total<<"\n";

	return 0;
}

Measured memory_bytes: 3632
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef unsigned long long int uint64_t ;

int H[100001] = {0};

int main()
{
	int N = 0,i = 0;
	int ans = 0, prev = 0;
	scanf("%d", &N);
	for (i = 0; i < N;i++) {
		scanf("%d", &H[i]);
	}

	for (i = 0; i < (N-1); i++) {
		if (H[i] >= H[i+1]) {
			ans++;
		} else {
			if (ans > prev) {
				prev = ans;
			}
			ans = 0;
		}
	}
	if (prev > ans) {
		ans = prev;
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
ls = [int(input()) for _ in range(5)]

t = 0
last_dish = 0

for i in range(5):
    if (ls[i] - 1) % 10 < (last_dish - 1) % 10:
        t += 10 * ((last_dish - 1) // 10 + 1)
        last_dish = ls[i]
    else:
        t += 10 * ((ls[i] - 1) // 10 + 1)
    
print(t + last_dish)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int table[100][100];

string changes(ll i) {
	stringstream ss;
	ss << i;
	return ss.str();
}

bool check(string s) {
	int e = 0;
	REP(i, s.size()) {
		e = table[e][s[i] - '0'];
	}
	if (e == 0)return true;
	return false;
}

int main() {
	int ans = 0;
	REP(i, 10)REP(j, 10)cin >> table[i][j];
	REP(i, 10000) {
		string s = changes(i);
		int size = s.size();
		while (s.size() < 4)s = "0" + s;
		int now = 0;
		REP(j, s.size()) {
			now = table[now][s[j] - '0'];
		}
		s += "0";
		s[4] += now;
		bool f = 0;
		string t;
		REP(j, s.size()) {
			REP(k, 10) {
				t = s;
				t[j] = (char)('0' + k);
				if (s == t)continue;
				if (check(t))f = 1;
			}
		}
		REP(j, s.size() - 1) {
			t = s;
			swap(t[j], t[j + 1]);
			if (s == t)continue;
			if (check(t))f = 1;
		}
		ans += f;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3176
using System;
using System.Collections;
using System.Collections.Generic;
class main{
	public static void Main(){
		int ct;
		int[] H = new int[100000];
		int[] W = new int[100000];
		for(ct = 0;; ct++)
		{
			string[] str = Console.ReadLine().Split(' ');
			H[ct] = int.Parse(str[0]);
			W[ct] = int.Parse(str[1]);
			if (H[ct] == 0 && W[ct] == 0)
			{
				break;
			}
		}
		for(int i = 0; i < ct; i++)
		{
			for(int j = 0; j < H[i]; j++)
			{
				for(int k = 0; k < W[i]; k++)
				{
					Console.Write('#');
				}
				Console.WriteLine();
			}
			Console.WriteLine();
		}
	}
}

Measured memory_bytes: 9720
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll e=c+b-d,f=d+c-a;
  cout<<e<<' '<<f<<' '<<e-(c-a)<<' '<<f-(d-b)<<endl;
}

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

using namespace std;

const int INF = 100000000;

int n;
bool table[5000][5];
int height[5];
int width[5000];
int ans;
int d, p, q;

void clear(){
  bool f = false;
  int h = -1;
  for(int i=0;i<5;i++){
    h = max(h, height[i]);
  }
  int pos = 0;
  for(int i=0;i<h;i++){
    if(width[i] == 5){
      width[i] = 0;
      ans -= 5;
      f = true;
      for(int j=0;j<5;j++){
	table[i][j] = false;
      }
    }else{
      if(i != pos){
	for(int j=0;j<5;j++){
	  table[pos][j] = table[i][j];
	  table[i][j] = false;
	}
	width[pos] = width[i];
	width[i] = 0;
      }
      ++pos;
    }
  }
  if(!f) return;
  fill(height, height+5, 0);
  for(int j=0;j<5;j++){
    for(int i=0;i<5000;i++){
      if(!table[i][j]) continue;
      height[j] = max(height[j], i+1);
    }
  }
}

main(){
  while(cin >> n && n){
    fill(table[0], table[5000], false);
    fill(height, height+5, 0);
    fill(width, width+5000, 0);
    ans = 0;
    for(int i=0;i<n;i++){
      cin >> d >> p >> q;
      --q;
      ans += p;
      if(d == 1){
	int h = -1;
	for(int j=0;j<p;j++){
	  h = max(h, height[q+j]);
	}
	for(int j=0;j<p;j++){
	  table[h][q+j] = true;
	  height[q+j] = h+1;
	}
	width[h] += p;
      }else if(d == 2){
	for(int j=0;j<p;j++){
	  table[height[q]+j][q] = true;
	  ++width[height[q]+j];
	}
	height[q] += p;
      }
      clear();
      /*for(int j=0;j<5;j++){
	cout << height[j] << ' ';
      }
      cout << endl;
      for(int j=0;j<8;j++){
	cout << width[j] << ' ';
      }
      cout << endl << endl;
      for(int i=9;i>=0;i--){
	for(int j=0;j<5;j++){
	  cout << table[i][j];
	}
	cout << endl;
      }
      cout << endl;*/
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main(){
    ll n ; cin >> n ;
    set<char> s ;
    for(int i = 0 ; i < n ; i++){
    	char ch ; cin >> ch ;
    	s.insert(ch);
	}
	if(s.size() == 1)
	cout <<"One" ;
	else if(s.size() == 2)
	cout << "Two";
	else if(s.size() == 3)
	cout << "Three" ;
	else cout << "Four" << endl;
}



Measured memory_bytes: 3612
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int A = sc.nextInt(), B = sc.nextInt();
			if(A + B >= 10){
				System.out.println("error");
			}else{
				System.out.println(A + B);
			}
		}
	}
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  ll K, A, B; cin >> K >> A >> B;
  ll T = K + 1;
  if (K < A + 1) {
    cout << K + 1 << endl;
    return 0;
  }
  K -= A + 1;
  ll c = B;
  if (B - A > 2) {
    c += (B - A) * (K / 2) + (K % 2);
  }
  else {
    c += K;
  }
  cout << max(T, c) << endl;
}


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

int main ()
{
  std::string s;
  std::cin >> s;
  int topping = 0;
  int ramen = 700;
  for (int i=0; i < 3; i++)
  {
    if (s[i] == 'o') topping = topping + 100;
  }
  
  std::cout << ramen + topping << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int a,b,c,d,p[4];
   cin>>a>>b>>c>>d;
   p[0]=a*c;
   p[1]=a*d;
   p[2]=b*c;
   p[3]=b*d;
   long long int m,n,ma;
   m=max(p[0],p[1]);
   n=max(p[2],p[3]);
   ma=max(m,n);
   cout<<ma<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"

int32_t main(){
	boost;
	int n;
	cin >> n;
	vector <int > g[n + 1];
	for(int i = 1,u ,v; i < n; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector< int > a(n);
	int tot = 0;
	for(int &i : a){
		cin >> i;
		tot += i;
	}
	sort(a.rbegin(), a.rend());
	tot -= a[0];

	int ans[n+1] = {0};
	int l = 0;
	function < void (int , int) > dfs = [&] (int u, int p) {
		ans[u] = a[l++];
		for(int v:g[u]) {
			if(v == p)
				continue;
			dfs(v, u);
		}
	};

	dfs(1,0);
	cout << tot << endl;
	for(int i = 1; i <= n; i++)
		cout << ans[i] << " ";
}



Measured memory_bytes: 5152
#include<bits/stdc++.h>
#define ll long long
#define N 200005
using namespace std;
struct T{
	long double x,y;
}s[N];
int n;long double a[N],b[N],c[N],q[N],p[N];
long double read(){
	int x=0,fl=1;char c=getchar();
	while(c<'0'||c>'9'){if (c=='-')fl=-1;c=getchar();}
	while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
	return (long double)(x*fl);
}
bool cmp(const T &a,const T &b){
	return a.x==b.x?a.y<b.y:a.x>b.x;
}
ll work(int l,int r){
	if (l>=r)return 0;
	int mid=(l+r)>>1;ll ans=0;
	ans+=work(l,mid);
	ans+=work(mid+1,r);
	int i1=l,i2=mid+1;
	for (int i=l;i<=r;i++){
		if (i1<=mid&&(i2>r||q[i1]<q[i2])) p[i]=q[i1++];
		else p[i]=q[i2++],ans+=mid-i1+1;
	}
	//cout<<l<<' '<<r<<' '<<i1<<' '<<i2<<endl;
	for (int i=l;i<=r;i++)
		q[i]=p[i];
	return ans;
}
ll Getx(long double x){
	for (int i=1;i<=n;i++)
		s[i]=(T){(c[i]-a[i]*x)/b[i],-a[i]/b[i]};
	//s[n+1]=(T){0,0};
	sort(s+1,s+n+1,cmp);
	for (int i=1;i<=n;i++)
		q[i]=s[i].y;
	ll ans=work(1,n);//+(x>=0?n+1:0);
	//cout<<x<<' '<<ans<<endl;
	return ans;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		a[i]=read();b[i]=read();c[i]=read();
	}
	ll sum=(ll)n*(n-1)/2;
	long double l=-1e9,r=1e9,ax,ay,mid;
	while(l+1e-10<r){
		mid=(l+r)/2;
		if (Getx(mid)*2>=sum)r=mid;
		else l=mid;
	}
	printf("%.9f ",(double)l);
	for (int i=1;i<=n;i++)
		swap(a[i],b[i]);
	l=-1e9;r=1e9;
	while(l+1e-10<r){
		mid=(l+r)/2;
		if (Getx(mid)*2>=sum)r=mid;
		else l=mid;
	}
	printf("%.9f\n",(double)l);
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;

int main() {
  int a[3][3];
  for(int i=0;i<9;i++) cin>>a[i/3][i%3];
  int n;
  cin>>n;
  int b[n];
  for(int i=0;i<n;i++) cin>>b[i];
  bool c[3][3];
  for(int i=0;i<9;i++) c[i/3][i%3]=false;
  for(int i=0;i<n;i++){
    for(int j=0;j<9;j++){
      if(b[i]==a[j/3][j%3]) c[j/3][j%3]=true;
    }
  }
  bool ans=false;
  if(c[0][0] && c[1][1] && c[2][2]) ans=true;
  if(c[0][2] && c[1][1] && c[2][0]) ans=true;
  for(int i=0;i<3;i++){
    if(c[i][0] && c[i][1] && c[i][2]) ans=true;
    if(c[0][i] && c[1][i] && c[2][i]) ans=true;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
 
typedef long long ll;
 
using namespace std; 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;
 
#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)

int main() {
    int n; cin >> n;
    vector<ll> h(n+5);
    REP(i,0,n+5) cin >> h[i];

    vector <ll> dp(n+5);
    REP(i,0,n+5) dp[i] = INF;
    dp[0] = 0;

    REP(i,0,n) {
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }

    cout << dp[n-1] << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int a;
    int hw = 0;
    rep(i,m) {
        cin >> a;
        hw += a;
    }
    int ans = n - hw;
    if (ans < 0) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
import sys
alphabet = 'abcdefghijklmnopqrstuvwxyz'
def shift(arg):
    tmp = arg.rstrip()
    while True:
        res = ''
        for c in tmp:
            if c in alphabet:
                if c == 'a': res += 'z'
                else: res  += chr(ord(c)-1)
            else: res += c
        if 'the' in res or 'this' in res or 'that' in res:
            return res
        tmp = res
for trg in sys.stdin:
    print shift(trg)

Measured memory_bytes: 4208
n,m=map(int,input().split())
d={}
A=[0]*n
B=[0]*n
for i in range(n):
    A[i],B[i]=map(int,input().split())
    d[str(i)]=A[i]
a=sorted(d.items(),key=lambda x:x[1])
ans=0
for i in range(n):
    if m>B[int(a[i][0])]:
        m-=B[int(a[i][0])]
        ans+=a[i][1]*B[int(a[i][0])]
    else:
        ans+=a[i][1]*m
        break
print(ans)

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

int main(void) {
    int m, nmin, nmax;
    int p[201];
    while(cin >> m >> nmin >> nmax && m) {
        REP(i, m) cin >> p[i];
        sort(p, p+m, greater<int>());
        int gap = 0;
        int ans = 0;
        for(int i=nmin-1; i<nmax; ++i) {
            if(p[i]-p[i+1] >= gap) {
                gap = p[i]-p[i+1];
                ans = i+1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3048
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
vector<int> parent;
int getparent(int place){
    if(parent[place] == place){
        return place;
    }
    return parent[place] = getparent(parent[place]);
}
int main(){
    int N;
    int M;
    cin >> N >> M;
    parent.resize(N+1);
    REPA(i, N+1){
        parent[i] = i;
    }
    REP(i, M){
        int a, b, c;
        cin >> a >> b >> c;
        int ap = getparent(a);
        int bp = getparent(b);
        if(ap==bp)continue;
        parent[ap] = bp;
    }
    vector<char> used(N+1, false);
    int ans = 0;
    REPA(i, N+1){
        int dp = getparent(i);
        if(used[dp]==false){
            ++ans;
            used[dp] = true;
        }
    }
    cout << ans << endl;
        return 0;
}


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

using namespace std;
int main()
{
    long long x,a,b,c,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int z=0;z<=c;z++){
                int k=i*500+j*100+z*50;
                if(k==x) ans++;
            }
    cout<<ans<<endl;
}

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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  const int MAXP = 1299709+1;
  vector<int> prime(MAXP, 0);
  for(int i=2;i<MAXP;++i)
	if(!prime[i])
	  for(int j=i+i;j<MAXP;j+=i)
		prime[j] = 1;

  int prv;
  for(int i=2;i<MAXP;++i){
	if(!prime[i]) prv = i;
	else{
	  ++prime[prv];
	  prime[i] = -1;
	}
  }
  //  REP(i,50) cout << prime[i] << ",";
  int N;
  while(cin >> N, N){
	if(prime[N] >= 0) cout << 0 << endl;
	else
	  for(int i=N-1;;--i)
		if(prime[i] > 0){
		  cout << prime[i]+1 << endl;
		  break;
		}
  }
  
  return 0;
}

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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

			string[] inputStrArray = Console.ReadLine().Split(' ');

			int a = int.Parse(inputStrArray[0]);
			int b = int.Parse(inputStrArray[1]);
			int c = int.Parse(inputStrArray[2]);
			int d = int.Parse(inputStrArray[3]);

			int ab = Math.Abs(b - a);
			int bc = Math.Abs(c - b);
			int ac = Math.Abs(c - a);

			string result = "";
			
			if (ab <= d && bc <= d) {
				result = "Yes";
			} else if(ac <= d) {
				result = "Yes";
			} else {
				result = "No";
			}

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11092
inputs = input().split(' ')

tmp = inputs[0]
tmp2 = inputs[1]
tmp3 = inputs[2]

inputs[1] = tmp
inputs[0] = tmp2


tmp = inputs[2]
inputs[2] = inputs[0]
inputs[0] = tmp

L=[str(a) for a in inputs]
L=" ".join(L)
print(L)


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

int N;
string s1;
string s2;

constexpr int M = 1000000007;

int main()
{
    cin >> N;
    cin >> s1 >> s2;

    int last_type = 0;
    int i = 0;
    long long count = 1;

    // |
    if (s1[0] == s2[0])
    {
        i = 1;
        count = 3;
        last_type = 0;
        // cout << '|';
    }
    else    // =
    {
        i = 2;
        count = 3*2;
        last_type = 1;
        // cout << '=';
    }

    while (i < N)
    {
        // |
        if (s1[i] == s2[i])
        {
            if (last_type == 0) // ||
            {
                count *= 2;
                count %= M;
            }
            else    // =|
            {
                // count *= 2;
                // count %= M;
            }
            last_type = 0;
            // cout << '|';
            i++;
        }
        else    // =
        {
            if (last_type == 0) // |=
            {
                count *= 2;
                count %= M;
            }
            else    // ==
            {
                count *= 3;
                count %= M;
            }
            last_type = 1;
            // cout << '=';
            i+=2;
        }
    }

    // cout << endl;
    cout << count << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int N, K;
	cin >> N >> K;
	int ans = K;
	REP(i, 1, N) ans*=(K-1);
	
	cout << ans;

}


Measured memory_bytes: 256
#include<stdio.h>



int main()
{
	int x, y, z;
	int tem;
	scanf("%d %d %d", &x, &y, &z);
	tem = x;
	x = y;
	y = tem;

	tem = x;
	x = z;
	z = tem;
	
		printf("%d %d %d", x, y, z);

		return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int i,j;
  int n,m;
  int s[100000];
  int rel1=0;
  int rel2=0;
  int flag=0;
  int ans1=1000,ans2,ans3;
  int w;
  
  while(1){
    rel1=0;
    rel2=0;
    flag=0;
    ans1=1000;
    
    scanf("%d %d",&n,&m);
   
    if(n==0&&m==0) break;
    
    for(i=0;i<n;i++){
      scanf("%d",&s[i]);
      rel1+=s[i];
      
    }
    for(j=n;j<m+n;j++){
      scanf("%d",&s[j]);
      rel2+=s[j];
    }
 
    if(rel1==rel2){
      for(i=0;i<n;i++){
	for(j=n;j<m+n;j++){
	  if(s[i]==s[j]&&flag==0){
	    printf("%d %d\n",s[i],s[j]);
	    flag=1;
	  }
	}
      }
    }else{
      for(i=0;i<n;i++){
	rel1-=s[i];
	for(j=n;j<m+n;j++){
	  rel2-=s[j];
	  rel1+=s[j];
	  rel2+=s[i];
	  if(rel1==rel2){
	    if(ans1>rel1){
	      ans1=rel1;
	      ans2=s[i];
	      ans3=s[j]; 
	    }
	    flag=1;
	  }else{
	    rel2+=s[j];
	    rel2-=s[i];
	    rel1-=s[j];
	  }
	}
	rel1+=s[i];
      }
    }
    if(ans1!=1000) printf("%d %d\n",ans2,ans3);
    if(flag==0) printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 620