akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 100000001
typedef  long  long ll;

int main(){

int N,i;
ll L[87];

scanf ("%d",&N);
L[0]=2,L[1]=1 ;
for( i=2;i<=N;i++)L[i]=L[i-2]+L[i-1];
printf ("% lld\n",L[N]);
return 0;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline int gcd(int a, int b) { while(a) swap(a, b%=a); return b; }


#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == 0) {
        v.clear();
        return 0;
    }
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}


int solve(int N, vi& a) {
    vi ac(N+1, 0), bc(N+1, 0);
    int best = 1;
    rep(i,N) {
        ac[i+1] = gcd(ac[i], a[i]);
    }
    rep(i,N) {
        bc[i+1] = gcd(bc[i], a[N-1-i]);
    }
    rep(i,N){
        int g = gcd(ac[i], bc[N-1-i]);
        amax(best, g);
    }
    return best;
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	rep(i,4){
		cout << s[i];
	}
	cout << " ";
	for (int i = 4; i < s.size(); ++i) {
		cout << s[i];
	}
	cout << endl;
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,tag,ans;
int read()
{
	int x=0;char ch=getchar();
	while(ch>'9'||ch<'0')ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}
int main()
{
	n=read();int x,y;x=read();
	for(int i=2;i<=n;++i)
	{
		if(!(i&1))
		{
			y=read();
			if(x==y&&!tag) tag=i,++ans;
			else if(x==y&&tag<i-1) tag=i,++ans;
		}
		else if(i&1)
		{
			x=read();
			if(x==y&&!tag) tag=i,++ans;
			else if(x==y&&tag<i-1) tag=i,++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)((a).size()))
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


inline void transpose(vector<string> &a) {

    int n = a.size();
    if (n == 0) return;
    int m = a[0].size();
    vector<string> b(m, string(n, ' '));
    fori (i, n) fori (j, m) b[j][i] = a[i][j];
    a = b;
}


template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    fori (i, SZ(a))
        out << a[i] << vector<string>{", ", "}"}[i + 1 == SZ(a)];
    return out;
}

void smain();

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


#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#define cerr cout
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\n";
    cout << "TOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}


const int N = 3009;

string s, t;
int n, m;

int dp[N][N];

void smain() {
    cin >> s >> t;
    n = s.size(), m = t.size();
    s = '#' + s;
    t = '#' + t;
    int ans = 0;
    pii bad = {-1, -1};
    pii cur = bad;
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) {
        if (s[i] == t[j]) {
            dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
        if (dp[i][j] > ans) {
            ans = dp[i][j];
            cur = {i, j};
        }
    }
    if (cur == bad) {
        cout << "";
    } else {
        string ans = "";
        while (min(cur.first, cur.second) > 0) {
            int i = cur.first, j = cur.second;
            if (s[i] == t[j]) ans += s[i], i--, j--;
            else {
                if (dp[i - 1][j] > dp[i][j - 1]) --i;
                else --j;
            }
            cur = {i, j};
        }
        reverse(ALL(ans));
        cout << ans;
    }
}

Measured memory_bytes: 35584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<String> list=new ArrayList<String>();
		//int[] array = new int[n];
		String a = sc.next();
		if(a.equals("ABC")) {
			System.out.println("ARC");
		}
		else {
			System.out.println("ABC");
		}
	}
}

Measured memory_bytes: 35644
s = input()
mod = [0] * 2019

cur_mod = 0
ten_mod = 1
mod[0] = 1
for c in s[::-1]:
  cur_mod = (cur_mod + int(c) * ten_mod) % 2019
  ten_mod = (ten_mod * 10) % 2019
  mod[cur_mod] += 1

count = 0
for m in mod:
  count += m * (m - 1) // 2

print(count)

