akhauriyash/Code-Regression huggingface dataset:
n=int(input())
c=[]
d=[]
for a,b in zip(map(int,input().split()),map(int,input().split())):
  e=a-b
  if e<0:
    c.append(e)
  else:
    d.append(e)
if sum(c)+sum(d)<0:
  print(-1)
  exit()

cs=-sum(c)
d.sort(reverse=True)
sm=0
i=0
while sm<cs:
  sm+=d[i]
  i+=1
print(i+len(c))



Measured memory_bytes: 27432
n = int(input())
w = list(map(int, input().split()))
ans = 1000

for i in range(n):
    s1 = 0
    s2 = 0
    for j in range(i):
        s1 += w[j]
    for k in range(i, n):
        s2 += w[k]
    if(ans > abs(s1 - s2)):
        ans = abs(s1 - s2)

print(ans)


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

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

long long mod = 1000000007;

long long int mod_pow(long long int x, long long int n, long long int p) {
    long long int res = 1;

    while (n > 0) {
        if (n & 1)
            res = res * x % p;
        x = x * x % p;
        n >>= 1;
    }
    return res;
}

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

    long long n, a, b;
    cin >> n >> a >> b;

    long long ans = 1;

    ans = mod_pow(2, n, mod) - 1;

    long long x = 1;
    long long y = 1;
    for (long long int i = 1; i <= b; i++) {
        x = x * (n - i + 1) % mod;
        y = y * i % mod;

        if (i == a || i == b) {
            long long t = x * mod_pow(y, mod - 2, mod) % mod;
            ans = (ans - t) % mod;

            if (ans < 0)
                ans += mod;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <string>
#include <sstream>
#include <iomanip>
#include <functional>
 
using namespace std;
 
 
#define sort(arr) sort(begin(arr), end(arr))

using ll = long long;

#define rep(n) for(int _i=0; _i<n; _i++)
int main() {

    int n;
    cin >> n;
    int curr = 1;
    ll ret;
    cin >> ret;
    --ret;


    rep(n-1){
        int x;
        cin >> x;
        //cout << x << " " << curr << " ";
        if(x == curr+1){
            ++ curr;
        }
        else if(x > curr+1){
            ret += (x - curr - 2)/(curr+1) + 1;
        }
       // cout << ret << endl;
    }
    cout << ret << endl;
   
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N+1), B(N);
    Rep (i, N+1) {
        cin >> A[i];
    }
    Rep (i, N) {
        cin >> B[i];
    }

    ll ans = 0;
    Rep (i, N) {
        if (B[i] <= A[i]) {
            ans += B[i];
        } else {
            ans += A[i];
            B[i] -= A[i];
            if (B[i] <= A[i+1]) {
                ans += B[i];
                A[i+1] -= B[i];
            } else {
                ans += A[i+1];
                A[i+1] = 0;
            }
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;
const int MAXN = 200050;
int n, q, A, lst;
LL tag, mn[MAXN<<2][2];
void build(int i, int l, int r) {
	if(l == r) {
		mn[i][0] = abs(l-A) - l;
		mn[i][1] = abs(l-A) + l;
		return;
	}
	int mid = (l + r) >> 1;
	build(i<<1, l, mid);
	build(i<<1|1, mid+1, r);
	mn[i][0] = min(mn[i<<1][0], mn[i<<1|1][0]);
	mn[i][1] = min(mn[i<<1][1], mn[i<<1|1][1]);
}
LL qry(int i, int l, int r, int x, int y, int o) {
	if(x <= l && r <= y) return mn[i][o];
	int mid = (l + r) >> 1; LL re = 1ll<<60;
	if(x <= mid) re = min(re, qry(i<<1, l, mid, x, y, o));
	if(y > mid) re = min(re, qry(i<<1|1, mid+1, r, x, y, o));
	return re;
}
void upd(int i, int l, int r, int x, LL val) {
	if(l == r) {
		if(val < mn[i][0]+l+tag) {
			mn[i][0] = val-tag-l;
			mn[i][1] = val-tag+l;
		}
		return;
	}
	int mid = (l + r) >> 1;
	if(x <= mid) upd(i<<1, l, mid, x, val);
	else upd(i<<1|1, mid+1, r, x, val);
	mn[i][0] = min(mn[i<<1][0], mn[i<<1|1][0]);
	mn[i][1] = min(mn[i<<1][1], mn[i<<1|1][1]);
}
LL ans;
void dfs(int i, int l, int r) {
	if(l == r) {
		ans = min(ans, mn[i][0]+l+tag);
		return;
	}
	int mid = (l + r) >> 1;
	dfs(i<<1, l, mid);
	dfs(i<<1|1, mid+1, r);
}
int main () {
	scanf("%d%d%d%d", &n, &q, &lst, &A);
	build(1, 1, n);
	for(int i = 1, x; i <= q; lst = x, ++i) {
		scanf("%d", &x);
		LL val = qry(1, 1, n, 1, x, 0) + tag + x;
		if(x < n) val = min(val, qry(1, 1, n, x+1, n, 1) + tag - x);
		tag += abs(x-lst);
		upd(1, 1, n, lst, val);
	}
	ans = 1ll<<60;
	dfs(1, 1, n);
	printf("%lld\n", ans);
}

Measured memory_bytes: 10368
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int[] h = new int[N];
        for (int i=0; i<N; i++) {
            h[i] = Integer.parseInt(scanner.next());
        }
        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(h[1]-h[0]);
        int a = 0;
        int b = 0;
        for (int i=2; i<N; i++) {
            a = dp[i-2] + Math.abs(h[i]-h[i-2]);
            b = dp[i-1] + Math.abs(h[i]-h[i-1]);
            if (a > b) {
                dp[i] = b;
            } else {
              dp[i] = a;  
            }
        }
        System.out.println(dp[N-1]);
    } 
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

//-----------------------------------------------------------------------------

int n;
map<ll,ll> mp;
const int mod=1e9+7;

void calc(ll m) {
	ll a=2;
	while (m>=a*a) {
		if(m%a==0) {
			mp[a]++,m/=a;
		}
		else a++;
	}
	mp[m]++;
}

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

	cin>>n;
	if(n==1) {
		cout<<1<<endl;
		return 0;
	}
	FOR(i,2,n+1) {
		calc(i);
	}

	ll ans=1;
	for(auto x:mp) {
		(ans*=(x.se+1))%=mod;
	}
	cout<<ans%mod<<endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
an = list(map(int, input().split()))
 
def distinct_or_not(an):
    an_dict = {}
    for a in an:
        if a in an_dict:
            return False
        else:
            an_dict[a] = 1
    return True
  
if distinct_or_not(an):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 32948
n, k = map(int, input().split())
A = list(map(int, input().split()))
ans1 = 0
ans2 = 0
mod = 10 ** 9 + 7
for i, a in enumerate(A):
    for j, b in enumerate(A):
        if a > b:
            if i < j:
                ans1 += 1
                ans2 += 1
            else:
                ans2 += 1

print(((ans1 * k) % mod + ((ans2 * ((k * (k - 1)) // 2) % mod)) % mod) % mod)



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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n, vector<int>(0));
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    vector<int> sign(n, -1);
    queue<int> q;
    vector<int> dist(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int nv : graph[v]) {
            if (dist[nv] != -1) continue;
            sign[nv] = v;
            dist[nv] = dist[v] + 1;
            q.push(nv);
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; ++i) {
        cout << sign[i] + 1 << endl;
    }
}


Measured memory_bytes: 10680
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if X == 500 * a + 100 * b + 50 * c:
                count = count + 1
print(count)

Measured memory_bytes: 9104
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int mo=998244353;
const int N=1e6+10;
long long jc[N],ny[N];
long long ksm(long long x,int y)
{
	x=x%mo;
	long long v=1;
	while (y)
	{
		if (y&1) v=v*x%mo;
		x=x*x%mo;
		y=y>>1;
	}
	return v;
}
long long calc(int x,int y)
{
	return jc[x]*ny[y]%mo*ny[x-y]%mo;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if (n<m) swap(n,m);
	jc[0]=1;
	for (int i=1;i<=n+m;i++) jc[i]=jc[i-1]*i%mo;
	ny[n+m]=ksm(jc[n+m],mo-2);
	for (int i=n+m-1;i>=1;i--) ny[i]=ny[i+1]*(i+1)%mo;
	ny[0]=1;
	long long ans=0;
	for (int i=1;i<=m;i++) ans=(ans+calc(2*i,i)*calc(n+m-2*i,m-i))%mo;
	ans=((ans*ksm(2*calc(n+m,m),mo-2)+n)%mo+mo)%mo;
	printf("%lld\n",ans);
}

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

using namespace std;

int main(){
  int n;
  int cntt=0,cnth=0;
  string t,h;
  
  cin >> n;

  for(int i=0;i < n;i++)
    {
      cin >> t >> h;

      if(t > h)
	{
	  cntt += 3;
	}
      else if(t < h)
	{
	  cnth += 3;
	}
      else
	{
	  cntt++;
	  cnth++;
	}
    }
  cout << cntt << " " << cnth << endl;
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    int ret=0;
    for (int i=0;i<s.size();i++)
    {
        if (s[i]==t[i])ret++;
    }
    cout<<ret<<endl;
}


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

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(size_t i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int ret = 0;
    bool alice = true;
    for(size_t i = 0; i < N; i++)
    {
        ret += alice ? a[i] : -a[i];
        alice = !alice;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    cout << "ABC" << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  N=gcd(N,K);
  Out(prime_factor(N).size()+1);
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  set<ll>st;
  rep(i,1,10)rep(j,0,10){
    st.insert(i*j);
  }
  ll n;cin>>n;
  ans1(st.count(n));
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val sc: Scanner = new Scanner(input)
    val n,x = sc.nextInt
    val m = List.fill(n)(sc.nextInt)
    (n + (x - m.sum) / m.min).toString
  }

  val tests = List(
    """3 1000
      |120
      |100
      |140""".stripMargin -> """9""",
    """4 360
      |90
      |90
      |90
      |90""".stripMargin -> """4""",
    """5 3000
      |150
      |130
      |150
      |130
      |110""".stripMargin -> "26"
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25544
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}


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

    for (;;) {
        int T; cin >> T;
        if (T == 0) break;
        vi t(T);
        REP(i, T) cin >> t[i];
        int N; cin >> N;
        vi d(N), m(N);
        REP(i, N) {
            cin >> d[i] >> m[i];
        }
        const int MAX = *max_element(ALL(d));
        vi plan(MAX, 24);
        REP(i, N) {
            chmin(plan[d[i]-1], m[i]);
        }

        vvi dp(MAX+1, vi(T, INF));
        dp[0][0] = 0;
        REP(i, MAX) {
            REP(j, T) {
                if (dp[i][j] == INF) continue;
                if (t[j] > plan[i]) continue;
                chmin(dp[i+1][0], dp[i][j] + 1);
                chmin(dp[i+1][(j+1) % T], dp[i][j]);
            }
        }
        cout << *min_element(ALL(dp[MAX])) << endl;

    }

    return 0;
}



Measured memory_bytes: 3136
#include<iostream>

using namespace std;

int main(){
    int numbers[5];
    for(int i = 0; i < 5; i++) cin >> numbers[i];
    int i;
    for(i = 0; i < 5; i++){
        if(numbers[i] == 0){
            break;
        }
    }
    cout << i+1;
    return 0;
}

Measured memory_bytes: 3612
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    A2IN(ll, s, ll, c, M);

    REP(i, 1000)
    {
        string x = to_string(i);
        if (x.size() == N)
        {
            bool ok = true;
            REP(j, M)
            {
                ok &= x[s[j] - 1] - '0' == c[j];
            }
            if (ok)
            {
                OUT(i);
                return 0;
            }
        }
    }
    OUT(-1);
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  REP(i, 3) ans += (s[i] == t[i]);
  cout << ans << endl;
  return 0;
}

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

int main(){
 long N,K;
 cin>>N>>K;
 long a,b;
 a=N%K;
 b=K-a;
 if(a<b){
     cout<<a<<endl;
 }else{
     cout<<b<<endl;
 }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,c,x;
  scanf("%d %d %d",&a,&b,&c);

   if(a>b){
    x=a;
    a=b;
    b=x;
  }
  if(b>c){
    x=b;
    b=c;
    c=x;
  }
  if(a>b){
    x=a;
    a=b;
    b=x;
  }

  printf("%d %d %d\n",a,b,c);
  
  return 0;

}



Measured memory_bytes: 2064
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

bool Isprime(int num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

int main() {
	int q; cin >> q;
	int l, r;
	int c[100001]; fill(c, c + 100001, 0);
	for (int i = 1; i <= 100000; i++) {
		if (Isprime(i) && Isprime((i + 1) / 2)) {
			c[i] = 1;
		}
	}
	for (int i = 2; i < 100001; i++) {
		c[i] += c[i-1];
	}
	int ans[100010];
	for (int i = 0; i < q; i++) {
		cin >> l >> r;
		ans[i]=(c[r] - c[l - 1]);
	}
	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}
}

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

int power(int a,int b) {
	long long int mul=1;
	while(b>0) {mul*=a; b--;}
	return mul;
}

int main() {
	int n,a,d=0,sum=0; cin>>n;
	a=n;
	while(a>0) { a/=10; d++; }
	if(d%2==0)  d--;
	else {
		sum = n-(power(10,d-1))+1;
		d-=2;
	}
  while(d>0) { sum+=9*power(10,d-1); d-=2;}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from operator import itemgetter

rl = sys.stdin.readline


def solve():
    N, W = map(int, rl().split())
    w1, w2, w3, w4 = [[0, 0]], [[0, 0]], [[0, 0]], [[0, 0]]
    w1.append(list(map(int, rl().split())))
    min_w = w1[1][0]
    for _ in range(N - 1):
        w, v = map(int, rl().split())
        d = w - min_w
        if d == 0:
            w1.append([w, v])
        elif d == 1:
            w2.append([w, v])
        elif d == 2:
            w3.append([w, v])
        else:
            w4.append([w, v])
    w1.sort(key=itemgetter(1), reverse=True)
    w2.sort(key=itemgetter(1), reverse=True)
    w3.sort(key=itemgetter(1), reverse=True)
    w4.sort(key=itemgetter(1), reverse=True)
    
    ans = 0
    for i in range(len(w1)):
        w_tmp1, v_tmp1 = 0, 0
        for j in range(i):
            w_tmp1 += w1[j][0]
            v_tmp1 += w1[j][1]
        for j in range(len(w2)):
            w_tmp2, v_tmp2 = w_tmp1, v_tmp1
            for k in range(j):
                w_tmp2 += w2[k][0]
                v_tmp2 += w2[k][1]
            for k in range(len(w3)):
                w_tmp3, v_tmp3 = w_tmp2, v_tmp2
                for l in range(k):
                    w_tmp3 += w3[l][0]
                    v_tmp3 += w3[l][1]
                for l in range(len(w4)):
                    w_tmp4, v_tmp4 = w_tmp3, v_tmp3
                    for m in range(l):
                        w_tmp4 += w4[m][0]
                        v_tmp4 += w4[m][1]
                    if w_tmp4 <= W:
                        ans = max(ans, v_tmp4)
    print(ans)


if __name__ == '__main__':
    solve()


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

int main(void){
    int n, l;
    std::cin >> n >> l;
    
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    
    for (int i = 0; i < n-1; i++){
        
        if (a[i] + a[i+1] >= l){
            
            std::cout << "Possible" << std::endl;
            
            for (int j = 0; j < i; j++) std::cout << j+1 << std::endl;
            for (int j = n-2; j >= i+1; j--) std::cout << j+1 << std::endl;
            
            std::cout << i+1 << std::endl;
            return 0;
        }
    }
    
    std::cout << "Impossible" << std::endl;
    return 0;
}


Measured memory_bytes: 1152
i = 0
j = 0
lis = []
while True:
    x,y = input().split()
    x = int(x)
    y = int(y)
    if x > y:
        i = x
        x = y
        y = i

    if x == 0 and y == 0:
        break
    fmt = "{a} {b}"
    s = fmt.format(a = x,b = y)
    lis.append(s)
    j += 1

for i in range(j):
    print(lis[i])

Measured memory_bytes: 7788
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>


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

using ll = long long;
using namespace std;

int main() {
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	int h_dist = tx - sx;
	int v_dist = ty - sy;
	rep(_, v_dist) cout << "U";
	rep(_, h_dist) cout << "R";
	rep(_, v_dist) cout << "D";
	rep(_, h_dist) cout << "L";

	cout << "L";
	rep(_, v_dist + 1) cout << "U";
	rep(_, h_dist + 1) cout << "R";
	cout << "DR";
	rep(_, v_dist + 1) cout << "D";
	rep(_, h_dist + 1) cout << "L";
	cout << "U";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010, p = 998244353;
int dp[maxn], pf[maxn];
int n, k, l[maxn], r[maxn];
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	for (int i = 0;i < k;++i)
		cin >> l[i] >> r[i];
	dp[1] = 1, pf[1] = 1;
#define get(i) (pf[ max(0, i) ])
	for (int i = 2;i <= n;++i) {
		for (int j = 0;j < k;++j) {
			int y = i - l[j], x = i - r[j];
			//DE(x, ' '), DE(y, '\n');
			dp[i] = ((ll)dp[i] + get(y) - get(x-1) + p) % p;
		}
		//cerr << dp[i] << '\n';
		pf[i] = (pf[i-1] + dp[i]) % p;
	}
	//debug(dp+1, dp+n+1);
	cout << dp[n] << '\n';


}



Measured memory_bytes: 5216
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, M;
vector<int> G[100009];
int C[100009], num[2];

void dfs(int cur, int col){
    if(C[cur]!=-1){
        if(C[cur]!=col){
            cout1(1LL*N*(N-1)/2-M);
            exit(0);
        }
    }else{
        C[cur]=col;
        num[col]++;
        for(auto& e:G[cur]) dfs(e,col^1);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    rep(i,M){
        int a,b; cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    mem(C,-1);
    dfs(0,0);
    cout1(1LL*num[0]*num[1]-M);
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int n = 0, m = 0;
  while (n * b < c) n++;
  while (m * d < a) m++;
  if (n <= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*

*/

ll dp[100010][2],n;
string s;

void init(){
	cin>>s;
	n=s.size();
	s=" "+s;
	rep(i,n+1)rep(j,2)dp[i][j]=1e18;
	cerr<<"初期化終了"<<endl;
}

int main(void){
	init();
	dp[0][0]=0;
	dp[0][1]=0;
	reg(i,1,n){
		if(s[i]=='0'){
			dp[i][0] = dp[i-1][1];
			dp[i][1] = dp[i-1][0]+1;
		}
		if(s[i]=='1'){
			dp[i][0] = dp[i-1][1]+1;
			dp[i][1] = dp[i-1][0];
		}
	}
	cout<<min(dp[n][0],dp[n][1])<<endl;
	return 0;
}

Measured memory_bytes: 2044
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int n;
s64 a, b;
s64 h[100000];

bool ok(s64 cnt)
{
    s64 ret = 0;
    s64 *s = h;
    s64 *e = s + n;
    while (s < e)
    {
        ret += CEIL(MAX(0, *s - b * cnt), (a - b));
        ++s;
    }
    s = h;
    return ret <= cnt;
}

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

    cin >> n;
    cin >> a >> b;

    rep (i, n) cin >> h[i];

    s64 l = 0, r = 1e9;
    while (l + 1 < r)
    {
        s64 m = (l + r) / 2;
        if (ok(m)) r = m;
        else l = m;
    }

    cout << r << "\n";
    return 0;
}



Measured memory_bytes: 4288
#include<bits/stdc++.h>
#define int long long 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define N 1005

int INF=1000000;
const int mod=1e9+7;
using namespace std;
int dp[N][N];
int n,r;
vector<int> v;

void need_for_speed(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}



int32_t main(){
	need_for_speed();
    int n;
    cin>>n;
    int sum=n+n*n+n*n*n;
    cout<<sum<<endl;
        
        
    
    return 0;
}
    
 

Measured memory_bytes: 3652
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    num_list = i_list()

    zero_c = num_list.count(0)

    if zero_c >= 1:
        print(0)
        exit()

    ans = 1

    max_num = 10**18

    for num in num_list:
        ans *= num
        if ans > max_num:
            print(-1)
            exit()

    print(ans)
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 94232
N, M=map(int, input().split())
dog=1
ape=1
ans=0
if abs(N-M)>1:
    print(ans)
else:
    for i in range (N):
        dog=dog*(i+1)%(pow(10,9)+7)
    for i in range (M):
        ape=ape*(i+1)%(pow(10,9)+7)
    ans=dog*ape%(pow(10,9)+7)
    if N==M:
        ans=ans*2%(pow(10,9)+7)
    print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

typedef pair<int,int> pii;
#define fi first
#define se second

int main() {
  int n,m;
  while(1) {
    scanf("%d", &m);
    if(!m) break;
    vector<pii> target;
    for(int i=0; i<m; ++i) {
      pii po;
      scanf("%d %d", &po.fi, &po.se);
      target.push_back(po);
    }

    vector<pii> v;
    scanf("%d", &n);
    for(int i=0; i<n; ++i) {
      pii po;
      scanf("%d %d", &po.fi, &po.se);
      v.push_back(po);
    }

    sort(target.begin(), target.end());
    sort(v.begin(), v.end());
    for(int i=0; i<n; ++i) {
      bool flag = true;
      int dx = v[i].fi - target[0].fi;
      int dy = v[i].se - target[0].se;
      for(int j=1; j<m; ++j) {
	if( find(v.begin(), v.end(), pii(target[j].fi+dx, target[j].se+dy) ) == v.end() ) {
	  flag = false;
	  break;
	}
      }
      if(flag)
	printf("%d %d\n",dx,dy);
    }
  }
}

Measured memory_bytes: 832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	const int N = 1e6 + 1;

	int n; cin >> n;
	vector<int> v(n);
	for (int &i : v)cin >> i;
	vector<int> count(N, 0), f(N, 0);
	for (int i : v)count[i]++;
	for (int i = 1; i < N; i++)for (int j = i; j <= N; j += i)f[j] += count[i];
	int ans = 0;
	for (int i : v)ans += (f[i] == 1);
	cout << ans;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
const int mod1 = 998244353;
const int mod2 = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 1e6+5;

struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

unordered_set<pii,HASH> heap;
int p1[N], p2[N];

void pre(){
  heap.reserve(1024);
  heap.max_load_factor(0.25);
  p1[0]=p2[0]=1;
  rep(i,1,N){
    p1[i]=(p1[i-1]*29)%mod1;
    p2[i]=(p2[i-1]*31)%mod2;
  }
}



pii hsh(pii h, int n, int c){
   int x = (h.fi+(c+1)*p1[n])%mod1;
   int y = (h.se+(c+1)*p2[n])%mod2;
   return {x,y};
}

void solve() {

  pre();
  int n, ans = 0;
  cin>>n;
  vector<string> str(n);
  rep(i,0,n)
    cin>>str[i];
  sort(all(str),[](string &s1, string &s2){
    return sz(s1)<sz(s2);
  });
  rep(i,0,n){
     string &s = str[i];
     int m = sz(s);
     vi f(26);
     rep(j,0,m)
       f[s[j]-'a']++;
     pii hs = {0,0};
     frev(j,0,m-1){
        rep(k,0,26){
          if(!f[k])
            continue;
          pii hs1 = hsh(hs,m-1-j,k);
          ans+=heap.count(hs1);
        }
        hs = hsh(hs,m-1-j,s[j]-'a');
        f[s[j]-'a']--;
     }
     heap.insert(hs);
  }
  cout<<ans;

}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}





/*


int powm(int a, int b, int mod) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}*/


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

int main() {
  int N;
  uint64_t S, n1 = 2, n2 = 1;
  
  cin >> N;
  
  if(N == 0){
    S = n1;
  }
  else if(N == 1){
    S = n2;
  }
  else{
    for(int i = 2; i <= N; i++){
      S = n1 + n2;
      n1 = n2;
      n2 = S;
    }
  }
  
  cout << S << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[20];
int main()
{
    int i,j,k,t;
    scanf("%s",a);
    k=strlen(a);
    t=0;
    for(i=1;i<k;i++)
    {
        if(a[i]=='C')
            t++;
        if(a[i]>='A'&&a[i]<='Z'&&a[i]!='A'&&a[i]!='C')
        {
            printf("WA\n");
            return 0;
        }
    }
    if(t==1&&a[0]=='A'&&a[1]!='C'&&a[k-1]!='C')
        printf("AC\n");
    else
        printf("WA\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			if (numN > 999) {
				System.out.println("ABD");
			} else {
				System.out.println("ABC");
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			int wk = numB - numA;

			int res = 0;
			for (int i = 1; i < wk; i++) {
				res += i;
			}

			System.out.println(res - numA);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string s;
    cin >> s;

    s[3] = '8';

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    string S;
    cin>>N>>S;
    vector<int> white(N+1);
    rep(i,N){
        white.at(i+1)=white.at(i);
        if(S.at(i)=='.')white.at(i+1)++;
    }
    int ans=N;
    rep(i,N+1){
        int now=i+white.at(N)-white.at(i)*2;
        chmin(ans,now);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4448
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=sc.Ia;
		int ans=0;
		for(int i = 0;i<s[0];i++) {
			if(a[i]>=s[1]){ans++;}
		}
		Console.WriteLine("{0}",ans);
	}
}

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 long[] La{get{return Array.ConvertAll(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();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 15968
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      
      	if((Math.abs(a-c)<=d)||((Math.abs(a-b)<=d)&&(Math.abs(b-c)<=d))){
	          	System.out.println("Yes");
	        }else {
	            System.out.println("No");
	        }
   }
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

vector<vector<int>> graph;
vector<int> ans;

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n, x, y;
    cin >> n >> x >> y;
    graph.resize(n+1);
    for(int i=1;i<n;i++)
    {
        graph[i].pb(i+1);
        graph[i+1].pb(i);
    }
    graph[x].pb(y);
    graph[y].pb(x);
    ans.resize(n);
    vector<bool> vis(n+1, 0);
    vector<int> dist(n+1, 0);
    for(int j=1;j<=n;j++)
    {
        int curr = 0;
        vis.assign(n+1, 0);
        dist.assign(n+1, 0);
        queue<int> q;
        q.push(j);
        vis[j] = 1;
        while(!q.empty())
        {
            int top = q.front();
            q.pop();
            for(int i:graph[top])
            {
                if(vis[i]) continue;
                dist[i] = dist[top]+1;
                ans[dist[i]]++;
                vis[i] = true;
                q.push(i);
            }
        }
    }
    for(int i=1;i<n;i++) cout << ans[i]/2 << "\n";
    
    return 0;
}



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

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

ll mod = 998244353;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200){
    cout << s << endl;
  }
  else{
    cout << "red" << endl;
  }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  
  double P = 0;
  rep(i,n) {
    double p = 1 / double(n);
    if (i < k) {
      int m = i;
      while (m < k) {
        p *= 0.5;
        m *= 2;
      }
      P += p;
    }
    else P += p;
  }
  
  cout << fixed << setprecision(12) << P << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
const int MAX_V=1000000;
int main() {
	int i,k,n,p1,q1,prime[MAX_V+1];
	for(i=2;i<=MAX_V;i++) {
		prime[i]=1;
	}
	for(i = 2; i*i <= MAX_V; i++) { 
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0;
			}
		}
	}
	while(1) {
		scanf("%d", &n);
		if(n==0) break;
		for(i=n;i>=5;i--) {
			if(prime[i]==1 && prime[i-2]==1) {
				q1=i; p1=i-2;
				printf("%d %d\n",p1,q1);
				break;
			}
		}
	}
	return 0; 
}

Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main() {
  string S;
  cin>>S;
  ll a=S.size();
  vl vec(26,0);
  rep(i,a){
    char X=S.at(i);
    vec.at(X-'a')++;
  }
  sort(all(vec));
  reverse(all(vec));
  ll b=(a-1)/3+1;
  if(vec.at(0)>b){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mm multimap<ll,ll>
#define mp make_pair
#define pii pair<ll,ll>

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
ll n,k;
cin>>n>>k;
ll ar[n+1],dp[n+1];
dp[0]=0;ar[0]=0;
for(ll i=1;i<=n;i++)
{
    cin>>ar[i];
    
}dp[1]=0;

for(ll i=2;i<=n;i++)
{
    ll mi=INT_MAX;
    for(ll j=i-1;j>=i-k &&j>=1;j--)
    mi=min(dp[j]+abs(ar[j]-ar[i]),mi);
    dp[i]=mi;
}
cout<<dp[n];
  return 0;
}

Measured memory_bytes: 1792