akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

template<i64 M>
struct modint {
    i64 x;

    constexpr modint(const i64 y = 0) noexcept : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

    constexpr modint operator-() const noexcept { return modint(-x); }
    constexpr modint operator+(const modint &rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept { return modint(*this) /= rhs; }

    constexpr modint &operator+=(const modint &rhs) noexcept {
        x += rhs.x;
        if (x >= M) x -= M;
        return *this;
    }

    constexpr modint &operator-=(const modint &rhs) noexcept {
        if (x < rhs.x) x += M;
        x -= rhs.x;
        return *this;
    }

    constexpr modint &operator*=(const modint &rhs) noexcept {
        x = x * rhs.x % M;
        return *this;
    }

    constexpr modint &operator/=(const modint &rhs) noexcept {
        i64 a = rhs.x, b = M, u = 1, v = 0;
        while (b > 0) {
            i64 t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        *this *= u;
        return *this;
    }

    friend ostream &operator<<(ostream &os, const modint &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, modint &a) {
        i64 t;
        is >> t;
        a = modint(t);
        return is;
    }
};

constexpr i64 MOD = 1e9 + 7;
using m64 = modint<MOD>;

i64 n;
vector<vector<i64>> g;
vector<i64> done;
vector<m64> dp;

m64 dfs(i64 x) {
    if (x == n) return 1;
    if (done[x]) return dp[x];
    done[x] = 1;

    m64 res = 0;
    for (auto& e : g[x]) res += dfs(e);
    return dp[x] = res;
}

void solve() {
    cin >> n;
    g.resize(n);
    map<i64, i64> pre;
    for (i64 i = 0; i < n; i++) {
        g[i].emplace_back(i + 1);
        i64 c;
        cin >> c;
        if (pre.find(c) != pre.end() && pre[c] != i - 1) g[pre[c]].emplace_back(i);
        pre[c] = i;
    }

    done.resize(n), dp.resize(n, -1);
    cout << dfs(0) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main() {
  int a,b,c,d,e;
  cin>>a;
  b=a/1000;
  c=(a%1000)/100;
  d=(a%100)/10;
  e=a%10;
  if (b == c && c == d){
  	cout<<"Yes"<<endl;
  }
  else if(c == d && d == e){
	cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long N=2e5+5,M=1e9+7;
long h,w,a,b,fac[N],ifac[N],ans=0,up,i;
inline long C(long n,long m){return fac[n]*ifac[m]%M*ifac[n-m]%M;}
int main(){
	cin>>h>>w>>a>>b,up=max(w,h),fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(i=2;i<=up<<1;++i)fac[i]=fac[i-1]*i%M,ifac[i]=ifac[M%i]*(M-M/i)%M;
	for(i=2;i<=up<<1;++i)ifac[i]=ifac[i]*ifac[i-1]%M;
	for(i=1;i<=h-a;++i)(ans+=C(b+i-2,b-1)*C(h+w-b-i-1,w-b-1)%M)%=M;
	cout<<ans;
}


Measured memory_bytes: 3328
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;
            var x = cin.ReadIntArray(N);
            var ans = 0;
            for(int i = 0; i < N; i++)
            {
                ans += 2 * Min(x[i], Abs(K - x[i]));
            }
            WriteLine(ans);
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vl m(5,0);
    rep(_,n) {
        string s;
        cin >> s;
        if(s[0] == 'M') m[0]++;
        else if(s[0] == 'A') m[1]++;
        else if(s[0] == 'R') m[2]++;
        else if(s[0] == 'C') m[3]++;
        else if(s[0] == 'H') m[4]++;
    }
    ll ans = 0;
    rep(bit,1<<5) {
        ll now = 1;
        int cnt = 0;
        rep(i,5) if(bit>>i&1) {
            cnt++;
            now *= m[i];
        }
        if(cnt != 3) continue;
        ans += now;
    }
    cout << ans << endl;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    ll ans = 0;
    ll sn = sqrt(n) + 1;
    for(int i = 1; i <= sn; ++i){
        ll l = n / (i + 1) + 1, r = n / i;
        while(r - l > 1){
            ll mid = (l + r) / 2;
            if(n % mid >= i) l = mid;
            else if(n % mid < i) r = mid;
        }
        if(n % l == i) ans += l;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if(x+r <= w && y+r <= h && x-r >= 0&&y-r >= 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3120
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int N = sc.nextInt();
		if (N==0) {
			System.out.println(X);
			return ;
		}
		Set<Integer> set = new HashSet<Integer> ();
		for (int i=0;i<N;i++) {
			set.add(sc.nextInt());
		}
		for (int i=0;i<200;i++) {
			int temp = X-i;
			if (set.contains(temp)==false) {
				System.out.print(temp);
				return ;
			}
			temp = X+i;
			if (set.contains(temp)==false) {
				System.out.print(temp);
				return ;
			}
		}

	}
}

Measured memory_bytes: 35776
#include <bits/stdc++.h>
#define inf 100000000
using namespace std;
int main (){
    int h,w;
    int c[11][11]={};


    cin >> h >> w;

    int a[h][w];


    for(int i=0;i<10;i++){
        for (int j = 0; j <10; j++){
            cin >> c[i][j];
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
        }
    }
    



    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(c[i][j]>c[i][k]+c[k][j]){
                    c[i][j]=c[i][k]+c[k][j];
                }
            }
        }
    }
    int ans=0;

for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        if(a[i][j]!=-1){
            ans += c[a[i][j]][1];
        }
    }
}
cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>

#include <string>

#include <vector>
#include <list>
#include <map>

#include <algorithm>
#include <utility>

using namespace std;

int main(const int argc, const char **argv){
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);

