akhauriyash/Code-Regression huggingface dataset:
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q, z;

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

  cin >> x >> y >> z;
  rep(i, ohara) {
    tmp = y * i + z * (i + 1);
    if (tmp <= x) {
      ans = max(ans, i);
    }
  }
  Cout(ans);
  return 0;
}

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

int main(){
  int n, k, h[100000], min = 1000000000;
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> h[i];
  sort(h, h + n);
  for(int i = k - 1; i < n; i++){
    if(min > h[i] - h[i-k+1]) min = h[i] - h[i-k+1];
  }
  cout << min;
  return 0;
}


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

// AAABC
// AABCA
// ABCAA
// BCAAA
int main() {
    string s {};
    cin >> s;

    long cnt = 0;
    if (s.length() >= 3) {
        int Acnt = 0;
        for (int i=0; i<s.length()-2; i++) {
            if (s[i] == 'A') {
                Acnt += 1;
            } else {
                Acnt = 0;
            }
            if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C') {
                s[i] = 'B';
                s[i+1] = 'C';
                s[i+2] = 'A';
                cnt += Acnt;
                if (Acnt >= 2) {
                    s[i+1] = 'A';
                }

                if (Acnt >= 3) {
                    Acnt -= 2;
                } else {
                    Acnt = 0;
                }
            }
        }
    }
    cout << cnt << endl;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }
    SORT(a);
    vector<lint> v;
    lint now = 1LL << 32;
    while(now > 1){
        v.push_back(now);
        now >>= 1;
    }
    map<lint, int> mp;
    rep(i, n){
        mp[a[i]] = upper_bound(ALL(a), a[i]) - lower_bound(ALL(a), a[i]);
    }
    int ans = 0;
    repr(i, n){
        rep(j, v.size()){
            bool flag = false;
            int cnt = upper_bound(ALL(a), v[j] - a[i]) - lower_bound(ALL(a), v[j] - a[i]);
            if(v[j] - a[i] == a[i]){
                if(cnt >= 1 && mp[a[i]] >= 2){
                    ++ans;
                    mp[a[i]] -= 2;
                    flag = true;
                }
            }else{
                if(cnt >= 1 && mp[a[i]] >= 1 && mp[v[j] - a[i]] >= 1){
                    ++ans;
                    --mp[a[i]];
                    --mp[v[j] - a[i]];
                    flag = true;
                }
            }
            if(flag){
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16384
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000000
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << "\n"
#define pr2(a,b)cout << a <<  " " <<b<< "\n"
#define pr3(a,b,c) cout << a <<" " << b << " " << c << "\n"

const long double PI = acos(-1);

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

int gcd(int a, int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
const int maxn = 2*1e5 + 10;


void solve(){
    int r;
    cin >> r;

    double ans = 2.0*pi*(double)r;

    cout << fixed << setprecision(20) << ans << endl;
    

} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 

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

using namespace std;

#define int long long
#define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll abc[100100][3];
ll dp[100100][3];

signed main() {
    LCIN(N);
    REP(i, N) {
        LCIN(a, b, c);
        abc[i][0] = a;
        abc[i][1] = b;
        abc[i][2] = c;
    }
    REP(i, N) REP(j, 3) REP(k, 3) {
        if(j == k && i) continue;
        dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]);
    }
    cout << *max_element(dp[N], dp[N] + 3) << "\n";
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int rui[2222222];
int mai[2222222];
int kokomade[2222222];

ll get_rui(int l,int r) {
	if(l > r)return 0;
	ll ret = rui[r];
	if(l >= 0){
		ret -= rui[l];
	}
	return ret;
}

int main(){

	int n;cin >> n;
	string str;cin >> str;

	REP(i,str.size()){
		if(str[i] == 'M'){
			rui[i]++;
		}
	}
	REP(i,str.size()){
		rui[i+1] += rui[i];
	}

	int q;cin >> q;
	REP(olphe,q){
		REP(i,2222222){
			kokomade[i] = 0;
			mai[i] = 0;
		}
		int k;cin >> k;
		ll now = 0;
		ll pla = 0;
		ll ans = 0;
		REP(i,str.size()){
			now -= kokomade[i];
			pla -= mai[i];
			if(str[i] == 'D'){
				now++;
				kokomade[i+k] = 1;
				mai[i+k] = get_rui(i, i + k - 1);
			}
			if(str[i] == 'M'){
				pla += now;
			}
			if(str[i] == 'C'){
				ans += pla;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


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

ll divisor=1e9+7;
int main(){
	ll n,k;
	cin>>n>>k;
	int a[n];
	rep(i,n){
		cin>>a[i];
	}
	bool used[n]={};
	used[0]=true;
	
	int now = a[0];
	while(!used[now-1]){
		used[now-1]=true;
		now=a[now-1];
	}
	int loop = now;
	int count = 1;
	now=a[loop-1];
	while(now!=loop){
		now = a[now-1];
		count++;
	}
	int count_f=0;
	now = 1;
	while(now!=loop){
		now=a[now-1];
		count_f++;
	}
	if(k<=count_f){
		now = 1;
		rep(i,k){
			now=a[now-1];
		}
		puts(now);
	}else{
		k=count_f+(k-count_f)%count;
		now = 1;
		rep(i,k){
			now=a[now-1];
		}
		puts(now);
	}
}

Measured memory_bytes: 4616
import sys
import bisect
from collections import deque
sys.setrecursionlimit(4100000)
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        edge[u].append(v)
        edge[v].append(u)

    ans = [0] * (N + 1)
    LIS = [-1]
    
    def dfs(v, p = N):
        if A[v] > LIS[-1]:
            LIS.append(A[v])
            ans[v] = ans[p] + 1
            for u in edge[v]:
                if u == p:
                    continue
                dfs(u,v)
            LIS.pop()
        else:
            ans[v] = ans[p]
            idx = bisect.bisect_left(LIS, A[v])
            old = LIS[idx]
            LIS[idx] = A[v]
            for u in edge[v]:
                if u == p:
                    continue
                dfs(u,v)
            LIS[idx] = old
    dfs(0)
    for i in range(N):
        print(ans[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 356188
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int H,W;
         
        H = in.nextInt();
        W = in.nextInt();
         
        while(H!=0 || W!=0){
            
            char[][] sharps = new char[H][W];
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    sharps[i][j] = '#';
                }
            }
            
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    System.out.print('#');
                }
                System.out.println();
            }
            System.out.println();
            H = in.nextInt();
            W = in.nextInt();
        }
    }
}



Measured memory_bytes: 35964
let () =
  let cross (x0,y0) (x1,y1) = x0*.y1-.x1*.y0 and
      inner (x0,y0) (x1,y1) = x0*.x1+.y0*.y1 and
      norm (x,y) = x*.x+.y*.y in
  let check_lines v0 v1 =
       if cross v0 v1 > (1e-10) then -1
       else if cross v0 v1 < -.(1e-10) then 1
       else if inner v0 v1 < -.(1e-10) then 1
       else if norm v0 < norm v1 then 0
       else 0
  in
  let intersect p0x p0y p1x p1y p2x p2y p3x p3y =
    ((check_lines (p2x-.p0x, p2y-.p0y) (p1x-.p0x, p1y-.p0y)) * (check_lines (p3x-.p0x, p3y-.p0y) (p1x-.p0x, p1y-.p0y)) <= 0) &&
      ((check_lines (p1x-.p2x, p1y-.p2y) (p3x-.p2x, p3y-.p2y)) * (check_lines (p0x-.p2x, p0y-.p2y) (p3x-.p2x, p3y-.p2y)) <= 0)
  in
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let rec read = function
      0 -> ()
    | i ->
       let (p0x,p0y,p1x,p1y,p2x,p2y,p3x,p3y) =
         Scanf.scanf " %f %f %f %f %f %f %f %f\n" (fun s t u v w x y z -> (s,t,u,v,w,x,y,z))
       in
       if intersect p0x p0y p1x p1y p2x p2y p3x p3y then print_endline "1"
       else print_endline "0"
       ;read (i-1)
  in read n
;;

Measured memory_bytes: 3796
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var t, h int
	for i := 0; i < n; i++ {
		var c1, c2 string
		fmt.Scan(&c1, &c2)
		if c1 > c2 {
			t += 3
		} else if c1 < c2 {
			h += 3
		} else {
			t++
			h++
		}
	}
	fmt.Println(t, h)
}



Measured memory_bytes: 1208
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.to_list @@ Array.init n @@ fun _ ->
    Scanf.scanf "%d\n" @@ fun a -> a in
  List.sort compare as_
  |> List.fold_left (fun (m, c) a ->
      (IntMap.add a c m, c + 1)) (IntMap.empty, 0)
  |> (fun (m, _) -> List.mapi (fun i a ->
      if i mod 2 = IntMap.find a m mod 2 then 0
      else 1) as_)
  |> List.fold_left ( + ) 0
  |> (fun s -> s / 2)
  |> Printf.printf "%d\n"


Measured memory_bytes: 17536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int n;
cin >> n;
vector<int>a(n);
for(int i=0;i<n;i++){
   cin >> a.at(i);
}
bool ans = true;
reverse(a.begin(),a.end());
for(int i=1;i<n;i++){
   if(a.at(i-1)>=a.at(i)){
   }
   else if(a.at(i-1)>=a.at(i)-1)a.at(i)--;
      else {
      ans = false;
   }
}
if(ans)cout <<"Yes"<<endl;
else cout <<"No"<<endl;
 }


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}

