akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  bool ok=true;
  if(s[a]!='-'){cout<<"No"<<endl;return;}
  for(int i=0;i<(int)s.size();i++){
	     if(i==a)continue;
	     int val=(s[i]-'0');
	     if(val<0 or val>9){
			  ok=false;
			  break; 
			}
	 }
	cout<<(ok?"Yes":"No")<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5, INF = 1E9 + 7;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
int n, w;
int weight[N], value[N];
int dp[105][N];
int recur(int idx, int currw) {
	if (idx == n) {
		return 0;
	}
	if (dp[idx][currw]!= -1)return dp[idx][currw];
	else {
		return dp[idx][currw]=max((currw-weight[idx]>=0)?(value[idx] + recur(idx + 1, currw - weight[idx])):INT_MIN, recur(idx + 1, currw));

	}
}
void solve() {

	cin >> n >> w;
	memset(dp, -1, sizeof(dp));
	rep(i, n)cin >> weight[i] >> value[i];
	cout << recur(0, w)<<endl;




}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



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

using namespace std;

char x[1005], y[1005];
int n, m;

int main() {
	int ans = INT_MAX;
	scanf("%s%s", x, y);
	n = strlen(x);
	m = strlen(y);
	for (int i = 0; i + m <= n; i++) {
		int cur = 0;
		for (int j = 0; j < m; j++)
			if (x[i + j] != y[j])
				cur++;
		ans = min(ans, cur);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3824
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
	lint a, b, n;
	cin >> a >> b >> n;
	// lint ans = 0;
	lint ans = (a * (min(b - 1, n))) / b - a * ((min(b - 1, n)) / b);
	// for(int i = 1; i <= n; i++){
	// 	lint now = (a * i) / b - a * (i / b);
	// 	deb(now);
	// 	ans = max(ans, now);
	// }
	cout << ans;
    return 0;
}
// Write Here


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll dp[4][4][4][110] = {};

    rep(k, 4) rep(l, 4) rep(m, 4) {
        if ((k == 0 && l == 2 && m == 3) ||
                (k == 2 && l == 0 && m == 3) ||
                (k == 0 && l == 3 && m == 2)) dp[k][l][m][0] = 0;
        else dp[k][l][m][0] = 1;
    }

    rep(i, 105) {

        rep(j, 4) rep(k, 4) rep(l, 4) rep(m, 4) {
            if ((k == 0 && l == 2 && m == 3) ||
                    (k == 2 && l == 0 && m == 3) ||
                    (k == 0 && l == 3 && m == 2) ||
                    (j == 0 && k == 2 && m == 3) ||
                    (j == 0 && l == 2 && m == 3)) continue;
            dp[k][l][m][i + 1] += dp[j][k][l][i];
            dp[k][l][m][i + 1] %= MOD;
        }
    }
    ll sum = 0;

    rep(i, 4) rep(j, 4) rep(k, 4) {
        sum += dp[i][j][k][n - 3];
        sum %= MOD;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n, 0));
    int dp[4][n+2];
    for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> a.at(i).at(j);
        }
    }

    for(int i = 0; i < 4; ++i) {
        for(int j = 0; j < n+2; ++j) {
            dp[i][j] = 0;
        }
    }

    dp[0][0] = a.at(0).at(0);

    for(int i = 1; i <= 2; ++i) {
        for(int j = 1; j <= n; ++j) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + a.at(i-1).at(j-1);
        }
    }

    cout << dp[2][n] << endl;
}

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

using namespace std;

const int MAX_SIZE = 1000000;
pair<string, int> que[MAX_SIZE];
int head = 0;
int tail = 0;

bool is_que_full() {
    if ( head == ((tail + 1) % MAX_SIZE) ) {
        return true;
    }
    return false;
}

bool is_que_empty() {
    if (head == tail) {
        return true;
    }
    return false;
}

void que_push(pair<string, int> x) {
    if (is_que_full()) {
        cout << "que_push: full push" << endl;
        exit(1);
    }
    que[tail] = x;

    tail = (tail + 1) % MAX_SIZE;
}