Measured memory_bytes: 9388
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	vll input(6);
	ll bn;
	rep(i, 0, 6) {
		in(input[i]);
	}
	bn = min({ input[1],input[2],input[3],input[4],input[5] });

	outn(4 + ((input[0] + (bn - 1)) / bn));

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> x(n); 
	for( auto &k : x ) cin >> k;
	int ans = inf;
	for( int p = -500; p < 500; ++p ){
		int sum = 0;
		for( auto k : x ) sum += (k-p)*(k-p);
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
function Main(input) {
    var lines = input.split("\n");
    var l0 = lines.shift().split(" ");
    var N = l0[0] - 0;
    var K = l0[1] - 0;
    var hs = lines.map(function(value) { return value - 0; }).sort(function(a,b) { return b - a; });
    var min = Number.MAX_VALUE;
    for (var n = 0; n < N - K + 1; n++) {
        min = Math.min(min, hs[n] - hs[n+K-1]);
    }

    console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 28496
import java.util.*;
import java.io.*;

public class Main {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static int nextInt() throws IOException {
		return Integer.parseInt(br.readLine());
	}

	public static int[] nextArr() throws IOException {
		String elements[] = br.readLine().split(" ");
		int arr[] = new int[elements.length];
		for (int j = 0; j < elements.length; j++)
			arr[j] = Integer.parseInt(elements[j]);
		return arr;
	}

	public static void printArr(int arr[]) {
		for (int i = 0; i < arr.length; i++)
			System.out.print(arr);
	}

	public static String next() throws IOException {
		return br.readLine();
	}

	public static void main(String[] args) throws IOException {

			int n = nextInt();
			int ans = 0;
			int a = n / 500;
			n = n % 500;
			int b = n / 5;
			n = n % 500;
			System.out.println((1000 * a) + (5 * b));
	}

}


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

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  
  int s=0;
  for(int i=0; i<n; i++){
    s += a[i];
  }
  
  int cnt=0;
  for(int i=0; i<n; i++){
    if(s <= a[i]*(4*m)){
      cnt++;
    }
  }
  
  if(cnt >= m){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int n,k;
vector<int>a;
void solve(){
   
rep(p,min(k,41)){
    vector<int>b(n);
  rep(i,n){
    int l=max(i-a[i],0);
    int r=min(i+a[i],n-1);
    b[l]++;
    if(r+1<n)b[r+1]--;
    }
    for(int i=1;i<n;i++)b[i]+=b[i-1];
     swap(a,b);
  }
   rep(s,n){
      if(s!=n-1){
          cout<<a[s]<<" ";
      }else cout<<a[s]<<endl;
  }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>k;
    a.resize(n);
    rep(i,n){
        cin>>a[i];
        }
    solve();
    return 0;
}

Measured memory_bytes: 4772
/*input
100 5
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>n>>m;
	sum=m*1900+(n-m)*100;
	sum<<=m;
	cout<<sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAX = 3000;

ll C[MAX];

void init(){
    for(ll i = 1; i < MAX; i++){
        C[i] = i*i*i*i*i;
    }
}


int main(){
    init();
    int X, Y;
    cin >> X;
    int A = 0, B = 0;
    int A2 = 0, B2 = 0;
    int A3 = 0, B3 = 0;
    while(1){
        if(C[A3] < X){
            A3++;
        }
        else if(C[A3] > X){
            Y = A3;
            break;
        }
        else{
            cout << A3 << " " << B3 << endl;
            return 0;            
        }
    }

    while(A3 > 0 && B3 < Y){
        if(C[A3] + C[B3] < X){
            B3++;
        }
        else if(C[A3] + C[B3] > X){
            A3--;
        }
        else{
            cout << A3 << " " << -B3 << endl;
            return 0;
        }       
    }

    while(A < MAX && B < MAX){
        if(C[A] - C[B] < X){
            A++;
        }
        else if(C[A] - C[B] > X){
            B++;
        }
        else{
            cout << A << " " << B << endl;
            return 0;
        }
    }

    return 0;
}

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

/*
Nの組み合わせの計算が問題
Nはたかだか12個なので、2^12 = 10^ (log_10 2 * 12) ~= 10^3.612
全探索でいける
*/

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

    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));

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

    int minv = 1e9;
    bool success = false;
    for (int tmp = 0; tmp < (1 << 12); tmp++)
    {
        bitset<12> s(tmp);

        int sum = 0;
        vector<int> S(M, 0);
        bool achieve = true;

        for (int i = 0; i < N; i++)
        {
            if (s.test(i)) {
                sum += C[i];
                for (int j = 0; j < M; j++)
                {
                    S[j] += A[i][j];
                }
                
            }
        }

        // check skills
        for (int i = 0; i < M; i++)
        {
            achieve *= (S[i] >= X);
        }

        if (achieve) {
            minv = min(minv, sum);
            success = true;
        }
    }

    if (success)
    {
        cout << minv << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
  if (a < b) a = b;
}

template <typename T, T MOD = 1000000007>
struct Mint {
  static constexpr T mod = MOD;
  T v;
  Mint() : v(0) {}
  Mint(signed v) : v(v) {}
  Mint(long long t) {
    v = t % MOD;
    if (v < 0) v += MOD;
  }

  Mint pow(long long k) {
    Mint res(1), tmp(v);
    while (k) {
      if (k & 1) res *= tmp;
      tmp *= tmp;
      k >>= 1;
    }
    return res;
  }

  static Mint add_identity() { return Mint(0); }
  static Mint mul_identity() { return Mint(1); }

  Mint inv() { return pow(MOD - 2); }

  Mint& operator+=(Mint a) {
    v += a.v;
    if (v >= MOD) v -= MOD;
    return *this;
  }
  Mint& operator-=(Mint a) {
    v += MOD - a.v;
    if (v >= MOD) v -= MOD;
    return *this;
  }
  Mint& operator*=(Mint a) {
    v = 1LL * v * a.v % MOD;
    return *this;
  }
  Mint& operator/=(Mint a) { return (*this) *= a.inv(); }

  Mint operator+(Mint a) const { return Mint(v) += a; };
  Mint operator-(Mint a) const { return Mint(v) -= a; };
  Mint operator*(Mint a) const { return Mint(v) *= a; };
  Mint operator/(Mint a) const { return Mint(v) /= a; };

  Mint operator-() const { return v ? Mint(MOD - v) : Mint(v); }

  bool operator==(const Mint a) const { return v == a.v; }
  bool operator!=(const Mint a) const { return v != a.v; }
  bool operator<(const Mint a) const { return v < a.v; }

  // find x s.t. a^x = b
  static T log(T a, T b) {
    const T sq = 40000;
    unordered_map<T, T> dp;
    dp.reserve(sq);
    Mint res(1);
    for (Int r = 0; r < sq; r++) {
      if (!dp.count(res.v)) dp[res.v] = r;
      res *= a;
    }
    Mint p = Mint(a).inv().pow(sq);
    res = b;
    for (Int q = 0; q <= MOD / sq + 1; q++) {
      if (dp.count(res.v)) {
        T idx = q * sq + dp[res.v];
        if (idx > 0) return idx;
      }
      res *= p;
    }
    assert(0);
    return T(-1);
  }

  static Mint comb(long long n, Int k) {
    Mint num(1), dom(1);
    for (Int i = 0; i < k; i++) {
      num *= Mint(n - i);
      dom *= Mint(i + 1);
    }
    return num / dom;
  }
};
template <typename T, T MOD>
constexpr T Mint<T, MOD>::mod;
template <typename T, T MOD>
ostream& operator<<(ostream& os, Mint<T, MOD> m) {
  os << m.v;
  return os;
}

int main() {
  string s;
  cin >> s;
  using M = Mint<Int>;
  const Int MOD = 13;
  vector<M> dp(13, 0);
  dp[0] = M(1);

  Int n = s.size();
  for (Int i = 0; i < n; i++) {
    vector<M> nx(13, 0);
    for (Int j = 0; j < 13; j++) {
      if (s[i] == '?') {
        for (Int k = 0; k < 10; k++) {
          nx[(j * 10 + k) % MOD] += dp[j];
        }
      } else {
        nx[(j * 10 + (s[i] - '0')) % MOD] += dp[j];
      }
    }
    swap(dp, nx);
  }

  cout << dp[5] << endl;
  return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll> pii;
const int maxn=305;
ll dp[maxn][maxn];int id[maxn][maxn];
ll h[maxn];
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&h[i]);
	}
	memset(id,0,sizeof id);
	for(int i=0;i<=n;i++)
	{
		dp[i][0]=0;
		for(int j=1;j<=n;j++)
		{
			dp[i][j]=1e18;
		}
	}
	dp[0][0]=0;
	dp[1][1]=h[1];
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(j==1)
			{
				dp[i][j]=h[i];continue;
			}
			for(int z=1;z<i;z++)
			{
				dp[i][j]=min(dp[i][j],dp[z][j-1]+max(0ll,h[i]-h[z]));
				//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
			}
		}
	}
	//for(int i=0;i<=n;i++)
	//{
	//	for(int j=0;j<=n;j++)
	//	{
	//		cout<<dp[i][j]<<" ";
	//	}
	//	cout<<endl;
	//}
	ll ans=1e18;
	for(int i=1;i<=n;i++) ans=min(ans,dp[i][n-k]);
	cout<<ans<<endl;
 } 
 /*
 
 0 2
 0 2 3
 0 2 3 4
 0 1 2 3 4
 */