  int max = B / A;

  if(max > C){
    printf("%d", C);
  }else{
    printf("%d", max);
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char kiroku[26] = {};
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        kiroku[s[i]-'a'] = 1;
    }
    for(int i = 0; i < 26; i++){
        if(kiroku[i] == 0){
            cout << s + (char)(i + 'a') << endl;
            return 0;
        }
    }
    for(int i = 25; i > 0; i--){
        if(s[i-1] < s[i]){
            for(int j = 25; j >= 0; j--){
                if(s[i-1] < s[j]){
                    s[i-1] = s[j];
                    break;
                }
            }
            for(int j = 0; j < i; j++){
                cout << s[j] << flush;
            }
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
//int COUNTDIV(int n) 素因数分解して+1してかける奴
int COUNTDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int N,x,max=0,ans=0;
	cin >> N;
	rep(i, N) {
		cin >> x;
		if (max < x)
			max = x;
		if (max <= x)
			ans++;
	}
	cout << ans <<endl;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

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
{
	public static void main (String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A[] = new int[N];
		int num[] = new int[N];
		boolean collect = true;

		for(int i = 0; i < N; i++){
			num[i] = 0;
		}
		
		for(int i = 0; i < N; i++){
			A[i] = Integer.parseInt(sc.next());
			if(N % 2 == A[i] % 2) collect = false;
			if(A[i] == 0){
				if(++num[A[i]] > 1) collect = false;
			}else{
				if(++num[A[i]] > 2) collect = false;
			}
		}
		
		int res;
		
		if(collect){
			res = 1;
			for(int i = 0; i < N / 2; i++){
				res = (res * 2) % 1000000007;
			}
		}else{
			res = 0;
		}
		
		System.out.println(res);
		
	}
}

Measured memory_bytes: 32388
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int i,j,n;
string str;

struct UnionFind {
  int *data;
  UnionFind(int size) {
      data = new int[size];
      for(int i = 0;i < size;i++)
          data[i] = -1;
  }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  cin >> n;
  vector<pair<int,int> > x,y;
  for(i = 0;i < n;i++){
    int xi,yi;
    cin >> xi >> yi;
    x.push_back(make_pair(xi,i));
    y.push_back(make_pair(yi,i));
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  vector<pair<int,pair<int,int> > > d;
  for(int i = 0;i < n-1;i++){
    d.push_back(make_pair(abs(x[i].first-x[i+1].first),make_pair(x[i].second,x[i+1].second)));
    d.push_back(make_pair(abs(y[i].first-y[i+1].first),make_pair(y[i].second,y[i+1].second)));
  }
  sort(d.begin(),d.end());
  long long ans = 0;
  UnionFind uf(n);
  for(int i = 0;i < d.size();i++){
    if(uf.unionSet(d[i].second.first,d[i].second.second)){
      ans += d[i].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7144
#include <iostream>

int A[200001] ={};
int n_divisor[1000001] ={};

int main() {
    int N;
    std::cin >> N;
    for (int i=1; i<=N; i++) {
        std::cin >> A[i];
    }

    for (int i=1; i<=N; i++) {
        n_divisor[A[i]]++;
        if (n_divisor[A[i]] == 1) {
            for (int j=2; A[i]*j<=1000000; j++) {
                n_divisor[A[i]*j]++;
            }
        }
    }
    int count = 0;
    for (int i=1; i<=N; i++) {
        if (n_divisor[A[i]] == 1) {
            count++;
        }
    }
    std::cout << count << std::endl;
}

Measured memory_bytes: 8284
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  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 {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= 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 {
    mint res(*this);
    return res /= a;
  }
};

mint factorial(ll n) {
  mint answer = 1;
  while (n > 1) {
    answer *= n;
    n--;
  }
  return answer;
}

mint combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

mint permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

// setprecision(8) 桁数指定
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

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

  cout << (n[0] == n[2] ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
from functools import lru_cache


@lru_cache()
def cal(x):
    if x & 1 or x == 0:
        return 0
    else:
        now = (x // 10) * 10
        now //= 5
        return now // 2 + cal(now)


n = int(input())
print(cal(n))

Measured memory_bytes: 38512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			double[][] p = new double[3][2];
			for (int i = 0; i < 3; i++) {
				p[i][0] = sc.nextDouble();
				p[i][1] = sc.nextDouble();
			}
			double px = sc.nextDouble();
			double py = sc.nextDouble();

			boolean f = true;
			boolean g = true;
			
			for (int i = 0; i < 3; i++) {
				double point = checkPointPlace(p[i][0], p[i][1], p[(i + 1) % 3][0],
						p[(i + 1) % 3][1], px, py);
				if (point >= 0) {
					f = false;
				}
				if (point <= 0) {
					g = false;
				}
			}
			if (f || g) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}

	public static double checkPointPlace(double x, double y, double x1, double y1,
			double x2, double y2) {
		double a = x1 - x;
		double b = y1 - y;
		double c = x2 - x;
		double d = y2 - y;
		
		return a * d - c * b;
	}

}

Measured memory_bytes: 32512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n;
    string s;
    cin >> n >> s ;

    if(n%2 == 1){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0; i<n/2 ; i++){
        if(s[i]!=s[n/2+i]){
            cout << "No" <<endl;
        return 0;
        }
    }
            cout << "Yes" <<endl;


    return 0;
}


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

using namespace std;
#define int long long
#define pb push_back
template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n);
	for (auto &i : a)
		cin >> i;
	for (auto &i : b)
		cin >> i;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x = min(a[i], b[i]);
		a[i] -= x;
		b[i] -= x;
		ans += x;
		x = min(a[i + 1], b[i]);
		a[i + 1] -= x;
		b[i] -= x;
		ans += x;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        aa: [usize; n]
    };
    let mut hs = std::collections::HashSet::new();
    for a in aa {
        if hs.contains(&a) {
            hs.remove(&a);
        } else {
            hs.insert(a);
        }
    }
    println!("{}", hs.len());
}


Measured memory_bytes: 5636
#include <stdio.h>
int main(){
  int N,K,k=0;
  scanf("%d %d",&N,&K);
  int h[100000]; 
  for(int i=0;i<N;i++){
    scanf("%d",&h[i]);
    if(h[i]>=K)k++;
  }
printf("%d",k);
}

Measured memory_bytes: 512
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define BACK(x) prev((x).end())
#define HASK(x, y) ((x).find(y) != (x).end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 20, mod = 1000000007;

template <class T1, class T2> inline void addMod(T1& a, T2 b)	{   a = (a + b) % mod;  }
template <class T1, class T2> inline void multMod(T1& a, T2 b)	{   a = a * b % mod;    }
template <class T1, class T2> inline void remax(T1& a, T2 b)	{   a = max(a, (T1)b);  }

long long qpow(long long a, long long b)
{
    long long ret = 1;
    for (; b!=0; b>>=1)
    {
        if (b & 1)  multMod(ret, a);
        multMod(a, a);
    }
    return ret;
}

int apd[maxN], deg[maxN], A[maxN];	

void solve()
{
	FOR(i, 1, maxN)
		apd[i] = i;
	for (int i=2; i*i<maxN; i++)
		if (apd[i] == i)
			for (int j=i*i; j<maxN; j+=i)
				apd[j] = i;
				
	int n;
	scanf ("%d", &n);
	FOR(i, 0, n)
	{
		scanf ("%d", A+i);
		for (int m = A[i]; m != 1; )
		{
			int p = apd[m], c = 1;
			while (m % p == 0)
				m /= p, c *= p;
			remax(deg[p], c);
		}
	}
	
	long long lcm = 1;
	FOR(i, 1, maxN)
		if (deg[i] != 0)
			multMod(lcm, deg[i]);
	long long res = 0;
	FOR(i, 0, n)
	{
		A[i] = qpow(A[i], mod-2);
		multMod(A[i], lcm);
		addMod(res, A[i]);
	}
	
	printf("%lld\n", res);
}
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}





Measured memory_bytes: 10292
/*input
snuke
snekee
*/
#include<bits/stdc++.h>
using namespace std;

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define X first
#define Y second
#define pb push_back
#define all(s) s.begin(),s.end()

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

const int MOD = 1e9+7;

void solve(){
    string s,t;
    cin >> s >> t;
    bool ans = true;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])
            ans = false;
    }
    if(ans)
        cout << "Yes";
    else
        cout << "No";
}