pair<string, int> que_pop() {
    if (is_que_empty()) {
        cout << "que_push: full push" << endl;
        exit(1);
    }

    pair<string, int> ret = que[head];
    head = (head + 1) % MAX_SIZE;

    return ret;
}

int main() {
    int n, q;
    int cur_time = 0;

    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        string s;
        int t;
        cin >> s >> t;
        que_push(make_pair(s, t));
    }

    while (!is_que_empty()) {
        pair <string, int> p = que_pop();

        if (p.second <= q) {
            cur_time += p.second;
            cout << p.first << " " << cur_time << endl;
        } else {
            cur_time += q;
            que_push(make_pair(p.first, p.second-q));
        }
    }

    return 0;
}



Measured memory_bytes: 21052
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

long long n,m,d;

int main() {

  scanf("%lld %lld %lld", &n, &m, &d);

  long long sum = 0;
  if (2*d < n && d != 0) {
    sum = 2*(n-2*d)+2*d;
  } else {
    sum = n;
  }

  sum *= m-1;
  printf("%.31Lf\n", sum/(n*n*1.0L));

  return 0;
}


Measured memory_bytes: 128
import itertools
n = int(input())
s = ['' for _ in range(n)]
for i in range(n):
    s[i] = input()[0]
cnt = [s.count('M'), s.count('A'), s.count('R'), s.count('C'), s.count('H')]
ans = 0
for x in itertools.combinations(cnt, 3):
    ans += x[0] * x[1] * x[2]
print(ans)

Measured memory_bytes: 3888
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	ans := 0
	for i := 1; i < n+1; i += 2 {
		if count(i) == 8 {
			ans++
		}
	}
	fmt.Fprintln(writer, ans)
}
func count(n int) int {
	ans := 0
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ans++
			if i*i == n {
				continue
			}
			ans++
		}
	}
	return ans
}


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

const int A = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }

  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }

  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

  cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 11164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String a = br.readLine();
		int l = a.length();
		boolean[] flag = new boolean[27];
		for(int i = 0; i < 27; i++){
			flag[i] = true;
		}
		for(int i = 0; i < l; i++){
			char c = a.charAt(i);
			flag[c-97] = !flag[c-97];
		}
		boolean v = true;
		for(int i = 0; i < 27; i++){
			v = v && flag[i];
		}
		sb.append(v ? "Yes" : "No");
		System.out.println(sb);
	}
}


Measured memory_bytes: 8016
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll a,b;
    cin>>a>>b;
    ll diff,sum,prod;
    diff=a-b;
    sum=a+b;
    prod=a*b;
    ll ans=NEGINF;
    ans=max(ans,diff);
    ans=max(ans,sum);
    ans=max(ans,prod);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

using namespace std;

int main(){

	string s;
	cin >> s;

	int a=0, b=0;
	for(int i=0; i<3; i++){
		if(s[i] == 'R') a++;
		else {
			b = max(b, a);
			a = 0;
		}
	} b = max(b, a);

	cout << b << endl;

	return 0;
}


Measured memory_bytes: 3620
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n;
        ll x,y;
        vector<pair<ll,ll>>v;
        for(int i=0;i<n;i++)
        {
        	cin>>x>>y;
        	v.pb(mp(y,x));
        }
        sort(all(v));
        x=0;
        for(int i=0;i<n;i++)
        {
             if(x+v[i].S<=v[i].F)
             {
             	x+=v[i].S;	
             }	
             else
             {
             	cout<<"No";
             	return 0;
             }
        }
        cout<<"Yes";
    }
    return 0;
}

Measured memory_bytes: 6384
import sys
input = sys.stdin.readline

def is_753(n):
	s = str(n)
	f = [0,0,0]
	for c in s:
		if c == '3':
			f[0] = 1
		elif c == '5':
			f[1] = 1
		elif c == '7':
			f[2] = 1
	if all(f):
		return True
	else:
		return False

