akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> A, B;
  rep(i,N){
    ll a;
    cin >> a;
    A.push_back(a);
  }
  rep(i,N){
    ll b;
    cin >> b;
    B.push_back(b);
  }

  vector<ll> ret;
  vector<ll> AA(N,0), BB(N,0);
  for(ll bit=0; bit<30; bit++){
    ll keta = 0;
    if(bit > 0){
      ll th = 1LL<<bit;
      vector<ll> aa = AA, bb = BB;
      sort(ALLOF(aa));
      sort(ALLOF(bb));
      int j = 0;
      for(int i=aa.size()-1; i>=0; i--){
        while(j<bb.size() && aa[i]+bb[j]<th) j++;
        keta += N-j;
      }
    }
    
    vector<ll> X(2,0), Y(2,0);
    rep(i,A.size()){
      if((A[i]>>bit)&1LL){
        X[1]++;
        AA[i] |= 1LL<<bit;
      }
      else X[0]++;
    }
    rep(i,B.size()){
      if((B[i]>>bit)&1LL){
        Y[1]++;
        BB[i] |= 1LL<<bit;
      }
      else Y[0]++;
    }
    
    ll sum = keta + X[0]*Y[1] + X[1]*Y[0];
    if(sum%2==1) ret.push_back(1);
    else ret.push_back(0);


    //cout << bit << "\t" << sum << " " << keta << " " << X[0] << " " << X[1] << " " << Y[0] << " " << Y[1] << endl;    
    //cout << ret[ret.size()-1] << endl;
  }

  reverse(ALLOF(ret));

  ll ans = 0;
  rep(i,ret.size()){
    ans <<= 1LL;
    ans += ret[i];
  }

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



Measured memory_bytes: 9712
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
using LL = int_fast64_t;
LL n,m;
int main(){
    ____();
    cin >> n >> m;
    if(m==1) swap(n,m);
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    cout << (n*m+1)/2 << endl;
    return 0;
}

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

int main() {
 
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if( a+b > c+d )
    cout << "Left" << endl;
  else if(a+b == c+d)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

int main(){
int n;
int m;
cin >> n;
cin >> m;
int x;
x=0;
int y;
y=0;
int a[m];
for(int i = 0; i <m; ++i) {
    cin >> a[i];
}
	std::vector<int> data;
	std::vector<int> sub;
for(int i = 0; i <m; ++i) {
    data.push_back(a[i]);
}

	std::sort(data.begin(),data.end(),std::greater<int>());//降順ソート
	//std::sort(&data[0],&data[5]);//上と同じ意味
for(int i = 0; i <m-1; ++i) {
	sub.push_back(-data[i+1]+data[i]);
}
	std::sort(sub.begin(),sub.end(),std::greater<int>());//降順ソート

for(int i = n-1; i <m-1; ++i) {
y=y+sub[i];
}
cout << y <<endl;
	return 0;
}


Measured memory_bytes: 1784
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i, a+1){
    rep(j, b+1){
      rep(k, c+1){
        if (500*i + 100*j + 50*k == x) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=60,MAXS=110;
map <string,int> mp;
int n,t[MAXN],ans;
string s;
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		cin >> s;
		scanf("%d",&t[i]);
		mp[s]=i;
	}
	cin >> s;
	int tmp=mp[s];
	for (int i=tmp+1;i<=n;i++) {ans+=t[i];}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#define inf 0x7fffffffffffffff
using namespace std;
typedef long long lint;
const lint Mod=1e9+7,Maxn=1e5+3;
int main()
{
	lint Ans=1,K=0,N,Data;
	scanf("%lld",&N);
	while(N--)
	{
		scanf("%lld",&Data);
		K++;
		if(Data<(2*K-1))
		{
			Ans=(Ans*K)%Mod;
			K--;
		}
	}
	for(int i=2;i<=K;i++)
	Ans=(Ans*i)%Mod;
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  int H, W;
  int C[10][10] = {};
  vector<vector<int>> A;
  vector<int> count;

  Tmp(int H, int W)
  : H(H), W(W)
  , A(H, vector<int>(W))
  , count(10, 0)
  {}

  void operator()() {
    input();
    vector<vector<ll>> costTable(10, vector<ll>(10, INF));
    for (int i = 0; i < 10; ++i) {
      for (int j = 0; j < 10; ++j) {
        costTable[i][j] = C[i][j];
      }
    }

    for (int k = 0; k < 10; ++k) {
      for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
          chmin(costTable[i][j], costTable[i][k] + costTable[k][j]);
        }
      }
    }

    ll res{};
    for (int i = 0; i < 10; ++i) {
      res += count[i] * costTable[i][1];
    }
    cout << res << CRLF;

  }

  void input() {
    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];
        if (A[i][j] == -1) {
          A[i][j] = 1;
        } else {
          ++count[A[i][j]];
        }
      }
    }
  }
};