int main(){
    FIN;   
    // test
    solve();
}

Measured memory_bytes: 3656
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
//template<class T> void SO(T& ve){sort(T.begin(),T.end());}
int main(void){
	char a,b;cin>>a>>b;
	cout<<((a==b)?'=':(a>b)?'>':'<')<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    char c;
    cin >> c;
    if (c == 'a' | c == 'e' | c == 'i' | c == 'o' | c == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define entire(a) (a).begin(),(a).end()
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
void solve()
{
	double d, s, t;
	cin >> d >> s >> t;
	cout<<(d/s <= t?"Yes":"No")<<endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	int T = 1;
	// cin >> T;
	while (T--)
	{
		solve();
	}
	return 0;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
LL s[N];
map<int, int> h;

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i ++ )
	{
		scanf("%lld", &s[i]);
		s[i] += s[i - 1];
	}
	
	h[0] = 1;
	LL res = 0;
	for (int i = 1; i <= n; i ++ )
	{
		if (h.count(s[i] % m)) res += h[s[i] % m];
		h[s[i] % m] ++ ;
	}
	
	printf("%lld\n", res);
	return 0;
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define INF LLONG_MAX
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int a;
  long long ans = INF;
  long long sum[200001];

  sum[0] = 0;
  
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> a;
    sum[i] = sum[i - 1] + a;
  }

  for(int i = 1;i < n;i++){
    ans = min(ans, llabs(sum[n] - sum[i] - sum[i]));
  }

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


Measured memory_bytes: 1792
"""
Writer: SPD_9X2
https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_e

最後の配列の状態は何で決定されるか。
同じaが同じ配列に複数回採用されたとき、効果があるのは最後に
採用したaのみ。(それ以前は合っても無くても同じになる)

最初、1が採用状態になっていると考えてよい。
→おそらく気にすべきは配列aのみ(Nこの配列は考慮しなくてよい)

1以外は、出現するなら少なくともN個出現しなければ不可能
2,3だけで考えてみよう

N==3のとき

322233 →不可能(2が先頭が1つ生まれてしまう)
232233 →可能

→終了後の配列の数字は、最後に出現した順に前から並ぶ
→よってaを見れば構成後の数列は分かる

→後ろからaを見ていって、先に登場したやつより後に登場したほうが数が越えたらダメ
→ただし、N個目以降は完全無視する
→終了時に数がNに達していないのがあったらダメ(1を除く？)

いや例3…
→初期状態、の扱い方を考え直さなきゃな…

aの前に M…M(N個),M-1…M-1,…,1…1 があると考える
すると、aを後ろから見ていった時に先に登場したやつより後に登場したほうが数が越えてはいけない、
だけの条件になる！！

あ、2233223 は…？
最後の2つの2を1箇所に適応すれば可能じゃん！
lis[a[i][0]]ってなんだ…？
→それ以降に先頭をa[i][0]に更新できる最大数
→よって、indに対して単調減少になっていなければいけない

うん？前を超えないようにして、最終的にすべてN以上になればおｋ？
"""
import sys
N,M = map(int,input().split())

Q = int(input())

A = list(map(int,input().split()))

dic = {}
lis = []
flag = True

a = [[M-i,N] for i in range(M)]
for i in range(Q):
    a.append([A[i],1])
a.reverse()
#print (a)

for i in range(len(a)):

    if a[i][0] not in dic:
        ind = len(dic)
        dic[a[i][0]] = ind
        if ind != 0:
            lis.append(min(lis[ind-1] , a[i][1]))
        else:
            lis.append(a[i][1])
    else:
        ind = dic[a[i][0]]
        if ind != 0:
            lis[ind] = min(N, lis[ind] + a[i][1] , lis[ind-1])
        else:
            lis[ind] = min(N, lis[ind] + a[i][1])

if lis[-1] == N:
    print ("Yes")
else:
    print ("No")

Measured memory_bytes: 87660
object Main extends App{
  //  val N= StdIn.readLine().split(" ").map(_ toInt)
  //  println(N(0))

  // A,Bくらいの入力しかないなら、Scanner使ったほうが楽そう
  val scanner = new java.util.Scanner(System.in)
  val N, M = scanner.nextInt(); val d = M-N; var sum = 0;
  for (i <- 1 to d){
    sum += i
  }
  println(sum - M)
}

Measured memory_bytes: 26008
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N;
	cin >> N;
	int ans = 0;
	vector<int> p(N);
	for(int i=0;i<N;i++){
		cin >> p[i];
	}
	for(int i=0;i<N;i++){
		if(i==0 && p[i] == 1){
			ans++;
			swap(p[0],p[1]);
			continue;
		}
		if(i==N-1&&p[i] == N){
			ans++;
			swap(p[N-1],p[N-2]);
			continue;
		}
		if(p[i] == i+1){
			ans++;
			if(p[i-1]==i){
				swap(p[i-1],p[i]);
			}else{
				swap(p[i],p[i+1]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
a = []
sum = 0
for i in range(N):
    a.append(list(map(str, input().split())))
for i in range(N):
    if a[i][1] == "BTC":
        a[i][0] = 380000 * float(a[i][0])
    sum = sum + float(a[i][0])
print(sum)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
    int n,m,x; cin >> n >> m >> x;
    int A[m+1],ans1 = 0, ans2 = 0;
    for (int i=0; i<m; i++) cin >> A[i];

    for (int i=x; i>=0; i--){
        for (int j=0; j<m; j++){
            if (i==A[j]) ans1++;
        }
    }

    for (int i=x; i<=n; i++){
        for (int j=0; j<m; j++){
            if (i==A[j]) ans2++;
        }
    }
    int ans = min(ans1, ans2);
    cout << ans << endl;
}

Measured memory_bytes: 256
program	main
  implicit none
  integer(8)::n,a,b,i
  integer(8),allocatable::x(:)
  read*,n,a,b
  allocate(x(n))
  read*,x
  forall(i=1:n-1)x(i)=(x(i+1)-x(i))*a
  where(x>b)x=b
  x(n)=0
  print'(i0)',sum(x)
end program main

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

int main() {
  double n, t, a;
  cin >> n >> t >> a;
  
  vector<double> vec(n);
  vector<double> vec_avg(n);
  
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
    double avg_def = a - (t - vec.at(i) * 0.006);
    
    if (avg_def < 0) {
      vec_avg.at(i) = avg_def * -1;
    } else {
      vec_avg.at(i) = avg_def;
    }
  }
  
  int ans = 1;
  double def_ans = vec_avg.at(0);
  
  for(int i = 1; i < n; i++) {
    if (vec_avg.at(i) < def_ans) {
      ans = i + 1;
      def_ans = vec_avg.at(i);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 764
//ABC108B
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;
int main(void){
    int x1=0, y1=0, x2=0, y2=0;
    int x3=0, y3=0, x4=0, y4=0;
    cin >> x1 >> y1 >> x2 >> y2;
    if(x1<x2){
        y3 = y2 + (x2-x1);
        y4 = y1 + (x2-x1);
    }else{
        y3 = y2 - (x1-x2);
        y4 = y1 - (x1-x2);
    }if(y1<y2){
        x3 = x2 - (y2-y1);
        x4 = x1 - (y2-y1);
    }else{
        x3 = x2 + (y1-y2);
        x4 = x1 + (y1-y2);
    }
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    string S;
    cin >> S;
    ll N = S.size();
    ll DP[N + 1] = {0};
    ll ans = 0;
    REP(i, 0, N) {
        if (S[i] == 'A') {
            DP[i] = DP[i + 1];
        } else if (S[i] == 'B' && i + 1 < N) {
            if (S[i + 1] == 'C') {
                DP[i] = DP[i + 2] + 1;
            }
        }
        if (S[i] == 'A') ans += DP[i];
    }
    cout << ans << endl;
}

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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
#define prarr(a,n) cout<<#a<<" : ";for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define prmat(mat,row,col) cout<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cout<<mat[i][j]<<"\t";cout<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }
const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
const int mod=1000*1000*1000+7;

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

const int nax=1e5+5;
vi adj[nax];

void solve(){
    int n;
    cin>>n;
    map<pii,int> m;
    int ma=0;

    pii p[n];
    int x,y;
    for(int i=1;i<n;i++){
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
        p[i].F=min(x,y);
        p[i].S=max(x,y);
        m[{p[i].F, p[i].S}] = 0;
    }


    queue<pii> q;
    q.push({1,0});
    while(!q.empty()){
        int u=q.front().F, no = q.front().S, un=1;
        q.pop();
        if(un==no) un++;
        for(int v:adj[u]){
            if(m[{min(u,v), max(u,v)}]==0){
                q.push({v,un});
                m[{min(u,v), max(u,v)}] = un;
                // pr(u,v,un);
                un++;
                if(un==no) un++;
            }
        }
        ma = max(ma, sz(adj[u]));
    }
    cout<<ma<<endl;
    for(int i=1;i<n;i++){
        // pr(p[i].F, p[i].S);
        cout<<m[{p[i].F, p[i].S}]<<endl;
    }
}


int main(){
    // clock_t beg=clock(); 
    fast_io; 
    cout << fixed << setprecision(13); 
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    } 
    // clock_t end=clock(); 
    // fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
#define per(i,a,n) for(int i=a;i<=n;i++)
#define ls l+mid>>1

#define rs mid+1+r>>1
using namespace std;
typedef  long long ll;
stack<char>s;
string str;
int main()
{
  cin>>str;
  /*if(str[0]=='h')
  s.push(str[0]);
  else {cout<<"No";return;}*/
  for(int i=0;i<str.size();i++){
      if(str[i]!='h'&&str[i]!='i'){{cout<<"No";return 0;}}
      if(str[i]=='h'&&s.size()==0){
        s.push(str[i]);
      }
      else if(str[i]=='i'&&s.size()==0){cout<<"No";return 0;}
      else if(str[i]=='i'&&s.top()=='h')s.pop();
      else {cout<<"No";return 0;}
  }
  if(s.size())cout<<"No";
  else
  cout<<"Yes"<<endl;
  return 0;
}



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

int main()
{
	int A, B, C, D;

	cin >> A >> B >> C >> D;

	while (true)
	{
		C -= B;
		if (C <= 0)
		{
			cout << "Yes" << endl;
			break;
		}

		A -= D;
		if (A <= 0)
		{
			cout << "No" << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,m;
ll F[4000005],inv[4000005],f[2005][2005];
ll quick_pow(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
ll C(ll n,ll m){
	return F[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	scanf("%d%d",&n,&m);
	if(m==1) return puts("1"),0;
	F[0]=inv[0]=1;
	for(int i=1;i<=n*m;i++) F[i]=F[i-1]*i%mod,inv[i]=quick_pow(F[i],mod-2);
	f[0][0]=1; 
	int len=n*m;
	for(int i=0;i<=n;i++){
		for(int p=0;p<=i;p++){
			if(!i&&!p) continue;
			if(i) f[i][p]=f[i-1][p];
			if(p) f[i][p]=(f[i][p]+f[i][p-1]*C(len-(p-1)*(m-1)-i-1,m-2))%mod;
		}
	}
	printf("%lld",f[n][n]*F[n]%mod);
	return 0;
}

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

using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a,sum=0;
    for(int i=0;i<m;i++){
       cin >> a;
       sum+=a;
    }   
    if(n>=sum) cout << n-sum << endl;
    else cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 3588
//
// Created by Hideaki Imamura on 2020-03-14.
//
# include <bits/stdc++.h>

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

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;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int H, W;
vector<string> S;

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; ++i) {
        string s;
        cin >> s;
        S.push_back(s);
    }

    vector<vector<int>> left, right, upper, lower;
    for (int i = 0; i < H; ++i) {
        left.push_back(vector<int>(W, 0));
        right.push_back(vector<int>(W, 0));
        upper.push_back(vector<int>(W, 0));
        lower.push_back(vector<int>(W, 0));

    }
    for (int i = 0; i < H; ++i) {
        left[i][0] = S[i][0] == '#' ? 0 : 1;
        right[i][W-1] = S[i][W-1] == '#' ? 0 : 1;
        for (int j = 1; j < W; ++j) {
            if (S[i][j] == '#') {
                left[i][j] = 0;
            } else if (S[i][j-1] == '#') {
                left[i][j] = 1;
            } else {
                left[i][j] = left[i][j-1] + 1;
            }
            if (S[i][W - j - 1] == '#') {
                right[i][W - j - 1] = 0;
            } else if (S[i][W - j] == '#') {
                right[i][W - j - 1] = 1;
            } else {
                right[i][W - j - 1] = right[i][W - j] + 1;
            }
        }
    }
    for (int j = 0; j < W; ++j) {
        upper[0][j] = S[0][j] == '#' ? 0 : 1;
        lower[H-1][j] = S[H-1][j] == '#' ? 0 : 1;
        for (int i = 1; i < H; ++i) {
            if (S[i][j] == '#') {
                upper[i][j] = 0;
            } else if (S[i - 1][j] == '#') {
                upper[i][j] = 1;
            } else {
                upper[i][j] = upper[i - 1][j] + 1;
            }
            if (S[H - i - 1][j] == '#') {
                lower[H - i - 1][j] = 0;
            } else if (S[H - i][j] == '#') {
                lower[H - i - 1][j] = 1;
            } else {
                lower[H - i - 1][j] = lower[H - i][j] + 1;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            ans = max(ans, max(0, left[i][j] + right[i][j] + upper[i][j] + lower[i][j] - 3));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 67200
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

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

    int N;
    cin >> N;
    vector<string> S(N);
    cin >> S;

    vector<vector<int>> m(N, vector<int>(26));
    REP(i, N) {
        REP(j, S[i].length()) {
            m[i][S[i][j] - 'a']++;
        }
    }

    string ans = "";
    REP(i, 26) {
        int cnt = m[0][i];
        REP(j, N) {
            cnt = min(cnt, m[j][i]);
        }
        ans += string(cnt, i + 'a');
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    private static final int BASE = 55555;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final Deque<Integer> primeNumbers = new ArrayDeque<>(sieveOfEratosthenes(BASE));
    
        final List<Integer> answers = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            int primeNumber;
            while ((primeNumber = primeNumbers.poll()) % 5 != 1) ;
            answers.add(primeNumber);
        }

        final String answer = answers.stream()
                .map(i -> Integer.toString(i))
                .collect(Collectors.joining(" "));

        System.out.println(answer);
    }

    private static List<Integer> sieveOfEratosthenes(final int number) {
        List<Integer> list = new ArrayList<>();
        for (int i = 2; i <= number; i++) {
            list.add(i);
        }

        final int sqrt = (int) Math.sqrt(number);
        final List<Integer> primeNumbers = new ArrayList<>();
        int condition;

        do {
            final int prime = list.get(0);
            primeNumbers.add(prime);
            list = list.stream()
                    .filter(i -> i % prime != 0)
                    .collect(Collectors.toList());
            condition = prime;
        } while (condition < sqrt);

        primeNumbers.addAll(list);
        return primeNumbers;
    }
}


Measured memory_bytes: 35284
loop do
    n = gets.to_i
    break if n == 0
    s = gets.split.map(&:to_i).inject(:+) * n
    a = gets.split.map(&:to_i).sort.reverse
    until a.empty?
        x = a.shift
        t = (s / n + x) * (n - 1)
        if t >= s
            s = t
            n -= 1
        else
            break
        end
    end
    puts s
end


Measured memory_bytes: 28668