Measured memory_bytes: 1280
N,M = [int(x) for x in input().split()]
ab = [[int(x) for x in input().split()]for _ in range(M)]

class UnionFind():
    def __init__(self,n):
        self.parent = [-1 for _ in range(n)]

    def size(self,x):
        return -self.parent[self.find(x)]

    def find(self,x):
        if(self.parent[x]<0):
            return x
        else:
            self.parent[x]=self.find(self.parent[x])
            return self.parent[x]

    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return False
        if(self.size(x)<self.size(y)):
            self.parent[y]+=self.parent[x]
            self.parent[x]=y
        else:
            self.parent[x]+=self.parent[y]
            self.parent[y]=x
        return True

    def same(self,x,y):
        return self.find(x)==self.find(y)

cnt = 0
for i in range(M):
    un = UnionFind(N+1)
    for ind,x in enumerate(ab):
        if(ind!=i):
            un.unite(x[0],x[1])

    if(un.find(ab[i][0])!=un.find(ab[i][1])):
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt(), h = sc.nextInt();
        int[] aw = new int[w], bh = new int[h];
        for (int i = 0; i < w; i++) {
            aw[i] = sc.nextInt();
        }
        for (int i = 0; i < h; i++) {
            bh[i] = sc.nextInt();
        }
        PriorityQueue<Integer> queue = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < w; i++) {
            queue.add(aw[i]);
        }
        Arrays.sort(bh);
        for(int back = h - 1; back >= 0; back--) {
            int pushCnt = bh[back];
            int[] tmp = new int[pushCnt];
            for (int i = 0; i < pushCnt; i++) {
                tmp[i] = queue.poll() - 1;
            }
            if (Arrays.stream(tmp).anyMatch(value -> value < 0)) {
                System.out.println(0);
                return;
            }
            for (int i : tmp) {
                queue.add(i);
            }
        }
        System.out.println(1);
    }
}