int main() {

	ll n,x;
	cin>>n>>x;

	cout<<3*(n-gcd(n,x))<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
      H   H
       \ / 	
        C
       / \ 
      H   H
*/

#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 vvi			vector<vi>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define tr(c,i)		for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)	((c).find(x) != (c).end()) 
#define cpresent(c,x)	(find(all(c),x) != (c).end()) 
#define int ll
using namespace std;

#define N  100005

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n;
		cin >> n;
		int x = n%10;
		if(x==3)
			cout << "bon";
		else if(x==0 || x==6 || x==1 || x==8)
			cout << "pon";
		else
			cout << "hon";
	}
	return 0;
}

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

int H, W, a[1009][1009];
vector<vector<int>>vec1, vec2, vecA, vecB;

bool converse(vector<int>A, vector<int>B) {
	for (int i = 0; i < A.size(); i++) {
		if (A[i] == B[i]) return false;
	}
	return true;
}

int main() {
	cin >> W >> H;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cin >> a[i][j];
	}
	for (int i = 0; i < H; i++) {
		vector<int>L; for (int j = 0; j < W; j++) L.push_back(a[i][j]);
		vecA.push_back(L);
	}
	for (int i = 0; i < W; i++) {
		vector<int>L; for (int j = 0; j < H; j++) L.push_back(a[j][i]);
		vecB.push_back(L);
	}
	vec1 = vecA; sort(vec1.begin(), vec1.end()); vec1.erase(unique(vec1.begin(), vec1.end()), vec1.end());
	vec2 = vecB; sort(vec2.begin(), vec2.end()); vec2.erase(unique(vec2.begin(), vec2.end()), vec2.end());

	if (vec1.size() != 2 || vec2.size() != 2) { cout << "no" << endl; return 0; }
	if (converse(vec1[0], vec1[1]) == false || converse(vec2[0], vec2[1]) == false) { cout << "no" << endl; return 0; }
	
	int s1[2] = { 0, 0 }; for (int i = 0; i < vecA.size(); i++) { if (vecA[i] == vec1[0]) s1[0]++; else s1[1]++; }
	int s2[2] = { 0, 0 }; for (int i = 0; i < vecB.size(); i++) { if (vecB[i] == vec2[0]) s2[0]++; else s2[1]++; }
	if (abs(s1[0] - s1[1]) <= 1 && abs(s2[0] - s2[1]) <= 1) {
		cout << "yes" << endl;
	}
	else cout << "no" << endl;
	return 0;
}


