akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a, b, ans;
    cin >> a >> b;
    if(a < 10 && b < 10) ans = a * b;
    else ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <map>
#include <cassert>
#include <sstream>
#include <string>

template<typename Type>
struct Matrix {
private:
    int R, C;
public:
    std::vector< std::vector<Type> > mat;
    Matrix (int R_, int C_, bool is_identity=false) {
        R = R_, C = C_;
        mat = std::vector< std::vector<Type> >(R, std::vector<Type>(C));
        if(is_identity) {
            assert(R == C);
            for(int i=0; i<R; i++) {
                mat[i][i] = 1;
            }
        }
    }
    int get_row() const {
        return mat.size();
    }
    int get_col() const {
        assert(mat.size() > 0);
        return mat[0].size();
    }
    std::vector<Type>& operator[](int x) {
        return mat[x];
    }
    Matrix& operator=(const Matrix &a) {
        mat = a.mat;
        return *this;
    }
    Matrix operator*(Matrix a) {
        assert(this->get_col() == a.get_row());
        int R = this->get_row(), C = a.get_col(), X = this->get_col();
        Matrix<Type> ret(R, C);

        for(int i=0; i<R; i++) {
            for(int j=0; j<C; j++) {
                for(int k=0; k<X; k++) {
                    ret[i][j] += ((*this)[i][k] * a[k][j]);
                }
            }
        }
        return ret;
    }
    Matrix pow(Matrix a, long long int k) {
        assert(a.get_row() == a.get_col());
        Matrix<Type> ret(a.get_row(), a.get_col(), true);
        for(; k>0; k>>=1) {
            if(k & 1) ret = ret * a;
            a = a * a;
        }
        return ret;
    }
};

int main() {
    int N, M, L; std::cin >> N >> M >> L;
    Matrix<long long> A(N, M), B(M, L);

    for(int i=0; i<N; i++) {
        for(int j=0; j<M; j++) {
            std::cin >> A[i][j];
        }
    }

    for(int i=0; i<M; i++) {
        for(int j=0; j<L; j++) {
            std::cin >> B[i][j];
        }
    }

    Matrix<long long> C = A * B;
    for(int i=0; i<N; i++) {
        for(int j=0; j<L; j++) {
            std::cout << C[i][j] << " \n"[j+1==L];
        }
    }
    return 0;
}



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

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

  rep(i,h) {
    rep(j,w) {
      cout<<(i<b==j<a?"1":"0");
    }
    cout<<endl;
  }
}


Measured memory_bytes: 1280
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std; 
int main(int argc,char const* argv[])
{
  string a;
  string b;
  cin >> a;
  cin >> b;
  if(a>b)
    {
      cout << ">" << endl;
    }
  else if(b>a)
    {
      cout << "<" << endl;
    }
 else
    {
      cout << "=" << endl;
    }
  return 0;
}


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

using namespace std;
string S;
int cnt[3];

