akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main()
{
    int X, N;
    cin >> X >> N;
    if (N == 0)
    {
        cout << X << endl;
        return 0;
    }
    int p[N];
    signed int up = X, down = X;
    int upcnt, downcnt;
    int x_cnt = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        if (p[i] == X)
        {
            x_cnt++;
        }
    }
    if (x_cnt == 0)
    {
        cout << X << endl;
        return 0;
    }

    while (1)
    {
        up++;
        down--;
        upcnt = 0;
        downcnt = 0;
        for (int i = 0; i < N; i++)
        {
            if (up == p[i])
                upcnt++;
            if (down == p[i])
                downcnt++;
        }
        if (downcnt == 0)
        {
            cout << down << endl;
            break;
        }
        else if (upcnt == 0)
        {
            cout << up << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll INF = (1LL << 60);

int main() {
    ll N, K;
    cin >> N >> K;
    ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    vector<ll> m, p;
    ll cnt_zero = 0;
    for(int i = 0; i < N; i++) {
        if(a[i] == 0) cnt_zero++;
        else if(a[i] > 0) p.push_back(a[i]);
        else m.push_back(-a[i]);
    }

    ll P = p.size();
    ll M = m.size();

    sort(p.begin(), p.end());
    sort(m.begin(), m.end());

    //cout << "hoge" << endl;

    ll l = -INF;
    ll r = INF;


    while(l + 1 != r) {
        ll piv = (l + r) / 2;
        ll k = 0;

        if(piv == 0) {
            k = P * M + cnt_zero * (P + M) + cnt_zero * (cnt_zero - 1) / 2;
        }
        if(piv < 0) {
            for(int i = 0; i < M; i++) {
                ll v = ((-piv + m[i] - 1) / m[i]); //Pからはv以上の個数
                ll cnt = p.end() - lower_bound(p.begin(), p.end(), v);
                k += cnt;
            }
        }
        else if(piv > 0) {
            ll cnt = 0;
            for(int i = 0; i < M; i++) {
                ll v = piv / m[i];
                cnt += max(0, (int)(upper_bound(m.begin(), m.end(), v) - m.begin()) - (i + 1));
            }
            for(int i = 0; i < P; i++) {
                ll v = piv / p[i];
                cnt += max(0, (int)(upper_bound(p.begin(), p.end(), v) - p.begin()) - (i + 1));
            }
            cnt += cnt_zero * (cnt_zero - 1) / 2 + cnt_zero * (P + M);
            k = P * M + cnt;
        }

        if(k < K) l = piv;
        else r = piv;
    }

    cout << r << endl;

    //=============================
    /*
    for(int piv = -10; piv <= 20; piv++) {
        cout << piv << " " ;
        ll k = 0;

        if(piv == 0) {
            k = P * M + cnt_zero * (P + M) + cnt_zero * (cnt_zero - 1);
        }
        if(piv < 0) {
            for(int i = 0; i < M; i++) {
                ll v = ((-piv + m[i] - 1) / m[i]); //Pからはv以上の個数
                ll cnt = p.end() - lower_bound(p.begin(), p.end(), v);
                k += cnt;
            }
        }
        else if(piv > 0) {
            ll cnt = 0;
            for(int i = 0; i < M; i++) {
                ll v = piv / m[i];
                cnt += max(0, upper_bound(m.begin(), m.end(), v) - m.begin() - (i + 1));
            }
            for(int i = 0; i < P; i++) {
                ll v = piv / p[i];
                cnt += max(0, upper_bound(p.begin(), p.end(), v) - p.begin() - (i + 1));
            }
            cnt += cnt_zero * (cnt_zero - 1) + cnt_zero * (P + M);
            k = P * M + cnt;
        }
        cout << k << endl;
    }
    */

    return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, ans = 0, n;
    cin >>n >> a >> b;
    vector<ll> x(n);
    for(int i=0;i<n;i++){
    	cin >> x[i];
    	if(i){
    		ans += min((x[i] - x[i-1]) * a , b);
    	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
/* ****revpro**** */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;	
	while(TESTS--)
	{
		long double n;
		cin>>n;
		long double x;
		rep(i,0,N) {x=i;if(floor(x*((long double)1.08))==n) {cout<<i;return 0;}}
		cout<<":(";
	}
	return 0;
}

Measured memory_bytes: 256
// 1824
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

#define MAX 500;

 
int32_t main()
{
    fast;
    int n; cin >> n;
    int ans = 1;
    Rep(i, 1, n) {
        ans = ( (ans % MOD) * (i % MOD) ) % MOD;
    }
    cout << ans;
    
    
    
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int X,N;
 int j=0;
 int answer;
 int check=0;
 cin >> X >> N;
 if(N==0){
   cout << X <<endl;
 }
 else {
 vector<int> P(N);
 for(int i=0;i<N;i++){
   cin >> P.at(i);
 }
 while(check==0){
   for(int i=0;i<N;i++){
     if(X-j==P.at(i)){
       break;
     }
     else if(i==N-1){
       check=1;
       answer=X-j;
     }
   }
   for(int i=0;i<N;i++){
     if(X+j==P.at(i)){
       break;
     }
     else if(i==N-1&&check==0){
       check=1;
       answer=X+j;
     }
   }
   j++;
 }
 cout << answer <<endl;
 }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define pii pair<ll, pair<int, char>>
ll n;
ll solve() {
	ll x, k, d;
	cin>>x>>k>>d;
	if(x == 0) {
		if(k&1) return min(abs(x-d), abs(x+d));
		return 0;
	}	
	ll steps = abs(x)/d;
	ll dist = steps*d;
	if(steps > k) {
		steps = k;
		dist = k*d;
	}
	ll left = k - steps;
	ll curPos = x > 0 ? x - dist : x + dist;
	if(left%2 == 0) return min(abs(x-dist), abs(x+dist));
	return min(abs(curPos - d), abs(curPos + d));
	
}
int main() {
	io
	ll t = 1;
	//cin>>t;
	while(t--) {
		cout<<solve()<<endl;
		//solve();
	}
}



Measured memory_bytes: 3640
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N, W;
  cin >> N >> W;
  vi w(N);
  vl v(N);
  rep(i, N) cin >> w[i] >> v[i];

  vl dp(W + 1, 0);

  rep(i, N) {
    irep(j, W) {
      if (j + w[i] <= W)
        chmax(dp[j + w[i]], dp[j] + v[i]);
    }
  }

  ll ans = 0;
  rep(i, W + 1) {
    chmax(ans, dp[i]);
  }
  out(ans);
}


Measured memory_bytes: 1024
N = int(input())
r = [list(map(int, input().split())) for _ in range(N)]
a = []
for i in r:
    a.append((i[0]-i[1],i[0]+i[1]))
a.sort(key=lambda x:x[1])
ans = 0
cur = -float('inf')
for i in a:
    if i[0] < cur:
        continue
    ans += 1
    cur = i[1]
print(ans)

Measured memory_bytes: 42792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m;
  cin>>n>>m;
  vl X(n),Y(n),Z(n);
  rep(i,n){
    cin>>X[i]>>Y[i]>>Z[i];
  }
  ll ans = 0;

  rep(t,1<<3){
    bitset<3> b(t);
    vi f(3,1);
    rep(k,3)if(b[k] == 0)f[k] = -1;
    vl cakes;
    rep(i,n){
      ll score =  f[0]*X[i]+ f[1]*Y[i]+f[2]*Z[i];
      cakes.push_back(score);
    }
    sort(rng(cakes),greater<ll>());
    ll sum = 0;
    rep(i,m){
      sum+=cakes[i];
    }
    maxs(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string a;
    cin>>n>>a;
    bool flag=1;
    if(n%2==0)
    {
        for(int i=0,j=n/2;i<n/2,j<n;i++,j++)
        {
            if(a[i]!=a[j])
            {
                flag=0;
            }
        }
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;







    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
set<char> st;
string s;
int a,b,x;
int main(int argc,char const* argv[])
{
  cin >> a >> b;
  if(b%a==0)
    {
      cout << a+b << endl;
      return 0;
    }
  else
    {
      cout << b-a << endl;
      return 0;
    }
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
u = [["."] * w for _ in range(h)]
v = [["."] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            u[i][j], v[i][j] = "#", "#"
        else:
            if i == 0:
                u[i][j] = "#"
            elif i == h - 1:
                v[i][j] = "#"
            else:
                if j % 2 == 0:
                    u[i][j] = "#"
                else:
                    v[i][j] = "#"
for s in u:
    print("".join(s))
print()
for t in v:
    print("".join(t))

Measured memory_bytes: 9844
import math
import numpy as np
pi = math.pi

a, b, x = map(int, input().split())
if x >= a**2*b/2:
    print(180/pi*np.arctan(2*(a**2*b-x)/a**3))
else:
    print(180/pi*np.arctan(a*b**2/(2*x)))

Measured memory_bytes: 12396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  if (a.at(2) == a.at(3) && a.at(4) == a.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

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

    int ans = 0;
    for (int i = 0; i < n - 2; ++i)
    {
        if(s.substr(i, 3)=="ABC")
        ++ans;
    }
    cout << ans << endl;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1002;
ll H, W, dp[MAXN][MAXN];
char grid[MAXN][MAXN];


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> H >> W;
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            cin >> grid[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            if(grid[i][j] == '.')
            {
                if(i)
                    dp[i][j] = add(dp[i][j], dp[i-1][j]);
                if(j)
                    dp[i][j] = add(dp[i][j], dp[i][j-1]);
            }
        }
    }
    cout << dp[H-1][W-1];
    return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<map> 
#include<vector>
#include<cmath>
using namespace std;

int main()
{
	long long n,b,k,ans=0;
	cin>>n>>k;
	if (k==0) ans=n*n;
	else
	{
		for (int b=k+1;b<=n;b++)
		{
			int num=min(b-k,(n-k)%b+1);
			int t=num*((n-k)/b)+(b-k-num)*((n-k)/b-1)+b-k;
			//cout<<t<<endl;
			ans+=t;
		}
	}
	cout<<ans<<endl;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 100005
using namespace std;

int main()
{
    FLASH
    string s;
    cin >> s;
    if(s[0] >= 65 && s[0] <= 90){
        cout << "A";
    }
    else{
        cout << "a";
    }
    return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007;
vector<vector<long long int>> mat_mul(vector<vector<long long int>>&a, vector<vector<long long int>>&b){
      int n=a.size();
      vector<vector<long long>>temp(n, vector<long long>(n, 0));

      for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                  for(int k=0; k<n; k++){
                        temp[i][j]+=(a[i][k]*(long long)b[k][j]);
                        temp[i][j]%=mod;
                  }
            }
      }
      /*for(int i=0; i<n; i++){
            for(int j=0; j<n; j++)
                  cout<<temp[i][j];
                  cout<<'\n';
      }
      cout<<'\n';*/
      return temp;
}

int main(){
      long long int n, k;
      cin>>n>>k;
      vector<vector<long long int>>a(n, vector<long long int>(n));
      for(int i=0; i<n; i++){
            for(int j=0; j<n; j++)
                  cin>>a[i][j];
      }
      vector<vector<long long int>>res(n, vector<long long int>(n));

      for(int i=0; i<n; i++)
            res[i][i]=1;
      
      while(k>0){
            if(k&1){
                  res=mat_mul(res, a);
                  /*for(int i=0; i<n; i++){
                        for(int j=0; j<n; j++)
                              cout<<res[i][j]<<' ';
                              cout<<'\n';
                  }*/
            }
            a=mat_mul(a, a);
            k=k>>1;
      }
      long long int ans=0;
      for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                  ans=(ans+res[i][j])%mod;

      cout<<ans<<'\n';
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
using namespace std;
int n,A[li],g=1,decc,incc;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]); 
	if(n==1 || n==2){
		printf("1\n");
		return 0;
	}
	for(int i=2;i<=n;i++){
		if(incc==1 && A[i]<A[i-1]){
			g++;
			incc=0;
		}
	    else if(decc==1 && A[i]>A[i-1]){
			g++;
			decc=0;
		} 
		else if(decc==0 && incc==0){
			if(A[i]>A[i-1]) incc=1;
			else if(A[i]<A[i-1]) decc=1;
		}
	}
	printf("%d\n",g);
	return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
int main(void){
	int i;
	int counter[26]={0};
	char ch;
	
	while(scanf("%c",&ch)!=EOF){
		if(ch==EOF) break;
		int num=ch-'a';
		if(0<=num && num<26){
			counter[num]++;
		}else if(-32<=num && num<-6){
			counter[num+32]++;
		}
	//	printf("%c %d\n",ch,ch);
	}
	
	for(i=0;i<26;i++){
		printf("%c : %d\n",'a'+i,counter[i]);
	}
	return 0;
}


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

int main() {
  int x,sum = 0,ans = 0;
  cin >> x;
  while(true){
    sum += x;
    ans++;
    if(sum%360 == 0){
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        int n,a,b;
        cin >> n >> a >> b;
        int i=a+b;
        int y=n/i;
        int ans=y*a;
        n=n%i;
        if(n>a)ans+=a;
        else ans+=n;
        cout << ans << '\n';
    

}

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

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;

ll pow_mod(ll a, ll b){
  vector<ll> f;
  while (b >= 1){
    f.push_back(b % 2);
    b /= 2;
  }
  f.push_back(b);
  //reverse(f.begin(), f.end());
  
  ll ret = 1;
  ll tmp = a;
  for (ll i=0; i<f.size(); i++){
    if (f[i] == 1) ret = (ret * tmp) % mod;
    tmp = (tmp * tmp) % mod;
  }
  
  return ret;
}
  

ll comb_mod(ll n, ll k, vector<ll> facts){
  ll ret = facts[n];
  ll inv1 = pow_mod(facts[k], mod - 2);
  ll inv2 = pow_mod(facts[n - k], mod - 2);
  
  ret = (ret * inv1) % mod;
  ret = (ret * inv2) % mod;
  return ret;
}

int main(){
  vector<ll> facts;
  ll tmp = 1;
  ll n, a, b;
  cin >> n >> a >> b;
  ll all_fact_sum = 0;
  tmp = 1;
  /*
  for (ll i=1; i<=n; i++){
    tmp = (tmp * (n - i + 1)) % mod;
    //tmp = (tmp * pow_mod(i, mod - 2)) % mod;
    tmp = (tmp / i) % mod;
    if (i != a && i != b) all_fact_sum = (all_fact_sum + tmp) % mod;
  }
  */
  all_fact_sum = pow_mod(2, n) - 1;
  cerr << all_fact_sum << endl;
  ll fa = 1;
  ll fa2 = 1;
  ll fb = 1;
  ll fb2 = 1;
  for (ll i=1; i<=a; i++){
    fa = (fa * (n - i + 1)) % mod;
    fa2 = (fa2 * i) % mod;
  }
  fa = (fa * pow_mod(fa2, mod - 2)) % mod;
  
  for (ll i=1; i<=b; i++){
    fb = (fb * (n - i + 1)) % mod;
    fb2 = (fb2 * i) % mod;
  }
  fb = (fb * pow_mod(fb2, mod - 2)) % mod;
  cerr << fa << " " << fb << endl;
  
  all_fact_sum -= (fa + fb) % mod;
  if (all_fact_sum < 0) all_fact_sum += mod;
  
    
  /*
  for (ll i=1; i<=n; i++){
    all_fact_sum += comb_mod(n, i, facts);
    all_fact_sum %= mod;
  }
  
  all_fact_sum -= (comb_mod(n, a, facts) + comb_mod(n, b, facts));
  if (all_fact_sum < 0) all_fact_sum += mod;
  cout << all_fact_sum << endl;
  */
  cout << all_fact_sum << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_B
 */
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int
partition(vector<int> &a, const int p, const int r)
{
    int x = a[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (a[j] <= x) {
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i + 1], a[r]);
    return i + 1;
}

int
main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n; cin.ignore();

    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i]; cin.ignore();
    }
    int q = partition(A, 0, A.size() - 1);

    for (int i = 0; i < n; i++) {
        cout << (i > 0 ? " " : "") << (i == q ? "[" : "") << A[i] << (i == q ? "]" : "");
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#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;

using namespace std;
vector<vector<int>>edge;
vector<int>wei;
int n,k;
int mod=1e9+7;
void dfs(int par,int node)
{
  int tk=k-1;
  if(par!=-1)tk--;
  for(int nn:edge[node])
  {
    if(nn==par)continue;
    //cout<<"dfs"<<nn<<" "<<node<<" "<<tk<<endl;;
    wei[nn]=tk--;
    dfs(node,nn);
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,t;
  cin>>a>>b>>t;
  cout<<(t/a)*b<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<algorithm>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 100004
#define INF 1e9+7

using namespace std;

ll n,ar[N],ans;

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;

    rep(i,0,n)
    {
        cin >> ar[i];

        ans += ar[i]-1;
    }

    cout<<ans;

    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    int tmp = max(H, W);
    cout << (N + tmp - 1)/tmp << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
s = list(map(int, input()))

# Run Length Encoding
rle = list()
target = 1
count = 0
for i in range(n):
    if s[i] == target:
        count += 1
    else:
        target = 1 - target
        rle.append(count)
        count = 1
rle.append(count)
if target == 0:
    rle.append(0)

offset = 2 * k + 1
res = 0

# cumsum
rle_cumsum = [0]
for i in range(len(rle)):
    rle_cumsum.append(rle_cumsum[i] + rle[i])


for i in range(0, len(rle), 2):
    left = i
    right = min(i + offset, len(rle))
    cand = rle_cumsum[right] - rle_cumsum[left]

    res = max(res, cand)

print(res)

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0, count = 0;
  for(int i = 0; i < n; i++){
    if(a[i] == a[i + 1]) count++;
    else{
      ans += (count + 1) / 2;
      count = 0;
    }
  }
  cout << (ans + (count + 1) / 2) << endl;
}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n, 0);
    for (int i = 0; i < m * 2; i++) {
        int tmp;
        cin >> tmp;
        a[tmp - 1]++;
    }

    for (int i = 0; i < n; i++) {
        cout << a[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
       int ar[]=new int[] {0,0,0,0};
       for(int i=0;i<3;i++)
       {
           int a=sc.nextInt();
           int b=sc.nextInt();
           ar[a-1]+=1;
           ar[b-1]+=1;
       }
       
       for(int i = 0; i < 4; i++) {
			if(ar[i] < 1 || ar[i] > 2) {
				System.out.println("NO");
				return;
			}
		}
		
		System.out.println("YES");
       
//       for(int i:ar)
//       {
//           if(i>2)
//           {
//               System.out.println("NO");
//               System.exit(0);
//           }
//       }
//       System.out.println("YES");
    }
}

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

#define int long long

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

  int N, M;
  cin >> N >> M;

  using P = pair<int, int>;
  priority_queue<P> Q;
  vector<int> v[100010];  
  for ( int i = 0; i < N; i++ ) {
    int a, b;
    cin >> a >> b;
    // Q.push(P(b, a));
    v[a].push_back(b);    
  }

  int ans = 0;
  for ( int i = 1; i <= M; i++ ) {
    for ( int j : v[i] ) {
      Q.push(P(j, i));      
    }
    if ( Q.size() ) {
      int j = Q.top().first; Q.pop();
      ans += j;      
    }
  }

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


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

int main()
{
	int t;
	cin >> t;
	while(t--)
	{
		ll a,b,c,d;
		cin >> a >> b >> c >> d;
		cout<<atcoder::floor_sum(a,b,c,d)<<endl;
	}
}


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

using namespace std;
typedef long long LL;

int N;
int A[2][101];
int memo[2][101];

int f(int r, int c) {
	if (r == 1 && c == N-1) {
		return A[r][c];
	}
	int& res = memo[r][c];
	if (res != -1) return res;

	res = A[r][c];
	if (r == 0) {
		int t = f(1, c);
		if (c != N-1) {
			t = max(t, f(0, c+1));
		}
		res += t;
	}
	else {
		res += f(1, c+1);
	}
	return res;
}
int main()
{
	cin >> N;

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	memset(memo, -1, sizeof(memo));
	cout << f(0, 0) << endl;
	exit(0);
}



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


int main(){
    int n, T, A, h, x;
    double  min = 10000000;
    cin >> n >> T >> A;
    vector<double> s(n);
    for (int i = 0; i < n; i++){
        cin >> h;
        s[i] = T - 0.006 * h - A;
        if (s[i] < 0){
            s[i] = 0 - s[i] ;
        }
        if (s[i] < min){
            min = s[i];
            x = i;
        }
    }
    cout << x + 1 << endl;
}

Measured memory_bytes: 256
function Main(input) {
      input =  input.split("\n");
 
	for(var i=0; i<input[0].length; i++){
           var moji =  input[0].substr(i, 1);
 
           if ( i%2==0 ){
                   if( moji == "L" ){ console.log("No"); return;}
           }else{
                   if( moji == "R" ){ console.log("No"); return;}
           }
        }
	
       console.log("Yes"); return;
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n = gets.to_i
s = gets.split.map(&:to_i)
q = gets.to_i
t = gets.split.map(&:to_i)

ans = 0
t.each do |key|
  v = s.bsearch { |x| x >= key }
  if v == key
    ans += 1
  end
end
puts ans



Measured memory_bytes: 15356
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		double a = Double.parseDouble(reader.ns());
		double b = Double.parseDouble(reader.ns());
		double h = Double.parseDouble(reader.ns());
		double m = Double.parseDouble(reader.ns());

		double angle = calcAngle(h, m);
		double c = a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle));

		c = Math.sqrt(c);
		
		out.println(c);

		return;
	}

	private double calcAngle(double h, double m) {
        double hour_angle = (0.5 * (h*60 + m));
        double minute_angle = (6*m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360-angle, angle);
        return angle;
    }
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 33392
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    int kansi = 2 * d + 1;
    if (n % kansi == 0)
    {
        cout << n / kansi << endl;
    }
    else
    {
        cout << n / kansi + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int N,M,Q,i,D[100],t;
main()
{
    for(;scanf("%d%d",&N,&Q),N;)
    {
        memset(D,0,sizeof(D));
        for(i=0;i<N;i++)
            for(scanf("%d",&M);M--;)
            {
                scanf("%d",&t);
                D[t]++;
            }
        for(i=0,t=-1;i<100;i++)
            if ((t==-1&&D[i]>=Q)||(t!=-1&&D[i]>D[t]))
                t=i;
                printf ("%d\n",t==-1?0:t);
    }
}

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

typedef unsigned long long ull;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ull N,K,b;
	int a=0;
	cin >> N >> K;
	while(1){
		if(N/K==0) {
          cout<<a+1<<endl;
          break;
        }
      N=N/K;
		a++;
	}

    return 0;
}

Measured memory_bytes: 256
s=str(input())
longest_len = 0
temp_len = 0

for i in range(0,len(s)):
    if (s[i] == "A")|(s[i] == "T")|(s[i] == "C")|(s[i] == "G"):
        temp_len += 1
    else:
        temp_len = 0
        
    if temp_len>longest_len:
        longest_len = temp_len
        
print(longest_len)

Measured memory_bytes: 3060
from collections import defaultdict

memo = []


def find(nowstr, rest):
    if rest < 0:
        return ""

    for i in costlist:
        if i < rest:
            find(nowstr+str(i), rest - i)
        elif i == rest:

            memo.append(nowstr+str(i))


def cost_to_num(c):
    if c == 2:
        return "1"
    if c == 3:
        return "7"
    if c == 4:
        return "4"

    if c == 5:
        if 2 in num_to_use:
            return "2"
        elif 3 in num_to_use:
            return "3"
        else:
            return "5"
    if c == 6:
        if 6 in num_to_use:
            return "6"
        else:
            return "9"
    if c == 7:
        return "8"


N, M = map(int, input().split())
Alist = list(map(int, input().split()))

num_to_use = set(Alist)
"""
1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 を 1 つ作るには、
2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 本のマッチ棒を使う。
"""
ref = [2, 5, 5, 4, 5, 6, 3, 7, 6]
if 9 in num_to_use:
    num_to_use.discard(6)
if 5 in num_to_use:
    num_to_use.discard(2)
    num_to_use.discard(3)
if 3 in num_to_use:
    num_to_use.discard(2)


costlist = [ref[i-1] for i in num_to_use]
costlist.sort()
# print(num_to_use)
# print(costlist)
# print(costlist[0])
minlength = N // costlist[0] - 5
if minlength < 0:
    minlength = 0
ans_tail = [cost_to_num(costlist[0])]*minlength

delta = N - minlength * costlist[0]
# print(delta)
find("", delta)

# print(memo)

ans_length = len(memo[0])
temp = 0
for i in memo:
    if len(i) < ans_length:
        continue

    numlist = [cost_to_num(int(j)) for j in i]+ans_tail
    # print(numlist)
    numlist.sort(reverse=True)
    joined = "".join(numlist)
    # print(joined)
    if temp < int(joined):
        temp = int(joined)
ans_head = str(temp)

# print("---")
print(ans_head)


Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll a, v, b, w, t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> v >> b >> w >> t;

  if(abs(a - b) - ((v * t) - (w * t)) > 0) cout << "NO" << endl;
  else cout << "YES" << endl;

}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << (a-c) * (b-d) << endl;

    
}





//              g++ -std=c++1z


Measured memory_bytes: 888
#include <iostream>

int main() {
  std::string s;
  std::cin >> s;
  
  for(int i = 0; i < s.length(); i++)
    std::cout << (s[i] == 'P' ? 'P' : 'D');
  
  std::cout << std::endl;
  return 0;
}


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

int main()
{
	int x, a ,b;
	cin >> x >> a >> b;
	if(a>=b)
	{
		cout<<"delicious"<<endl;
	}
	else if(b-a<=x)
	{
		cout<<"safe"<<endl;
	}
	else
	{
		cout<<"dangerous"<<endl;
	}

	return 0;
}

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

using namespace std;

const int maxn = 1e5 + 10;

vector<int> g[maxn];
int n, m, deg[maxn];
int a[4], pn, cnt;

void dfs(int x, int fa = 0) {
    if (x == a[2]) return ++cnt, void();
    if (x == a[1] && fa) return;
    for (auto v: g[x]) if (v != fa) dfs(v, x);
}

int main() {
    scanf("%d %d", &n, &m);
    if (m < n + 2) return puts("No"), 0;
    for (int u, v, i = 1; i <= m; ++i) {
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i) {
        deg[i] = g[i].size();
        if (deg[i] & 1)
            return puts("No"), 0;
    }

    for (int i = 1; i <= n; ++i) {
        if (deg[i] >= 6) return puts("Yes"), 0;
        if (deg[i] >= 4) {
            if (pn == 2) return puts("Yes"), 0;
            a[++pn] = i;
        }
    }

    dfs(a[1]);
    if (cnt == 4) puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAXN = 100005;
const int mod = 1e9 + 7;

int n, m, a[MAXN];
int b[MAXN];

int main(){
	scanf("%d %d",&n,&m);
	while(n--){
		int l, r; scanf("%d %d",&l,&r);
		l--;
		for(int i=1; i<=505; i++){
			if(r / i != l / i) a[i]++;
		}
		if(506 <= r){
			b[506]++;
			b[r+1]--;
			for(int i=1; i<=200; i++){
				// xi <= l < x(i+1)
				// xi <= r < x(i+1)
				int ed = l / i;
				int st = (r + i + 1) / (i + 1);
				st = max(st, 506);
				if(st <= ed){
					b[st]--;
					b[ed+1]++;
				}
			}
		}
	}
	for(int i=1; i<=m; i++) b[i] += b[i-1];
	for(int i=1; i<=m; i++) printf("%d\n", a[i] + b[i]);
}


Measured memory_bytes: 1280
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int cnt = sc.nextInt();
        int[] time = new int[cnt], point = new int[cnt];
        String ans = "Yes";
        for(int i = 0; i < cnt; i++){
            time[i] = sc.nextInt();
            point[i] = sc.nextInt() + sc.nextInt();
            if(time[i] < point[i]){
                ans = "No";
            }
            if((time[i] % 2) != (point[i] % 2)){
                ans = "No";
            }
        }
        System.out.println(ans);

    }
}


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

#define N 2000000

int A[N];
int H;

void maxHeapify(int);
void build();
void swap(int *, int *);

int main(){
  char com[10];
  int i, num, e=0;

  while(1){
    scanf("%s",com);

    switch(com[0]){
    case 'i':
      scanf("%d",&num);
      H++;
      A[H] = num;

      i=H;
      while(i > 1 && A[i/2] < A[i]){
    swap(&A[i/2], &A[i]);
    i = i/2;
      }

      break;

    case 'e':
      if(com[1] == 'x'){
    printf("%d\n",A[1]);

    A[1] = A[H];
    H--;

    maxHeapify(1);
      }

      if(com[1] == 'n')
    e++;

    break;
    }

    if(e>0)
      break;
  }
}

void maxHeapify(int i){
  int l = 2*i;
  int r = 2*i + 1;
  int largest;

  if(l <= H && A[l] > A[i])
    largest = l;

  else
    largest = i;

  if(r <= H && A[r] > A[largest])
    largest = r;

  if(largest != i){
    swap(&A[i], &A[largest]);
    maxHeapify(largest);
  }
}

void build(){
  int i;

  for(i=H/2; i>0; i--)
    maxHeapify(i);
}

void swap(int *a, int *b){
  int t;

  t = *a;
  *a = *b;
  *b = t;
}



Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N,ans = 0;
string A,B,C;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> A >> B >> C;

	
	REP(i,N){
		if(A[i] == B[i]){
			if(B[i] == C[i]) continue;
		}
		if(A[i] != B[i] && B[i] != C[i] && C[i] != A[i]){
			ans += 2;
		}else{
			ans++;
		}
	}
	
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, H[100000];

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

    cin >> N;
    for(int i = 0; i < N; ++i) cin >> H[i];
    for(int i = N - 1; i > 0; --i) {
        if(H[i] < H[i - 1]) {
            if(H[i - 1] - 1 == H[i]) --H[i - 1];
            else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

  char N ;
  int ans = 0 ;
  cin >> N ;
  char A = N + 1 ;
  cout << A << endl;
}

Measured memory_bytes: 256
n,k,r,s,p,t=$<.read.split
n,k,r,s,p = [n,k,r,s,p].map(&:to_i)

ret = 0
n.times do |i|
  if i-k < 0 || t[i-k] != t[i]
    ret += case t[i]
    when 'r' then p
    when 's' then r
    when 'p' then s
    end
  else
    t[i] = '-'
  end
end

p ret


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

// ??¨????????????????????????
// [0,n) ???????????? i ???????????????primes[i] != 0 ??? i ????´???°
vector<int> erat(int n) {
    vector<int> primes(n);
    for (int i = 2; i < n; ++i) primes[i] = i;
    for (int i = 2; i*i < n; ++i)
        if (primes[i])
            for (int j = i*i; j < n; j+=i) primes[j] = 0;
    // ?´???°?????????vector???????´?????????´????????\?????????????????? (0 ??§??????????´??????¨??????)
    primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
    return primes;
}
 
int main() {
 	vector<int> v = erat(110000);
 	rep(i,1,10001) v[i] += v[i-1];

 	int n;
 	while(cin >> n) {
 		if(n==0) break;
 		cout << v[n-1] << endl;
 	}
    return 0;
}

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

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	int i, sum, p;
	while(1) {
	cin >> sum;
	if(sum == 0)
		break;
	for(i = 0; i < 9; i++) {
		cin >> p;
		sum -= p;
	}
	cout << sum << endl;
	}

	return 0;

}

Measured memory_bytes: 1160
//#include<bits/stdc++.h>
//using namespace std;
//typedef unsigned long long ll;
//const long long mod=4294967296;
//const int N=1e8;
//bool _check(int N,int pos)
//{
//    return (bool)(N & (1<<pos));
//}
//int _set(int N,int pos)
//{
//    return N=N| (1<<pos);
//}
//int isprime[N/32+3];
//vector<int>prime;
//int pos;
//void seive()
//{
//    prime.push_back(2);
//    for(int i=3; i*i<=N; i+=2)
//        if(!_check(isprime[i/32],i%32))
//            for(ll j=i*i; j<=N; j+=i+i)
//                isprime[j/32]=_set(isprime[j/32],j%32);
//    int j=0;
//    pos=-1;
//    for(int i=3; i<=N; i+=2)
//        if(!_check(isprime[i/32],i%32))
//        {
//            prime.push_back(i);
//            if(pos==-1 and i>=1e4)
//            {
//                pos=j;
//            }
//            j++;
//        }
//}
//
//ll P[N+3];
//void PRE()
//{
//    for(int i=0;i<=N;i++)P[i]=1;
//    for(int i=0;i<prime.size() and prime[i]<=1e4;i++)
//    {
//        int p=prime[i],inc=p,lim=prime[i]*prime[i];
//        for(int j=prime[i];j<=N;j++)
//        {
//            if(j==lim)
//            {
//                inc=lim;
//                lim*=p;
//            }
//            P[j]*=inc;
//            P[j]%=mod;
//        }
//    }
//}
//int main()
//{
//
//    // freopen("input.txt","r",stdin);
//    //freopen("output.txt","w",stdout);
////    seive();
////    PRE();
////    int test;
////    scanf("%d",&test);
////    for(int _t=1; _t<=test; _t++)
////    {
////        ll n;
////        scanf("%llu",&n);
////        printf("Case %d: %llu\n",_t,solve(n));
////    }
//}

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

int min_2nd(int a,int b,int c)
{
    if((a>=b and a<=c) || (a>=c and a<=b))
        return a;
    if((b>=a and b<=c) || (b>=c and b<=a))
        return b;
    if((c>=a and c<=b) || (c>=b and c<=a))
        return c;
}
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int min1=min(a,min(b,c));
    int min2=min_2nd(a,b,c);
    int min3=max(a,max(b,c));
    int movv=0;
    while(min1!=min2 or min1!=min3)
    {
        if(min2<min3 and min1<min3)
        {
            movv++;
            min1++;
            min2++;
        }
        else if(min2==min3 and min1<min3)
        {
            min1+=2;
            movv++;
            a=min1,b=min2,c=min3;
            min1=min(a,min(b,c));
            min2=min_2nd(a,b,c);
            min3=max(a,max(b,c));
        }
    }
    printf("%d\n",movv);
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n;
	scanf("%lld", &n);
	ll c[n+1]={0}, tmp;
	vi o;
	set<int> s;
	REP(i, 0, n){
		scanf("%lld", &tmp);
		o.PB(tmp);
		s.insert(tmp);
		++c[tmp];
	}
	ll pos = 0, val;
	for(auto i: s){
		val = c[i];
		pos += val* (val - 1)/2;
		c[i] = (val - 1)*(val - (val-2))/2;
	}
	for(auto i: o){
		cout <<  pos - c[i] << endl;
	}
		

}


Measured memory_bytes: 9844