Measured memory_bytes: 55840
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>(int)(y);i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

int a,b,c;

int solve() {
    int ans;
    ans = min(min(a+b,b+c),c+a);
    return ans;
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> a;
    cin >> b;
    cin >> c;
    cout << solve() << "\n";
    return 0;
}


Measured memory_bytes: 256
INF = float('inf')

H, W = map(int, input().split())
Sss = ['#'*(W+2)] + ['#'+input()+'#' for _ in range(H)] + ['#'*(W+2)]

def convGrid2Graph(Sss):
    dxys = [(-1,0), (1,0), (0,-1), (0,1)]
    sizeX, sizeY = len(Sss)-2, len(Sss[0])-2

    numV = sizeX * sizeY
    adjL = [[] for _ in range(numV)]
    for x in range(1, sizeX+1):
        for y in range(1, sizeY+1):
            if Sss[x][y] != '.': continue
            z = (x-1)*sizeY + (y-1)
            for dx, dy in dxys:
                x2, y2 = x+dx, y+dy
                if Sss[x2][y2] != '.': continue
                z2 = (x2-1)*sizeY + (y2-1)
                adjL[z].append(z2)
    return adjL

def WarshallFloyd(adjList, INF):
    numV = len(adjList)
    D = [[INF]*numV for _ in range(numV)]
    for u, adj in enumerate(adjList):
        for v in adj:
            D[u][v] = 1
        D[u][u] = 0
    for k in range(numV):
        Dk = D[k]
        for i in range(numV):
            Di = D[i]
            Dik = Di[k]
            for j in range(numV):
                D2 = Dik + Dk[j]
                if D2 < Di[j]:
                    D[i][j] = D2
    return D

adjL = convGrid2Graph(Sss)

distss = WarshallFloyd(adjL, INF)

ans = 0
for i in range(H*W):
    for j in range(H*W):
        if distss[i][j] != INF:
            ans = max(ans, distss[i][j])

print(ans)


Measured memory_bytes: 75224
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int a,b,c;
    cin>a>b>c;
    a-=c;
    b-=c;
    Yes(a*b<0);
    return 0;
}


Measured memory_bytes: 256
def is_acgt(s: str)->int:
    AGCT = 'AGCT'
    for c in s:
        if c not in AGCT:
            return False
    return True


def atcoder(S: str)->int:
    n = len(S)
    max_len = 0
    for i in range(n):
        for j in range(i, n):
            if is_acgt(S[i:j+1]):
                max_len = max(max_len, j - i + 1)
    return max_len