int main(void)
{
	cin >> S;
	for(int i = 0; i < S.size(); i++){
		cnt[S[i] - 'a']++;
	}
	
	int M = max(max(cnt[0], cnt[1]), cnt[2]);
	int m = min(min(cnt[0], cnt[1]), cnt[2]);
	
	if(M - m <= 1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
S = int(input())

if S == 10**18:
  x1,y1 = 0,0
  x2 = 10**9
  y3 = 10**9
  x3 = 0
  y2 = 0

else:
  x1, y1 = 0,0

#|x2y3-x3y2|=S

  x2 = 10**9
  y2 = 1

#|10**9y3-x3|= s

  y3 = (S//(10**9)) + 1
  x3 = (10**9)*y3 - S

print(int(x1),int(y1),int(x2),int(y2),int(x3),int(y3))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, x, y;
  cin >> n >> d;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (x * x + y * y <= d * d) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3644
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int ak = sc.nextInt();
		int mi = sc.nextInt();
		int ao = sc.nextInt();
		int k = sc.nextInt();

		for(int i=0;i<k;i++){
			if(ao <= mi || ao <= ak){
				ao *= 2;
			} else if(mi <= ak){
				mi *= 2;
			}
		}
		if(mi>ak && ao>ak && ao>mi){
			System.out.println("Yes");
		} else System.out.println("No");
		}
	}

Measured memory_bytes: 35812
let calc s k =
  if k = 0 then
    Array.fold_left (fun (v, w) (_, x) -> if x = '1' then max v (w+1), w+1 else v, 1) (0, 0) s |> fst else
  let t = Array.make 101010 0 in
  let ans, _, _, _, _ =
    Array.fold_left (fun (ans, cur, cs, ti, p) (i, x) ->
      match p, x with
      | '1', '1' -> (max ans (cur+1), cur+1, cs+1, ti, '1')
      | '0', '0' -> (max ans (cur+1), cur+1, cs+1, ti, '0')
      | '0', '1' -> begin
        t.(ti) <- cs;
        (max ans (cur+1), cur+1, 1, ti+1, '1')
      end
      | _ (* 1, 0 *) -> begin
        if ti < k then
          (max ans (cur+1), cur+1, cs+1, ti, '0')
        else
          (max ans (cur+1-t.(ti-k)), cur+1-t.(ti-k), cs+1, ti, '0')
      end) (0,0,0,0,'1') s
  in
  ans
let () =
  Scanf.scanf "%d %d %s" @@ fun n k s ->
  let s = Array.init n (fun i -> i, s.[i]) in
  max (calc s k) (calc (Array.map (fun (i, x) -> i, (if x = '0' then '1' else '0')) s) (k-1))
  |> Printf.printf "%d\n"


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int T; cin>>T;
    for(int problem=0;problem<T;problem++){
        int N; cin>>N;
        vec_int K(N);
        vec_int L(N);
        vec_int R(N);
        vec_int diff(N); //このdiffはK[i]番目以内に入れたときの報酬

        int N1=0;
        int N2=0;

        ll tot_score = 0;
        for(int i=0;i<N;i++){
            cin>>K.at(i)>>L.at(i)>>R.at(i);
            diff.at(i) = L.at(i)-R.at(i); 
            if (diff.at(i)>=0){
                N1++;
                tot_score += R.at(i);
            }else{
                N2++;
                tot_score += L.at(i);
            }
        }
        vector<Tu> vec_T1(N1);// 前に並べる奴ら
        vector<Tu> vec_T2(N2);// 前に並べる奴ら
        int index1 = 0;
        int index2 = 0;
        for(int i=0;i<N;i++){
            if(diff.at(i)>=0){
                vec_T1.at(index1) = make_tuple(K.at(i),diff.at(i),L.at(i));
                index1++;
            }else{
                vec_T2.at(index2) = make_tuple(N-K.at(i),-1*diff.at(i),R.at(i));
                index2++;
            }
        }
        sort(vec_T1.begin(),vec_T1.end());
        sort(vec_T2.begin(),vec_T2.end());


        priority_queue<P, vector<P>, greater<P>> pq1;// 前に並べる奴ら
        priority_queue<P, vector<P>, greater<P>> pq2;// 後ろに並べる奴ら

        for(int i=0;i<N1;i++){
            Tu temp = vec_T1.at(i);
            int K, diff, score;
            tie(K,diff,score) = temp;
            if(pq1.size()<K){
                pq1.push(make_pair(diff,score));
            }else{
                int min, sc;
                tie(min,sc) = pq1.top();
                if(min<=diff){
                    pq1.pop();
                    pq1.push(make_pair(diff,score));
                }else{
                }
            }
        }
        for(int i=0;i<N2;i++){
            Tu temp = vec_T2.at(i);
            int K, diff, score;
            tie(K,diff,score) = temp;
            if(K==0){
                //tot_score+=score-diff;
                continue;
            }
            if(pq2.size()<K){
                pq2.push(make_pair(diff,score));
            }else{

                int min, sc;
                tie(min,sc) = pq2.top();
                if(min<=diff){
                    pq2.pop();
                    pq2.push(make_pair(diff,score));
 //                   tot_score+=sc-min;
                }else{
//                    tot_score+=score-diff;
                }
            }
        }



        while(pq1.size()>0){
                int diff, sc;
                tie(diff,sc) = pq1.top(); pq1.pop();
                tot_score+=diff;
        }
        while(pq2.size()>0){
                int diff, sc;
                tie(diff,sc) = pq2.top(); pq2.pop();
                tot_score+=diff;
        }
        cout<<tot_score<<endl;
    }
    


    return 0;
}

Measured memory_bytes: 18844
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

S,W=get_i
if S<=W
    puts "unsafe"
else
    puts "safe"
end

Measured memory_bytes: 14292
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long f(const vector<long long>& a) {
	long long r1 = 0;
	long long r2 = 0;
	int N = a.size();
	for (int i = 1; i < N; ++ i) {
		long long d = a[i] - a[i-1];
		(r2 += d*i) %= mod;
		//cerr << " " << d << " " << r2 << endl;
		(r1 += r2) %= mod;
	}
	return r1;
}
int main() {
	int N, M;
	cin >> N >> M;
	vector<long long> X(N), Y(M);
	for (auto& x : X) cin >> x;
	for (auto& x : Y) cin >> x;
	cout << f(X) * f(Y) % mod << endl;
}


