akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// type alias
using ll = long long;
using ull = unsigned long long;

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getMaxEffectiveBit(ull a)
{
	ll index = -1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

inline ll getSpecifiedBit(ull a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}


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

	ll N, L;
	cin >> N >> L;

	ll res = N * (2 * L + N - 1) / 2;
	if (L >= 0)
	{
		res -= L;
	}
	else if ( L + N - 1 < 0)
	{
		res -= L + N - 1;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int m; cin >> m;
	ll ans=0;
	ll now=0;
	vector<ll> d(m),c(m);
	for(int i=0;i<m;i++){
		cin >> d[i] >> c[i];
		ans+=c[i];
		now+=d[i]*c[i];
	}
	ans--;
	ans+=now/10;
	now=now/10+now%10;
	for(ll i=2;i<=18;i++){
		ans+=now/10;
		now=now/10+now%10;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,m[100001][3];
ll memo[100001][3];

ll dp(int day,int act){
	if(day == 0) return 0;
	if(memo[day][act] != -1) return memo[day][act];
	memo[day][act] = LLONG_MIN;
	for(int i=0;i<3;i++){
		if(i == act) continue;
		memo[day][act] = max(memo[day][act],
						dp(day-1,i)+m[day][i]);
	}
	return memo[day][act];
}

int main() {
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>m[i][0]>>m[i][1]>>m[i][2];
		memo[i][0] = memo[i][1] = memo[i][2] = -1;
	}
	ll ans = max(dp(n,0),max(dp(n,1),dp(n,2)));
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

int getSum(int x) {
	int res = 0;
	while(x > 0) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int ans = 10000;
	int n;
	cin >> n;
	for (int i = 1; i < n; i++)
		ans = min(ans, getSum(i) + getSum(n - i));
	cout << ans << endl;

	return 0;
}


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

set<int> alp[10],U;
map<char,int> m;
set<int>::iterator ite;

set<int> parse(string s){
  int p = 0;
  int l = s.size();
  set<int> a,b,res;

  if(!s.size())return res;
  for(int i=l-1;i>=0;i--){
    if(s[i]==')')p++;
    if(s[i]=='(')p--;
    if(!p && ('a'<=s[i] && s[i]<='z' && s[i]!='c')){
      a = parse(s.substr(0,i));
      b = parse(s.substr(i+1,l-i-1));
      if(s[i] == 'u'){
	for(ite = a.begin();ite!=a.end();ite++)res.insert(*ite);
	for(ite = b.begin();ite!=b.end();ite++)res.insert(*ite);
	return res;
      }
      if(s[i] == 'i'){
	for(ite = a.begin();ite!=a.end();ite++)
	  if(b.find(*ite)!=b.end())res.insert(*ite);
	return res;
      }
      if(s[i] == 'd'){
	for(ite = a.begin();ite!=a.end();ite++)
	  if(b.find(*ite)==b.end())res.insert(*ite);
	return res;
      }
      if(s[i] == 's'){
	for(ite = a.begin();ite!=a.end();ite++)
	  if(b.find(*ite)==b.end())res.insert(*ite);
	for(ite = b.begin();ite!=b.end();ite++)
	  if(a.find(*ite)==a.end())res.insert(*ite);
	return res;
      }
    }
  }

  if(s[0] == 'c'){
    a = parse(s.substr(1,l-1));
    for(ite = U.begin();ite!=U.end();ite++)
      if(a.find(*ite)==a.end())res.insert(*ite);
    return res;
  }
  if(s[0] == '(' && s[l-1] == ')')return parse(s.substr(1,l-2));

  return alp[m[s[0]]];
}

int main(){
  char c;
  int n;
  string str;

  while(cin >> c >> n){
    m.clear();
    for(int i=0;i<5;i++)alp[i].clear();
    U.clear();
    while(c != 'R'){
      int tmp;

      m[c] = m.size();
      for(int i=0;i<n;i++){
	cin >> tmp;
	alp[m[c]].insert(tmp);
	U.insert(tmp);
      }
      cin >> c >> n;
    }
    cin >> str;
    
    set<int> ans = parse(str);
    if(ans.empty())cout << "NULL\n";
    else{
      set<int>::iterator ansend = --(ans.end());
      for(ite = ans.begin();ite!=ansend;ite++)cout << *ite << " ";
      cout << *ansend << endl;
    }
  }
}     

Measured memory_bytes: 0
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl



int main(){
    ll n; cin >> n;
    string s;cin >> s;
    if(n>=3200)cout << s << endl;
    if(n<3200)cout << "red" << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
bool a[22][22];
void solve(){
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            char x;
            cin >> x;
            if (x == '.') a[i][j] = 1;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (!a[i][j]) continue;
            vector<vb> used(n+2, vb(m+2, 0));
            queue<pair<pii, int>> q;
            q.push({{i, j}, 0});
            used[i][j] = true;
            int mx = 0;
            while (!q.empty()) {
                auto t = q.front();q.pop();
                mx = max(mx, t.se);
                int x = t.fi.fi;
                int y = t.fi.se;
                if (a[x+1][y] && !used[x+1][y]) {
                    used[x+1][y] = true;
                    q.push({{x+1, y}, t.se + 1});
                }
                if (a[x][y+1] && !used[x][y+1]) {
                    used[x][y+1] = true;
                    q.push({{x, y+1}, t.se + 1});
                }
                if (a[x-1][y] && !used[x-1][y]) {
                    used[x-1][y] = true;
                    q.push({{x-1, y}, t.se + 1});
                }
                if (a[x][y-1] && !used[x][y-1]) {
                    used[x][y-1] = true;
                    q.push({{x, y-1}, t.se + 1});
                }
            }
            ans = max(ans, mx);
        }
    }
    cout << ans;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test(t) int t;cin>>t;while(t--)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define rforn(i,b,a) for(int i=b-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl;

const int MOD = 1e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	vector<int> A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	int i=1;
	int p=0;
	for(int j=0;j<n;j++)
	{
		if(A[j]==i) i++;
		else p++;
	}	
	if(p==n) cout<<-1<<endl;
	else cout<<p<<endl;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, a, b;
  cin >> n >> a >> b;
  int wa = a + b;

  string s;
  cin >> s;
  rep(i, 0, s.size()) {
    if (s[i] == 'a' && wa > 0) {
      cout << "Yes\n";
      --wa;
    } else if (s[i] == 'b' && wa > 0 && b > 0) {
      cout << "Yes\n";
      --wa, --b;
    } else {
      cout << "No\n";
    }
  }
  return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
void chkax (int &x, int y) { x = max (x, y); }
void chkin (int &x, int y) { x = min (x, y); }
int n;
int a[200005], b[200005], id[200005];
int ama, ami = inf, bma, bmi = inf;
int dma, dmi = inf;
int cmp (int x, int y) {
	return a[x] < a[y];
}
int main () {
    scanf ("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf ("%d %d", &a[i], &b[i]);
        if (a[i] > b[i]) swap(a[i], b[i]);
        id[i] = i;
        chkax (ama, a[i]), chkin (ami, a[i]);
        chkax (bma, b[i]), chkin (bmi, b[i]);
    }
    long long ret = (long long)(ama - ami) * (bma - bmi);
    sort (id+1, id+n+1, cmp);
    for (int i = 1; i <= n; i++) {
        chkax (dma, b[id[i]]), chkin (dmi, b[id[i]]);
        ret = min (ret, (long long)(max(dma, a[id[n]]) - min(dmi, a[id[i+1]])) * (bma - ami));
    }
    printf ("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 2560
function Main(input) {
    var input_arr = input.split("\n");
    // var input_arr_line0 = input_arr[0].split(" ");
    var s = input_arr[0];
    if (s <= "2019/04/30") {
        console.log("Heisei")
    } else {
        console.log("TBD")
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
from collections import deque
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)
visited=[0]*n
def bfs(s):
    q=deque([s])
    visited[s]=1
    while q:
        x=q.popleft()
        for nx in edge[x]:
            if visited[nx]==0:
                visited[nx]=1
                q.append(nx)
    return
ans=0
for s in range(n):
    if visited[s]==0:
        bfs(s)
        ans+=1
print(ans-1)

Measured memory_bytes: 26592
package main

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

func main() {
	D, T, S := ReadInt(), ReadInt(), ReadInt()
	if S*T >= D {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	int[] ar;
	boolean[] used;
	void run() {
		Scanner sc = new Scanner(System.in);
		
		for (;;) {
			ar = new int[10];
			used = new boolean[11];
			for (int i=1;i<=9;i++) {
				ar[i] = sc.nextInt();
			}
			ar[0] = sc.nextInt();
			if (ar[0] == -1) break;
			
			for (int i=0;i<10;i++) used[ar[i]] = true;
			ans = 0;
			solve(0);
			System.out.println(ans);
		}
	}
	
	void solve(int d) {
		if (ar[d] != 0) {
			exec(d);
			return;
		}

		for (int i=1;i<=10;i++) if (!used[i]) {
			used[i] = true;
			ar[d] = i;
			exec(d);
			ar[d] = 0;
			used[i] = false;
		}
	}
	
	int sum;
	int ans;
	void exec(int d) {
		if (d == 0) {
			solve(d+1);
			return;
		}
		if (d <= 3) sum = -1;
		if (d % 3 == 0 && !ok(ar[d-2], ar[d-1], ar[d])) return;
		if (d > 6 && !ok(ar[d-6], ar[d-3], ar[d])) return;
		if (d == 7 && !ok(ar[3], ar[5], ar[7])) return;
		if (d == 9 && !ok(ar[1], ar[5], ar[9])) return;
		if (d == 9) {
			ans++; return;
		}
		solve(d+1);
	}
	
	boolean ok(int a, int b, int c) {
		if (sum < 0) {
			sum = ( a + b + c ) % ar[0];
			return true;
		}
		return ( a + b + c ) % ar[0] == sum;
	}
	
	void debug(Object...os) {
		System.out.println("[" + Arrays.deepToString(os) + "]");
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		new Main().run();
	}
}

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

int main() {
  int x, n;
  cin >> x >> n;
  if(n == 0) cout << x << endl;
  else {
  vector<int> v(105);
  for(int i = 0; i < 105; i++) {
    v.at(i) = i + 1;
  }
  for(int i = 0; i < n; i++) {
    int p;
    cin >> p;
    v.at(p - 1) = 10000;
  }
  v.erase(remove(v.begin(), v.end(), 10000), v.end());
  int ans = 100;
  for(int i = 0; i < 105 - n; i++) {
    int a = 0;
    if(x > v.at(i)) a = (x - v.at(i));
    else a = (v.at(i) - x);
    if(ans == a) {
      if(ans < x) cout << v.at(i - 1) << endl;
      else cout << 0 << endl;
      break;
    }
    else if(ans > a) ans = a;
    else {
      if(ans < x) cout << v.at(i - 1) << endl;
      else cout << 0 << endl;
      break;
    }
  }
  }
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N;
  cin>>N;
  vector<ll> col;
  for(ll i = 0LL; i < N; i++) {
    ll x;
    cin>>x;
    if(i==0) col.push_back(x);
    else if(*(col.end()-1)!=x) col.push_back(x);
  }
  unordered_map<ll,ll> m;
  ll l = col.size();
  vector<ll> dp(l+1,1LL);
  for(ll i = 0; i < l; i++) {
    dp[i+1]=dp[i];
    if(m[col[i]]!=0) dp[i+1]=(dp[i+1]+dp[m[col[i]]])%mod;
    m[col[i]]=i+1;
  }
  cout<<dp[l]<<endl;
}

Measured memory_bytes: 11632
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	N, _ := nextInt(), nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}
	maxProfit := 0
	maxCnt := 0
	maxA := A[N-1]
	for i := N - 2; i >= 0; i-- {
		profit := max(0, maxA-A[i])
		if maxProfit < profit {
			maxProfit = profit
			maxCnt = 1
		} else if maxProfit == profit {
			maxCnt++
		}
		maxA = max(maxA, A[i])
	}
	out(maxCnt)
}


Measured memory_bytes: 5504
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.util.Arrays;

/*Question
n ????????´??°???????????°??? S ??¨???q ????????°????????´??°???????????°??? T ??????????????????T ?????????????????´??°????????§ S ?????????????????????????????° C ???????????????????????°???????????????????????????????????? 
*/

/*Input
???????????? n??????????????? S ?????¨??? n ????????´??°??????????????? q??????????????? T ?????¨??? q ????????´??°???????????????????????? 
*/

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		//??\???

		int n = Integer.parseInt(br.readLine());
		String[] tmp = br.readLine().split(" ");
		int[] s = new int[n];
		for (int a = 0;a < n;a++){
			s[a] = Integer.parseInt(tmp[a]);
		}
		n = Integer.parseInt(br.readLine());
		tmp = br.readLine().split(" ");
		int[] t = new int[n];
		for (int a = 0;a < n;a++){
			t[a] = Integer.parseInt(tmp[a]);
		}

		//?¨??????¨
		int len; //??????????????????????¨????
		int b = 0;

		//????????¨ - ?????´?????????????????°????¨????
		int count = 0;

		//??´?????????
		Arrays.sort(s);
		Arrays.sort(t);

		/*????????????????????????
		/????????????????????´?????\?????§??¢?´¢??????????????????????????¨??????????????????????????£???
		*/
		for (int a = 0;a < t.length;a++){
			while (b < s.length) {
				if (t[a] < s[b]) {
					break;
				} else if (t[a] == s[b]) {
					count++;
					len = b;
					break;
				}
				b++;
			}
		}

		//??????
		System.out.println(count);
	}
}

Measured memory_bytes: 28128
#include <stdio.h>
#include <stdlib.h>

int bubble_sort(int *data, int size){
	int swap_count = 0;
	int swap_done;
	int i;
	int tmp;

	swap_done=1;
	while(swap_done){
		swap_done=0;
		for(i=size-1;i>=1;i--){
			if( data[i] < data[i-1] ){
				tmp = data[i];
				data[i] = data[i-1];
				data[i-1] = tmp;
				swap_done = 1;;
				swap_count++;
			}
		}
	}

	return swap_count;
}

int main(int argc, char** argv){
	int n,*data;
	int i;
	int swap_count;

	// Input
	scanf("%d",&n);
	data = malloc(sizeof(int)*n);
	for(i=0;i<n;i++){
		scanf("%d",data+i);
	}
	
	// Sort
	swap_count = bubble_sort(data,n);
	
	// Output
	printf("%d",data[0]);
	for(i=1;i<n;i++){
		printf(" %d",data[i]);
	}
	printf("\n");
	printf("%d\n",swap_count);

	// Release
	free(data);

	return 0;
}

Measured memory_bytes: 604
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
        Deck deck = new Deck();
        Scanner input = new Scanner(System.in);
        int number = Integer.parseInt(input.nextLine());
        for(int i = 0; i < number; i++){
            String line = input.nextLine();
            String suit = line.substring(0,1);
            String card = line.substring(2);
            deck.removeCard(suit, card);
        }
        deck.display();
    }
}

class Deck {
    public HashMap<String, List<String>> deck;
    public String[] suits;
    public Deck(){
        this.deck = new HashMap<>();
        this.suits = new String[]{"S","H","C","D"};

        // Add cards set with each suit
        for(String suit : suits){
            List<String> cards = new ArrayList<>();
            // Build cards
            for(int i = 1; i < 14; i++){
                cards.add(String.valueOf(i));
            }
            this.deck.put(suit, cards);
        }
    }

    public void removeCard(String suit, String card){
        this.deck.get(suit).remove(card);
    }

    public void display(){
        for(String suit : this.suits){
            if(this.deck.get(suit).size() != 0){
                for(String i: this.deck.get(suit)){
                    System.out.println(suit + " " + i);
                }
            }
        }
    }
}


Measured memory_bytes: 26240
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String x = Console.ReadLine();
            //???????????????????????£??\
            String[] array = x.Split(' ');

            //??°???????????´????????£??\
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int c = int.Parse(array[2]);

            int[] temp = new int[3] { a, b, c };


            for (int i = 0; i < 3; i++)
            {
                for (int j = 2; j > i; j--)
                {
                    if (temp[i] > temp[j])
                    {
                        int w = temp[i];
                        temp[i] = temp[j];
                        temp[j] = w;
                    }
                }
            }

            Console.WriteLine(temp[0] + " " + temp[1] + " " + temp[2]);

         }
    }
}

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