N = 0
c = 0
def gen(n):
	global c
	for i in [3,5,7]:
		k = 10 * n + i
		# print(k)
		if k > N:
			return
		if is_753(k):
			c += 1
			# print(k)
		gen(k)

def main():
	global N
	s = input().strip()
	N = int(s)
	n = len(s)

	gen(0)
	print(c)


if __name__ == '__main__':
	main()


Measured memory_bytes: 57564
#include<bits/stdc++.h>
using namespace std;
int read(){
	int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
    	if(c=='-') f=-1;
    	c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
#define maxn 105
int n,a[maxn],t[maxn];
int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++){
        if(a[i]>i){
        	printf("-1");return 0;
		}
		for(int j=n;j>=a[i]+1;j--) t[j]=t[j-1];
		t[a[i]]=a[i];
	}
	for(int i=1;i<=n;i++) printf("%d\n",t[i]);
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int n;cin >> n;
    for(int i = 0; i < n; i++){
        set<string> s;
        string t;
        cin >> t;
        int m = t.size();
        for(int j = 1; j < m; j++){
            string x = t.substr(0,j);
            string y = t.substr(j);
            reverse(x.begin(),x.end());
            reverse(y.begin(),y.end());
            string z = x;
            string w = y;
            reverse(x.begin(),x.end());
            reverse(y.begin(),y.end());
            s.insert(x+y);
            s.insert(x+w);
            s.insert(z+y);
            s.insert(z+w);
            s.insert(y+x);
            s.insert(y+z);
            s.insert(w+x);
            s.insert(w+z);
        }
        cout << s.size() << endl;
    }
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  ld ans=0;
  for(ll i=0;i<N;i++){
    ld a;
    cin>>a;
    ans+=1/a;
  }
  cout<<fixed << setprecision(9) <<(ld)1/ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n+2,sizeof(int));
  int i;
  for(i=1;i<=n;i++) scanf("%d",a+i);
  int64 sum=0;
  for(i=1;i<n+2;i++) sum+=ABS(a[i]-a[i-1]);
  for(i=1;i<=n;i++){
    printf("%lld\n",sum-ABS(a[i]-a[i-1])-ABS(a[i+1]-a[i])+ABS(a[i+1]-a[i-1]));
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
	
	Scanner stdin = new Scanner(System.in);
	int n = stdin.nextInt();
	int m = stdin.nextInt();
	long S[] = new long[n];
	final long mod = 1000000007;

	for (int i = 0 ; i < n ; i++ ){
	    S[i] = stdin.nextInt();
	}

	//System.out.println(S[0]+S[1]);

	long nowmax = 0;
	long X[] = new long[n];

	for (int i = 0 ; i < n ; i++){
	    X[i] = nowmax;
	    nowmax = Math.max(nowmax , S[i]);
	}

	long nowmin = 10000;
	long Y[] = new long[n];

	for (int i = n-1 ; i > -1 ; i-- ){
	    Y[i] = nowmin;
	    nowmin = Math.min(nowmin , S[i]);
	}

	long dp[][] = new long[n][m+1];

	for (int i = 0 ; i < n ; i++ ){

	    if (i == 0){
		dp[i][1] = 2;
		continue;
	    }

	    long s = S[i];
	    long x = X[i];
	    long y = Y[i];

	    if (x < y && x < s){
		for (int p = 0 ; p < m+1 ; p++){
		    if (p + 1 <= m){
			dp[i][p+1] += dp[i-1][p];
			dp[i][p+1] %= mod;
		    }
		    if (i-p+1 <= m && 0 <= i-p+1){
			dp[i][i-p+1] += dp[i-1][p];
			dp[i][i-p+1] %= mod;
		    }	    
		}
	    }else if (x < y && s < x){
		for (int p = 0; p < m+1 ; p++){
		    if (i-p+1 <= m && 0 <= i-p+1){
			dp[i][p] += dp[i-1][p];
			dp[i][p] %= mod;
		    }
		}
	    }else if (x > y && x < s){
		for (int p = 0; p < m+1 ; p++){
		    if (p+1 <= m){
			dp[i][p+1] += dp[i-1][p];
			dp[i][p+1] %= mod;
		    }
		}
	    }else if (s > y){
		System.out.println(0);
		return;
	    }else{
		for (int p = 0 ; p < m+1 ; p++){
		    if (i-p+1 <= m && 0 <= i-p+1){
			dp[i][p] += dp[i-1][p];
			dp[i][p] %= mod;
		    }
		}
	    }
   
	}

	long ans = 0;
	for (int i = 0; i < m+1 ; i++){
	    ans += dp[n-1][i];
	    ans %= mod;
	}

	System.out.println(ans);
	
    }

}



