akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
  #define pb push_back
#define f first
#define s second
  #define MAXN 100005
using namespace std;
int arr[MAXN];
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int c=0;
	int at=0,bt=0,ct=0;
	int a,b; cin>>a>>b;
	for(int i=0; i<n; i++) {
		cin>>c;
		if(c<=a) at++;
		if(c>a&&c<=b) bt++;
		if(c>b) ct++;
	}
	int ans=min(at,min(bt,ct));
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    string S;
    cin >> S;
    if(S=="ARC")cout << "ABC";else cout << "ARC";
    return 0;
}


Measured memory_bytes: 3624
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;

signed main() {
		int N;
		cin >> N;
		int ans = 0;
		vector<int> city(N + 1);
		vector<int> hero(N);
		for (int i = 0; i < N + 1; i++) cin >> city[i];
		for (int i = 0; i < N; i++) cin >> hero[i];
		for (int i = 0; i < N; i++) {
			if (hero[i] >= (city[i] + city[i + 1])) {
				ans += (city[i] + city[i + 1]);
				city[i + 1] = 0;
				city[i] = 0;
			}
			else if (hero[i] > city[i] && hero[i] < (city[i] + city[i + 1])) {
				ans += hero[i];
				city[i + 1] -= hero[i] - city[i];
				city[i] = 0;

			}
			else {
				ans += hero[i];
				city[i] -= hero[i];
			}
		}
		cout << ans << endl;
}	


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main(void)
{
	int x=0,y=0,work=0,answer=1,first=1;
	cin>>x;
	cin>>y;
	if(x<=y){
		work=x;
		x=y;
		y=work;
	}
	while(1){
		first=x%y;
		if(first==0){
			answer=y;
			break;
		}
		x=y;
		y=first;		
	}
	cout<<answer<<endl;
	return (0);
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
const int N=1e5+5;
bool f[N];
int a[10];
int main()
{
	ri n=read();
	a[1]=100;rep(i,2,6)a[i]=a[i-1]+1;
	f[0]=1;
	rep(i,1,6){
		rep(j,0,n-a[i]){
			if(f[j])f[j+a[i]]=1;
		}
	}
	printf("%d\n",f[n]);
	return 0; 
}

Measured memory_bytes: 384
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r * g * b
for i in range(n - 2):
    for j in range(i + 2, n, 2):
        if s[i] != s[(i + j) >> 1] != s[j] != s[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 9104
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None]*n
for i in range(n):
    a[i] = list(map(int, input().split()))

dp = [None]*pow(2,n)
val = [None]*pow(2,n)
for b in range(pow(2,n)):
    v = 0
    for i in range(n):
        for j in range(i,n):
            if b&1<<i and b&1<<j:
                v += a[i][j]
    val[b] = v
            
def sub(b):
    if dp[b] is not None:
        return dp[b]
    ans = 0
    sb = b
#     print(b)
    while True:
        sb = (sb-1) & b
        if sb==b:
            break
        ans = max(sub(sb) + val[b-sb], ans)
    dp[b] = ans
    return ans
    
print(sub(pow(2,n)-1))

Measured memory_bytes: 76816
#include "bits/stdc++.h"
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007

template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}

int32_t main()
{
    fastio
    int n;
    cin>>n;
    int arr[n];
    fora(i,n) cin>>arr[i];
    int ans[n];
    int net=0;
    for(int i=0;i<n;i++) {
    	
    	net^=arr[i];

    }
    fora(i,n) cout<<(net^arr[i])<<" ";
    // reverse(ans,ans+n);
    // swap(ans[0],ans[1]);
    // forb(i,1,n) cout<<ans[i]<<" ";
    // cout<<ans[0];
    // for(auto it:ans) cout<<it<<" ";


    return 0;


}

Measured memory_bytes: 5192
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
 
public class Main {
 
	public static void main(String[] args) {
 
		FastScanner fs = new FastScanner();
		String s = fs.next();
 
		s = s.substring(0,3);
 
		//Output
		PrintWriter out = new PrintWriter(System.out);
		out.println(s);
		out.flush();
 
	}
 
}
 