if __name__ == "__main__":
    S = input()
    ans = atcoder(S)
    print(ans)


Measured memory_bytes: 3060
#include<cstdio>

using namespace std;

const int N = 100005;
int n, m, a[N], u, v, fa1[N], fa2[N], cnt;

inline int findfa(int fa[], int x){
	if(x != fa[x])	fa[x] = findfa(fa, fa[x]);
	return fa[x];
}
inline void unionn(int fa[], int x, int y){
	fa[findfa(fa, y)] = findfa(fa, x);
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]), fa1[i] = fa2[i] = i;
	while(m--){
		scanf("%d%d", &u, &v);
		if(findfa(fa1, u) != findfa(fa1, v)){
			unionn(fa1, u, v);
			unionn(fa2, a[u], a[v]);
		}
	}
	for(int i = 1; i <= n; i++)
		if(a[findfa(fa1, i)] == findfa(fa2, i))
			cnt++;
	printf("%d\n", cnt);
	return 0;
}

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

int main(){
  string s;cin>>s;
  string d="dream",dr="dreamer",e="erase",er="eraser";
  int N=s.size();
  reverse(s.begin(),s.end());
  reverse(d.begin(),d.end());
  reverse(dr.begin(),dr.end());
  reverse(e.begin(),e.end());
  reverse(er.begin(),er.end());
  s+="########";
  bool NG=0;
  for(int i=0;i<N;i++){
    if(s.substr(i,5)==d)i+=4;
    else if(s.substr(i,7)==dr)i+=6;
    else if(s.substr(i,5)==e)i+=4;
    else if(s.substr(i,6)==er)i+=5;
    else NG=1;
  }
  if(NG)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
  string S;
  cin>>S;
  int x,y;
  for(int i=0;i<S.length();i++){
      if(S[i]=='A'){
          x=i;
          break;
      }
  }
  for(int i=S.length()-1;i>=0;i--){
      if(S[i]=='Z'){
          y=i;
          break;
      }
  }
  cout<<y-(x-1)<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

ll arr[3];
int main()
{
	scanf("%lld", &arr[0]);
	scanf("%lld", &arr[1]);
	scanf("%lld", &arr[2]);
	sort(arr, arr + 3);
	if((arr[0] & 1) & (arr[1] & 1 )&(arr[2] & 1))std::cout << arr[0]*arr[1];
	else { std::cout << 0; }





}











Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	S := next()
	result := S
	if S[len(S)-1] == 's' {
		result += "es"
	} else {
		result += "s"
	}
	fmt.Println(result)
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1
#define j0 gray_cat_j0

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 100 + 5;

char g[MAXN][MAXN];

int dp[MAXN][MAXN];

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, 0, n) {
		scanf("%s", &g[i][0]);
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = (g[0][0] == '#' ? 1 : 0);
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (i > 0) {
				int add = 0;
				if (g[i][j] != g[i - 1][j] && g[i][j] == '#') {
					add = 1;
				}
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + add);
			}
			if (j > 0) {
				int add = 0;
				if (g[i][j] != g[i][j - 1] && g[i][j] == '#') {
					add = 1;
				}
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + add);
			}
		}
	}
	printf("%d\n", dp[n - 1][m - 1]);
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input){
    var args = input.split('\n').map(n => parseInt(n, 10));
    var N = args[0];
    var d = args.slice(1);
    var uniqueArray = d.filter( (value, index, self) => {return self.indexOf(value) === index;} );

    console.log( uniqueArray.length );
}

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