Measured memory_bytes: 1792
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    try:
        f = open('input'+ str(inId) + '.txt', 'r')
        sys.stdin = f #标准输出重定向至文件
    except Exception:
        dprint('invalid input file')
if outId>0:
    dprint('use output', outId)
    try:
        f = open('stdout'+ str(outId) + '.txt', 'w')
        sys.stdout = f #标准输出重定向至文件
    except Exception:
        dprint('invalid output file')
        
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, = getIntList()
#print(N)
s0 = input()
s1 = input()
s2 = input()
r = 0
for i in range(N):
    if s0[i] == s1[i] == s2[i]:
        continue
    if s0[i] == s1[i] or s1[i] == s2[i] or s2[i] == s0[i]:
        r+=1
        continue
    r+=2
print(r)







Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}
int n;
vector<int> x;
vector<int> y;
vector<int> h;

int ch;

int func(int cy, int cx){
  int ch;
  for(int i=0; i<n; i++){
    if(h[i] >= 1) ch = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
  }
  for(int i=0; i<n; i++){
    int tmp = ch - abs(x[i]-cx) - abs(y[i]-cy);
    tmp = max(tmp, 0);
    if(tmp != h[i]) return -1;
  }
  cout << cx << " " << cy << " " << ch << endl;
  return ch;
}

int main() {
  cin >> n;
  x.resize(n);
  y.resize(n);
  h.resize(n);
  for(int i=0; i<n; i++){
    cin >> x[i] >> y[i] >> h[i];
  }

  for(int i=0; i<=100; i++){
    for(int j=0; j<=100; j++){
      func(i, j);
    }
  }


  return 0;
}



//


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int digit(int n){
  int cnt = 0;
  while(0 < n){
    cnt++;
    n /= 10;
  }
  return cnt;
}
void push_zero(int n){
  int cnt = 6-digit(n);
  rep(i,cnt) cout << 0;
  cout << n;
}
int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  vi p(m),y(m);
  map<int,map<int,int>> mp;
  rep(i,m){
    cin >> p[i] >> y[i];
    mp[p[i]][y[i]];
  }
  for(auto &x : mp){
    int cnt = 1;
    for(auto &y : x.second) y.second = cnt++;
  }
  rep(i,m){
    push_zero(p[i]);
    push_zero(mp[p[i]][y[i]]);
    cout << endl;
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 17972
n = gets.to_i

prime = []
for i in 2..n
  f = true
  for j in 2...i
    f = false if i%j==0
    #p [i,j]
  end
  prime << i if f
end

fac = []
prime.each{|l|
  t = l
  a = 0
  while n/t>0
    a += n/t
    t *= l
  end
  fac << a+1
}
#p prime

p fac.inject(1){|ans, x| ans*x % (10**9+7)}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int		main(void){
	ll sum;
	ll	n;
	ll  i;

	cin >> n;
	sum = 0;
	i = 0;
	while (i <= n)
	{
		if (i % 3 && i % 5)
			sum += i;
		i++;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    int k;
    cin>>k;
    ll ans=0;
    for (int i=1;i<=k;i++)
    {
        for (int j=1;j<=k;j++)
        {
            for (int f=1;f<=k;f++)
                ans+=__gcd(__gcd(i,j),f);
        }
    }
    cout<<ans;




}

Measured memory_bytes: 3652
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Name:- OMHARI 
  Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY)
  Email:- omharicu@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include<bits/stdc++.h>
using namespace std; 

#define F first
#define S second
#define ull unsigned long long
#define ll long long
#define ul unsigned long
#define db double
#define pb push_back
#define mp make_pair
#define el "\n"
#define vll vector <ll>
#define vl vector <long int>
#define vi vector <int>
#define all(v) (v.begin(), v.end()) 
#define rall(v) (v.rbegin(), v.rend()) 
const ll mod = 1e9+7;


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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
     #endif
    /***************-Code starts from here-***************/
    
        ull n;
        ull m;
        ull x;
        cin >> n >> m >> x;
        
        vector<ull> a(n);
        for(ull a_i = 0; a_i <n; a_i++){
           cin >> a[a_i];
        }
        
        vector<ull> b(m);
        for(ull b_i =0; b_i <m; b_i++){
           cin >> b[b_i];
        }
        
        ull sum=0,count=0,temp=0,i=0,j=0;        
        
        while(i<n && sum+a[i]<=x){   
            sum+=a[i];
            i++;
        }
        count=i;        
       
        while(j<m && i>=0){          
            sum+=b[j];             
            j++;
            while(sum>x && i>0){
                i--;
                sum-=a[i];
            }
            if(sum<=x && i+j>count)
                count=i+j;
        }
        cout<<count<<endl;
    
    
    return 0;
} 