string check(string s) {
  int i, j, count = 0, n = s.size();
  if (s[0] != 'A') {
    return "WA";
  }
  for (i = 1; i < n; i++) {
    if (s[i] == 'C') {
      j = i;
      count++;
    }
  }
  if (count != 1) {
    return "WA";
  } else if (j == 1 || j == n - 1) {
    return "WA";
  } else {
    for (i = 1; i < n; i++) {
      if (i == j) {
        continue;
      }
      if (s[i] >= 'A' && s[i] <= 'Z') {
        return "WA";
      }
    }
  }
  return "AC";
}

int main() {
  string s;
  cin >> s;
  cout << check(s) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int K, X; cin >> K >> X;
    int left = max(X - K + 1, -1000000);
    int right = min(X + K - 1, 1000000);
    for (int x = left; x <= right; ++x)
    {
        cout << x << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <sstream>
using namespace std;
int main()
{
    int c=0;
    string a;
    getline(cin,a);
    if(a[0]=='1'){
        c++;
    }
    if(a[1]=='1'){
        c++;
    }
    if(a[2]=='1'){
        c++;
    }
    cout << c;
	
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  int n; cin >> n;
  vi a(n),b(n),x(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) x[i] = a[i] - b[i];

  ll cnt_minus = 0, cnt_plus = 0;
  rep(i,n) {
    //cout << x[i] << endl;
    if(x[i] < 0){
      cnt_minus += -x[i]/2;
    }
    else{
      cnt_plus += x[i];
    }
  }
  //cout << cnt_minus << " " << cnt_plus << endl;
  cout << (cnt_minus >= cnt_plus ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int KYR = 1, JNY, OOTJNY = 10;
  long double MRS = 1;
  int PKRN = -1;
  int OOT, TIERU;
  cin >> OOT;
  
  for(int YUNI = 0; YUNI < OOT; YUNI++){
    cin >> JNY;
    if(KYR < 1000000000000000001){
      KYR *= JNY;
      MRS *= JNY;
    }
    else if(JNY == 0){
      KYR *= JNY;
      MRS *= JNY;
      break;
    }
  }
  
  if(MRS > 1000000000000000000){
    cout << -1 << endl;
  }
  
  else{
  cout << KYR << endl;;
  }
}

Measured memory_bytes: 3620
moji = str(input())
a = list(moji)
cost = 700
if len(a) == 3:
    for item in a:
        if item == "o":
            cost += 100
        elif item == "x":
            continue
        else:
            print('hoge!')
            exit()
    print(cost)
else:
    print('hoge!')

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

signed main(){
  
  string s;
  cin>>s;
  
  int ans = 0;
  
  int d = 0;
  
  for(int i=0;i<(int)s.size();i++){
    
    if( d == 0 && s[i] == 'R' ){
      
      int cnt[4] = {};
      int dir = 0;
      
      for(int j=i;j<(int)s.size();j++){
	
	if( s[j] == 'R' ) dir = ( dir + 1 ) % 4;
	else dir = ( dir + 3 ) % 4;
	
	cnt[dir]++;
	
	if( dir == 0 ){

	  if( s[j] == 'R' ){
	    
	    int flag = 1;
	  
	    for(int k=1;k<=3;k++){
	      if( cnt[k] == 0 ) flag = 0;
	    }

	    ans += flag;
	    
	  }
	  
	  break;
	}
	
      }
      
    }
    
    if( s[i] == 'R' ) d = ( d + 1 ) % 4;
    else d = ( d + 3 ) % 4;
    
  }

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



Measured memory_bytes: 3232
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		UnionFind uf = new UnionFind(n);
		for(int i = 0; i < m; i++){
		    int x = sc.nextInt() - 1;
		    int y = sc.nextInt() - 1;
		    int z = sc.nextInt();
		    
		    uf.union(x, y);
		}
		
		// 計算
		int result = 0;
		HashSet<Integer> set = new HashSet<Integer>();
		for(int i = 0; i < n; i++){
		    set.add(uf.find(i));
		}
		result = set.size();
		
		// 出力
        System.out.println(result);
	}
}

class UnionFind {
    int[] parent;
    int[] rank;
    
    UnionFind(int n){
        this.parent = new int[n];
        this.rank = new int[n];
        for(int i = 0; i < n; i++){
            parent[i] = i;
            rank[i] = 0;
        }
    }
    
    public int find(int i){
        if(i == parent[i]) return i;
        parent[i] = find(parent[i]);
        return parent[i];
    }
    
    public void union(int x, int y){
        int xRoot = find(x);
        int yRoot = find(y);
        if(rank[xRoot] < rank[yRoot]){
            parent[xRoot] = yRoot;
        }else if(rank[xRoot] > rank[yRoot]){
            parent[yRoot] = xRoot;
        }else{
            parent[yRoot] = xRoot;
            rank[xRoot]++;
        }
    }
    
    public boolean same(int x, int y){
        return find(x) == find(y);
    }
    
}

Measured memory_bytes: 92680
#include <iostream>
using namespace std;
int main(void){
	int l,a,b,c,d,p,q,ans;
	cin>>l>>a>>b>>c>>d;
	p=a/c;a=a%c;p+=(a)?1:0;
	q=b/d;b=b%d;q+=(b)?1:0;
	cout<<l-((p>q)?p:q)<<endl;
	return 0;
}

Measured memory_bytes: 1160
n, m = map(int, input().split())
gate = []
l, r = map(int, input().split())
for i in range(1, m):
    m, s = map(int, input().split())
    if l < m:
        l = m
    if s < r:
        r = s
print(len([i for i in range(l, r + 1)]))

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;
int N;

ll solve(vi arr) {
	F0R(i, N) arr[i] += i;
	map<int, ll> occ;
	ll ans = 0;
	F0R(i, N) {
		int req = 2 * i - arr[i];
		ans += occ[req];
		occ[arr[i]]++;
	}
	return ans;
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];
	ll ans = 0;
	ans += solve(arr);
	print(ans);
}

Measured memory_bytes: 27372
#include<bits/stdc++.h>
#define rg register
#define il inline
#define cn const
#define gc getchar()
#define fp(i,a,b) for(rg int i=(a),ed=(b);i<=ed;++i)
using namespace std;
typedef cn int cint;
typedef long long LL;
il int rd(){
   rg int x(0),f(1); rg char c(gc);
   while(c<'0'||'9'<c){ if(c=='-') f=-1; c=gc; }
   while('0'<=c&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=gc;
   return x*f;
}
template<typename T> il void ckmax(T &x,cn T &y){ if(x<y)x=y; }
cint maxn=200010,maxm=2010,bs=2000,mod=1000000007,inv2=500000004;

int n,maxa,maxb,a[maxn],b[maxn],f[maxm<<1][maxm<<1];
int fac[maxm<<2],inv[maxm<<2],ifac[maxm<<2];
LL ans;

il int c(cint &n,cint &m){
	return 1ll*fac[n]*ifac[m]%mod *ifac[n-m]%mod;
}

int main(){
//    freopen("sample.in","r",stdin);
	n=rd();
	fp(i,1,n){
		a[i]=rd(),b[i]=rd(),++f[bs-a[i]][bs-b[i]];
		ckmax(maxa,a[i]),ckmax(maxb,b[i]);
	}
	fp(i,bs-maxa,bs+maxa)fp(j,bs-maxb,bs+maxb){
		f[i][j]=(f[i][j]+(f[i-1][j]+f[i][j-1])%mod)%mod;
	}
	fac[0]=1; fp(i,1,maxa+maxb<<1)fac[i]=1ll*fac[i-1]*i%mod;
	inv[1]=1; fp(i,2,maxa+maxb<<1)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	ifac[0]=1; fp(i,1,maxa+maxb<<1)ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
	fp(i,1,n)ans=(ans+f[bs+a[i]][bs+b[i]]-c(a[i]+b[i]<<1,a[i]<<1)+mod)%mod;
	printf("%lld\n",ans*inv2%mod);
	return 0;
}

Measured memory_bytes: 65024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		long[][] a=new long[n][];
		long c=int.MaxValue,d=0,e=0;
		for(int i = 0;i<n;i++) {
			a[i]=sc.La;
			if(a[i][0]>a[i][1]){a[i][0]^=a[i][1];a[i][1]^=a[i][0];a[i][0]^=a[i][1];}
			c=Math.Min(c,a[i][1]);
			e=Math.Max(e,a[i][1]);
		}
		Array.Sort(a,Ca);
		long ans=(a[n-1][0]-a[0][0])*(e-c);
		c=a[0][1];
		d=a[0][1];
		for(int i = 1;i<n;i++) {
			ans=Math.Min(ans,(e-a[0][0])*(Math.Max(d,a[n-1][0])-Math.Min(c,a[i][0])));
			c=Math.Min(c,a[i][1]);
			d=Math.Max(d,a[i][1]);
		}
		Console.WriteLine(ans);
	}
	static int Ca(long[] a,long[] b){
		if(a[0]>b[0]){return 1;}
		else if(a[0]<b[0]){return -1;}
		else if(a[1]>b[1]){return 1;}
		else if(a[1]<b[1]){return -1;}
		else{return 0;}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}


Measured memory_bytes: 30236
a, b = map(int, input().split())

al = []
for i in range(1, 10001):
    if int(i * 0.08) == a:
        al.append(i)
    elif int(i * 0.08) > a:
        break

bl = []
for i in range(1, 10001):
    if int(i * 0.1) == b:
        bl.append(i)
    elif int(i * 0.1) > b:
        break

for aa in al:
    for bb in bl:
        if aa == bb:
            print(aa)
            exit(0)
else:
    print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>
#include <stdlib.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> hoge(n);
  for (int i = 0; i < n; i++){
    cin >> hoge.at(i);
  }
  
  int min = 100000000;
  for (int i = 0; i < n - 1; i++){
    int left = accumulate(&hoge[0], &hoge[i + 1], 0);
    int right = accumulate(&hoge[i + 1], &hoge[n], 0);
    // cout << "left : " << left << endl;
    // cout << "right : " << right << endl;
    if (abs(left - right) <= min){
      min = abs(left - right);
    }
  }
  cout << min << endl;
}

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