Measured memory_bytes: 22644
#include<bits/stdc++.h>
#define maxn 505050

using namespace std;
typedef long long ll;
ll dp[maxn],a[maxn],n;
int main(){
  cin >> n;
  for (int i=1;i<=n;i++) cin >> a[i];
  dp[1]=0; dp[2]=abs(a[2]-a[1]);
  for (int i=3;i<=n;i++) dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 5120
#include <string>
#include <iostream>
using namespace std;
int n, x, y; string s = "0 1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 5 4 3 2 1";
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d%d", &x, &y);
		string t = "0 1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 5 4 3 2 1";
		for(int i = 0; i < s.size(); i += 2) {
			for(int j = i + 2; j < s.size(); j += 2) {
				if(s[i] == x + 48 && s[j] == y + 48 && j - i + 1 < t.size()) {
					t = s.substr(i, j - i + 1);
				}
			}
		}
		cout << t << endl;
	}
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<bool> v(n);
    for (int i = 0; i < k; i++)
    {
        int d;
        cin>>d;
        for (int j = 0; j < d; j++)
        {
            int a;
            cin>>a;
            a--;
            v[a]=true;
        }
    }
    int ans=0;
    for (int i = 0; i < n; i++)
    {
        if(v[i]==false) 
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
	string X; cin >> X;
	int N = X.size();
	stack<char> s;
	rep(i,N){
		if(s.empty() || X[i] == 'S') s.push(X[i]);
		else if(s.top() == 'S') s.pop();
		else s.push(X[i]);
	}
	cout << s.size() << endl;
}