Measured memory_bytes: 6340
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <utility>

using std::min;
using std::pair;
typedef pair<int,int> pii;
const int N = 810;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const int INF = 1e9;
int _w;

int n, m, k, a[N][N];
pii s, q[N*N];
int begin, end, d[N][N];

bool inside( int x, int y ) {
	return x >= 1 && x <= n && y >= 1 && y <= m;
}

int calc( int x, int y ) {
	int d = min(x-1, y-1);
	d = min(d, n-x);
	d = min(d, m-y);
	if( d <= 0 ) return 1;
	return 1 + d/k + bool(d%k);
}

void solve() {
	memset(d, -1, sizeof d);
	d[s.first][s.second] = 0;
	q[end++] = s;
	while( begin != end ) {
		pii u = q[begin++];
		int x = u.first;
		int y = u.second;
		if( d[x][y] == k ) continue;
		for( int i = 0; i < 4; ++i ) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if( inside(nx, ny) && d[nx][ny] == -1 && a[nx][ny] ) {
				d[nx][ny] = d[x][y] + 1;
				q[end++] = pii(nx, ny);
			}
		}
	}
	int ans = INF;
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			if( d[i][j] != -1 )
				ans = min( ans, calc(i, j) );
	printf( "%d\n", ans );
}

int main() {
	_w = scanf( "%d%d%d", &n, &m, &k );
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j ) {
			char ch;
			_w = scanf( " %c", &ch );
			if( ch != '#' ) a[i][j] = 1;
			if( ch == 'S' ) s = pii(i, j);
		}
	solve();
	return 0;
}


Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

ll sq(ll x) {return x*x;}

ll fastExp(ll base, ll power){
	if(power == 0) return 1;
	if(power&1LL) return base*sq(fastExp(base, power/2));
	return sq(fastExp(base, power/2));
}

int main(){
	fastio;
	ll h;
	cin >> h;
	ll lg = log2(h);
	cout << fastExp(2, lg) - 1 + fastExp(2, lg) << endl;
	return 0;
}

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

int main(){
	int N, answer;
	cin >> N;
	
	for(int i = 1; i <= N; i++){
		if( ((int)log10(i)) % 2 == 0){
			answer++;
		}
	}
	
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;


int main()
{
	int n,m;
	cin>>n>>m;
	long long Ans=1e15;
	for(int i=1;i<=n;i++)
	{
		long long S=(long long)i*m;
		long long S1=(long long)((n-i)/2+((n-i)%2))*m;
		long long S2=(long long)((n-i)/2)*m;
		if(S>=S1) Ans=min(Ans,S-S2);
		if(S2>=S) Ans=min(Ans,S1-S);
		S1=(long long)(m/2+(m%2))*(n-i);
		S2=(long long)(m/2)*(n-i);
		if(S>=S1) Ans=min(Ans,S-S2);
		if(S2>=S) Ans=min(Ans,S1-S);
	}
	swap(n,m);
	for(int i=1;i<=n;i++)
	{
		long long S=(long long)i*m;
		long long S1=(long long)((n-i)/2+((n-i)%2))*m;
		long long S2=(long long)((n-i)/2)*m;
		if(S>=S1) Ans=min(Ans,S-S2);
		if(S2>=S) Ans=min(Ans,S1-S);
		S1=(long long)(m/2+(m%2))*(n-i);
		S2=(long long)(m/2)*(n-i);
		if(S>=S1) Ans=min(Ans,S-S2);
		if(S2>=S) Ans=min(Ans,S1-S);
	}
	cout<<Ans<<endl;
	return 0;
}
	
		
		
	 

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

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a >= 0){
        if(d <= 0){
            cout << a * d << endl;
        }else{
            cout << b * d << endl;
        }
    }else if(b <= 0){
        if(c >= 0){
            cout << b * c << endl;
        }else{
            cout << a * c << endl;
        }
    }else{
        if(c >= 0){
            cout << b * d << endl;
        }else if(d <= 0){
            cout << a * c << endl;
        }else{
            if(b * d <= a * c){
                cout << a * c << endl;
            }else{
                cout << b * d << endl;
            }
        }
    }
}