//Input
class FastScanner{
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
 
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
 
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
 
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
 
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using namespace std;

int n,ans;
int r;
struct P
{
    int x,y;
    int z;
    bool operator<(const P &a)const
    {
        if(x!=a.x) return x<a.x;
        else return y<a.y;
    }
} p[20],Ge[20],nn[20];

vector<P> G[20];
int vis[20];

void DFS(int pre,int id,int num)
{
    vis[id]=1;
    if(num==n/2)
    {
        for(int i=0; i<r; i++)
            nn[i]=Ge[i];
        sort(nn,nn+r);
        int X=nn[0].x;
        int Y=nn[0].y;
        int sum=1;
        int temp=0;
        for(int i=1; i<r; i++)
        {
            if(nn[i].x!=X || nn[i].y!=Y)
            {
                X=nn[i].x;
                Y=nn[i].y;
                temp+=(sum*(sum-1)/2);
                sum=1;
            }
            else sum++;
        }
        temp+=(sum*(sum-1)/2);
        ans=max(ans,temp);
        return ;
    }
    for(int i=pre+1; i<=n; i++)
    {
        if(!vis[i])
        {
            vis[i]=1;
            for(int j=0; j<G[i].size(); j++)
            {
                int u=G[i][j].z;
                if(!vis[u])
                {
                    Ge[r]=G[i][j];
                    r++;
                    DFS(i,u,num+1);
                    vis[u]=0;
                    r--;
                }
            }
            vis[i]=0;
            break ;
        }
    }
}

int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<=n;i++) G[i].clear();
        memset(vis,0,sizeof(vis));
        r=ans=0;
        for(int i=1; i<=n; i++)
            scanf("%d%d",&p[i].x,&p[i].y);
        for(int i=1; i<=n; i++)
        {
            for(int j=i+1; j<=n; j++)
            {
                P node;
                node.x=p[i].x-p[j].x;
                node.y=p[i].y-p[j].y;
                if(node.x<0 && node.y<0)
                {
                    node.x=-node.x;
                    node.y=-node.y;

                }
                else if(node.x*node.y<0 || (node.x<0 && node.y==0) || (node.x==0 && node.y<0))
                {
                    node.x=abs(node.x);
                    node.y=abs(node.y);
                    node.x*=-1;
                }
                if(node.x==0) node.y=1;
                else if(node.x!=0 && node.y!=0)
                {
                    int c=__gcd(abs(node.x),abs(node.y));
                    node.x/=c;
                    node.y/=c;
                }
                else if(node.y==0) node.x=1;
                node.z=j;
                G[i].push_back(node);
            }
        }
        vis[1]=1;
        for(int i=0; i<G[1].size(); i++)
        {
            Ge[r]=G[1][i];
            r++;
            int u=G[1][i].z;
            DFS(1,u,1);
            vis[u]=0;
            r--;
        }
        printf("%d\n",ans);
    }
    return 0;
}



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

int N;
vector<int> a;

struct op {
  int x, y;
};