Measured memory_bytes: 644
INF = 1 << 60

n = int(input())
x = [0 for i in range(n)]
l = [0 for i in range(n)]
for i in range(n):
    x[i], l[i] = map(int, input().split())

itv = [[x[i] - l[i], x[i] + l[i]] for i in range(n)]
itv.sort(key=lambda x:x[1])
# print("itv =", itv)

ans = 0
t = -INF
for i in range(n):
    if t <= itv[i][0]:
        ans += 1
        t = itv[i][1]
print(ans)


Measured memory_bytes: 91824
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        int min = 0;
        int max = n;

        for(int i = 0;i<m;i++){
            min = Math.max(min,scanner.nextInt());
            max = Math.min(max,scanner.nextInt());
        }

        System.out.println(Math.max(0,max - min + 1));
    }
}


Measured memory_bytes: 63872
IDENTIFICATION DIVISION.
	PROGRAM-ID. IDEONE.

	ENVIRONMENT DIVISION.

	DATA DIVISION.
	WORKING-STORAGE SECTION.
	01 INP PIC X(100).
	01 K PIC 9(10).
	01 X PIC 9(10).
	01 temp1 PIC 9(10).
    01 temp2 PIC 9(10).
    01 N PIC 9(10).
	
	PROCEDURE DIVISION.
	MAIN.
		ACCEPT INP.
        PERFORM VARYING temp1 FROM 1 BY 1 UNTIL INP(temp1:1)=SPACE
        END-PERFORM.
        SUBTRACT 1 FROM temp1.
        MOVE INP(1:temp1) TO K.
        ADD 2 TO temp1.
        PERFORM VARYING temp2 FROM temp1 BY 1 UNTIL INP(temp2:1)=SPACE
        END-PERFORM.
        COMPUTE N=temp2 - temp1.
        MOVE INP(temp1:N) TO X.
		COMPUTE K = K * 500.
		IF K >= X THEN
			DISPLAY "Yes"
		ELSE 
			DISPLAY "No"
		END-IF.
		STOP RUN.

Measured memory_bytes: 636
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
  	string s,t;
  	cin >> s >> t;
  	int result = 0;
  	for(int i=0;i < s.length();i++){
      if(s[i] != t[i]){
		result++;
      }
    }
  
      cout << result;
}

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

typedef long long int ll;

ll MOD = 1000000007;
ll INF = 100000000000;
double PI = 3.1415926535;

long long int fact(int A){
  if(A==0)return 1;
  else return fact(A-1)*A;
}

