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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;

const ll MOD = (ll)(1e9 + 7);

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 b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // 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 x[MAX_N];
mint Q[MAX_N];

int main2() {
  int N = nextInt();
  REP(i, N) x[i] = mint(nextInt());

  mint ans = 0;

  Q[0] = 0;
  for (int i = 1; i <= N; i++) Q[i] = Q[i-1] + mint(1) / mint(i);
  for (int i = 1; i <= N-1; i++) {
    ans += (x[i]-x[i-1]) * Q[i];
  }
  for (int i = 1; i <= N-1; i++) ans *= mint(i);
  cout << ans.x << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 2048
import java.math.*;
import java.util.*;
import javax.swing.Spring;

public class Main {
	final static int maxn = (int) (1e6 + 5);
	static int[] vis = new int[maxn];

	static int gcd(int a, int b) {/// 欧几里得辗转相除法
		return b == 0 ? a : gcd(b, a % b);
	}

	public static void sieve(int N) {
		for (int i = 0; i <= N; i++)
			vis[i] = 1;
		vis[0] = 0;
		vis[1] = 0;
		vis[2] = 1;
		for (int i = 2; i <= N; i++) {
			if (vis[i] == 1) {
				for (int j = 2 * i; j <= N; j += i) {
					vis[j] = 0;
				}
			}
		}
	}

	public static void main(String[] args) {
//		int[] book = new int[maxn];
		int[] a = new int[maxn];
		int[] b = new int[maxn];
		Scanner cin = new Scanner(System.in);
		HashMap  mp = new HashMap();
//		Map map = new HashMap();
//		Set<Character> s = new HashSet<>();
//		Set<Set<Character>> ss = new HashSet<>();
		// System.out.println(String2);
		// String String2 = cin.next();
//		char []a = String2.toCharArray();// 字符串拆分成数组
//		String s1 = cin.nextLine();/// 吃掉换行符
		int ans = 0;
		int n = cin.nextInt();
		for(int i = 1 ;i <= n;i++) {
			a[i] = cin.nextInt();///第i个人是第几个
			b[a[i]] = i;
		}
		for(int i = 1;i <= n;i++) {
			System.out.print(b[i] + " ");
		}
	}
}


Measured memory_bytes: 75532
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int D, alp = 26;
    cin >> D;
    vector<int> c(alp);
    vector<vector<int>> s(D, vector<int>(alp));
    for (int i = 0; i < alp; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < alp; j++) {
            cin >> s[i][j];
        }
    }

    int ans = 0;
    vector<int> last(alp, 0);
    for (int i = 0; i < D; i++) {
        int sat = 0;
        int lastchoise = 0;
        for (int j = 0; j < alp; j++) {

            sat += s[i][j];
            for (int k = 0; k < alp; k++) {
                if (k != j) {
                    sat -= c[k] * (i + 1 - last[k]);
                }
            }

            if (ans < sat) {
                ans = sat;
                lastchoise = j;
            }
        }

        last[lastchoise] = i + 1;

        cout << lastchoise + 1 << endl;
    }

    return 0;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int tak = (c + b - 1) / b;
    int aok = (a + d - 1) / d;
    if(tak <= aok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const double EPS = 1e-6;
const int MAX = 200 * 1000 + 47;

char S[MAX];
int C[255];

int main()
{
    scanf("%s", S);
    int n = strlen(S);
    LL ans = 0;
    FOR(i, 0, n)
        ans += C[S[i]]++;
    ans =  n * 1LL * (n - 1) / 2 - ans;
    ans ++;
    cout << ans << endl;
    
}


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

using namespace std;

int main(){
  int n,i;
  cin >> n;
  char s[n];
  cin >> s;
  char pre_ch = s[0];
  int ans = 0;

  for(i=0;i<n;i++){
    if(s[i] != pre_ch) ans++;
    pre_ch = s[i];
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<numeric>
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
int main() {
	long long  a[3][3] = {0}, b = 1,bb,cc,dd,ee,ff, c = 0, x = 0, max = 0, dig = 0, ans = 0;
	int n = 0, k = 0, nc = 0, m = 0,out=-1;
	long long left = 0, right = 0, ii[3] = { 0 }, ic = 0;
	string s, t, u,now;
	vector<double> z, zz,count,countc;
	vector<string>ss;
	vector<long long int>::iterator position;
	bool q = false;
	vector<vector<bool>>counter(3,vector<bool>(3,false));
	cin >> n >> m;
	if (m != 0) {
		for (int i = 0; i < m; i++) {
			cin >> b >> c;
			z.push_back(b);
			zz.push_back(c);
		}
		bb = z.at(0);
		if (m >= 2)cc = z.at(1);
		if (m >= 3)dd = z.at(2);
		if (m >= 4)ee = z.at(3);
		if (m >= 5)ff = z.at(4);

		if (n == 1) {
			left = 0;
			right = 10;
		}
		if (n == 2) {
			left = 10;
			right = 100;
		}
		if (n == 3) {
			left = 100;
			right = 1000;
		}
		for (int i = left; i < right; i++) {
			ic = i;
			ii[0] = ic % 10;
			ic /= 10;
			ii[1] = ic % 10;
			ic /= 10;
			ii[2] = ic % 10;
			if (m == 0 || m == 1 && ii[n - bb] == zz.at(0) || m == 2 && ii[n - bb] == zz.at(0) && ii[n - cc] == zz.at(1) ||
				m == 3 && ii[n - bb] == zz.at(0) && ii[n - cc] == zz.at(1) && ii[n - dd] == zz.at(2) ||
				m == 4 && ii[n - bb] == zz.at(0) && ii[n - cc] == zz.at(1) && ii[n - dd] == zz.at(2) && ii[n - ee] == zz.at(3) ||
				m == 5 && ii[n - bb] == zz.at(0) && ii[n - cc] == zz.at(1) && ii[n - dd] == zz.at(2) && ii[n - ee] == zz.at(3) && ii[n - ff] == zz.at(4)) {
				cout << i << endl;
				break;
			}
			if (i == right - 1)cout << out << endl;
		}
	}
	else if (n == 1)cout << 0 << endl;
	else if (n == 2)cout << 10 << endl;
	else if (n == 3)cout << 100 << endl;
	
	please AC;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int A, B;

int main() {
    cin >> A >> B;

    string SA = "";
    for (int i = 0; i < B; i++) {
        SA += to_string(A);
    }
    string SB = "";
    for (int i = 0; i < A; i++) {
        SB += to_string(B);
    }

    string ans;

    if (SA < SB)
        ans = SA;
    else
        ans = SB;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int n;
ll a[200009];
ll dp1[200009][16];
ll dp2[200009][16];

ll pow4[30];

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

    pow4[0] = 1;
    FOR(i, 1, 30) pow4[i] = pow4[i - 1] << 2;

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

    rep(i, 16) dp1[n - 1][i] = i;

    FORR(i, n - 1) rep(j, 16) {
        double x = a[i] * pow4[j];
        int k = 0;
        while(a[i + 1] < x / pow4[k])
            k++;
        if(k <= 15)
            dp1[i][j] = dp1[i + 1][k] + j;
        else
            dp1[i][j] = dp1[i + 1][15] + (n - 1 - i) * (k - 15) + j;
    }

    rep(i, 16) dp2[0][i] = i;

    FOR(i, 1, n) rep(j, 16) {
        double x = a[i] * pow4[j];
        int k = 0;
        while(a[i - 1] < x / pow4[k])
            k++;
        if(k <= 15)
            dp2[i][j] = dp2[i - 1][k] + j;
        else
            dp2[i][j] = dp2[i - 1][15] + i * (k - 15) + j;
    }

    ll ans = min(dp1[0][0] * 2, dp2[n - 1][0] * 2 + n);

    rep(i, n - 1) chmin(ans, dp2[i][0] * 2 + dp1[i + 1][0] * 2 + i + 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 51840
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,sse,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
using ll = long long;
const int mod = 1000003;
int fact[mod];
ll bp(ll a, ll p) {
	ll r = 1;
	while(p) {
		if(p&1) r = r*1ll*a%mod;
		a=a*1ll*a%mod, p>>=1;
	}
	return r;
}
ll solve(ll x, ll n) {
	ll r = x+n-1;
	if(r >= mod) return 0;
	if(x == 0) return 0;
	return fact[r]*1ll*bp(fact[x-1], mod-2)%mod;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	ll q, n, d, x;
	fact[0] = 1;
	for(int i = 1; i < mod; i++) fact[i] = fact[i-1]*1ll*i%mod;
	cin >> q;
	while(q--) {
		cin >> x >> d >> n;
		if(d == 0) cout << bp(x, n) << '\n';
		else cout << bp(d, n)*1ll*solve(x*1ll*bp(d, mod-2)%mod, n)%mod << '\n';
	}
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using i64 = long long;

template <typename T, typename U, typename V>
auto pow(T x_, U n_, V mod_) {
    std::common_type_t<T, U, V> ret = 1, x = x_, n = n_, mod = mod_;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <typename T, typename U>
auto inverse(T x, U p) { return pow(x, p - 2, p); }

int main() {
    constexpr i64 mod = 1000000007;
    i64 n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;
    std::vector<i64> t(n), s(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) s[i]++;
            if (j > i && a[i] > a[j]) t[i]++;
        }
    }

    i64 d = inverse(2ll, mod), ss = 0, st = 0;
    for (int i = 0; i < n; i++) {
        ss = (ss + s[i]) % mod;
        st = (st + t[i]) % mod;
    }

    i64 ret = (k * k % mod + mod - k * (k + 1) % mod * d % mod) % mod * ss % mod + k * st % mod;
    std::cout << ret % mod << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll dp[100000+10][13];memset(dp,0,sizeof(dp));dp[0][0]=1;
  ll c=0,mod=1e9+7,l=s.length();
  for(ll i=0;i<l;++i) {
    c=(s[i]=='?')?-1:(s[i]-'0');
    for(ll j=0;j<10;++j) {
      if(c!=-1&&c!=j) continue;
      for(ll k=0;k<13;++k) dp[i+1][(k*10+j)%13]+=dp[i][k];
    }
    rep(j,13) dp[i+1][j]%=mod;
  }
  print(dp[l][5]);
  return 0;
}

Measured memory_bytes: 10704
N = int(input())
S = sorted([''.join(sorted(input())) for _ in range(N)])
S.append('')
keep = ''
result = cnt = 0
for s in S:
    if keep == s:
        cnt += 1
    else:
        result += ((cnt - 1) * cnt) // 2
        cnt = 1
        keep = s
print(result)


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


int main() {
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<min(A,B)+min(C,D)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const ll MAXN = (1LL << 62);
const int maxn = 200000 + 50;
const ll mod = 1e9+7;
ll a[maxn], pre[maxn], c[maxn];
int n, m;
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i < n; i++){
      int s = a[i], t = a[i+1];
      if(s <= t){
        pre[1] += t - s;
        pre[s+1] -= t - s;
        pre[s+1] += t + 1;
        c[s+1] -= 1;
        c[t+1] += 1;
        pre[t+1] -= t + 1;
        pre[t+1] += t - s;
      }
      else{
        pre[1] += t + 1;
        pre[t+1] -= t + 1;
        c[1] -= 1;
        c[t+1] += 1;
        pre[t+1] += m - s + t;
        pre[s+1] -= m - s + t;
        pre[s+1] += 1 + m + t;
        c[s+1] -= 1;
      }
    }
    for(int i = 2; i <= m; i++) pre[i] += pre[i-1], c[i] += c[i-1];
    ll ans = MAXN;
    for(int i = 1; i <= m; i++){
      ans = min(ans, (ll)pre[i] + i * c[i]);
    }
    cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3584
/*input
3 2
2
1 3
1
33
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll t=1,i,j;
    ll n,k;
    cin>>n>>k;
    ll d;
    ll a[n]={0};
    ll ans=n;
    rep(i,0,k){
    	cin>>d;
    	rep(j,0,d){
    		ll b;
    		cin>>b,--b;
    		if(!a[b])--ans;
    		a[b]=1;
    	}
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3660
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();

        if (30 <= n) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }

}



Measured memory_bytes: 35648
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

from collections import defaultdict
count = defaultdict(int)

for a in A:
  count[a] += 1

ans = sum(A)

for _ in range(Q):
  B, C = map(int, input().split())
  if count[B] > 0:
    ans += C * count[B]
    ans -= B * count[B]
    count[C] += count[B]
    count[B] = 0
  print(ans)


Measured memory_bytes: 23136
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	vector< int > X(5);
	rep(i, 5) cin >> X[i];
	int ans;
	rep(i, 5) if (X[i] == 0) ans = i + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> v(m);
  rep(i,m) cin >> v[i];
  int l = 0;
  int r = 0;
  rep(i,m) {
    if (v[i] < x) l++;
    else r++;
  }
  cout << min(l,r) << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define forn(a,n) for(int i = a; i < n; i++)


using namespace std;

typedef long long int ll;
typedef vector<int> vec;
typedef vector<ll> vecl;
typedef unsigned long long int ull;
typedef vector<ull> vecu;


void print(const vec &a)
{
    forn(0,a.size())
        cout << a[i];
    cout << "\n";
}

int main()
{

    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a*c, b *d, a*d, b*c});
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
string s;
ll a[200005] , p[200005];
int main()
{
        cin>>s;
        ll n = s.length();
        for(ll i=1;i<=n;i++) a[i] = (s[i-1] == 'B');
        for(ll i=1;i<=n;i++) p[i] = p[i-1] + a[i];
        ll ans = 0;
        for(ll i=1;i<=n;i++) {
                if(a[i] == 0) ans += p[i];
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 3716
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

void Main() {
    //code here
    int k = gi;
    int res = 0;
    OneToN(a, k) {
        OneToN(b, k) {
            OneToN(c, k) {
                res += gcd(a,(gcd(b,c)));
            }
        }
    }
    print(res);
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 3656
import kotlin.system.exitProcess
fun main(args:Array<String>) {
    val n:Int = readLine()!!.toInt()
    for (x in 1..9) {
        for (y in 1..9) {
            if (x * y == n) {
                println("Yes")
                exitProcess(0)
            }
        }
    }
    println("No")
}

Measured memory_bytes: 32020
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    A = int(input())
    if N % 500 > A:
        print(No)
    else:
        print(Yes)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b] <- getInts
  ; putInts [a*b, 2*(a+b)]
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
using namespace std;
int main(){
    string N;
    cin >> N;
    int size = N.length();
    int N_num[size];
    int count = 0;
    for(int i=0;i<size;i++){
        N_num[i] = N[i]-'0';
        count = count + N_num[i];
    }

    if(count%9==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 4528
def solve():
    N, M, K = [int(i) for i in input().split()]
    for k in range(N + 1):
        for l in range(M + 1):
            if k * (M - l) + (N - k) * l == K:
                return True
    return False

if solve():
    print("Yes")
else:
    print("No")


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

int main() {
    int n;
    cin >> n;
    vector<int> rui(n);
    rep(i,n) {
      int w;
      cin >> w;
      if (i == 0) rui[i] = w;
      else rui[i] = rui[i-1] + w;
    }
    int ans = 1001001001;
    for (int i = 0; i < n-1; i++) {
      int s1 = rui[i];
      int s2 = rui[n-1]-s1;
      ans = min(ans, abs(s1-s2));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int h,w;
  cin >> h >> w;
  int a,b;
  cin >> a >> b;
  
  rep(i,h-b){
    rep(j,w-a) cout << 0;
    rep(j,a) cout << 1;
    cout  << "\n";
  }

  rep(i,b){
    rep(j,w-a) cout << 1;
    rep(j,a) cout << 0;
    cout  << "\n";
  }

  
  return 0;
}


Measured memory_bytes: 1280
# coding: utf-8

n = int(input().rstrip())
b_list = list(map(int, input().rstrip().split(" ")))

a_list = list(range(n))

a_list[0] = b_list[0]
for i in range(1, n):
    if i >= len(b_list):
        a_list[i] = b_list[i - 1]
        break
    a_list[i] = min(b_list[i - 1], b_list[i])

print(sum(a_list))


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] Array = new int[N][2];
        for (int i=0;i<N;i++){
            Array[i][0] = sc.nextInt();
            Array[i][1] = sc.nextInt();
        }
        Arrays.sort(Array, Comparator.comparingInt(o -> o[0]));
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());
        int Ans = 0;
        int A = 0;
        for (int j =1;j<=M;j++){

            while(A!=N&&Array[A][0]==j){
                pq.add(Array[A][1]);
                A++;
            }
            if(!(pq.isEmpty())){
            Ans += pq.remove();
            }
        }
        System.out.println(Ans);
        sc.close();
    }
}

Measured memory_bytes: 97544
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N,i,j,v;
    cin >> N;
    vector<int> A(N);
    for(i=0;i<N;i++) cin >> A.at(i);
    for(i=1;i<N;i++){
        for(j=0;j<N;j++){
            if(j) cout << " ";
            cout << A.at(j);
        }
        cout << endl;
        v = A.at(i);
        j = i-1;
        while(j>=0&& A.at(j)>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1] = v;
    }
    for(i=0;i<N;i++){
        if(i) cout << " ";
        cout << A.at(i) ;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

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

  VI s = VI(500000, 0);

  REP(i, 0, n){
    int tmp;
    cin >> tmp;
    s[tmp]++;
  }

  int ans = 0;

  REP(i, 1, 500000-1){
    ans = max(ans, s[i-1]+s[i]+s[i+1]);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

void trace(int A[],int N){
    for(int i=0;i<N;i++){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionsort(int A[],int N){
    int v;
    for(int i=1;i<N;i++){
        v=A[i];
        int j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(){
    int A[100];
    int N,i,j;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    trace(A,N);
    insertionsort(A,N);
    
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll a, b;
    cin >> a >> b;
    if (a*b%2==1) cout << "Odd\n";
    else cout << "Even\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int w,h;
    int i,j;
    while(1){
    scanf("%d %d\n",&h,&w);
    if(h == 0 && w == 0) break;
    for(i = 0;i < h; i++){
        for(j = 0; j < w; j++){
            printf("#");
        }
        printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2124
/**
 *      ABC 78 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-03 02:17:35
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int X, Y, Z; cin >> X >> Y >> Z;

    cout << (X - Z) / (Y + Z) << endl;

    return 0;
}


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

vector<int> input(int N){
    vector<int> vec;    
    int temp = 0;
    for (int i = 0; i < N; i++ )    {
        cin >> temp;
        vec.push_back(temp);
    }
    return vec;
}


int main(){
    int N; // 100
    cin >> N;
    vector<int> a1 = input(N); // max 100
    vector<int> a2 = input(N);
    vector<int> b1 = vector<int>(N);
    vector<int> b2 = vector<int>(N);

    b1.at(0) = a1.at(0);
    b2.at(0) = a2.at(0);
    for(int i = 0; i < N-1; i++)    {
        b1.at(i+1) = b1.at(i) + a1.at(i+1);
        b2.at(i+1) = b2.at(i) + a2.at(i+1);
    }
  
    int max_val = 0;
    // zero
    int value = b1.at(0) + b2.at(N-1);
    max_val = value;
    for (int i = 0; i < N-1; i++) {
        int value = b1.at(i+1) - b2.at(i) + b2.at(N-1);
        if (value > max_val){
            max_val = value;    
        }
    }
    cout << max_val << endl;
}

Measured memory_bytes: 3600
/**
 *    author:  lets
 *    created: 2020-06-07 18:34:47 JST
 **/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> col(9, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 400)
      col[0] = 1;
    else if (a[i] < 800)
      col[1] = 1;
    else if (a[i] < 1200)
      col[2] = 1;
    else if (a[i] < 1600)
      col[3] = 1;
    else if (a[i] < 2000)
      col[4] = 1;
    else if (a[i] < 2400)
      col[5] = 1;
    else if (a[i] < 2800)
      col[6] = 1;
    else if (a[i] < 3200)
      col[7] = 1;
    else
      col[8]++;
  }
  int ans = 0;
  for (int i = 0; i < 8; i++) {
    ans += col[i];
  }
  if (ans == 0) {
    ans = 1;
    col[8]--;
  }
  cout << ans << ' ' << ans + col[8] << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<long long> x,y,z;
long long n,a;
 
bool check(long long end_val){
	y = x;
	y[n-1] -= end_val;
	z[n-1] = 2*end_val;
	for(long long i = n-2 ; i >= 0 ; i -= 1){
		y[i] -= end_val;
		end_val = y[i];
		z[i] = 2*end_val;
	}
	if(end_val <= y[n-1]){
		return true;
	}else{
		return false;
	}
}
     
int main(){
	cin >> n;
	z.assign(n,0);
	for(long long i = 0 ; i < n ; i += 1){
		cin >> a;
		x.push_back(a);
	}
	long long first = 0, last = 4000000000 , mid;
	while(last - first > 1){
		mid = (first + last)/2;
		if(check(mid)){
			first = mid;
		}else{
			last = mid;
		}
	}
	if(check(first)){
		for(long long i : z){
			cout << i << " ";
		}
	}else{
		check(last);
		for(long long i : z){
    		cout << i << " ";
    	}
    }
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

constexpr lint MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> acc(3);
    lint ret = 1;
    REP(i, N)
    {
        int x;
        cin >> x;
        int n = 0;
        for (auto v : acc)
        {
            if (x  == v) n++;
        }
        ret = ret * n % MOD;
        for (auto &v : acc) if (v == x)
        {
            v++;
            break;
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
import numpy as np
N, M = map(int, input().split())
C = list(map(int, input().split()))
B = [1 for _ in range(N)]

for i in range(M):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
C = np.array(C)
D = np.argsort(-C)
#print(B, C, D)
S = 0
n = 0
for i in D:
    #print(B[i], N-n, min(B[i], N-n))
    S += C[i] * (min(B[i], N-n))
    n += min(B[i], N-n)
    #print(S, n)
    if n == N:
        break
print(S)

Measured memory_bytes: 27068
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

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

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


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

    vector<int> p(n);
    REP(i,n) cin >> p[i];

    int ans=0;

    REP(i,n-2){
    	if(p[i+1]>p[i] && p[i+1]<p[i+2]) ans++;
    	else if(p[i+1]<p[i] && p[i+1]>p[i+2]) ans++;

    }



	cout << ans << endl;

}



Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (a, b): (i32, i32) = read();
    let diff = b - a;
    let height = diff * (diff + 1) / 2;
    println!("{}", height - b);
}


Measured memory_bytes: 4352
// C - Conunt Order
#include <stdio.h>
#include <stdlib.h>

int cOrder(int n, int a[]){
    int i, j, cnt=0;
    for(i=0; i<n-1; i++){
        for(j=i; j<n; j++){
            if(a[i] > a[j]) cnt++;
        }
        cnt *= n-i-1;
    }
    return cnt;
}

int main(void){
    int n;
    scanf("%d", &n);
    int p[9], q[9];
    for(int i=0; i<n; i++) scanf("%d", &p[i]);
    for(int i=0; i<n; i++) scanf("%d", &q[i]);
    printf("%d\n", abs(cOrder(n, p) - cOrder(n, q)));
    return 0;
}

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

int main(){
    int a, b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '+') cout << a + b << endl;
        else if(op == '-') cout << a - b << endl;
        else if(op == '*') cout << a * b << endl;
        else if(op == '/') cout << a / b << endl;
        else break;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#define int long long
#define REP(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define MOD 998244353
#define IDE -1

using namespace std;

const int MAX_N = 1 << 20;
int n_max,n, dat[2 * MAX_N - 1];

void init(int n) {
    n_max = 1;
    while (n_max < n) n_max *= 2;
    REP(i,2 * n_max - 1) dat[i] = IDE;
}

int segfunc(int l, int m) {
    return max(l,m);
}

//k番目の値(0-indexed)をaに変更
void update(int k, int a) {
    k += n_max - 1;
    dat[k] = a;
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = segfunc(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

int query(int a, int b, int k, int l, int r) {
    //cout << "query: " << a << " " << b << " " << k << " " <<  l << " " << r << "\n";
    if (r <= a || b <= l) {
        //cout << "-1\n";
        return IDE;
    }
    if (a <= l && r <= b) {
        //cout << dat[k] << "\n";
        return dat[k];
    }
    else {
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return segfunc(vl, vr);
    }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false); 
    cin >> n;
    init(n);
    vector< pair<int, int> > robots;
    REP(i,n) {
        int xt,dt;
        cin >> xt >> dt;
        robots.pb(mp(xt,dt));
    }
    sort(robots.begin(),robots.end());
    vector<int> x(n), d(n);
    REP(i,n) {
        x[i] = robots[i].first;
        d[i] = robots[i].second;
    }
    REP(i,n) {
        int j = i;
        update(j,j);
    }
    for (int i = n-1; i >= 0; i--) {
        int idx_direct = lower_bound(x.begin(),x.end(),x[i] + d[i]) - x.begin();
        //cout << "idx_direct " << i << ":" << idx_direct << "\n";
        int q = query(i + 1, idx_direct, 0, 0, n_max);
        int upval = max(i, q);
        if (upval >= 0) update(i, upval);
        
        for (int j = 0; j < n + n_max - 1; j++) {
            //cout << dat[j] << " ";
        }
        //cout << "\n";
        
    }

    vector<int> dp(n + 1);
    dp[n] = 1;
    for (int i = n-1; i >= 0; i--) {   
        dp[i] = (dp[i + 1] + dp[dat[i + n_max - 1] + 1]) % MOD;
    }
    cout << dp[0] << "\n";
    return 0;
}

Measured memory_bytes: 15084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main(void){
    long A,B,H,M;
    std::cin >> A >> B >> H >> M;
    long double pi=3.14159265358979;
    long double kakudo=(pi*M)/(double)30;
    long double kakudo2=pi*(60*H+M)/(double)360;
    long double kakudo3=std::fabs(kakudo-kakudo2);
    if(2*pi-kakudo3>kakudo3){
        kakudo3=2*pi-kakudo3;
    }
    long temp1=A*A+B*B;
    long temp2=2*A*B;
    long double temp3 =cos(kakudo3);
    long double temp4=temp1-temp2*temp3;
    long double result = std::sqrt(temp4);
    std::cout << std::setprecision(15) << result << std::endl;
    return 0;
}

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

signed main() {
    int N, K;
    cin >> N >> K;

    vector<vector<int>> vv(N);
    for (int i = 0; i < N; i++) {
        int t, d;
        cin >> t >> d;

        vv[--t].push_back(d);
    }

    for (auto& v : vv) {
        sort(v.rbegin(), v.rend());
    }

    vector<int> inc, others;
    for (auto v : vv) {
        for (int i = 0; i < v.size(); i++) {
            if (!i) inc.push_back(v[i]);
            else others.push_back(v[i]);
        }
    }
    sort(inc.begin(), inc.end());
    sort(others.begin(), others.end());
    inc.push_back(0);
    others.push_back(0);
    reverse(inc.begin(), inc.end());
    reverse(others.begin(), others.end());

    for (int i = 1; i < inc.size(); i++) {
        cerr << inc[i] << " ";
        inc[i] += inc[i - 1];
    }
    cerr << endl;

    for (int i = 1; i < others.size(); i++) {
        cerr << others[i] << " ";
        others[i] += others[i - 1];
    }
    cerr << endl;

    int ans = 0;
    for (int i = 1; i <= K; i++) {
        if (i >= inc.size()) break;
        if (K - i >= others.size()) continue;
        int t = i * i;
        t += inc.at(i) + others.at(K - i);

        ans = max(ans, t);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6904
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	
	// a + b >= 2c -> should buy c.
	
	int totalCost = 0;;
	if ((a + b) >= (2 * c))
	{
		totalCost += min(x, y) * c * 2;
		if (x > y)
		{
			totalCost += min((x - y) * a, (x - y) * c * 2);
		}
		else if (x < y)
		{
			totalCost += min((y - x) * b, (y - x) * c * 2);
		}
	}
	else
	{
		totalCost += ((a * x) + (b * y));
	}
	
	cout << totalCost << endl;
	
#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs'
const reader = (s: string) => s.split('\n') // .map(t => parseInt(t, 10))

function Main(input: string) {
  const N = parseInt(reader(input)[0], 10)
  const v = reader(input)[1]
    .split(' ')
    .map(x => parseInt(x, 10))
    .sort((a, b) => a - b)

  let ans = v[0]
  for (let i = 1; i <= N - 1; i++) {
    ans = (ans + v[i]) / 2
  }

  console.log(ans)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
/**
 *   author: BinaryBox
**/

#include <bits/stdc++.h>
#define Endl cout<<"\n"
#define Test cout<<"Hello\n"

using namespace std;

using ll = long long;

const int N = int(1e6 + 1);
const ll INF = ll(1e17);

vector<vector<ll> > tree(4*N, {0, INF});

ll f(vector<ll> line, int x){
    return line[0] * x + line[1];
}

void insert(vector<ll> line, int lo = 1, int hi = N, int i = 1){
    int m = (lo + hi) / 2;
    bool left = f(line, lo) < f(tree[i], lo);
    bool mid = f(line, m) < f(tree[i], m);

    if(mid) swap(tree[i], line);

    if(hi - lo == 1) return;
    else if(left != mid) insert(line, lo, m, 2*i);
    else insert(line, m, hi, 2*i+1);
}

ll query(int x, int lo = 1, int hi = N, int i = 1){
    int m = (lo+hi)/2;
    ll curr = f(tree[i], x);
    if(hi-lo==1) return curr;
    if(x<m) return min(curr, query(x, lo, m, 2*i));
    else return min(curr, query(x, m, hi, 2*i+1));
}

int main(){
    int n;
    ll C;
    cin>>n>>C;
    vector<ll> dp(n, 0), h(n);
    for(int i=0; i<n; i++){
        cin>>h[i];
        if(i!=0) dp[i] = C + h[i]*h[i] + query(h[i]);
        insert({-2*h[i], dp[i]+h[i]*h[i]});
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 224128
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll n;cin >> n;
  ll x;cin >> x;

  vector<ll> b(n+1);
  vector<ll> p(n+1);
  b[0] = 1;
  p[0] = 1;
  rep(i,n) {
    b[i+1] = b[i]*2 + (ll)3;
    p[i+1] = p[i]*2 + (ll)1;    
  }

  int index = n;
  ll res = 0;
  while(index > 0) {
    ll th = b[index-1] + (ll)2;
    if(x < th) {
      x--;
      index--;
    }
    else if(x > th) {
      res += p[index-1] + (ll)1;
      x -= th;
      index--;
    }
    else {
      res += p[index-1] + (ll)1;
      break;
    }
    if(x <= 0) break;
    if(index == 0) res += (ll)1;

  }

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


Measured memory_bytes: 256