Measured memory_bytes: 303148
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int x;
  vector<int> ans(N);
  for(int i=0;i<N;i++){
    cin >> x;
    ans.at(x-1) = i+1;
  }
  for(int i=0;i<N-1;i++){
    cout << ans.at(i) << " ";
  }
  cout << ans.at(N-1) << endl;
}

Measured memory_bytes: 1152
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
int n, X, Y;
vector<vector<int>> g;

vi bfs(int u){
    vi d(n + 1);
    d[u] = 1;
    queue<int> q;
    q.push(u);
    while (!q.empty()){
        int v = q.front();
        q.pop();
        for (int nxt: g[v])
            if (d[nxt] == 0){
                d[nxt] = d[v] + 1;
                q.push(nxt);
            }
    }
    for (int i = 1; i <= n; i++) d[i]--;
    return d;
} 


int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> X >> Y;
    g.assign(n + 1,vi ());

    for (int i = 1; i < n; i++){
        g[i].eb(i + 1);
        g[i + 1].eb(i);
    }
    g[X].eb(Y);
    g[Y].eb(X);

    vi cnt(n + 1);
    for (int i = 1; i < n; i++){
        vi d = bfs(i);
        for (int j = i + 1; j <= n; j++) cnt[d[j]]++;
    }

    for (int i = 1; i < n; i++) cout << cnt[i] << '\n';
    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int r, g, b, n;