int main(){
 int N;
 cin >> N;
 vector<pair<double,double>> L(N);
 double sum = 0;
 for(int i = 0;i < N;i++){
    cin >> L[i].first >> L[i].second;
 }
 vector<int> A(N);
 for(int i = 0;i < N;i++)A[i] = i;
 do{
    double D = 0;
        for(int i = 0;i < N-1;i++){
           D += pow(pow(L[A[i+1]].first - L[A[i]].first,2) + pow(L[A[i+1]].second - L[A[i]].second,2),0.5);
        }
      sum += D;
    }while(next_permutation(A.begin(),A.end()));
    cout << setprecision(25) << fixed;
    cout << sum / fact(N) << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;

  if (r <= x && x <= w - r && r <= y && y <= h - r)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3088
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1000000007;
const llint big=(llint)(2.19e18)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	//ダイナミックプログラミンッ!!!
	int i,j,n;cin>>n;
	static llint dp[2505][2505]={0};
	vector<tuple<llint,llint,llint>> kuka(n);
	for(i=0;i<n;i++){
		llint L,R;cin>>L>>R;
		kuka[i]=mt(L+R,L,R);
	}
	SO(kuka);REV(kuka);
	//でかい奴から両端に埋めていく
	//(n/2個) ((n+1)/2個) になる
	dp[0][0]=-big;
	//n%2==1のとき、片方が埋まった状態も考えなければならない
	for(i=0;i<n;i++){
		for(j=0;j<=i;j++){
			int hi=j;
			int mg=i-j;
			if(n/2<hi){continue;}
			if(n/2<mg){continue;}
			llint wa,L,R;
			tie(wa,L,R)=kuka[i];
			mineq(dp[hi+1][mg],dp[hi][mg]+hi*wa+L);
			mineq(dp[hi][mg+1],dp[hi][mg]+mg*wa+R);
			if(n%2==1){
				dp[hi][mg]+=(n/2)*wa;
				if(hi>0){mineq(dp[hi][mg],dp[hi-1][mg]+(hi-1)*wa+L);}
				if(mg>0){mineq(dp[hi][mg],dp[hi][mg-1]+(mg-1)*wa+R);}
			}
		}
	}
	cout<<dp[n/2][n/2]+big<<endl;
	RE;
}


Measured memory_bytes: 49280
def main():
    N = int(input())
    D, X = map(int, input().split())
    A = [int(input()) for _ in range(N)]
    ans = X
    for i in range(N):
        ans += D // A[i]
        if D % A[i] > 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> nums = new HashSet<Integer>();
        for (int i = 0; i < n; i++){
            nums.add(sc.nextInt());
        }
        System.out.println(solve(x, n, nums));
    }
    static int solve(int x, int n, Set<Integer> nums){
        if (!(nums.contains(x))) return x;
        int cloSmall = x - 1, cloLarge = x + 1;
        boolean sml = false, lg = false;
        while (!(sml)){
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        }
        while (!(lg)){
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        }
        if (x - cloSmall == cloLarge - x){
            return Math.min(cloSmall, cloLarge);
        }else{
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        }
    }
}
class FastReader{ 
    BufferedReader br; 
    StringTokenizer st; 
    public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
      return Double.parseDouble(next()); 
    } 
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } 
}


Measured memory_bytes: 32884
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I a,b;
  cin >> a >> b;
  if (a != 1 && b != 1){
    cout << 1 << endl;
    return 0;
  }else if (a != 2 && b != 2){
    cout << 2 << endl;
    return 0;
  }else if (a != 3 || b != 3){
    cout << 3 << endl;
    return 0;
  }
  return 0;
}



Measured memory_bytes: 256
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define Mod 998244353
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}
ll lim=1000000000000000000;
int main()
{
   ll A,B;
   cin>>A>>B;
   cout<<A*B;
}


Measured memory_bytes: 3624
#include	<iostream>
#include	<string>

using namespace std;

bool search(string &, int, string);
void replace(string &, int, string);

int main() {
	string str;

	getline(cin, str);
	for (int i = 0; i + 4 < str.size(); i++) {
		if (search(str, i, "apple")) { replace(str, i, "peach"); i += 4; }
		else if (search(str, i, "peach")) { replace(str, i, "apple"); i += 4; }
	}
	cout << str << endl;
}

bool search(string &str, int pos, string target) {
	for (int i = 0; i < target.size(); i++) {
		if (str[pos + i] != target[i]) { return false; }
	}
	return true;
}