int main () {
  cin >> N;
  a.resize(N);
  rep(i,N) cin >> a[i];

  vector<op> ans;

  int iMax = distance(a.begin(), max_element(all(a)));
  int iMin = distance(a.begin(), min_element(all(a)));

  bool right = (iMin >= 0);
  if(abs(a[iMax]) > abs(a[iMin])) {
    rep(i,N) if(a[i] < 0) {
      ans.push_back(op{iMax, i});
    }
    right = true;
  } else {
    rep(i,N) if(a[i] > 0) {
      ans.push_back(op{iMin, i});
    }
    right = false;
  }

  rep(i,N-1) {
    if(right) {
      ans.push_back(op{i, i+1});
    } else {
      ans.push_back(op{N-1-i, N-2-i});
    }
  }

  cout << ans.size() << endl;
  for(auto &e: ans) {
    cout << (e.x+1) << " " << (e.y+1) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  string s;
  cin >> s;
  if(s == "ABC") {
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N;
	cin >> N;
	vector<ll> H(N);
	rep(i, N) cin >> H[i];

	H[0]--;
	for(ll i = 1; i < N; i++) {
		if(H[i-1] < H[i]) {
			H[i]--;
		} else if (H[i-1] > H[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

}

Measured memory_bytes: 3972
#include <iostream>

using namespace std;

typedef long long ll;

int main(){

	ll a,b;
	while(1){
		cin >> a >> b;
		if(cin.eof()){
			break;
		}
		ll sum = a + b;
		int cnt = 1;
		while(sum / 10){
			sum/=10;
			cnt++;
		}
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	//#define LOCAL_INPUT_FILE
#else
	//#define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	int64_t s; cin >> s;
	int64_t q = sqrt(s);
	while (q*q < s) {
		++q;
	}
	int64_t rem = q*q - s;
	int add = 0;
	if (rem > q) {
		rem -= q;
		add = 1;
	}
	assert(rem <= int(1e9));
	cout << 0 << " " << 0 << " " << q << " " << rem << " " << 1 << " " <<  q - add << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <char> v;
vector<int> num;
string s ;
int table[100001][3];
int main(){
  int X;
  int ans = 1;
  cin >>X;
  for (int i = 2;i <= X;i++){
    int v = i*i;
    while(v <= X){
      ans = max(ans ,v);
      v *= i;
    }
  }
  cout << ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
renga=list(map(int,input().split()))

ans=-1
inf=0
for i in range(1,n+1):
    flag=0
    for j in range(inf,n):
        if renga[j]==i:
            ans=i
            inf=j+1
            flag=1
            break
    if flag==0:
        break

if ans!=-1:
    ans=n-ans

print(ans)


Measured memory_bytes: 26268
import numpy as np
N,K = map(int,input().split())
H = np.array(list(map(int,input().split())))
 
dp = np.zeros(N, dtype=int)
for i in range(1,N):
    start = max(i-K,0)
    dp[i] = np.min(dp[start:i] + np.abs(H[i] - H[start:i]))
print(dp[-1])

Measured memory_bytes: 22836
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::max;
 
int LCS(char* s1, char* s2,char *res)
{
    int i,j,M,N,k=0,upbd;
    M=strlen(s1);
    N=strlen(s2);
    int **dp;
    dp=new int* [M+2];
    for(i=0;i<M+2;i++)
        dp[i]=new int [N+2];
    for(i=0;i<N+2;i++)
        dp[0][i]=0;
    
    for(i=1;i<M+1;i++)
    {
        dp[i][0]=0;
        for(j=1;j<N+1;j++)
        {
            if(s1[i-1]==s2[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    k=dp[M][N];
 
    i=M;
    j=N;
    upbd=k;
    res[k]='\0';
    while(i>0 && j>0)
    {
        if(dp[i-1][j]==dp[i-1][j-1] && dp[i-1][j-1]==dp[i][j-1] )
        {
            if (dp[i][j]==dp[i-1][j-1]+1)
                res[--upbd]=s1[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]==dp[i][j])
                i--;
            else
                j--;
        }
    }
    for(i=0;i<M+2;i++)
        delete [] dp[i];
    delete [] dp;
 
    return k;
}
 
 
#define MAXLENGTH 3003
int main(void)
{
    char s[MAXLENGTH],t[MAXLENGTH],r[MAXLENGTH];
    scanf("%s%s",s,t);
    LCS(s,t,r);
    printf("%s\n",r);
    return 0;
}

Measured memory_bytes: 35456
#--約数のリスト--#

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            upper_divisors.append(n//i)
        i += 1
    return lower_divisors,upper_divisors

#--処理の開始--#
N = int(input())
l,u = make_divisors(N)
ans = 0
for ln,un in zip(l,u):
    if un-1>ln:
        ans += un-1
print(ans)
    



Measured memory_bytes: 9076
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int N;
  cin >> N;
  rep(i, 1, INF) {
    if (i * i > N) {
      cout << (i - 1) * (i - 1) << endl;
      return;
    }
  }
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long mx(long long a,long long b){if(a>b)return a;else return b;}
long long mn(long long a,long long b){if(a<b)return a;else return b;}
long long cei(long long a,long long b){if(a%b==0)return a/b;else return (a/b+1);}
const int MOD=1e9+7;
long long po(long long a,long long b){long long res=1;while(b>0){res=(res*a);res%=MOD;b--;}return res;}


int main()
{
string s;
cin>>s;
int count=0;
int ans=0;
for(int i=0;i<3;i++){
if(s[i]=='R'){count++;
ans=max(ans,count);}
else
count=0;}

cout<<ans<<endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b,c,d; cin>>a>>b>>c>>d;
    ll low=max(a,c),up=min(b,d);
    cout<<max((ll)0,up-low)<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=20;
const int MAXID=41943041;

int n,want;

char s[MAXN+1][(1<<MAXN)+1];

int nid;
vector<vector<int> > id[MAXN+1][MAXN+1]; // id[alen][blen][amask][bmask]
int cnt[MAXID];

int nxt0[MAXN+1][1<<MAXN];
int nxt1[MAXN+1][1<<MAXN];

void upd(int alen,int blen,int amask,int bmask,int nalen,int nblen,int namask,int nbmask) {
	int cid=id[alen][blen][amask][bmask],nid=id[nalen][nblen][namask][nbmask];
	cnt[nid]+=cnt[cid];
	//for(int k=alen-1;k>=0;--k) printf("%d",(amask>>k)&1); printf("|"); for(int k=blen-1;k>=0;--k) printf("%d",(bmask>>k)&1); printf(" -> ");
	//for(int k=nalen-1;k>=0;--k) printf("%d",(namask>>k)&1); printf("|"); for(int k=nblen-1;k>=0;--k) printf("%d",(nbmask>>k)&1); printf("\n");
}

void run() {
	scanf("%d%d",&n,&want); REPE(i,n) scanf("%s",s[i]);
	//n=MAXN; want=12797; REPE(i,n) REP(j,1<<i) { int nbit=0; REP(k,i) if(j&(1<<k)) ++nbit; s[i][j]='0'+(rand()%(nbit+1)!=0?1:0); }

	nid=0; 
	REPE(alen,n) REPE(blen,n-alen) {
		id[alen][blen]=vector<vector<int> >(1<<alen,vector<int>(1<<blen));
		REPSZ(amask,id[alen][blen]) REPSZ(bmask,id[alen][blen][amask]) id[alen][blen][amask][bmask]=nid++;
	}

	memset(cnt,0,sizeof(cnt));
	REPE(i,n) REP(j,1<<i) if(s[i][j]=='1') ++cnt[id[0][i][0][j]];

	REPE(len,n) REP(mask,1<<len) { nxt0[len][mask]=nxt1[len][mask]=-1; for(int i=len-1;i>=0;--i) { int z=(mask>>i)&1; if(z==0&&nxt0[len][mask]==-1) nxt0[len][mask]=i; if(z==1&&nxt1[len][mask]==-1) nxt1[len][mask]=i; } }

	REPE(alen,n) REPE(blen,n-alen) REPSZ(amask,id[alen][blen]) REPSZ(bmask,id[alen][blen][amask]) {
		if(blen!=0) upd(alen,blen,amask,bmask,alen,0,amask,0);
		int idx0=nxt0[blen][bmask],idx1=nxt1[blen][bmask];
		if(idx0!=-1) upd(alen,blen,amask,bmask,alen+1,idx0,2*amask+0,bmask&((1<<idx0)-1));
		if(idx1!=-1) upd(alen,blen,amask,bmask,alen+1,idx1,2*amask+1,bmask&((1<<idx1)-1));
	}


	for(int i=n;i>=0;--i) REP(j,1<<i) if(cnt[id[i][0][j][0]]>=want) {
		for(int k=i-1;k>=0;--k) printf("%d",(j>>k)&1); puts(""); return;
	}
	assert(false);
}

int main() {
	run();
	return 0;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

ll dp[81][10101];

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll bestAns = 1000;
    for (int i = 1; i < N; ++i) {
        if (A[i-1] < A[i]) {
            ll tmp = bestAns / A[i-1];
            ll less = bestAns - A[i-1] * tmp;
            ll now = less + A[i] * tmp;
            bestAns = now;
        }
    }
    cout << bestAns << endl;
}


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

T = [T[0]] + T + [T[-1]]
A = [A[0]] + A + [A[-1]]

ans = 1
mod = 10**9 + 7
for i in range(1, N+1):
    if T[i-1] < T[i] and A[i + 1] < A[i]:
        if T[i] != A[i]:
            ans *= 0
        continue

    if T[i-1] < T[i]:
        if A[i] < T[i]:
            ans *= 0
        continue

    if A[i] > A[i+1]:
        if T[i] < A[i]:
            ans *= 0
        continue

    if i == 1 or i == N:
        if T[N] != A[1]:
            ans *= 0
        else:
            ans *= 1
        continue

    ans = (ans * min(T[i], A[i])) % mod

print(ans % mod)


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

int main() {
 int X,a,b;
 cin >>X>>a>>b;

 if (b-a<X+1&&b-a<=0){
    cout<<"delicious"<<endl;
 }
 else if(b-a<X+1&&b-a>0){
    cout<<"safe"<<endl;
 }
 else{cout<<"dangerous"<<endl;}
}

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

int integar(int n);

int main(){
    int n;
    while(cin >> n){
        cout << integar(n) << endl;
    }
}

int integar(int n){
    int sum=0;
    int i,j,k,l;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            for(k=0;k<10;k++){
                for(l=0;l<10;l++){
                    if(i+j+k+l==n)
                        sum++;
                }
            }
        }
    }
    return sum;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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 (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
    SS(string,s);
    bool ans = regex_match(s, regex("A?KIHA?BA?RA?"));
    YES(ans);
}

Measured memory_bytes: 256
S = input()
m = 2019
dp = [0]*m
dp[0] = 1

acc, d = 0,1

for s in S[::-1]:
    acc = (acc + d*int(s)) % m
    dp[acc] += 1
    d = (d*10) % m

print(str(sum([n*(n-1)//2 for n in dp])))

Measured memory_bytes: 68664
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(char a, char b) {
	return a > b;
}

int kuraiwa(int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (b < 10) {
		b += a * 10;
	}
	else if (b < 100) {
		b += a * 100;
	}
	else {
		b += a * 1000;
	}
	int x = pow(b, (double)0.5);
	if (x*x == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fori(i,a,n) for(i=a;i<=n;i++)
#define ford(i,n,a) for(i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
ll a,b,c,ans;
int main()
{
	cin>>a>>b>>c;
	if (a==b) ans++;
	if (a==c) ans++;
	if (b==c) ans++;
	if (ans==1) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

class Main{
        public static void main(String args[]){
                Scanner scanner = new Scanner(System.in);
                int N = scanner.nextInt();

                String sugar = "a";

                for(int i=0;i<N;i++){
                        sugar = scanner.next();
                        if(sugar.equals("Y")){
                                System.out.println("Four");
                                break;
                        }
                        //System.out.println(i+"/"+N+"  "+sugar);
                }
                if(!(sugar.equals("Y")))System.out.println("Three");
        }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n;cin >> n;
    vl a(n),b(n),d(n);rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n){
        d[i]=a[i]-b[i];
    }
    if(accumulate(all(d),0LL)<0)cout << -1 <<endl,exit(0);
    sort(all(d));
    ll res=0;
    ll lack=0;
    rep(i,n){
        if(d[i]<0){
            lack+=d[i];
            res++;
        }
    }
    per(i,n){
        if(lack>=0)break;
        lack+=d[i];
        res++;
    }
    cout << res <<endl;
}

Measured memory_bytes: 5796
#include <cstdio>

using namespace std;

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

typedef long long ll;

const int N_MAX = 200000;

int N;
int A[N_MAX];

void solve() {
  if (A[0] > 0) {
    puts("-1");
    return;
  }
  ll ans = 0;
  FOR(i, 1, N - 1) {
    int d = A[i] - A[i - 1];
    if (d > 1) {
      puts("-1");
      return;
    } else if (d == 1) {
      ans += 1;
    } else if (d == 0) {
      ans += A[i];
    } else {
      ans += A[i];
    }
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 896
N = int(input())
w = []
w1 = ""
flag = 0
for i in range(N):
  s = input()
  if i == 0:
    w1 = s
    w.append(w1)
  else:
    if s[0] == w[i-1][-1] and s not in w:
      w1 = s
      w.append(w1)
    else:
      flag += 1
      break
print("No") if flag == 1 else print("Yes")

Measured memory_bytes: 9112
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  double ans = 0;
  double a;
  char s[4];
  for (int i = 0; i < n; ++i)
  {
    scanf("%lf %s", &a, s);
    ans += (*s == 'J' ? a : a * 380000);
  }
  printf("%.8f\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<string.h>


using namespace std;
void insertionsort(int a[],int b);




int main()
{
	int a[101];
	
	for(int i=0;i<3;i++)
		cin>>a[i];
	insertionsort(a,3);
	
	




	
	
	


	
	
	
	



}
void insertionsort(int a[],int b)
{
	for(int i=0;i<b;i++)
		{
			int v=a[i];
		int j=i-1;
			while(j>=0&&a[j]>v)
				{
					a[j+1]=a[j];
					j--;
			}

						a[j+1]=v;
	}

					for(int k=0;k<3;k++)
							{
								cout<<a[k];
					if(k!=2)
						cout<<" ";
					else
						cout<<endl;
					




			
			
	}
	






}

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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265

int main( void ) {
    int a, b;
    while( 1 ) {
        cin >> a >> b;
        rep( i, a ) {
            rep( i, b )cout << '#';
            cout << endl;
        }
        if( a == 0 ) break;
        cout << endl;
    }
}



Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  x--;
  y--;
  g[x].push_back(y);
  g[y].push_back(x);
  vector<vector<int>> dist(n, vector<int>(n, -1));
  for (int st = 0; st < n; st++) {
    vector<int> que;
    dist[st][st] = 0;
    que.push_back(st);
    for (int i = 0; i < (int) que.size(); i++) {
      for (int nbr : g[que[i]]) {
        if (dist[st][nbr] == -1) {
          dist[st][nbr] = dist[st][que[i]] + 1;
          que.push_back(nbr);
        }
      }
    }
  }
  vector<int> ans(n);
  for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ans[dist[i][j]]++;
  for (int i = 1; i < n; i++) {
    cout << ans[i] / 2 << '\n';
  }
  return 0;
}

Measured memory_bytes: 16128
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=input()
    T=input()
    YesNo(S==T[:-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 61688
fn main() {
    proconio::input! {
        s: proconio::marker::Chars,
    }
    let mut v = vec![false; s.len()];
    for w in s.windows(2) {
        v.push(w[0] != w[1]);
    }
    let count = v.iter().filter(|x| **x).count();
    println!("{}", count);
}


Measured memory_bytes: 2704
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    cout<<v[n/2]-v[n/2-1];
    return 0;
}



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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	ll n , k ;
	cin >> n >> k ;
	vector<int> hp(n);
	rep(i,n) cin >> hp[i];
	SORT(hp);
	rSORT(hp);
	ll ans = 0 ;
	for(int i =  k  ; i < n ; i ++){
		ans += hp[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 1010
using namespace std;
ll h,w,dp[N][N];
char grid[N][N];
int main(){
	ll i,j;
	cin>>h>>w;
	memset(dp,0,sizeof(dp));
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			cin>>grid[i][j];
		}
	}
	dp[1][1]=1;
	grid[1][1]='#';
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			if(grid[i][j]=='.')
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
			}
		}
	}
	cout<<dp[h][w]<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

class UnionFind {
public:
	vector<int> Parent;

	UnionFind(int N){
		Parent=vector<int>(N, -1);
	}

	int root(int A){
		if(Parent[A]<0) return A;
		return Parent[A]=root(Parent[A]);
	}

	int size(int A){
		return -Parent[root(A)];
	}

	bool connect(int A, int B){
		A=root(A);
		B=root(B);
		if(A==B){
			return false;
		}
		if(size(A)<size(B)) swap(A, B);
		Parent[A]+=Parent[B];
		Parent[B]=A;
		return true;
	}
};

int main(){

	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for(int i=0; i<M; i++){
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
	vector<long long> ans(M);
	ans[M-1]=(long long)N*(N-1)/2;
	UnionFind Uni(N);
	for(int i=M-1; i>=1; i--){
		ans[i-1]=ans[i];
		if(Uni.root(A[i])!=Uni.root(B[i])){
			ans[i-1]-=(long long)Uni.size(A[i])*Uni.size(B[i]);
			Uni.connect(A[i], B[i]);
		}
	}
	for(int i=0; i<M; i++){
		cout << ans[i] << endl;
	}

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int w, a, b; cin >> w >> a >> b;
    if(a < b) cout << max(0, b - a - w) << endl;
    else cout << max(0, a - b - w) << endl;
}


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

int main(){
	int a, b; cin >> a >> b;
	
	if(a + b == 15) cout << '+' << endl;
	else if(a * b == 15) cout << '*' << endl;
	else cout << 'x' << endl;
	return 0;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int main(){
    string s;
    int k;
    int n;
    cin >> n >> k >> s;
    s[k - 1] = s[k - 1] - 'A' + 'a';
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll h, w;
    cin >> h >> w;
    ll ans = INF;
    if(h >= 3){
        if(h%3 == 0){
            chmin(ans, 0ll);
        }else{
            chmin(ans, w);
        }
    }
    if(w >= 3){
        if(w%3 == 0){
            chmin(ans, 0ll);
        }else{
            chmin(ans, h);
        }
    }
    repr(i, 1, h){
        ll x = (w/2)*i;
        ll y = (w-w/2)*i;
        ll z = w*(h-i);
        chmin(ans, max({x, y, z})-min({x, y, z}));
    }
    repr(i, 1, w){
        ll x = (h/2)*i;
        ll y = (h-h/2)*i;
        ll z = h*(w-i);
        chmin(ans, max({x, y, z})-min({x, y, z}));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
  ($line:expr, $name:ident, $t:tt) => {
    let $name = value!($line, $t);
  };
}

macro_rules! values_def {
  ($lines:expr, $n:expr, $name:ident, $t:tt) => {
    let $name = {
      let mut vec = Vec::new();
      for i in 0..$n {
        let mut next = $lines.next().unwrap().split_whitespace();
        vec.push(value!(next, $t));
      }
      vec
    };
  };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
  let mut input = String::new();
  io::stdin().read_to_string(&mut input).unwrap();
  let output = solve(input.trim().to_string());
  println!("{}", output);
}

fn solve(input: String) -> String {
  input!(input=>(n:i64 m:usize)(list:[i64]));
  std::cmp::max(-1, n - list.into_iter().sum::<i64>()).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}
tests! {
  test1: "41 2\n5 6\n" => "30\n",
  test2: "10 2\n5 6\n" => "-1\n",
  test3: "11 2\n5 6\n" => "0\n",
  test4: "314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n" => "9\n",
}


Measured memory_bytes: 2352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ans;
  cin>>n;
  ans=n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=1; i<n; i++){
    if(vec.at(i)==vec.at(i-1)){
      ans--;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <unordered_map>

using namespace std;

namespace {

typedef int (*Op)(int, int);

class Stack {
 public:
  Stack() : size_(100), ptr_(0) {
    s_ = new int[size_];
  }

  ~Stack() {
    delete[] s_;
  }

  bool Empty() const {
    return ptr_ == 0;
  }

  bool IsFull() const {
    return ptr_ >= size_;
  }

  pair<int, bool> Pop() {
    if (Empty()) {
      return make_pair(0, false);
    }
    const int r = s_[--ptr_];
    return make_pair(r, true);
  }

  bool Push(int n) {
    if (IsFull()) {
      return false;
    }

    s_[ptr_] = n;
    ptr_++;
    return true;
  }

 private:
  int size_;
  int ptr_;
  int* s_;
};

void Parse(const unordered_map<char, Op>& m,
           Stack* stack, const string& s) {
  if (s.size() == 0) {
    return;
  }
  const auto it = m.find(s[0]);
  if (it == m.end()) {
    stack->Push(atoi(s.c_str()));
    return;
  }

  const pair<int, bool> a = stack->Pop();
  if (!a.second) {
    return;
  }
  const pair<int, bool> b = stack->Pop();
  if (!b.second) {
    return;
  }
  stack->Push(it->second(b.first, a.first));
}
} // namespace

int main() {
  string line;
  getline(cin, line);
  Stack stack;

  unordered_map<char, Op> ops = {
    {'+', [](int a, int b) { return a + b; }},
    {'-', [](int a, int b) { return a - b; }},
    {'*', [](int a, int b) { return a * b; }},
  };

  size_t begin = 0;
  for (;;) {
    const size_t end = line.find_first_of(" ", begin);
    if (end == string::npos) {
      Parse(ops, &stack, line.substr(begin));
      break;
    }
    Parse(ops, &stack, line.substr(begin, end-begin));
    begin = end + 1;
  }
  cout << stack.Pop().first << endl;
  return 0;
}

Measured memory_bytes: 1204
# 解説

s = input()
k = int(input())

st = set()
for start in range(len(s)):
    for len_ in range(1, k + 1):
        st.add(s[start:start + len_])
*a, = sorted(st)
print(a[k - 1])

# 高々k文字
# kが小さいので
# 全列挙してソート


Measured memory_bytes: 4592
// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
//#include <bits/stdc++.h>

using namespace std;
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {

	int N;
	string S;
	cin >> N >> S;
	char c = S[0];
	int val;
	if (c == 'W') {
		val= N - count(S.begin(), S.end(), c);
	}
	else {
		val = count(S.begin(), S.end(), c)-1;
	}
		int ret = val;
	for (int i = 1; i < N; i++) {
		if (S[i - 1] == S[i]) {
			if (S[i] == 'W') {
				val += 1;
			}
			else {
				val -= 1;
			}
		}
		ret = min(ret, val);
	}
	cout << ret;
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  int a[3], k;
  cin >> a[0] >> a[1] >> a[2] >> k;
  sort(a, a+3);
  cout << a[2] * pow(2, k) + a[0] + a[1] <<endl;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int x = s.size();
  int y = t.size();
  vector<char> a(x), b(y);
  for (int i = 0; i < x; i++) {
    a.at(i) = s.at(i);
  }
  
  for (int i = 0; i < y; i++) {
    b.at(i) = t.at(i);
  }
  
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  
  if (x > y) {
    for (int i = 0; i < y; i++) {
      if (a.at(i) < b.at(i)) {
        cout << "Yes" << endl;
        break;
      }
      if (a.at(i) > b.at(i)) {
        cout << "No" << endl;
        break;
      }
      if (a.at(i) == b.at(i)) {
        if (i == y-1) {
          cout << "No" << endl;
        }
      }
    }
  }
  else {
    for (int i = 0; i < x; i++) {
      if (a.at(i) < b.at(i)) {
        cout << "Yes" << endl;
        break;
      }
      if (a.at(i) > b.at(i)) { 
        cout << "No" << endl;
        break;
      }
      if (a.at(i) == b.at(i)) {
        if (i == x-1) {
          if (x == y) {
            cout << "No" << endl;
          }
          if (x != y) {
            cout << "Yes" << endl;
          }
        }
      }
    }
  }
}

Measured memory_bytes: 3688
#include <stdio.h>

int main()
{
  char c[3][4];
  int i;
  for(i = 0;i < 3;i++){
    scanf("%s",c[i]);
  }

  printf("%c%c%c\n",c[0][0],c[1][1],c[2][2]);
  return(0);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int n,c[5][5],m,i,j,k;
int main()
{
	
	for(i=1;i<=3;i++)
	for(j=1;j<=3;j++)
	cin>>c[i][j];
	for(i=0;i<=100;i++)
	 for(j=0;j<=100;j++)
	  for(k=0;k<=100;k++)
	  {
	  	if(c[1][1]-i==c[2][1]-j&&c[1][1]-i==c[3][1]-k)
	  	  	if(c[1][2]-i==c[2][2]-j&&c[1][2]-i==c[3][2]-k)
	  	  		if(c[1][3]-i==c[2][3]-j&&c[1][3]-i==c[3][3]-k)
			{cout<<"Yes";return 0; 
			}
	   } 
	   cout<<"No";
 } 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char map[114][514];
int h, w;
void dfs(int i, int j, char c) {
	map[i][j] = '.';
	if (i > 1 && map[i - 1][j] == c)dfs(i - 1, j, c);
	if (i < h && map[i + 1][j] == c)dfs(i + 1, j, c);
	if (j > 1 && map[i][j - 1] == c)dfs(i, j - 1, c);
	if (j < w && map[i][j + 1] == c)dfs(i, j + 1, c);
}
int main() {
	while (cin >> h >> w) {
		if (!h && !w)return 0;
		int sum = 0;
		for (int i = 1; i <= h; i++)for (int j = 1; j <= w; j++)cin >> map[i][j];
		for (int i = 1; i <= h; i++)for (int j = 1; j <= w; j++) {
			if (map[i][j] != '.') {
				dfs(i, j, map[i][j]);
				sum++;
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3496
(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    let lines = input.split(/\n/);
    const n = lines.shift();
    const points = lines.slice(0, n).map(line => line.split(/\s/).map(v => +v));

    let min = Infinity;
    let max = -Infinity;
    let min_ = Infinity;
    let max_ = -Infinity;
    for (const point of points) {
        min = Math.min(point[0] + point[1], min);
        max = Math.max(point[0] + point[1], max);
        min_ = Math.min(point[0] - point[1] , min_);
        max_ = Math.max(point[0] - point[1] , max_);
    }
    console.log(Math.max(max - min, max_ - min_));
})();


Measured memory_bytes: 98684