void solve(void)
{
  int H, W; cin >> H >> W;
  Tmp t(H, W);
  t();
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

using namespace std;
typedef long long LL;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define print(arr, r, c) rep(i, 0, r) {rep(j, 0, c)cout<<arr[i][j]<<"";cout<<endl;}
#define all(b) b.begin() , b.end()
#define mp(a, b) make_pair(a,b)
#define pb(a) push_back(a)
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define turnOff(k, i) (k&(~(1<<(i-1))))
#define isOn(k, i) (k&&(1<<i-1)?true:false)
#define pll pair<long long int , long long int>
#define ull unsigned long long int
#define ll  long long int
#define add(a, b) (((a)+(b))%MOD)
#define sub(a, b) (((a)-(b)+MOD)%MOD)
#define mul(a, b) ((1ll*(a)*(b))%MOD)
#ifdef  DEBUG
#define MAXN 5203
#else
#define MAXN 300007
#endif
#define MAXLG 20
#define endl '\n'
#define PI 3.141592653589793238
#define MOD (998244353)
#define INF (2000000000)
#define EPS (0.00000001)
#define treap treapNode
long mod_pow(long x, int y)
{
    // exponentiation by squaring
    long r = 1;
    while (y > 0) {
        if (y % 2 == 1) {
            r = (r*x) % MOD;
        }
        x = (x*x) % MOD;
        y /= 2;
    }
    return r;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input", "r", stdin);
#endif
    int n;
    cin>>n;
    ii p[n];
    rep (i,0,n)
        cin>>p[i].first>>p[i].second;

    ll ans = sub(mod_pow(2,n),1+n);


    rep (i,0,n) {
        map<ii,int> sl;
        rep (j, i+1, n) {
            int m1 = (p[i].first-p[j].first);
            int m2 = (p[i].second-p[j].second);
            int gcd = __gcd(abs(m1),abs(m2));
            ii slope;
            slope.first = abs(m1)/gcd;
            slope.second = abs(m2)/gcd;

            if (m1*m2 <0) {
              slope.first *=-1;
            }
            if (sl.count(slope)==0) {
                sl[slope]=0;
            }
            sl[slope] =  sl[slope] + 1;

        }


        for (pair<ii,int> val : sl) {
            int k = val.second;
            ans =  (MOD + ans - sub(mod_pow(2,k),1))%MOD;
        }
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int h, w; cin >> h >> w;
    vector<string> table(h);
    for(int i = 0; i < h; i++) cin >> table[i];

    vector<string> ans(h);
    const int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
    const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
    for(int i = 0; i < h; i++)
    {
        ans[i].resize(w);
        for(int j = 0; j < w; j++)
        {
            int cnt = 0;
            if(table[i][j] == '#')
            {
                ans[i][j] = table[i][j];
                continue;
            }
            for(int k = 0; k < 8; k++)
            {
                int ny = i + dy[k];
                int nx = j + dx[k];
                if(ny < 0 or nx < 0 or ny >= h or nx >= w) continue;
                if(table[ny][nx] == '#') cnt++;
            }
            ans[i][j] = cnt + '0';
        }
    }
    for(int i = 0; i < h; i++) cout << ans[i] << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) begin(x), end(x)

int main(){
    ll n,m;cin>>n>>m;
    vector<ll> vx(n),vy(n),vz(n),vans(n);
    ll ans=0,temp1=0,temp2=0;
    rep(i,n){
      cin>>vx[i]>>vy[i]>>vz[i];
    }

    int J[][3]={{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};

    rep(j,4){
      rep(i,n){
        vans[i]=0;
        vans[i]=J[j][0]*vx[i]+J[j][1]*vy[i]+J[j][2]*vz[i];
      }
      sort(all(vans));
      temp1=0,temp2=0;
      rep(i,m){
        temp1+=vans[i];
        temp2+=vans[n-i-1];
      }
      ans=max(max(abs(temp1),abs(temp2)),ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10ll+ch-'0';ch=getchar();}
	return x*f;
}
inline ll fast_pow(ll a,ll b,ll p){
    ll t=1;a%=p;
    while (b){
        if (b&1) t=t*a%p;
        b>>=1;a=a*a%p;
    }
    return t;
}
ll n,K,g[1010],a[1010],dp[1010][1010],_;
signed main(){
	n=read()*2,K=read();
	for (int i=1;i<=K;i++){
		int x=read(),y=read();
		a[x]=y,a[y]=x;
	}
	g[0]=1;
	for (ll i=2;i<=n;i+=2) g[i]=g[i-2]*(i-1)%ljc;
	for (int len=2;len<=n;len+=2){
		for (int i=1;i+len-1<=n;i++){
			int j=i+len-1,col=len;
			bool flag=1;
			for (int k=i;k<=j;k++){
				if (a[k]&&(a[k]<i||a[k]>j)) flag=0;
				col-=(a[k]>0);
			}
			if (!flag) continue;
			dp[i][j]=g[col];
			for (int k=j,d=0;k>i;k--){
				d+=(!a[k]);
				dp[i][j]=(dp[i][j]-dp[i][k-1]*g[d]%ljc+ljc)%ljc;
			}
			_=(_+dp[i][j]*g[n-2*K-col]%ljc)%ljc;
		}
	}
	cout<<_;
	return 0;
}

Measured memory_bytes: 7164
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

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


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

  int n; std::cin >> n;
  std::vector<ll> a(n); rep(i,n) std::cin >> a[i];

  auto f = [&] (int p) -> ll {
    ll q = 0, s = 0;
    for(int i=0; i<n; i++, p = -p) {
      q += a[i];
      if ( p > 0 ) {
        if ( q <= 0 ) s += -q+1, q = 1;
      }
      else {
        if ( q >= 0 ) s += q + 1, q = -1;
      }
    }
    return s;
  };

  std::cout << std::min( f(1), f(-1) ) << std::endl;

  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define find(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));

  int n; cin >> n;
  int mat[n][n]; memset(mat, 0, sizeof(mat));

  for (int i = 0; i < n; i++) {
    int u; cin >> u;
    int k; cin >> k;
    for (int ki = 0; ki < k; ki++) {
      int v; cin >> v;
      mat[u - 1][v - 1] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    cout << mat[i][0];
    for (int j = 1; j < n; j++) {
      cout << " " << mat[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec(32, 1);
  vec.at(3) = 2;
  vec.at(5) = 2;
  vec.at(7) = 5;
  vec.at(8) = 2;
  vec.at(9) = 2;
  vec.at(11) = 5;
  vec.at(13) = 2;
  vec.at(15) = 14;
  vec.at(17) = 5;
  vec.at(19) = 5;
  vec.at(20) = 2;
  vec.at(21) = 2;
  vec.at(23) = 15;
  vec.at(24) = 2;
  vec.at(25) = 2;
  vec.at(26) = 5;
  vec.at(27) = 4;
  vec.at(29) = 4;
  vec.at(31) = 51;
  
  int i;
  cin >> i;
  cout << vec.at(i - 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s,t;
cin >> s >> t;
for(ll i = 0; i < s.size(); i++){
    if(s[i] != t[i])
    {
        cout << "No" << endl;
        return 0;
    }
}
cout << "Yes" << endl;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL << 31;
constexpr static int dx[] = {1, 0, -1, 0};
constexpr static int dy[] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<int> imos(n, 0);
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        imos[l - 1] += 1;
        if (r != n) imos[r] -= 1;
    }

    rep(i, n + 1) {
        if (i) imos[i] += imos[i - 1];
    }
    int ans = 0;
    rep(i, n) {
        if(imos[i] == m) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
using namespace std;
int main()
{
	int n;scanf("%d",&n);
	int a=n/100,b=n/10%10,c=n%10;
	if(a==1) printf("9");else if(a==9) printf("1");
	if(b==1) printf("9");else if(b==9) printf("1");
	if(c==1) printf("9");else if(c==9) printf("1");printf("\n");
	return 0;
}

Measured memory_bytes: 128
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	move := scanInts(5)
	mi := 1 <<63-1
	for i := 0; i < 5; i++ {
		mi = min(mi, move[i])
	}
	fmt.Fprintln(wr, (n+mi-1)/mi+4)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <map>
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
#define ll long long
constexpr ll MOD = 1e9 + 7;
ll gcd(ll a, ll b) {return b % a ? gcd(b % a, a) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
using namespace std;
using P = pair<ll, ll>;
using VI = vector<ll>;

int main() {
    char a[3];
    REP(i,3) {
        cin >> a[i];
    }
    long ans = 700;
    REP(i,3) {
        ans += 100 * (a[i] == 'o');
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
const Int INF = 1LL<<55;
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


Int n, K, M;

Int Add(Int &a,Int b){return a = (a + b%M)%M;}

void DP2(Int num, vector<vector<Int> > &dp){

  // dp[i][j] := 長さiで残り(j+1)箇所にinsertできる時の通り数。
  for(Int i=0;i<=n;i++) //長さ
    for(Int j=n; j >= 0; j--){ //カーソル
      if(j) Add(dp[i][j-1],dp[i][j]); //カーソルを左に動かす
      if(i < n) Add(dp[i+1][j], dp[i][j] * (j + 1));  //現在のカーソルの左側のどこかにinsert
    }
}

Int DP(){
  // dp[i][j] := iまでの数を使って長さjの数列を作る。
  vector<vector<Int> > dp(K+2, vector<Int>(n+1,0));
  dp[0][0] = 1;
  for(Int i=1;i<=K;i++){ // 使う数

    vector<vector<Int> > dp2(n+1, vector<Int>(n+1));
    for(Int x=0;x<=n;x++) dp2[x][x] = dp[i-1][x]; //今ままでに作った長さxの物をカーソルxで初期化
    DP2(i, dp2);
    
    for(Int j=0;j<=n;j++) dp[i][j] = dp2[j][0];
  }
  return dp[K][n];
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>n>>K>>M;

  Int ans = DP();
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 1760
using System;
using System.Linq;

namespace ITP1 {
	class Program {
		public static void Main() {
			int[] input;
			while (true) {
				input = Console.ReadLine()
					.Split()
					.Select(int.Parse)
					.ToArray();
				if (input[0] == 0 && input[1] == 0) break;
				else printOrdered(input[0], input[1]);
			}
		}

		private static void printOrdered(int arg0, int arg1) {
			if (arg0 < arg1) Console.WriteLine(arg0 + " " + arg1);
			else Console.WriteLine(arg1 + " " + arg0);
		}
	}
}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    ll n,a,b;
    cin>>n>>a>>b;

    ll ans=(n/(a+b));
    n-=ans*(a+b);
    ans*=a;

    if(n<a)ans+=n;
    else ans+=a;

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        try(Scanner sc=new Scanner(System.in)){
            int n=sc.nextInt();
            System.out.print(n+":");
            int x=n;
            for(int i=2; i*i<=x; i++) {
                while(n%i==0) {
                    System.out.print(" "+i);
                    n/=i;
                }
            }
            if(n!=1)
                System.out.println(" "+n);
            else
                System.out.println();
 
 
 
        }
    }
}


Measured memory_bytes: 26376
import sys

input = sys.stdin.readline


def main():
    a, b = map(int, input().split())

    x = (a + b) / 2
    if x.is_integer():
        ans = int(x)
    else:
        ans = int(x) + 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
const char bn = '\n';
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T,typename S,typename U>
ostream& operator<<(ostream& os, tuple<T,S,U> const& P){
    os << "(";
    os << get<0>(P);
    os << ", ";
    os << get<1>(P);
    os << ", ";
    os << get<2>(P);
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

vector<int64> calc_score(int D, vector<int64> const& C, vector<vector<int64>> const& S, vector<int> T){
    int64 score = 0;
    vector<int> last(26, -1);
    vector<int64> res(D);
    REP(i,D){
        last[T[i]] = i;
        score += S[i][T[i]];
        REP(j,26){
            score -= C[j] * (i-last[j]);
        }
        res[i] = score;
    }
    // return score;
    return res;
}

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

    vector<int64> C(26);
    REP(i,26) cin >> C[i];

    vector<vector<int64>> S(D, vector<int64>(26));
    REP(i,D) REP(j,26) cin >> S[i][j];

    vector<int> T(D);
    REP(i,D) cin >> T[i], T[i]--;


    auto ans=calc_score(D, C, S, T);

    for(auto a:ans) cout << a << endl;

}

Measured memory_bytes: 3708
#include <iostream>

using namespace std;

int main(){

	long long int n,m;
	long long int ans;
	cin>>n>>m;
	if(n==1||m==1){
	
		cout<<1;
		return 0;
	}
	ans=n*m;
	cout<<(ans+1)/2;
	return 0;
}


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

using namespace std;

int main()
{
    int N, M, A, B;
    cin >> N >> M >> A >> B;
    vector<int> D(N);
    for (int i = 0; i < N; i++) {
        cin >> D[i];
    }
    
    int cnt = 0;
    vector<int> p;
    for (int i = 0; i < N; i++) {
        if (D[i] >= A) {
            if (D[i] <= B) cnt++;
            p.emplace_back(D[i]);
        } else {
            break;
        }
    }
    
    int n = p.size(), res = n;
    if (N - n < M) {
        for (int i = n - 1; i >= 0 && cnt > 0; i--) {
            if (p[i] <= B) {
                res--;
                cnt--;
            } else {
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3156
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	string s;
	cin>>s;
	int t=0;
	rep(i,s.size()){
		int c=0;
		loop(j,i,s.size()){
			if(s[j]!='A'&&s[j]!='C'&&s[j]!='G'&&s[j]!='T')break;
			c++;
		}
		cmax(t,c);
	}
	cout<<t<<endl;
}


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

int al[26]={};
int main() {
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++) {
    al[s[i]-'a']=1;
  }
  for(int i=0;i<26;i++) {
    if(al[i]==0) {
      cout << char('a'+i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n):
        a[i] = -a[i]
    heapify(a)
    for _ in range(m):
        b = heappop(a)
        b = -(-b // 2)
        heappush(a, b)
    print(-sum(a))




if __name__ == '__main__':
    main()

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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D;
  if (A<B) {
    E=A;
  } else {
    E=B;
  }
  if (C<D) {
    F=C;
  } else {
    F=D;
  }
  cout << E+F << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll inf=17441744174417441;
ll dist[105]={0};
bool used[105];
vector<ll> node[105];
void dfs(ll pos,ll cos){
  used[pos]=true;
  dist[pos]=min(dist[pos],cos);
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i];
    if(!used[to]){
      used[to]=true;
      dfs(to,cos+1);
    }
  }
}
int main(){
  ll n;
  cin>>n;
  for(int i=1;i<n;i++){
    ll s,t;
    cin>>s>>t;
    node[s].push_back(t);
    node[t].push_back(s);
  }
  ll min_dis=inf;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      used[j]=false;
      dist[j]=inf;
    }
    dfs(i,1);
    ll kans=0;
    for(int j=1;j<=n;j++) kans=max(kans,dist[j]);
    min_dis=min(min_dis,kans);
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<node[i].size();j++){
      ll s=i,t=node[i][j];
      for(int k=1;k<=n;k++){
        used[k]=false;
        dist[k]=inf;
      }
      dfs(s,1);
      for(int k=1;k<=n;k++){
        used[k]=false;
      }
      dfs(t,1);

      ll kans=0;
      for(int k=1;k<=n;k++) kans=max(kans,dist[k]);
      min_dis=min(kans,min_dis);
    }
  }
  cout<<min_dis<<" ";

  ll ans2=inf;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      used[j]=false;
      dist[j]=inf;
    }
    dfs(i,1);
    ll kans=0;
    for(int j=1;j<=n;j++) kans=max(kans,dist[j]);

    if(kans==min_dis){
      vector<ll> min_k(min_dis+5,0);
      for(int k=1;k<=n;k++){
        ll cnt=0;
        for(int p=0;p<node[k].size();p++){
          ll to=node[k][p];
          if(dist[to]>dist[k]) cnt++;
        }
        min_k[dist[k]]=max(min_k[dist[k]],cnt);
      }
      ll kans2=1;
      for(int k=1;k<min_dis;k++) kans2*=min_k[k];
      ans2=min(ans2,kans2);
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<node[i].size();j++){
      ll s=i,t=node[i][j];
      for(int k=1;k<=n;k++){
        used[k]=false;
        dist[k]=inf;
      }
      dfs(s,1);
      for(int k=1;k<=n;k++){
        used[k]=false;
      }
      dfs(t,1);

      ll kans=0;
      for(int k=1;k<=n;k++) kans=max(kans,dist[k]);

      if(kans==min_dis){
        vector<ll> min_k(min_dis+5,0);
        for(int l=1;l<=n;l++){
          ll cnt=0;
          for(int p=0;p<node[l].size();p++){
            ll to=node[l][p];
            if(dist[to]>dist[l]) cnt++;
          }
          min_k[dist[l]]=max(min_k[dist[l]],cnt);
        }
        ll kans2=2;
        for(int k=1;k<min_dis;k++) kans2*=min_k[k];
        ans2=min(ans2,kans2);
      }
    }
  }
  cout<<ans2<<endl;
}


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

int main(){
  long n,k,i,j;
  double cur,ans=0;
  cin >> n >> k;
  for(i=1; i<=n; i++){
    j=i;
    cur=1.0/n;
    while(j<k){
      j*=2;
      cur/=2.0;
    }
    ans+=cur;
  }
  printf("%.9f",ans);
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>










int a, b, h, m;
long double anglH, anglM, xH, yH, xM, yM, res;



void solve()
{
	cin >> a >> b >> h >> m;
	anglH = (30 * h) + (0.5*m);
	anglM = 6 * m;
	xH = a*cosl((anglH*pi) / 180);
	yH = a*sinl((anglH*pi) / 180);
	xM = b*cosl((anglM*pi) / 180);
	yM = b*sinl((anglM*pi) / 180);
	res = sqrtl(((xH - xM)*(xH - xM)) + ((yH - yM)*(yH - yM)));
	cout << fixed << setprecision(11) << res << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

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


int main() {
    int A, B, H, M;
    std::cin >> A >> B >> H >> M;

    double percent = double(M) / 60.0;
    double m_theta = M_PI / 4.0 - percent * M_PI * 2;
    double h_theta = M_PI / 4.0 - M_PI / 6.0 * (H + percent);

    double x_h = A * std::cos(h_theta);
    double y_h = A * std::sin(h_theta);
    double x_m = B * std::cos(m_theta);
    double y_m = B * std::sin(m_theta);

    std::cout << std::fixed << std::setprecision(10) << std::hypot(x_m - x_h, y_m - y_h) << std::endl;;
}


Measured memory_bytes: 4096
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
ll a[200005];
ll b[200005]={0};
int main(){
	ll n;
	scanf("%lld",&n);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		b[a[i]]++;
	}
	ll sum=0;
	for(ll i=0;i<=n;i++)
	{
		sum+=b[i]*(b[i]-1)/2;
	}
	for(ll i=0;i<n;i++)
	{
		ll ans=sum;
		if(b[a[i]]>1)
		{
			ans=ans-b[a[i]]*(b[a[i]]-1)/2+(b[a[i]]-1)*(b[a[i]]-2)/2;
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> flowers(n);
  rep(i, n) cin >> flowers[i];
  int cnt = 0;
  for(int i=1; i<=100; i++){
    bool s = false;
    rep(j, n){
      if(flowers[j] >= i) s = true;
      else{
        if(s){
          cnt++;
          s = false;
        }
      }
    }
    if(s) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, M, Q = LI()
ABCD = LRI(Q)

def calc(A):
    ret = 0

    for a, b, c, d in ABCD:
        if A[b] - A[a] == c:
            ret += d
    
    return ret


def bfs(A):
    ans = 0
    stack = collections.deque(A)

    while stack:
        s = stack.popleft()
        
        if len(s) < N+1:
            back = s[-1]
            while back <= M:
                stack.append(s + [back])
                back += 1
        else:
            ans = max(ans, calc(s))

    return ans

print(bfs([[1]]))


Measured memory_bytes: 104804
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

ll mod = 1000000007;
ll modpow(ll a,ll b){
    if(b==0)return 1;
    if(b%2==0){
        ll d=modpow(a,b/2);
        return d*d%mod;
    }else{
        return modpow(a,b-1)*a%mod;
    }
}
ll divide(ll a,ll b){
    return a*modpow(b,mod-2)%mod;
}
int main(){
    ll n=in();
    ll k=in();
    ll ans = 0;
    rep2(i,k,n+1){
        ll tmp=n*(n+1)/2-(n-i)*(n-i+1)/2-i*(i-1)/2+1;
        ans=(ans+tmp)%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3680
n,q=map(int,input().split())

#Union-Find木の構築
par=[-1]*n

def find(v):
    if par[v]<0:
        return v
    else:
        par[v]=find(par[v])
        return par[v]

def union(u,v):
    root_u=find(u)
    root_v=find(v)

    if root_u==root_v:
        return 
    
    #大きい方に接続
    if par[root_u]>par[root_v]:
        par[root_v]+=par[root_u]
        par[root_u]=root_v
    else:
        par[root_u]+=par[root_v]
        par[root_v]=root_u

def same(u,v):
    if find(u)==find(v):
        return True
    else:
        return False

for i in range(q):
    c,x,y=map(int,input().split())
    if c==0:
        union(x,y)
    else:
        ans=same(x,y)
        if ans:
            print(1)
        else:
            print(0)




Measured memory_bytes: 5768
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pll pair<ll,ll>
int main() {
  string s; 
  cin >> s; 
  ll len = s.size(); 
  ll N = len; 
  bool flag = true; 
  for (ll i=0; i <len/2; i++){
    if (s[i] != s[len - i - 1]){
      flag = false; 
    }
  }
  for (ll i=0; i < N/2 - 1; i++){
    if (s[i] != s[N/2 - 1 - i]){
      flag = false; 
    }
  }
  for (ll i=N/2 + 1; i <len; i++){
    if (s[i] != s[len - i + N/2]){
      flag = false; 
    }
  }
  
  if (flag){
    cout << "Yes";
  } else {
    cout << "No"; 
  }
  

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int n;
long long sum[5003][5003];
long long dp[5003][5003];
long long a[5003];
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			sum[i][j] = sum[i][j-1] + a[j];
		}
	}
	
	for(int j=1;j<=n;j++){
		for(int i=j;i>0;i--){
			dp[i][j] = max(a[j] + sum[i][j-1] - dp[i][j-1],a[i] + sum[i+1][j] - dp[i+1][j]);
		}
	}
	
	cout<<2*dp[1][n]-sum[1][n]<<endl;
	
	return 0;
}


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

using namespace std;

int main(int argc, char* artgv[]) {
  vector<int> I(3);
  cin >> I[0] >> I[1] >> I[2];

  sort(I.begin(), I.end());

  if (I[0] == 5 && I[1] == 5 && I[2] == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 764
let rec f n =
  if n mod 4 = 0 then true
  else if n mod 7 = 0 then true
  else if n > 4 then f (n-4)
  else false
let rec g n =
  if n mod 7 = 0 then true
  else if n mod 4 = 0 then true
  else if n > 7 then g (n-7)
  else false
let () =
  Scanf.scanf "%d\n"
    (fun n -> if f n || g n then "Yes" else "No") |> print_string

Measured memory_bytes: 384
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
count = 0

for i in range(q):
    t = T[i]
    for j in range(n):
        if S[j] == t:
            count += 1
            break

print(count)



Measured memory_bytes: 6548
n=input()
l=list(map(int,input().split()))
p=1;t=0
if 0 in l:
  print(0)
else:
    for i in l:
        if( p*i > 10**18 ):
        	t=1
        	break
        p=p*i
    if(t):
    	print(-1)
    else:
    	print(p)

Measured memory_bytes: 21632
import numpy as np


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    A = np.int32(A)
    D = np.diff(A)
    if np.all(D <= 0):
        return 1000
    if np.all(D >= 0):
        stock, money = divmod(1000, A[0])
        money = stock * A[-1] + money
        return money

    money = 1000
    s = 0
    while s < N - 1:
        t = s + 1
        if A[t] >= A[s]:
            while t < N and A[t] >= A[t - 1]:
                t += 1
            stock, money = divmod(money, A[s])
            money = stock * A[t - 1] + money
            # print('++:', A[s:t], money)
            s = t
        else:
            while t < N and A[t] < A[t - 1]:
                t += 1
            # print('--:', A[s:t], money)
            s = t - 1
    
    return money


print(solve())


Measured memory_bytes: 27368
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    long long int n,h,ans,ans1,ans2;
    cin>>n;
     ans=n/500;
    ans1=n%500;
    ans2=ans1/5;
    h=(ans*1000)+(ans2*5);
    cout<<h<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char const *argv[])
{
  int bct[100];
  int N,a;
  int c=0;
  scanf("%d",&N);
  int i;
  for(i=0;i<100;i++){
    bct[i]=0;
  }
  for(i=0;i<N;i++){
    scanf("%d",&a);
    if(bct[a-1]==0) c++;
    bct[a-1]=1;
  }
  printf("%d",c);
  return (0);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Text;
using System.Threading.Tasks;

namespace B_coins
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = ReadLine();
            string[] arrey = input.Split(' ');
            long[] n = new long[2];
            n[0] = long.Parse(arrey[0]);
            n[1] = long.Parse(arrey[1]);
            long total = 0;
            long[] box = new long[3];
            long l = 0;
            for (long i = 0; i < n[0] + 1; i++)
            {
                for (long m = 0; m + i < n[0] + 1; m++)
                {
                    l =  n[0]- (i + m);
                    total = 10000 * i + 5000 * m + 1000 * l;
                    if (n[1] == total && n[0] == i + m + l)
                    {
                        box[0] = i;
                        box[1] = m;
                        box[2] = l;
                    }
                }
            }
            if (0 == box[0] && 0 == box[1] && 0 == box[2])
            {
                box[0] = -1;
                box[1] = -1;
                box[2] = -1;
            }
            WriteLine("{0} {1} {2}", box[0], box[1], box[2]);
            ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main() {
	int i = 1;
	int a=0;
	while (true) {
		cin >> a;
		if (a == 0) break;
		cout << "Case" <<' '<< i << ':' <<' '<< a << endl;
		i++;
	}
}


Measured memory_bytes: 3072
//Line++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "

using p = pair<ll,string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,x,y;cin>>n>>x>>y;
    garph g(n+1);
    g[x].pb(y);
    g[y].pb(x);    
    rep(i,1,n){
        g[i].pb(i+1);
        g[i+1].pb(i);
    }
    vector<int>m(n+1,0);
    rep(i,1,n+1){
        queue<int>q;
        vector<int>dist(n+1,-1);
        dist[i]=0;
        q.push(i);
        while(!q.empty()){
            int c=q.front();
            q.pop();
            irep(j,g[c]){
                if(dist[*j]!=-1)continue;
                dist[*j]=dist[c]+1;
                m[dist[c]]++;
                q.push(*j);
            }
        }   
    }
    rep(i,0,n-1)cout<<m[i]/2<<nnn;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<double,double> pdd;
typedef pair<string,int> psi;
const int MOD = 1e9 + 7;

const int N = 200001;

ll n , m ;
ll x[N],y[N],preX[N],preY[N];

ll sum = 0;
ll fn = 0;
int main() {
    //freopen("input.txt","r",stdin);
    scanf("%lld%lld",&n,&m);
    for (ll i = 1 ;  i <= n; ++i){
        scanf("%lld",&x[i]);
        preX[i] = x[i] + preX[i-1];
    }
    for(ll i = 1 ; i <= n ; i++){
        ll add = (preX[n]-preX[i]) - ((n-i) * x[i]);
        add = add % MOD;
        sum += add;
        sum = sum % MOD;
    }
    for (ll i = 1 ;  i <= m; ++i){
        scanf("%lld",&y[i]);
        preY[i] = y[i] + preY[i-1];
    }
    for (ll i = 1 ; i <= m; ++i){
        ll add = (preY[m] - preY[i]) - ((m-i)*y[i]);
        add = add % MOD;

        fn += (sum * add%MOD)%MOD;
        fn %= MOD;
    }
    printf("%lld\n", fn);
    return 0;
}

Measured memory_bytes: 5632