void replace(string &str, int pos, string target) {
	for (int i = 0; i < target.size(); i++) {
		str[pos + i] = target[i];
	}
}

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

namespace abc088_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool ret = true;
            if (!(a[0] - b[0] == a[1] - b[1] && a[1] - b[1] == a[2] - b[2])) ret = false;
            if (!(a[0] - c[0] == a[1] - c[1] && a[1] - c[1] == a[2] - c[2])) ret = false;
            if (!(a[0] - a[1] == b[0] - b[1] && a[1] - a[2] == b[1] - b[2])) ret = false;
            if (!(a[0] - a[1] == c[0] - c[1] && a[1] - a[2] == c[1] - c[2])) ret = false;
            Console.WriteLine(ret ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
#pragma optimize("", off)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(i) (int)(i.size())
#define setto(n) cout << fixed << setprecision(n)
#define fi first
#define se second
#define ld long double
#define inf LONG_MAX
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int mod = 1000000007;
using namespace std;

#ifndef ONLINE_JUDGE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
//Check N size twiceeeeeeeeeeeeeeeeee, and verify it

#define int ll
const int N = 1e5 + 10;

int n, m;
string s, t;

int lcm(int a, int b){
	return (a/__gcd(a, b))*b;
}

int32_t main(){_

	cin>>n>>m;
	cin>>s;
	cin>>t;

	int length = lcm(n, m);

	int low = length, high = 2e18, ans = -1;

	std::map<int, char> tmp;
	while(low <= high){
		int mid = (low + high) >> 1;

		int i = ((mid)/length)*length;
		tmp.clear();

		for (int j = 0; j < n; ++j)
		{
			tmp[(j*(i/n)) + 1] = s[j];
		}
		int f = 0;
		for (int j = 0; j < m; ++j)
		{
			int place = (j*(i/m)) + 1;
			if(tmp.count(place) == 0){
				tmp[place] = t[j];
			}
			else{
				if(tmp[place] != t[j]){
					f = 1;
					break;
				}
			}
		}
		if(f == 0){
			ans = i;
			high = mid - 1;
		}
		else{
			low = mid + 1;
		}
	}

	cout<<ans;
	return 0;
}

Measured memory_bytes: 10880
using System;
//using System.Collections;
//using System.Collections.Generic;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      int count = 0;
      while (true)
      {
        string s = Console.ReadLine();
        if (s == "0 0") break;
        var num = s.Split().Select(int.Parse).ToArray();
        int n = num[0];
        int x = num[1];

        int jj = 2;
        int kk = 3;

        for (int i = 1; i <= n - 2; i++)
        {
          for (int j = jj; j <= n - 1; j++)
          {
            for (int k = kk; k <= n; k++)
            {
              if (i + j + k == x) count++;
            }
            kk++;
          }
          jj++;
          kk = jj + 1;
        }
        Console.WriteLine(count);
        count = 0;
      }
    }
  }
}


Measured memory_bytes: 9620
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 50;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
struct edge{
    int from, to; ll cost;
};

//  通ってください

int main(){
    unordered_map<ll, int> mp;
    int n;
    cin >> n;
    REP(i, n){
        ll tmp;
        cin >> tmp;
        if(mp[tmp]){
            mp[tmp] = 0;
        }else{
            mp[tmp] = 1;
        }
    }
    int ans = 0;
    for(auto it = mp.begin(); it != mp.end(); ++it){
        if(it->second) ans++;
    }
    cout << ans << endl;
}

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

int mincost(vector<int> v, int n,int k)
{
	int dp[n] = {0};
	for(int i=1;i<n;i++){ dp[i] = INT_MAX; }
		
	for(int i=0;i<n-1;i++)
	{
		for(int j=1;j<=k && j+i<n;j++)
		{

			dp[i+j] = min(dp[i+j],dp[i]+abs(v[i+j]-v[i]));
		
		}

	}
	return dp[n-1];
}
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> p(n);
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	
	cout<<mincost(p,n,k)<<endl;
}


Measured memory_bytes: 1408
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
X = LI()
D = [0] * n
r = X[0]
ans = 1
for i in range(1, n):
    if r:
        D[i] = D[i - 1] + 1
        r -= 1
    else:
        D[i] = D[i - 1]
        r += 1
    r += X[i] - X[i - 1] - 1