int t[16][17];
int dp[1<<16];//bitの立っているステージを攻略する最短時間
int main()
{
	while(1)
	{
		int n;
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n+1;j++)
				cin>>t[i][j];
		}
		fill(dp,dp+(1<<16),1e8-1);
		dp[0]=0;

		for(int i=1;i<(1<<n);i++)
		{
			bool bit[16];
			fill(bit,bit+16,false);
			int tmp=i;
			for(int j=0;j<n;j++)
			{
				if((tmp&(1<<j))>0)
					bit[j]=true;
			}

			for(int j=0;j<n;j++)
			{
				if(!bit[j])
					continue;
				
				dp[i]=min(dp[i],dp[i&~(1<<j)]+t[j][0]);
				for(int k=0;k<n;k++)
				{
					if(k==j)
						continue;
					
					if(!bit[k])
						continue;
					
					dp[i]=min(dp[i],dp[i&~(1<<j)]+t[j][k+1]);
				}
			}
		}
		/*
		for(int i=0;i<(1<<n)-1;i++)
			cerr<<dp[i]<<endl;
			*/
		cout<<dp[(1<<n)-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3340
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
using namespace std;
#define LL long long
#define PP pair<int,int>
#define TT tuple<int,int,int>

const LL mod=998244353;
LL N,A,B,K;
LL kai[300010];
LL F[300010];
LL ans;

LL fer(LL x){
    LL add=(kai[N]*F[x])%mod;
    add*=F[N-x];
    add%=mod;
    return add;
}

void solve(LL R,LL G){
    if(R>N||G>N)return;
    LL add=fer(R);
    add*=fer(G);
    ans+=add%mod;
    ans%=mod;
}

LL fermat(LL x, int y) {
	if (y == 0)return 1;
	if (y == 1)return x;
	LL F = fermat(x, y / 2);
	F *= F;
	F %= mod;
	if (y % 2)return(F*x) % mod;
	else return F;
}

void init(int n){
    kai[1]=1;
    for(int i=2;i<=N;i++){
        kai[i]=kai[i-1]*i%mod;
    }
    F[N]=fermat(kai[N],mod-2);
    for(int i=N;i>0;i--){
        F[i-1]=(F[i]*i)%mod;
    }
}

int main(){
    cin>>N>>A>>B>>K;
    init(N);
    LL g=__gcd(A,B);
    LL r=K/A;
    LL b=(K-A*r)/B;
    while(r*A+b*B!=K){
        r--;
        b=(K-A*r)/B;
        if(r<0)break;
    }
    while(r>=0){
        solve(r,b);
        r-=B/g;
        b+=A/g;

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

Measured memory_bytes: 4992
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n;
    cin >> n;
    
    pair<pair<string, int>, int> rest[n];
    rep(i,n){
        string s;
        int p;
        cin >> s >> p;
        rest[i] = {{s, -p}, i + 1};
    }
    sort(rest, rest + n);
    
    rep(i,n) cout << rest[i].second << ln;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ara[26];
int main()
{
    string s;
    cin>>s;
    int n=s.length(),i;
    for(i=0;i<n;i++){
        ara[s[i]%97]++;
    }
    for(i=0;i<26;i++){
        if(ara[i]%2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	
	vector<ll> wa(N+1);
	wa[0] = 0;
	for(int i=1; i<=N; i++) wa[i] = wa[i-1] + A[i-1];

	
	combination comb(N);

	mint ans(0);
	for(int i=0; i<=N-2 - (K-2); i++){

		mint nCk=comb(N-2-i,K-2);
		mint MAXwa(wa[N] - wa[N-1-i]);
		mint MINwa(wa[i+1] - wa[0]);

		ans += nCk * (MAXwa - MINwa);
		//cout << " nCk: " << nCk << " MAXwa: " << MAXwa.x << " MINwa: " << MINwa.x << " ans: " << ans.x << endl;
	}


	cout << ans.x << endl;
	
}


Measured memory_bytes: 6360
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(10001, 0);
  rep(x, 1, 100) {
    rep(y, 1, 100) {
      rep(z, 1, 100) {
        if(x*x+y*y+z*z+x*y+y*z+z*x < 10002)
        v[x*x+y*y+z*z+x*y+y*z+z*x]++;
      }
    }
  }
  rep(i, 1, n+1) cout << v[i] << "\n";
}

Measured memory_bytes: 3632
n, m = map(int, input().split())  # 複数数値入力
s = list()

for i in range(m):
    tmp = list(map(int, input().split()))  # 複数数値入力(リスト格納)
    s.append(tmp[1:])

p = list(map(int, input().split()))  # 複数数値入力(リスト格納)

# print(s)
ans = 0
# bit全探索
for i in range(2 ** n):
    flg = 0
    onswitchkosuu = [0] * m
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # j番目のスイッチがついているならここに入るよ
            for k in range(m):  # この中で各電球についてj番目のスイッチと接続されているかを確認
                if j+1 in s[k]:
                    onswitchkosuu[k] += 1

   # print(onswitchkosuu)    # これには各電球について何個のスイッチが押されているかが書いてある
    # この下で各電球がつくのかどうかを検証

    for j in range(m):
        if onswitchkosuu[j] % 2 != p[j]:
            flg = 1

    if flg == 0:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;

    if (s.size() > 3 && s.substr(0, 4) == "YAKI")
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  a = int(input())
  b = int(input())
  c = int(input())
  x = int(input())
  cnt = 0
  """for i in range(x//500 +1):
    m500 = 0
    mob = x
    if x//500 != 0:
      m500 += mob//500
      mob -=m500 * 500
    else:
      pass
    for j in range(mob//100 + 1):
      m100 = 0
      mob = x - m500 * 500
      if mob//100 != 0:
        m100 += mob//100
        mob -=m100*100
      else:
        pass
      # c = x - a - b
      mob = x - m100*100 - m500*500
      m50 = mob//50
      
      if 0 <= m500 <= a and 0 <= m100 <= b and 0 <= m50 <= c:
        cnt += 1"""
  for i in range(a+1):
    for j in range(b+1):
      for k in range(c+1):
        sum = 500 * i + 100 * j + 50 * k
        if sum == x:
          cnt += 1
  print(cnt)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <iostream>
static const int READMAX = 100;
using namespace std;

void read_stdin(int (&array)[READMAX], int N) {
  for (int i = 0; i < N; ++i) {
    cin >> array[i];
  }
}

void printArray(int (&array)[READMAX], int N) {
  for (int i = 0; i < N - 1; ++i) {
    cout << array[i] << " ";
  }
  cout << array[N - 1] << endl;
}

void insertionSort(int (&A)[READMAX], int N) {
  for (int i = 1; i < N; ++i) {
    int key = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > key) {
      A[j + 1] = A[j];
      --j;
    }
    A[j + 1] = key;
    printArray(A, N);
  }
}

int main() {
  int arr[READMAX];
  int N;
  cin >> N;
  read_stdin(arr, N);
  printArray(arr, N);
  insertionSort(arr, N);
  return 0;
}


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

diff = [None] * N

for i in range(N-1):
    diff[i] = A[i+1] - A[i]

diff[N-1] = K - A[N-1] + A[0]

max_diff = max(diff)
answer = sum(diff) - max(diff)
print(answer)

Measured memory_bytes: 26444