Measured memory_bytes: 3600
import numpy as np


arr = np.zeros(100000, dtype=np.int32)

for s in range(3, 128+1):
    for x in range(1, s-2+1):
        for y in range(1, s-1+1):
            z = s - (x + y)
            if z <= 0:
                continue
            arr[s**2 - (x*y + y*z + z*x) - 1] += 1

num = int(input())
for i in range(0, num):
    print(arr[i])


Measured memory_bytes: 27048
#include <stdio.h>

int main(void){
	int n;
	int i,j;
	int ans =0;
	int min =0;

	scanf("%d",&n);
	char s[n];
	int E[n];
	int W[n];
	scanf("%s",&s);
	for(i=0;i<n;i++){	//配列の初期化
		E[i]=0;
		W[i]=0;
	}
	if( s[0] =='E'){
		E[0] = 1;
		W[0] = 0;
	}else{
		E[0] = 0;
		W[0] = 1;
	}
	for(i=1;i<n;i++){	//iまででEの人の人数とWの人の人数を配列に格納する
		if( s[i]=='E'){
			E[i] = E[i-1] + 1;
			W[i] = W[i-1];
		}else{
			E[i] = E[i-1];
			W[i] = W[i-1] + 1;
		}
	}
	min = E[n-1]-E[0];
	for(i=1;i<n;i++){
		ans = W[i-1];
		ans += E[n-1] - E[i];
		if( min > ans){
			min = ans;
		}
	}
		/*i-1番目までのWの数を数える。これはW[i-1]の値。
		i+1番めのEの数を数える。これはE[n]-E[i]の値。
		足す。
		一番小さいやつを取得する。それを最後に出力する。*/
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define vb vector<bool>
#define vs vector<string>
#define px(x) cout << x << endl
#define pfi(x) printf("%d\n", x)
#define pfs(x) printf("%s\n", x)
#define sfi(x) scanf("%d", &x)
#define sfs(x) scanf("%s", x)

int main() {
    char ch;
    cin >> ch;

    cout << (char)(ch+1);


	return 0;
}

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

int main(){
    int N; cin >> N;
    int s[N];
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }
    bool dp[10010] = {};
    dp[0] = true;
    for(int i = 0; i < N; i++){
        for(int j = 10010; j >=0; j--){
            if(dp[j]) dp[j+s[i]] = true;
        }
    }
    for(int i = 10000; i >= 0; i--){
        if( i % 10 != 0 && dp[i]== true){
            cout << i << endl;
            break;
        }
        if( i == 0){
            cout << i << endl;
        }
    }

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

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

    deque<ll> B;
    rep(i, N) {
        ll a = A[i];
        auto idx = lower_bound(B.begin(), B.end(), a);
        if (idx == B.begin()) {
            B.push_front(a);
        } else {
            idx--;
            *idx = a;
        }
    }
    cout << B.size() << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	char c = 0x00;
	int seq = 0,res = 0;
	for(int i = 0;i < 4;i++) {
		if(s[i] == c) {
			seq++;
			res = max(res,seq);
		}
		else {
			seq = 0;
			c = s[i];
		}
	}
	if(res > 1) cout << "Yes" << endl;
	else cout <<"No" << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	  static int mod=1_000_000_007;
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
      long cnt =0;
      long N = sc.nextInt();
      long K = sc.nextInt();
      
      for(long i=1;i<K+1;i++) {
       	  cnt = (long) (( nCr(N-K+1,i) * nCr(K-1,i-1) ) % mod);
    	  System.out.println(cnt);
      }
  }
  
  
	public static long factorial(long n) {
		long tmp = 1;
		for (long i=n;i>0;i--) {
			tmp = (tmp*i)%mod;
		}
		return tmp;
	}
 
	public static long pow(long a,long n) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a)%mod;
	        }
	        a=(a*a)%mod;
	        n>>=1;
	    }
	    return res;
	}
 
	public static long modinv(long n) {
		return pow(n, mod-2);
	}
 
	public static long nCr(long n, long r) {
		if(n<r) {
			return 0;
		} else {
			return factorial(n) * modinv(factorial(n-r)) % mod * modinv(factorial(r)) % mod;
		}
	}
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;

/*
    二部グラフでないなら-1を返す.
    二部グラフなら頂点0を含む方の頂点の個数を返す.
    O(n).
*/