ans = 1
for i in range(n):
    ans = ans * (D[i] + 1) % mod

print(ans)








Measured memory_bytes: 98500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
int get_digent(int);


int main(){
  often();
  ll n,ans=0;
  cin >> n;
  REP(i,1,n) ans += i;
  cout << ans << endl;
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

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

int get_digent(int x){
  string s;
  s = to_string(x);
  int digent = s.size();
  return digent;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
class mint{
    public:
        long long x;
 
    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<int> t(m);
    for(int i=0;i<m;i++){
        int k;cin >> k;
        for(int j=0;j<k;j++){
            int s;cin >> s;
            s--;
            t[i]+=(1<<s);
        }
    }
    vector<int> p(m);
    for(int i=0;i<m;i++){
        cin >> p[i];
    }
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        int cnt=0;
        for(int j=0;j<m;j++){
            int x=i&t[j];
            int sum=0;
            for(int l=0;l<n;l++){
                if(x&(1<<l)){
                    sum++;
                }
            }
            if(sum%2==p[j]){
                cnt++;
            }
        }
        if(cnt==m){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#define rep(i,l,n) for(i=l;i<n;i++)

int main(void){
	int n,a[1010],i,j,k,v;
	
	scanf("%d",&n);
	rep(i,0,n) scanf("%d",&a[i]);
	
	rep(i,0,n){
		v=a[i];
		j=i-1;
		while(j>=0 && a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		rep(k,0,n-1) printf("%d ",a[k]);
		printf("%d\n",a[n-1]);
	}
	
	
	return 0;
}

Measured memory_bytes: 600
n,m=map(int,input().split())
lists=list(map(int,input().split()))
uselist=[]
for some in lists:
    some=some//2
    uselist.append(some)

import fractions
import math
ans = uselist[0]
for i in range(1, n):
    ans = ans* uselist[i] // fractions.gcd(ans, uselist[i])

flags=True
for some in uselist:
    a=ans//some
    if a%2==0:
        flags=False
        break
if flags:
    p=math.floor(m/ans)
    if p%2==0:
      print(p//2)
    elif p%2!=0:
      print(p//2+1)
    
else:
    print(0)


Measured memory_bytes: 14124
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		int n;
		int k;
		FastScanner sc = new FastScanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();

		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}

		// その数値より小さい数値の数を入れる
		long [] tmp = new long[n];
		for(int i = 0 ; i < n ; i++) {
			long cnt = 0;
			for(int j = 0 ; j < n ; j++) {
				if(a[i] > a[j]) {
					cnt++;
				}
			}
			tmp[i] = cnt;
		}

		long ans = 0;
		// aだけで真面目にカウント
		for(int i = 0 ; i < n - 1 ; i++) {
			for(int j = i + 1 ; j < n ; j++) {
				if(a[i] > a[j]) {
					ans++;
				}
			}
		}

		// 真面目カウント * K
		ans = (ans * k) % 1000000007;

		// 2回目のループ以降
//		for(int i = 0 ; i < n ; i++) {
//			for(int j = 1 ; j <= k ; j++) {
//				ans += (tmp[i] * (k - j)) % 1000000007;
//				ans = ans % 1000000007;
//			}
//		}

		long x = 0;
		for(int i = 1 ; i <= k ; i++) {
			x += k - i;
		}
		x = x % 1000000007;

		for(int i = 0 ; i < n ; i++) {
			ans += (tmp[i] * x) % 1000000007;
			ans = ans % 1000000007;
		}

		System.out.println(ans % 1000000007);

	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n,x,y;
x=0;
y=0;
cin>>n;
string c;
cin>>c;
for(int i=0;i<n;i++){
  if(c.at(i)=='R'){
    x++;
  }
}
for(int i=0;i<x;i++){
  if(c.at(i)=='R'){
    y++;
  }
}
cout<<x-y<<endl;
}

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

int main()
{
  ll ans = 1;
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    ans = i * (ans % 1000000007);
  }
  cout << ans % 1000000007 << endl;
  

  return 0;
}


Measured memory_bytes: 3616