int main(int argc, char const *argv[]) {
  int n,i,j,k;
  cin >> n;
  long long a[n],b[n+2]={};
  for(i=0;i<n;i++){
    cin >> a[i];
    if(i==0)b[i]=a[i];
    else b[i]+=b[i-1]+a[i];
  }
  int l=0,r=2;
  long long ret=1e16;
  for(int c=1;c<n-2;c++){
    long long P,Q,R,S;
    while(1){
      if(c>l+1 && abs(b[c]-2*b[l+1])<abs(b[c]-2*b[l]))l++;
      else break;
    }
    P=b[l];
    Q=b[c]-b[l];
    while(1){
      if(r+1<n-1 && abs((b[n-1]-b[r])-(b[r]-b[c]))>abs((b[n-1]-b[r+1])-(b[r+1]-b[c])))r++;
      else break;
    }
    R=b[r]-b[c];
    S=b[n-1]-b[r];
    long long M,m;
    M = max(max(P,Q),max(R,S));
    m = min(min(P,Q),min(R,S));
    ret = min(M-m,ret);
  }
  cout << ret << endl;
  return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
using namespace std;

int retmaxidx(vector<int> &vec) {
	int max = -1000000;
	int maxidx = 0;
	int vsize = SZ(vec);
	FOR(i, 0, vsize) {
		if (max < vec[i]) {
			max = vec[i];
			maxidx = i;
		}
	}
	return maxidx;
}
int retminidx(vector<int> &vec) {
	int min = 1000000;
	int minidx = 0;
	int vsize = SZ(vec);
	FOR(i, 0, vsize) {
		if (min > vec[i]) {
			min = vec[i];
			minidx = i;
		}
	}
	return minidx;
}


int main() {
	int N = 0;
	cin >> N;
	vector<int> a(N, 0);
	FOR(i,0,N) cin >> a[i];

	int posi = 0;
	int nega = 0;
	int zero = 0;

	FOR(i, 0, N) {
		if (a[i] < 0)
			++nega;
		else if (a[i] > 0)
			++posi;
		else {
			++zero;
		}
	}

	if (nega == 0 && posi != 0) {
		cout << N - 1 << "\n";
		FOR(i, 1, N)
			cout << i << " " << i + 1 << "\n";
	}
	else if (posi == 0 && nega != 0) {
		cout << N - 1 << "\n";
		RFOR(i, N, 1)
			cout << i << " " << i - 1 << "\n";
	}
	else if (zero == N) {
		cout << 0 << "\n";
	}
	else {
		int maxidx = retmaxidx(a);
		int minidx = retminidx(a);
		if (a[maxidx] + a[minidx] >= 0) {
			cout << 2 * N - 1 << "\n";
			FOR(i, 1, N + 1)
				cout << maxidx + 1 << " " << i << "\n";
			FOR(i, 1, N)
				cout << i << " " << i + 1 << "\n";
		}
		else {
			cout << 2 * N - 1 << "\n";
			FOR(i, 1, N + 1)
				cout << minidx + 1 << " " << i << "\n";
			RFOR(i, N, 1)
				cout << i << " " << i - 1 << "\n";
		}

	}
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var m = parseInt(input[0].split(" ")[1]);
  x = new Array(n);
  y = new Array(n);
  z = new Array(n);
  sum1=new Array(n);
  sum2=new Array(n);
  sum3=new Array(n);
  sum4=new Array(n);
  sum5=new Array(n);
  sum6=new Array(n);
  sum7=new Array(n);
  sum8=new Array(n);
  var ans = 0;
  for(i=0;i<n;i++){
    tmp=input[i+1].split(" ");
    x[i]=parseInt(tmp[0]);
    y[i]=parseInt(tmp[1]);
    z[i]=parseInt(tmp[2]);
    sum1[i]=x[i]+y[i]+z[i];
    sum2[i]=x[i]+y[i]-z[i];
    sum3[i]=x[i]-y[i]+z[i];
    sum4[i]=x[i]-y[i]-z[i];
    sum5[i]=-x[i]+y[i]+z[i];
    sum6[i]=-x[i]+y[i]-z[i];
    sum7[i]=-x[i]-y[i]+z[i];
    sum8[i]=-x[i]-y[i]-z[i];
  }
  sum1.sort(function(a,b){return b-a});
  sum2.sort(function(a,b){return b-a});
  sum3.sort(function(a,b){return b-a});
  sum4.sort(function(a,b){return b-a});
  sum5.sort(function(a,b){return b-a});
  sum6.sort(function(a,b){return b-a});
  sum7.sort(function(a,b){return b-a});
  sum8.sort(function(a,b){return b-a});
  var sum1s=0;
  var sum2s=0;
  var sum3s=0;
  var sum4s=0;
  var sum5s=0;
  var sum6s=0;
  var sum7s=0;
  var sum8s=0;

  for(i=0;i<m;i++){
    sum1s+=sum1[i];
    sum2s+=sum2[i];
    sum3s+=sum3[i];
    sum4s+=sum4[i];
    sum5s+=sum5[i];
    sum6s+=sum6[i];
    sum7s+=sum7[i];
    sum8s+=sum8[i];
  }
  ans=Math.max(sum1s,sum2s,sum3s,sum4s,sum5s,sum6s,sum7s,sum8s);

  


  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11040
#include<bits/stdc++.h>
using namespace std;
int m,x[16],y[16],dp[1<<16];
bool s[1<<16][16][16],f[1<<16];
int hei(int a,int b,int c,int d){return a*d-b*c;}

int main(){
  cin>>m;
  for(int i=0;i<m;i++)cin>>x[i]>>y[i];
  s[0][0][1]=1;
  for(int i=0;i<1<<m;i++){
    for(int a=0;a<m;a++)
      for(int b=a+1;b<m;b++)
	if(s[i][a][b])
	  for(int c=0;c<m;c++)
	    if(!(i&1<<c))
	      for(int d=c+1;d<m;d++)
		if(!(i&1<<d))
		  if(!i||hei(x[a]-x[b],y[a]-y[b],x[c]-x[d],y[c]-y[d])==0)
		    s[i|1<<c|1<<d][c][d]=1;
    for(int j=0;j<m;j++)
      for(int k=j+1;k<m;k++)if(s[i][j][k])f[i]=1;
  }
  memset(dp,-1,sizeof(dp));
  dp[0]=0;
  int ans=0;
  for(int i=0;i<1<<m;i++)
    if(dp[i]!=-1)
      for(int j=0;j<1<<m;j++){
	if(!(i&j)&&f[j]){
	  int a=__builtin_popcount(j)/2;
	  ans=max(ans,dp[i|j]=max(dp[i|j],dp[i]+a*(a-1)/2));
	}
      }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4724
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int max1 = 0;
        if (a >= b) {
            max1 = a;
            a -= 1;
        } else {
            max1 = b;
            b -= 1;
        }
        int max2 = Math.max(a, b);

        System.out.println(max1 + max2);
    }

}


Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#define SIZE 505

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

char mp[SIZE][SIZE];
char A[SIZE][SIZE];
char B[SIZE][SIZE];
P pos[SIZE*SIZE];

int main()
{
	int h,w;
	scanf("%d %d",&h,&w);
	int sz=0;
	for(int i=0;i<h;i++)
	{
		scanf("%s",&mp[i]);
		for(int j=0;j<w;j++)
		{
			A[i][j]=mp[i][j];
			B[i][j]=mp[i][j];
		}
	}
	for(int i=1;i<h-1;i++)
	{
		for(int j=1;j<w-1;j++)
		{
			if(mp[i+1][j]=='.'&&mp[i][j+1]=='.')
			{
				if(A[i][j]=='#'&&A[i][j+1]=='.') A[i+1][j]='#';
				if(B[i][j]=='#'&&B[i][j+1]=='.')
				{
					if(A[i][j+1]=='.') B[i][j+1]='#';
					else if(i+1!=h-1) B[i+1][j]='#';
				}
			}
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(i==h-1) A[i][j]='#';
			if(A[i][j]=='.') B[i][j]='#';
		}
	}
	for(int i=0;i<h;i++) printf("%s\n",A[i]);
	puts("");
	for(int i=0;i<h;i++) printf("%s\n",B[i]);
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((ll)(1e18))

using namespace std;

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

ll f(ll b, ll n){
	if (b > n){
		return n;
	} // end if
	
	return f(b, n/b) + (n % b);
}

ll solve(ll n, ll s){
	if (n == s){
		return n + 1LL;
	} // end if

	ll ans = INF;
	for (ll b = 2LL; b <= sqrt(n); ++b){
		if (f(b,n) == s){
			ans = min(ans, b);
		} // end if
	} // end for

	for (ll p = 1LL; p < sqrt(n); ++p){
		ll b = (n - s) / p + 1LL;
		if (b < 2LL) continue;
		if (f(b,n) == s){
			ans = min(ans, b);
		} // end if
	} // end for

	return (ans == INF ? -1 : ans);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, s; cin >> n >> s;

	ll res = solve(n,s);

	cout << res << endl;

	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;

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

int main(){
    int n;
    cin >> n;
    ll pp = 1000000007;
    vector<int> A(n);
    ll sum = 0;

    rep(i,n){
        cin >> A[i];
        sum += A[i];
        sum %= pp;
    }

    ll ans = sum * sum % pp;

    rep(i,n){
        ans -= (ll)A[i] * A[i] % pp;
        if(ans < 0) ans += pp;
    } 

    ans *= (pp+1) /2;
    ans %= pp;
    cout << ans << endl;
}

Measured memory_bytes: 4028
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]
#CW = [list(map(int, list(input()))) for _ in range(H)]


N = int(input())
c = list(input())
ans = 0
l = 0
r = N-1

while True:
  if(l>=r):
    break
  if(c[l]=="R"):
    l+=1
    continue
  elif(c[r]=="W"):
    r-= 1
    continue
  else:
    l+=1
    r-=1
    ans+=1
    continue

print(ans)


Measured memory_bytes: 76844
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

ans = [0, 0, 0]
for i in p:
    if i <= a:
        ans[0] += 1
    elif i <= b:
        ans[1] += 1
    else:
        ans[2] += 1
print(min(ans))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll n; cin >> n;
    ll a[n]; rep(i, n) cin >> a[i];
    vector<ll> sum(n + 2, 0);
    for(int i = n - 1; i >= 0; --i) {
        sum[i] = (sum[i + 1] + a[i]) % MOD;
    }
    ll ans = 0;
    rep(i, n - 1) {
        ans = (ans + a[i] * sum[i + 1]) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6420
N=int(input())
A=[int(x) for x in input().split()]
ma=max(A)
mi=min(A)
ans=True

if ma-mi > 1:
  ans=False
elif ma==mi:
  if ma!=N-1 and ma*2 > N:
    ans=False
else:
  uniq=ma*N - sum(A)
  no_uni=N-uniq
  if no_uni==1:
    ans=False
  else:
    if uniq >= ma or 2*(ma-uniq) > no_uni:
      ans=False
if ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 13964
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353



N = int(sys.stdin.buffer.readline())
S = sys.stdin.buffer.readline().decode().rstrip()

ans = ''
for c in S:
    ans +=chr(((ord(c) + N) - ord('A')) % 26 + ord("A"))
print(ans)


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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for(int i=0; i<=A; ++i){
    for(int j=0; j<=B; ++j){
      for(int k=0; k<=C; ++k){
        int total = 500*i+100*j+50*k;
        if(total == X)++count;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int MAX_N = 100100;

int par[MAX_N];
int Rank[MAX_N];
int size;

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        Rank[i] = 0;
    }
    size = n;
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    size--;
    if (Rank[x] < Rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (Rank[x] == Rank[y]) {
            Rank[x]++;
        }
    }
}
bool same(int x, int y) {
    return find(x) == find(y);
}
PP p[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    
    vector<PP> cost;
    rep(i, N) cin >> p[i].second.first >> p[i].second.second;
    rep(i, N) p[i].first = i;
    sort(p, p + N, [](const PP &a, const PP &b) {
        return a.second.first < b.second.first;
    });
    rep(i, N - 1) {
        int c = min(abs(p[i].second.first - p[i + 1].second.first), abs(p[i].second.second - p[i + 1].second.second));
        cost.push_back({c, {p[i].first, p[i + 1].first}});
    }
    sort(p, p + N, [](const PP &a, const PP &b) {
        return a.second.second < b.second.second;
    });
    rep(i, N - 1) {
        int c = min(abs(p[i].second.first - p[i + 1].second.first), abs(p[i].second.second - p[i + 1].second.second));
        cost.push_back({c, {p[i].first, p[i + 1].first}});
    }
    int ans = 0;
    sort(cost.begin(), cost.end());
    init(N);
    rep(i, cost.size()) {
        int s = cost[i].second.first;
        int t = cost[i].second.second;
        if(!same(s, t)) {
            unite(s, t);
            ans += cost[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10736
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
vector<vector<pair<int,string>>> wr;
int n;
void dfs(int id,int right) {
	REP(i, wr[id].size()) {
		REP(j, right)
			cout << ".";
		cout << wr[id][i].second << endl;
		if (!wr[wr[id][i].first].empty()) {
			dfs(wr[id][i].first, right + 1);
		}
	}
}

int main() {
	cin >> n;
	wr.resize(n+1);
	REP(i, n) {
		int k;
		string s;
		cin >> k >> s;
		wr[k].push_back({i+1,s});
	}
	dfs(0,0);
}

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

int main(){
    int n;
    cin >> n;
    priority_queue<double, vector<double>, greater<double>> q;
    rep(i,n){
        double v;
        cin >> v;
        q.push(v);
    }
    rep(i,n-1){
        double x = q.top();
        q.pop();
        double y = q.top();
        q.pop();
        q.push((x+y)/2.0);
    }
    cout << q.top() << endl;
}

Measured memory_bytes: 3612