#define MAX_N 205
vector<int> G[MAX_N];
int f[MAX_N];
int BipartiteGraph(int start){
    rep(i,MAX_N)f[i] = -1;
    queue<int> que;
    que.push(start);
    f[start] = 0;
    int flag = 0;
    while(que.size() > 0){
        int x = que.front();
        que.pop();
        rep(i,G[x].size()){
            if(f[G[x][i]] == -1){
                f[G[x][i]] = (f[x] + 1) % 2;
                que.push(G[x][i]);
            }else{
                if(f[G[x][i]] == f[x]){
                    flag = 1;
                    break;
                }
            }
        }
        if(flag == 1)break;
    }
    if(flag == 1) return -1;
    int res = 0;
    rep(i,MAX_N){
        if(f[i] == 0)res++;
    }
    return res;
}


int main() {
    ll n;
    cin >> n;
    string s[n];
    rep(i,n)cin >> s[i];
    int m = 0;
    rep(i,n){
        rep(j,n){
            if(s[i][j] == '1'){
                G[i].push_back(j);
                m++;
            }
        }
    }
    m /= 2;
    rep(i,n){
        ll nibu = BipartiteGraph(i);
        if(nibu == -1){
            cout << nibu << endl;
            return 0;
        }
    }
        
    int ans = 0;
    int dist[MAX_N];
    
    rep(i,n){
        rep(j,MAX_N)dist[j] = -1;
        if(dist[i] == -1){
            dist[i] = 1;
            queue<int> que;
            que.push(i);
            while(que.size() > 0){
                int x = que.front(); que.pop();
                rep(j,G[x].size()){
                    if(dist[G[x][j]] == -1){
                        dist[G[x][j]] = dist[x] + 1;
                        que.push(G[x][j]);
                    }
                }
            }
            int u = i;
            int ma = 1;
            rep(j,n){
                if(ma < dist[j]){
                    u = j;
                    ma = dist[j];
                }
                if(-1 < dist[j])dist[j] = -1;
            }
            dist[u] = 1;
            que.push(u);
            while(que.size() > 0){
                int x = que.front(); que.pop();
                rep(j,G[x].size()){
                    if(dist[G[x][j]] == -1){
                        dist[G[x][j]] = dist[x] + 1;
                        que.push(G[x][j]);
                    }
                }
            }
            ma = 1;
            rep(j,n){
                if(ma < dist[j]){
                    ma = dist[j];
                }
                if(-1 < dist[j])dist[j] = -2;
            }
            ans = max(ans, ma);
        }
    }

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string A,B;
    cin >> A >> B;
    if(A.length()>B.length()){
        cout << "GREATER" << endl;
        return 0;
    }
    else if(A.length()<B.length()){
        cout << "LESS" << endl;
        return 0;
    }
    else{
        for(int i=0;i<A.length();i++){
            string a1,b1;
            a1=A[i];
            b1=B[i];
            int a=atoi(&a1[0]);
            int b=atoi(&b1[0]);
            if(a==b) continue;
            if(a>b){
                cout << "GREATER" << endl;
                return 0;
            }
            if(a<b){
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    int ans=0;
    cin>>b>>a;
    ans=fabs(fabs(a)-fabs(b));
    if(fabs(a)-fabs(b)>0){
        if(a<0)ans++;
        if(b<0)ans++;
    }
    else{
        if(a>0)ans++;
        if(b>0)ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e6) + 17;

int n, q;
string s;

bool read() {
    if (!(cin >> n >> s >> q))
        return false;
    
    return true;
}

void solve() {
    forn (i, q) {
        int k;
        cin >> k;
        ll D, M, C, DM, MC, ans;
        D = M = C = DM = MC = ans = 0;

        forn (i, n) {
            if (i >= k) {
                D -= s[i - k] == 'D';
                M -= s[i - k] == 'M';
                C -= s[i - k] == 'C';
                DM -= M * (s[i - k] == 'D');
                MC -= C * (s[i - k] == 'M');
            }

            D += s[i] == 'D';
            M += s[i] == 'M';
            C += s[i] == 'C';
            DM += D * (s[i] == 'M');
            MC += M * (s[i] == 'C');
            ans += DM * (s[i] == 'C');
        }

        cout << ans << endl;
    }
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 1948
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

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

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

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

struct Dish
{
    ll time;
    ll taste;
};

static ll FACTORIAL[10000010] = {};
ll nCk(ll n, ll k) {
    if (FACTORIAL[1] == 0) {
        FACTORIAL[0] = 1;
        FACTORIAL[1] = 1;
        for (ll i = 2; i <= 10000000; i++)
        {
            FACTORIAL[i] = FACTORIAL[i - 1] * i;
            FACTORIAL[i] %= MOD;
        }
    }
    ll N_fact = FACTORIAL[n];
    ll K_fact = pow_fast(FACTORIAL[k], MOD - 2);
    ll N_K_fact = pow_fast(FACTORIAL[n - k] , MOD - 2);
    ll ret = N_fact;
    ret %= MOD;
    ret *= K_fact;
    ret %= MOD;
    ret *= N_K_fact;
    ret %= MOD;
    return ret;
}

void solve(string s, ll K)
{
    ll sum = 0;
    for (ll i = s.size(); i <= s.size() + K; i++)
    {
        // 25
        ll cnt = pow_fast(25, i - s.size()) % MOD;
        cnt *= nCk(i - 1, s.size() - 1);
        cnt %= MOD;

        // 26
        cnt *= pow_fast(26, s.size() + K - i);
        cnt %= MOD;

        sum += cnt;
        sum %= MOD;
    }
    cout << sum << endl;
    return;
}

int main()
{
    ll K;
    string S;
    cin >> K >> S;
    solve(S, K);
}

Measured memory_bytes: 83404
#include <stdio.h>
typedef long long ll;
using namespace std;

ll min(ll a, ll b) {
  return a < b ? a : b;
}

int main(void) {
  ll i, j, k, a, b, c, n, m;
  scanf("%lld%lld%lld", &n, &a, &b);
  ll cnt[3] = {0, 0, 0};
  for(i - 0; i < n; ++i) {
    scanf("%lld", &c);
    if(c <= a) cnt[0]++;
    else if(c <= b) cnt[1]++;
    else cnt[2]++;
  }
  printf("%lld", min(cnt[0], min(cnt[1], cnt[2])));
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc049/tasks/abc049_b

int main() {

    int H, W;
    cin >> H >> W;

    string c;
    REP(i, H) {
        cin >> c;
        cout << c << "\n";
        cout << c << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
# ABC 085 D
import bisect, math
N, H = map(int, input().split())
a = []
b = []
for k in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = sorted(a)
b = sorted(b)

l = N - bisect.bisect_left(b,a[-1])
b = b[::-1]
ans = 0
for k in range(l):
    ans += 1
    H -= b[k]
    if H <= 0:
        print(ans)
        exit(0)

print(ans + math.ceil(H/a[-1]))


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(),a.end())
#define NP(a) next_permutation(a.begin(),a.end())

typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout<<"input"<<endl;freopen("input.txt","r",stdin);
    //cout<<"output"<<endl;freopen("output.txt","w",stdout);
    
    
    int x;
    cin>>x;
    if(x==0)
        cout<<1<<endl;
    else    cout<<0<<endl;
    
    
    
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include<vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdexcept>
using namespace std;
int main(void)
{
	int N, L;
	cin >> N>>L;
	vector<string> data(N);
	for (int i = 0; i < N; i++)
	{
		
			cin >> data[i];
		
	}

	sort(data.begin(), data.end());
	for (int i = 0; i < N; i++)
	{

		cout << data[i];

	}
	
	
}

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

char *reverse(char *s)
{
    int i;
    char tmp;
    for(i=0; i<strlen(s)/2; i++){
        tmp = s[i];
        s[i] = s[strlen(s)-1-i];
        s[strlen(s)-1-i] = tmp;
    }
    return s;
}

int main()
{

    char str[21];

    scanf("%s", str);
    printf("%s\n", reverse(str));

    return 0;
}

Measured memory_bytes: 948
#include<bits/stdc++.h>
#include<iomanip>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;


int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  long long x=0;
  REP(i,n){
    cin>>a[i];
    x=(i%2)?x-a[i]:x+a[i];
  }
  x/=2;
  vector<int> ans(n);
  ans[0]=x;
  REP(i,n-1){
    ans[i+1]=a[i]-ans[i];
  }
  REP(i,n)ans[i]*=2;
  cout<<fixed<<setprecision(6);
  REP(i,n){
    cout<<ans[i];
    if(i==n-1)cout<<endl;
    else cout<<" ";
  }
}


Measured memory_bytes: 2048
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int ans = 0;
	std::string s;
	std::cin >> s;

	for(int i=0; i<s.size(); i++){
		for(int j=i; j<s.size(); j++){
			for(int x=i; x<=j; x++){
				if(s[x]!='A' and s[x]!='C' and s[x]!='G' and s[x]!='T'){
					break;
				}else if(x==j){
					ans = std::max(ans, j-i+1);
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main()
{
    LL n,i,j,k;
    cin>>n;
    vector <LL> h(n+1);
    vector <LL> cost(n+1);
    for(i=1;i<=n;i++)
    {
        cin>>h[i];
    }

    cost[1]=0;
    cost[2]=fabs(h[2]-h[1]);

    for(i=3;i<=n;i++)
    {
        cost[i]=min(cost[i-1]+fabs(h[i]-h[i-1]),cost[i-2]+fabs(h[i]-h[i-2]));
    }
    cout<<cost[n]<<endl;




    
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repe(i, n) for (ll i = 0; i <= (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

bool check = 0;
bool boo = 0;
int maxx = 0;
long long ans = 0;
int sum = 0;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．

// vector
// sum: accumulate(ALl(x),0)
int main()
{
    INIT;
    int n, m, a;
    cin >> n >> m;
    rep(i, m)
    {
        cin >> a;
        sum += a;
    }
    if (sum <= n)
        pr(n - sum);
    else
        pr(-1);
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, M, ans[100100], t[200200];

int q (int i) {
        int res = 0;
        for (i += M+1; i >= 1; i /= 2) res += t[i];
        return res;
}

void u (int l, int r, int v) {
        for (l += M+1, r += M+1; l<r; l /= 2, r /= 2) {
                if (l&1) t[l++] += v;
                if (r&1) t[--r] += v;
        }
}

pair<int, int> r[300300];

#define rs first
#define re second
bool comp (pair<int,int>& a, pair<int,int>& b) {
        return a.second-a.first+1 > b.second-b.first+1;
}

int main () {
        scanf("%d %d", &N, &M);
        fo(i, 0, N) {
                scanf("%d %d", &r[i].rs, &r[i].re);
                u(r[i].rs, r[i].re+1, 1);
        }
        sort(r, r+N, comp);

        int rem = 0;

        for (int d = M; d >= 1; d--) {
                while (rem < N && r[rem].second-r[rem].first+1 >= d) {
                        u(r[rem].rs, r[rem].re+1, -1);
                        rem++;
                }
                ans[d] = rem;
                for (int i = d; i <= M; i += d) {
                        ans[d] += q(i);
                }
        }

        fo(d, 1, M+1) printf("%d\n", ans[d]);

        return 0;
}


Measured memory_bytes: 4480
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define MAX_N 16
#define INF 10000005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int V,E;
ll K;
int d[MAX_N][MAX_N];
int dp[1<<MAX_N][MAX_N];
int color[MAX_N];

void solve(){
	for(int S=0;S<1<<V;S++){
		fill(dp[S],dp[S]+V,INF);
	}
	dp[(1<<V)-1][0] = 0;
	for(int S=(1<<V)-2;S>=0;S--){
		for(int v=0;v<V;v++){
			for(int u=0;u<V;u++){
				if(!(S>>u&1)){
					dp[S][v] = min(dp[S][v],dp[S|1<<u][u]+d[v][u]);
				}
			}
		}
	}
	if(dp[0][0]>=INF)printf("-1\n");
	else printf("%d\n",dp[0][0]);
}

//dfsで塗る
int dfs(int v,int a){
	color[v] = 1;
	a++;
	for(int i=0;i<V;i++){
		if(d[v][i]!=INF && color[i]==0){
			a = dfs(i,a);
		}
	}
	return a;
}


int main()
{
	int s,t,dd;
	scanf("%d %d",&V,&E);
	if(E==0){
		printf("-1\n");
		return 0;
	}
	for(int i=0;i<=V;i++){
		fill(d[i],d[i]+V+1,INF);
	}
	for(int i=0;i<E;i++){
		scanf("%d%d%d",&s,&t,&dd);
		d[s][t] = dd;
	}
	//printf("%d\n",dfs(0,0));
	solve();
	return 0;
}



Measured memory_bytes: 4764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

#define N 100010

int prime[N];

void eratosthenes(){
  rep(i,N) prime[i]=1;
  prime[0]=prime[1]=0;
  rep(i,N){
    if(prime[i]){
      for(int j=i+i;j<N;j+=i) prime[j]=0;
    }
  }
}


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int q;
  cin>>q;
  int niteru[100010]={};
  eratosthenes();
  rep(i,100010){
    if(prime[i] && prime[(i+1)/2] ) niteru[i]=1;
  }
  rep(i,100009){
    niteru[i+1]+=niteru[i];
  }
						   
  rep(i,q){
    int l,r;
    cin>>l>>r;
    cout<<niteru[r]-niteru[l-1]<<endl;
  }

  return 0;
}

Measured memory_bytes: 2176