signed main() {
	cin >> r >> g >> b >> n;
	int ans = 0;
	for (int i = 0; i <= n; i += r) {
		for (int j = 0; j <= n; j += g) {
			if ((n - i - j) % b == 0 && n - i - j >= 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

const long long mod = 1e9 + 7;

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

    int logN;
    int x = 1;
    for(int i = 0; i <= 5; i++){
        if(n >= x) logN = i;
        else break;
        x *= 10;
    }

    int sum = 0;
    if(logN >= 1) sum += 9;
    if(logN >= 3) sum += 900;
    if(logN >= 5) sum += 90000;
    if(!(logN&1)){
        x /= 10;
        sum += n-x+1;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int N;
int R[200];
int dp[200][200];

int min(int x, int y) { return x < y ? x : y; }

int main(void) {
	scanf("%d", &N);
	for (int i = 0; i < N; i ++) {
		scanf("%d %d", &R[i], &R[i+1]);
	}
	for (int i = 0; i < N; i ++) {
		for (int j = 0; j < N; j ++) {
			dp[i][j] = 1 << 20;
		}
	}
	for (int i = 0; i < N; i ++) {
		dp[i][0] = 0;
	}
	for (int j = 0; j < N; j ++) {
		for (int i = 0; i + j < N; i ++) {
			// M_j ... M_{j+i}のi+1個の積について考える
			for (int k = 0; k < j; k ++) {
				// (M_j ... M_{j+k}) (M_{j+k+1} ... M_{j+i})
				//   (k+1個の積)            (i-k個の積)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[i+k+1][j-k-1] + R[i] * R[i+k+1] * R[i+j+1]);
			}
		}
	}
	printf("%d\n", dp[0][N-1]);
	return 0;
}

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

using namespace std;

#define N 1001

int vis[N][N] = {0};
string s[N];
int n, m;
int dp[N][N] = {0};
const int mod = 1e9 + 7;

long long solve(int i, int j)
{
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= m; j++)
		{
			if (i == 1 && j == 1)
				dp[i][j] = 1;
			else if (i == 0 || j == 0 || s[i - 1][j - 1] == '#')
				dp[i][j] = 0;
			else
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	return dp[n][m];
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	cout << solve(0, 0) << endl;
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

    int N; cin >> N;
    VI a(N);
    int absmax = -1;
    int index = -1;
    REP(i,N){
        cin >> a[i];
        if(abs(a[i]) > absmax){
            absmax = abs(a[i]);
            index = i;
        }
    }
    vector<PII> ans;
    if(a[index] >= 0){
        REP(i,N){
            if(i != index){
                ans.eb(index+1,i+1);
            }
        }
        REP(i,N-1){
            ans.eb(i+1,i+2);
        }
    }else{
        REP(i,N){
            if(i != index){
                ans.eb(index+1,i+1);
            }
        }
        for(int i = N; i > 1; i--){
            ans.eb(i,i-1);
        }
    }

    cout << ans.size() << endl;
    for(auto p : ans){
        cout << p.first << " " << p.second << endl;
    }

    //-2,5,-1
    //a,b
    //a > b
    //ex: 3,1 -> 3,4
    //ex: 3 -7 ->  -11,-7
    //ex: -2, -5 -> -7,-5


    //1,9,8,5,4,2
    //-1,-9,-8,-5,-4,-2
    //1,-9,8,-5,4,-7

    //-8,-9,-1,-14,-5,-16

    //1,-16,9,-7,13,-2




}


Measured memory_bytes: 256
target = input()
length = len(target)
binary = length - 1
target_list = []
for i in range(length):
    if i:
        target_list.append("")
    target_list.append(target[i])
for bit in range(binary ** 2):
    temp = target_list.copy()
    for i in range(binary):
        if bit & (1 << i):
            temp[1 + 2 * i] = "+"
        else:
            temp[1 + 2 * i] = "-"
    temp = "".join(temp)
    if eval(temp) == 7:
        print(temp + "=7")
        break

Measured memory_bytes: 3064
/*input
4 2 
2020
*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
// const int inf = 1e18;
const int maxn = 6e3 +5;
void solve(int test ) 
{		
	int n , p ;
	cin >> n >> p ;
	string s;
	cin >>s; 
	map<int, int > m;
	int curr = 0;int ans =0;int x =1;
	if ( p == 2 || p == 5){
		for ( int i = n-1 ; i >= 0 ; i--){
			if (( s[i] -'0' ) %  p == 0 ) ans += i+1;
		}
		cout << ans;
		return ;
	}
	for ( int i = n -1 ; i >= 0 ; i--){
		curr = (curr + ((s[i ] - '0') *x)%p ) %p;
		x = (x * 10 ) % p;
		if ( m[curr] > 0 ){
		ans += m[curr];
	}
		if (curr == 0)ans ++;
		m[curr]++;
	}
	cout << ans;
}
signed main(){
	bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	auto start = chrono::steady_clock::now();
	for ( int i = 0 ; i < t; i++)
	solve(i+1 );
	auto end = chrono::steady_clock::now();
	auto diff = end - start;
	// cout <<  (chrono::duration <double, milli> (diff).count()  / 1000 .0 )<< " s" << endl;
}

Measured memory_bytes: 1044
#include <stdio.h>
int main(){
  int sum=0, c1,c5,c10,c50,c100,c500;

  scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
  sum+=c1*1+c5*5+c10*10+c50*50+c100*100+c500*500;
  if(sum<1000)printf("0\n");
  else printf("1\n");
  return 0;
}

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

using Bit = bitset<2000>;
const int INF = 10000;

int solve(auto N, auto A, auto B) {
  auto res = INF;

  vector<int> L(3*N), R(3*N);
  if(B[0]) L.front() = 1;
  for(auto i = 1; i < L.size(); ++i) {
    if(B[i%N]) L[i] = i;
    else       L[i] = L[i-1];
  }
  if(B[N-1]) R.back() = 1;
  for(auto i = R.size()-1; 0 < i; --i) {
    if(B[(i-1+N)%N]) R[i-1] = i-1;
    else             R[i-1] = R[i];
  }

  for(auto d = 0; d < N; ++d) {
    auto cost = d;
    vector<int> P(N);
    for(auto i = 0; i < N; ++i) {
      auto j = (i+d)%N;
      if(A[i] == B[j]) continue;
      ++cost;
      auto ii = i+N;
      auto jj = j+N;
      auto t = R[ii] - ii;
      if(t <= d) continue;
      auto s = ii - L[ii];
      auto g = R[jj] - jj;
      P[s] = max(P[s], g);
    }
    auto add = INF;
    multiset<int, greater<int>> S;
    S.emplace(0);
    for(auto i: P) S.emplace(i);
    for(auto i = 0; i < N; ++i) {
      S.erase(S.lower_bound(P[i]));
      add = min(add, 2*(i + *begin(S)));
    }
    if(add == INF) add = 0;
    res = min<int>(res, cost + add);
  }

  return res;
}

int solve(auto A, auto B) {
  auto zero = [](auto s){return all_of(begin(s),end(s),[](auto c){return c=='0';});};
  if(zero(B)) return zero(A) ? 0 : -1;

  int N = A.size();
  auto rBit = [](auto s){reverse(begin(s), end(s)); return Bit(s);};
  return min(solve(N, Bit(A), Bit(B)), solve(N, rBit(A), rBit(B)));
}

int main() {
  string A, B;
  cin >> A >> B;
  cout << solve(A, B) << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String...args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
//        byte[] S= new byte[N+2];
       byte[] S = scanner.next().getBytes();
        int abcCount=0;
        for(int i=2;i<N;i++){
            if(S[i-2]=='A' && S[i-1]=='B'&& S[i]=='C'){
                abcCount++;
            }
        }
        System.out.println(abcCount);

    }
}






Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n, m;cin >> n >> m;
	vector<bool> used(222222);

	ll now = n-1;
	for(ll i = 1;i <= m;i++){
		if(!used[now] && !used[n-now] && now != n-now){
			used[n-now] = true;
			used[now] = true;
			cout << i << " " << i + now << endl;
		}
		else{
			now--;
			used[n-now] = true;
			used[now] = true;
			cout << i << " " << i + now << endl;
		}
		//cout << "now " << now << " " << n-now << endl;
		now -= 2;
		//SHOW1d(used, 10);
	}



	return 0;
}


Measured memory_bytes: 3668
using System;

namespace ITP1_10_C_2
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                    Environment.Exit(0);
                string[] data = Console.ReadLine().Split(' ');
                int[] tokuten = new int[n];
                double sum = 0;

                for (int i = 0; i < n; i++)
                {
                    tokuten[i] = int.Parse(data[i]);
                    sum += tokuten[i];
                }
                double m = sum / n;       //平均
                double m2 = Math.Pow(m, 2);  //平均の2乗

                double sum2 = 0;

                for (int i = 0; i < n; i++)
                {
                    double before = Math.Pow(tokuten[i], 2);　//データの2乗
                    sum2 += before;
                }
                double a = sum2 / n;　　//データの2乗の平均
                double a2 = a - m2;
                double root = Math.Sqrt(a2);

                Console.WriteLine("{0:F8}", root);
            }
        }
    }
}


Measured memory_bytes: 7984
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
#define MAX_V 100001
#define INF 10000000000001
typedef long long ll;

struct edge { ll to, cost; };
typedef pair<ll, ll> P; // firstは最短距離、secondは頂点の番号
vector<edge> G[MAX_V];
ll d[MAX_V];
ll N;
ll u[MAX_V], v[MAX_V], w[MAX_V];

void dijkstra(ll s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + MAX_V, INF);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		ll v = p.second;
		if (d[v] < p.first) continue;
		for (ll i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				if (e.cost % 2 == 0) d[e.to] = d[v]; else d[e.to] = (d[v]+1)%2;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){	
	cin >> N;
	for (int i = 1; i <= N-1; i++) {
		cin >> u[i];
		cin >> v[i];
		cin >> w[i];
		edge e1 = {v[i],w[i]};
        G[u[i]].push_back(e1);
		edge e2 = {u[i],w[i]};
        G[v[i]].push_back(e2);
	}
	dijkstra(1);
	for (int i = 1; i <= N; i++) {
		if (d[i] == 0) cout << "0" << endl; else cout << "1" << endl;
	}
	return 0;
}


Measured memory_bytes: 11008
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

//bool comp(
//
//	st pll &a, const pll &b) {
//	return a.first < b.first;
//}
//std::vector<int> enum_div(int n)//nの約数を列挙
//{
//	std::vector<int> ret;
//	for (int i = 1; i*i <= n; ++i)
//	{
//		if (n%i == 0)
//		{
//			ret.push_back(i);
//			if (i != 1 && i*i != n)
//			{
//				ret.push_back(n / i);
//			}
//		}
//	}
//	return ret;
//}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	priority_queue<int> q;
	string s = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	ll x[300005] = {};
	ll y[620] = {};
	ll y2[302][302] = {};
	cin >> a;
	cin >> s;
	for (int i = 0; i < a-2; i++)
	{
		if (s[i] == 'A'&&s[i+1] == 'B'&&s[i+2] == 'C')
		{
			ans++;
		}
	}
	
	cout << ans << endl;
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


Measured memory_bytes: 256
from collections import deque
n,h=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
l.sort(reverse=True)
fa,fb=l[0]
M=max(fa,fb)
if n==1:
	print(max(0,(h-M-1)//fa)+2-(h<=M))
else:
	cnt=0;tmp=[]
	for _,j in l[1:]:
		if j>fa:
			tmp.append(j)
	b=deque(sorted(tmp))
	lim=len(b)
	while h > M and cnt < lim:
		h-=b.pop()
		cnt+=1
	if len(b)!=0:
		print(cnt+1)
	else:
		print(cnt+max(0,(h-M-1)//fa)+2-(h<=M))

Measured memory_bytes: 30032
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;

int main()
{
    fastio;
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    int x=0; 
    for(int i=0; i<n; i++)
    {
        if(a[i]!=i+1)x++;
    }
    if(x==2 ||x==0)cout<<"YES\n";
    else cout<<"NO\n";
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    vector<ll> v;
    cin>>n;
    for(int i = 0; i < n; i++){
        ll x;cin>>x;v.push_back(x);
    }
    ll ans =0;
    for(int i =0; i<n ;i++){
            ll x = v[i];
        ll ct = 0;
        while(x%2 == 0) ct++,x/=2;
        ans+=ct;
    }
    cout<<ans<<endl;
    return 0;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

int main(int argc, char **argv)
{
	ll N, M, X; cin >> N >> M >> X;
	vector<ll> C(N);
	vector<vector<ll>> A(N, vector<ll>(M));
	REP(i, N)
	{
		cin >> C[i];
		REP(j, M) cin >> A[i][j];
	}


	ll res{INF};
	for (ll bits = 0; bits < (1 << N); ++bits)
	{
		vector<ll> v(M, 0);
		ll tmp{0};
		REP(i, N)
		{
			if (bits & (1 << i))
			{
				tmp += C[i];
				REP(j, M)
				{
					v[j] += A[i][j];
				}
			}
		}

		bool ok{true};
		for (auto &e : v)
		{
			if (e < X )
				ok = false;
		}
		if (ok)
			res = min(res, tmp);
	}
	std::cout << (res == INF ? -1 : res) << std::endl;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;

int main()
{
	string s;
	cin>>s;
	int n=s.length();
	if(s[n-1]=='s')
	s+="es";
	else
	s+="s";
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[105];
int main(){
	ll n,i,k,ans=0;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		scanf("%lld",&k);
		a[k]++;
	}
	for(i=1;i<=100;i++){
		if(a[i])ans++;
	}
	printf("%lld\n",ans);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;

int main(){
    map<ll,int> mp;
    ll ans = 1;
    int k = 2;
    
    ll A,B; cin>>A>>B;
    ll G = gcd(A,B);
    ll x = G;
    for(ll k=2;k<sqrt(x)+1;++k){
        if(x%k==0){
            ++ans;
            x /= k;
        }
        while(x%k==0){
           x /= k;
        }
    }
    if(x>1){ ++ans; }
   
   cout << ans << "\n";
}


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

int main(){
    int H, W;
    cin >> H >> W;
    char s[H][W];
    int flag[H][W];
    int p = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) flag[i][j] = 0;
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> s[i][j];
            if(s[i][j]=='.') flag[i][j] = 1;
        }
    }
    int dx[4] = {-1,0,1,0};
    int dy[4] = {0,1,0,-1};
    for(int i=0;i<H;i++){
        for(int j=0;j<W-1;j++){
            int c = 0;
            if(flag[i][j]==0){
                for(int k=0;k<4;k++){
                    int nx = j+dx[k];
                    if(nx<0 || nx >=W) continue;
                    int ny = i + dy[k];
                    if(ny<0 || ny>=H) continue;
                    if(flag[i+dy[k]][j+dx[k]]==0){
                        c++;
                    }
                }
                if(c==0){
                    p=1;
                    break;
                }
            }
        }
        if(p==1) break;
    }

    if(p==1) cout <<"No" <<"\n";
    else cout <<"Yes" <<"\n";

    return 0;
}


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

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

  int len = s.size();
  int i = 0;
  while (i < s.size() - 1) {
    if (s.at(i) != s.at(i + 1)) {
      s.erase(s.begin() + i, s.begin() + i + 2);
      if (s.size() == 0) break;
      if (i != 0) i--;
    } else {
      i++;
    }
  }

  int ans = len - s.size();
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int main() {
    int i,j;
    int n;
    long long int h,w;

    scanf("%lld %lld", &h, &w);
    if(h == 1 || w == 1){
        printf("1");
    }else{
        printf("%lld", h * w / 2 + (h*w %2 == 0 ? 0 : 1 ));
    }
    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	string s;
	cin>>s;

	lli cnt=0;
	REP(i,0,s.size()-1){
		if(s[i] != s[i+1])cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 512
N, x = map(int, input().split())
a1 = list(map(int, input().split()))
a2 = a1[::-1]
ans1 = 0
ans2 = 0

for i in range(N-1):
    tmp = a1[i] + a1[i+1] - x
    if tmp <= 0:
        continue
    red = min(a1[i+1], tmp)
    a1[i+1] -= red
    ans1 += red
    if red < tmp:
        a1[i] -= tmp-red
        ans1 += tmp-red
    
for i in range(N-1):
    tmp = a2[i] + a2[i+1] - x
    if tmp <= 0:
        continue
    red = min(a2[i+1], tmp)
    a2[i+1] -= red
    ans2 += red
    if red < tmp:
        a2[i] -= tmp-red
        ans2 += tmp-red
print(min(ans1, ans2))

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

using namespace std;

typedef long long ll;

int main(int, char**)
{
	string s;
	cin >> s;
	int x = 0;
	for (int i = 0; i < s.length(); i++)
		if (s[i] == 'x') x++;

	if (x > 7)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n, k;
  cin >> n >> k;
  LL major = n / k;
  LL minor = (n + k / 2) / k;
  LL answer = major * major * major;
  if (k%2 == 0) answer += minor * minor * minor;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split(" ")))

sum = 0

for ib, value in enumerate(B):
    if ib > 0:
        if value >= B[ib-1]:
            sum += B[ib-1]
        else:
            sum += value
    else:
        sum += value

sum += B[len(B) - 1]
print(sum)


Measured memory_bytes: 3060