akhauriyash/Code-Regression huggingface dataset:
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    vector<ll> v(n);
    rep(i,n)   cin >> v[i];
    ll lmax=0;
    lmax=v[0];
    rep(i,n){
        if(lmax<=v[i]){
            lmax=max(lmax,v[i]);
        }else{
            sum+=lmax-v[i];
        }
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
#define EPS 1e-9
#define PI acos(-1)
int main()
{
   // freopen("in.txt","r",stdin);
    int a,b,x;
    double theta,area,volume,total_vol;
    cin >> a >> b >> x;
    if(((a*a*b)/2)>x){
        theta = PI/2 - atan((2*x*1.0)/(a*b*b));
        theta *= 180/PI;
    }
    else{
        theta = atan((((2*a*a*b)-2*x)*1.0)/(a*a*a));
        theta *= 180/PI;
    }
    cout.precision(10);
    cout << fixed << theta << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define REP(i, s, n) for(signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(co) co.begin(), co.end()
typedef pair<int, int> P;

signed main() {
	int m, n;
	while (cin >> m && m) {
		vector<P> stars(m);
		rep(i, m) cin >> stars[i].first >> stars[i].second;
		cin >> n;
		set<P> ss;
		rep(i, n) {
			int x, y; cin >> x >> y;
			ss.insert(P(x, y));
		}

		for (P p : ss) {
			int dx = p.first - stars[0].first, dy = p.second - stars[0].second;
			if (all_of(all(stars), [&](P& p) { return ss.count(P(p.first + dx, p.second + dy)); })) {
				cout << dx << " " << dy << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1248
#include<stdio.h>
#include<math.h>

void koch(int n, double p1[], double p2[]){
    if (n == 0) return;
    
    double s[2], t[2], u[2];
    for (int i = 0; i < 2; i++){
        s[i] = (2.0 * p1[i] + p2[i]) / 3.0;
        t[i] = (2.0 * p2[i] + p1[i]) / 3.0;
    }
    u[0] = (t[0] - s[0]) * 0.5 - (t[1] - s[1]) * sqrt(3.0) * 0.5 + s[0];
    u[1] = (t[0] - s[0]) * sqrt(3.0) * 0.5 + (t[1] - s[1]) * 0.5 + s[1];
    
    koch(n-1, p1, s);
    printf("%f %f\n", s[0], s[1]);
    koch(n-1, s, u);
    printf("%f %f\n", u[0], u[1]);
    koch(n-1, u, t);
    printf("%f %f\n", t[0], t[1]);
    koch(n-1, t, p2);
}

int main(){
    int n = 0;
    scanf("%d", &n);
    double p1[2] = {0.0, 0.0};
    double p2[2] = {100.0, 0.0};
    printf("%f %f\n", p1[0], p1[1]);
    koch(n, p1, p2);
    printf("%f %f\n", p2[0], p2[1]);
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string a,b;
    cin>>a>>b;
    reverse(ALL(a));
    if(a==b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

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

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

typedef long long LL;
typedef pair<int, int> PII;

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

const int MAX = 1 << 17;

int a[MAX];

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
		cin >> a[i];
	sort(a, a + n);
	if(n % 3 != 0)
		cout << (a[0] == a[n - 1] ? "Yes" : "No");
	else
		cout << (a[0] == a[n / 3 - 1] && a[n / 3] == a[2 * n / 3 - 1] && a[2 * n / 3] == a[n - 1] &&
			(a[0] ^ a[n / 3] ^ a[2 * n / 3]) == 0 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n';
int lim=1e6;
int inf=1e9+7;
vector<vector<long double> > dp;
long double solve(int i,int j,long double* p,int n){
	if(i==n){
		if(j==0){
			return 1;
		}else{
			return 0;
		}
	}else if(dp[i][j]!=-1){
		return dp[i][j];
	}else{
		long double ans1=(1-p[i])*solve(i+1,j,p,n);
		long double ans2=0;
		if(j>0){
			ans2=(p[i])*(solve(i+1,j-1,p,n));
		}
		dp[i][j]=ans1+ans2;
		return dp[i][j];
	}
}
int main()
{	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;cin>>n;
	long double p[n];
	for(int i=0;i<n;i++){
		cin>>p[i];
	}	
	dp.resize(n,vector<long double>(n+1,-1));
	long double ans=0;
	for(int j=(n/2+1);j<=n;j++){
		ans+=solve(0,j,p,n);
	}
	cout<<setprecision(10)<<ans<<ln;
}

Measured memory_bytes: 141440
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
typedef pair< int, P > PP;

int main() {
  int N, H;
  while(cin >>N >>H && N){
    set<PP> S;
    REP(h, H){
      string s; int a, b; cin >>s >>a >>b;
      FOR(i, 1, N + 1){
        if(s == "xy") S.insert(PP(a, P(b, i)));
        if(s == "xz") S.insert(PP(a, P(i, b)));
        if(s == "yz") S.insert(PP(i, P(a, b)));
      }
    }
    cout <<N * N * N - S.size() <<endl;
  }
  return 0;
}

Measured memory_bytes: 4336
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	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 getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(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

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	x := getNextInt(scanner)
	y := getNextInt(scanner)

	if x > y {
		x, y = y, x
	}
	if x*2 < y || (x+y)%3 != 0 {
		fmt.Println(0)
		return
	}

	c := (x + y) / 3
	cm := Com{}
	cm.init(c)

	fmt.Fprintln(writer, cm.calc(c, x-c))
	writer.Flush()
}

// Com ...
type Com struct {
	facs, invs []int64
	mod        int64
}

func (cm *Com) init(n int) {
	cm.facs = make([]int64, n+1)
	cm.invs = make([]int64, n+1)

	cm.facs[0] = 1
	cm.mod = int64(1e9 + 7)
	for i := 1; i <= n; i++ {
		cm.facs[i] = (cm.facs[i-1] * int64(i)) % cm.mod
	}
	cm.invs[n] = cm.inv(cm.facs[n])
	for i := n - 1; i >= 0; i-- {
		cm.invs[i] = cm.invs[i+1]*int64(i+1)%cm.mod
	}
}

func (cm *Com) inv(n int64) int64 {
	var ii [32]int64
	ii[0] = n
	for i := 1; i < 31; i++ {
		ii[i] = (ii[i-1] * ii[i-1]) % cm.mod
	}
	var ans int64
	ans = 1
	m := cm.mod - 2
	for i := 30; i >= 0; i-- {
		for m >= 1<<uint(i) {
			ans = (ans * ii[i]) % cm.mod
			m -= 1 << uint(i)
		}
	}

	return ans
}

func (cm *Com) calc(n, k int) int64 {
	ans := cm.facs[n] * cm.invs[k]
	ans %= cm.mod
	ans = ans * cm.invs[n-k]
	ans %= cm.mod
	return ans
}


Measured memory_bytes: 11392
//STL ABC088 B
#include <iostream>
#include <algorithm>
#include <vector>
#define mac(i,n)for(int i =0; i < (int)(n);i++)
using namespace std;

int main(){
    int A,B,C;
    B = 0;
    C = 0;
    cin >> A;
    vector<int> SAI(A);
    mac(i,A){
        cin >> SAI.at(i);
    }
    sort(SAI.begin(),SAI.end());
    reverse(SAI.begin(),SAI.end());
    mac(i,A){
        if(i % 2 == 0){
            B += SAI.at(i);
        }else{
            C += SAI.at(i);
        }
    }
    cout << B - C << endl;

    
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

bool can[10];
int N,M;

int main(){
	scanf("%d%d",&N,&M);
	for(int i=0,a;i<M;i++)	scanf("%d",&a),can[a]=true;
	while(1){
		int n=N;
		while(n>0){
			if(can[n % 10])	break;
			n=n/10;
		}
		if(n==0){
			printf("%d",N);
			return 0;
		}
		++N;
	}
}

Measured memory_bytes: 128
<?php
fscanf(STDIN, "%d", $n);
$s_keys = array();
for($i = 0; $i < $n; ++ $i){
	$s_temp = trim(fgets(STDIN));
	!isset($s_keys[$s_temp]) && $s_keys[$s_temp] = 0;
	++$s_keys[$s_temp];
}

$max = 0;
$ans = array();
arsort($s_keys);
foreach($s_keys as $f_key => $f_val){
	if($f_val >= $max){
		$max = $f_val;
		$ans[] = $f_key;
	}else{
		break;
	}
}
sort($ans);
foreach($ans as $f_val){
	echo $f_val . "\n";
}
?>

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

int main(){
	int N;
	cin >> N;
	int minB = 1000000001;
	int mini;
	int A[100001],B[100001];
	for(int i = 1;i <= N;i++){
		cin >>A[i] >> B[i];
		if(minB > B[i]){
			minB = B[i];
			mini = i;
		}
	}
	cout << minB + A[mini] << endl;
	return 0;
}

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

const int MAX = 100000; // N

int main() {
	int N, M, x, y;
	cin >> N >> M;
	static pair<int, bool> box[MAX]; // ボールの個数, 赤の可能性
	box[0] = make_pair(1, true);
	for (int i = 1;i < N;++ i) box[i] = make_pair(1, false);
	for (int i = 0;i < M;++ i) {
		cin >> x >> y;
		-- box[x - 1].first;
		++ box[y - 1].first;
		box[y - 1].second |= box[x - 1].second;
		box[x - 1].second &= box[x - 1].first > 0;
	}
	int ans = 0;
	for (int i = 0;i < N;++ i) ans += box[i].second ? 1 : 0;
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

要するに、赤いボールと白いボールが混ざるまでは常に1, それ以降は動かす度に増えると考えれば良い
*/

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  int cntA = 0, cntB = 0, cntC = 0;
  int now = 1;
  for (;;) {
    if (a.size() == cntA && now == 1) {
      cout << "A" << endl;
      return 0;
    }
    if (b.size() == cntB && now == 2) {
      cout << "B" << endl;
      return 0;
    }
    if (c.size() == cntC && now == 3) {
      cout << "C" << endl;
      return 0;
    }
    // A
    if (now == 1) {
      if (a.at(cntA) == 'a') {
        now = 1;
        cntA++;
        continue;
      }
      if (a.at(cntA) == 'b') {
        now = 2;
        cntA++;
        continue;
      }
      if (a.at(cntA) == 'c') {
        now = 3;
        cntA++;
        continue;
      }
    }
    // B
    if (now == 2) {
      if (b.at(cntB) == 'a') {
        now = 1;
        cntB++;
        continue;
      }
      if (b.at(cntB) == 'b') {
        now = 2;
        cntB++;
        continue;
      }
      if (b.at(cntB) == 'c') {
        now = 3;
        cntB++;
        continue;
      }
    }
    // C
    if (now == 3) {
      if (c.at(cntC) == 'a') {
        now = 1;
        cntC++;
        continue;
      }
      if (c.at(cntC) == 'b') {
        now = 2;
        cntC++;
        continue;
      }
      if (c.at(cntC) == 'c') {
        now = 3;
        cntC++;
        continue;
      }
    }
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		// 出力
		System.out.println(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? 
                           "Possible" : "Impossible");
	}
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

int main(){
  int n, a, b;
  cin >> n >> a >> b;

  int ans = 0;
  rep(i,n){
    int t;
    cin >> t;
    if(not (a<=t && t<b) ) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  char c[15];
  int before;
  int after;

  for( int i = 0 ; i < 9 ; i++ ){
    cin >> c >> before >> after;
    cout << c << " " << before + after << " " << before*200 + after*300 << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;

  int32_t main()
  {
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/


    IOS
    string s,t;
    cin>>s>>t;
    for(char i='a';i<='z';i++)
    {
        string temp=s+i;
        if(temp==t)
        {
          cout<<"Yes";
          return 0;
        }
    }
    cout<<"No";
    return 0;
  }

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;

#define BITTYPE int

#define BITCNT  2

#define BITSIZE 512345

namespace _BIT{

    int i=0;

    BITTYPE t[27][BITSIZE];

    inline BITTYPE* get(){

        return t[i++];

    }

}



struct BIT{

    using T=BITTYPE;

    T *t;

    int n;
    BIT(int N):t(_BIT::get()),n(N+1){

        REP(i,n+1)t[i]=0;

    }

    void add(int r,T v){//add v for [1,r]

        for(;r;r-=r&-r)t[r]+=v;

    }

    void add(int l,int r,T v){//add v for [l,r]

        add(r,v);

        add(l-1,-v);

    }

    T get(int i){//get sum[i]

        T res=0;

        for(;i<=n;i+=i&-i)res+=t[i];

        return res;

    }

};

int N;
string S;
int Q;
int A[100001];
int B[100001];
int C[100001];

int main(){
	cin>>N;
	cin>>S;
	cin>>Q;
	BIT a[26]={N+10,N+10,N+10,N+10,N+10,
	           N+10,N+10,N+10,N+10,N+10,
	           N+10,N+10,N+10,N+10,N+10,
	           N+10,N+10,N+10,N+10,N+10,
	           N+10,N+10,N+10,N+10,N+10,N+10};
	REP(i,N){
		a[S[i]-'a'].add(i+1,N+10,1);
	}
	/*REP(i,N){
		cout<<a[i].get(N)<<endl;
	}
	return 0;*/
	REP(i,Q){
		//cout<<"s"<<endl;
		cin>>A[i];
		if(A[i]==1){
			//cout<<"aa"<<endl;
			int b;
			string c;
			cin>>b>>c;
			if(S[b-1]==c[0]){
				//cout<<"same"<<endl;
			}else{
				a[S[b-1]-'a'].add(b,N+10,-1);
				a[c[0]-'a'].add(b,N+10,1);
				S[b-1]=c[0];
			}
			//cout<<"end"<<endl;
		}else{
			//cout<<"bb"<<endl;
			int b,c;
			cin>>b>>c;
			int ans=0;
			REP(j,26){
				//cout<<"cc"<<endl;
				int x=a[j].get(c);
				//cout<<"dd"<<endl;
				int y=0;
				//cout<<"ee"<<endl;
				if(b!=1){
					y=a[j].get(b-1);
				}
				
				//cout<<x<<" "<<y<<endl;
				if(x-y>0){
					ans++;
				}
			}
			cout<<ans<<endl;
			//cout<<"end"<<endl;
		}
	}
}

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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  // vector<int> s(n + 1);
  map<int, int> s;
  vector<int> cnt(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    cnt[a[i + 1]]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < cnt[i]; j++) {
      s[i - j]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += s[i] == 0;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    s[a[x] - cnt[a[x]] + 1]--;
    if (s[a[x] - cnt[a[x]] + 1] == 0 && a[x] - cnt[a[x]] + 1 > 0) {
      ans++;
    }
    cnt[a[x]]--;
    a[x] = y;
    cnt[a[x]]++;
    s[a[x] - cnt[a[x]] + 1]++;
    if (s[a[x] - cnt[a[x]] + 1] == 1 && a[x] - cnt[a[x]] + 1 > 0) {
      ans--;
    }
    cout << ans << '\n';
  }

  return 0;
}

Measured memory_bytes: 21888
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int N;
	vector<int> A;
	int inputA;
	int now;

	int continuity = 1;
	int answer = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> inputA;
		A.push_back(inputA);
	}

	now = A[0];
	for (int i = 1; i < N; i++) {
		if (A[i] == now) {
			++continuity;
		}
		
		if (i < N - 1) {
			if (A[i] != now) {
				now = A[i];
				answer += continuity / 2;
				continuity = 1;
			}
		}
		else {
			answer += continuity / 2;
		}
	}

	cout << answer << endl;
	cin >> inputA;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN  100005
vector<int>adj[MAXN];
int vis[MAXN];
int dp[MAXN];

void dfs(int node)
{
    vis[node]=1;
    for(auto child:adj[node])
    {
        if(!vis[child])
        {
            dfs(child);
        }
        dp[node]=max(dp[node],1+dp[child]);
    }
}

int main()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
      int a,b;
      cin>>a>>b;
      adj[a].push_back(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
    int ans=-1;
    for(int i=1;i<=n;i++)
    {
       ans=max(ans,dp[i]);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 8576
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = ~~arg[0].split(" ")[0];
    const B = ~~arg[0].split(" ")[1];
    const T = ~~arg[0].split(" ")[2];
    
    console.log(B * Math.floor(T / A));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

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

    int n;
    cin >> n;
    vector<int> xs(n), ys(n);
    for (int i = 0; i < n; i++) cin >> xs[i] >> ys[i];

    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 0);

    double sum = 0;
    int cnt = 0;

    do {
        for (int i = 0; i < n - 1; i++) {
            sum += hypot(xs[perm[i + 1]] - xs[perm[i]], ys[perm[i + 1]] - ys[perm[i]]);
        }
        cnt++;
    } while (next_permutation(perm.begin(), perm.end()));

    cout << setprecision(20) << fixed << sum / cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     998244353
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
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...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){ return powm(a,m-2,m); }
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>s;
n=s.size();
for(i=0;i<n;i++)
{
  if(s[i]=='?')
  {
    s[i]='D';
  }
}
cout<<s;
}


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

long long a[100010];
int main(){
	int n;
	long long k;
	scanf("%d%lld", &n, &k);
	for(int i = 0;i < n;i++){
		int x, y;
		scanf("%d%d", &x, &y);
		a[x] += y;
	}
	int ans = 0;
	long long cnt = 0;
	for(int i = 1;i <= 100000;i++){
		cnt += a[i];
		if(cnt >= k){
			ans = i;
			break;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MN 2005
struct edge{
	int to,nxt;
}e[MN<<1];
char ok[MN];
int n,r[MN],l[MN],siz[MN],Ans=2147483647,h[MN];
void ins(int x,int y) {
	static int cnt=0;
	e[++cnt].nxt=h[x];h[x]=cnt;e[cnt].to=y;
}
void dfs(int x,int f)
{
	siz[x]=ok[x]=='1';l[x]=r[x]=0;
	for(int i=h[x];i;i=e[i].nxt)
	{
		if(e[i].to==f) continue;
		dfs(e[i].to,x);
//		if(x==3) printf("%d : %d\n",x,e[i].to);
		if(l[e[i].to]>r[x]) {
			l[x]=l[e[i].to]-r[x];
		} else if(r[e[i].to]<l[x]) {
			l[x]=l[x]-r[e[i].to];
		} else l[x]=(l[x]^l[e[i].to])&1;
		r[x]+=r[e[i].to];
//		if(x==3) printf("%d %d\n",l[x],r[x]);
		siz[x]+=siz[e[i].to];
	}
	l[x]+=siz[x];r[x]+=siz[x];
//	if(x==3) printf("%d : %d %d\n",x,l[x],r[x]);
}
int main()
{
	scanf("%d%s",&n,ok+1);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		ins(x,y);
		ins(y,x);
	}
	for(int i=1;i<=n;i++)
	{
//		printf("I ; %d dddddddddddd\n",i);
		dfs(i,0);
//		printf("%d %d %d\n",siz[i],l[i],r[i]);
		if(l[i]==siz[i]) Ans=std::min(Ans,r[i]-siz[i]);
	}
	if(Ans==2147483647) puts("-1");
	else printf("%d\n",Ans/2);
}

Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1,T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using Vote = pair<ll,ll>;
using Unordered_map = unordered_map<Vote, int, pair_hash>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define showvec(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" ";
#define read_input(arr,a,b) for(ll i=a;i<b;i++) cin>>arr[i];
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define SmooothOperatorrrrr()                 \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                    \
    cout.tie(0);                   
#define deci(n) cout<<fixed<<setprecision(n)
const int mod=998244353;
const int mod2=1000000007;
#define M_PI 3.14159265358979323846
#define LL_MAX 9223372036854775807
#define MAXN 2000001
/**************************************************************************************************/
int main()
{
    SmooothOperatorrrrr();
    ll h,w,m;cin>>h>>w>>m;
    ll M=m;
    unordered_map<ll,int> bombs;
    vector<ll> row(h);
    vector<ll> col(w);
    while(m--)
    {
        ll x,y;cin>>x>>y;
        x--;y--;
        ll val=x*1e9+y;
        bombs[val]=1;
        row[x]++;
        col[y]++;
    }
    ll max1=0;
    ll max2=0;
    FOR(i,0,h)
        max1=max(max1,row[i]);
    FOR(i,0,w)
        max2=max(max2,col[i]);
    vll v1,v2;
    FOR(i,0,h)
    {
        if(row[i]==max1)
            v1.pb(i);
    }
    FOR(i,0,w)
    {
        if(col[i]==max2)
            v2.pb(i);
    }
    int ok=0;
    FOR(i,0,v1.size())
    {
        FOR(j,0,v2.size())
        {
            ll val=v1[i]*1e9+v2[j];
            if(bombs.find(val)==bombs.end())
            {
                ok=1;
                break;
            }
        }
    }
    if(ok)
        cout<<max1+max2<<endl;
    else
        cout<<max1+max2-1<<endl;
}       

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

using namespace std;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

class RollingHash {
 private:
  using u64 = std::uint_fast64_t;

  const u64 mod = (1ULL << 61) - 1;
  const u64 base = 2009;
  std::vector<u64> hashes, pows;

  inline u64 add(u64 a, u64 b) const {
    a += b;
    if (a >= mod) a -= mod;
    return a;
  }

  inline u64 sub(u64 a, u64 b) const {
    if (a < b) a += mod;
    a -= b;
    return a;
  }

  inline u64 mul(u64 a, u64 b) const {
    u64 ah = a >> 31, al = a & ((1ULL << 31) - 1), bh = b >> 31,
        bl = b & ((1ULL << 31) - 1), m = ah * bl + al * bh,
        v = (ah * bh << 1) + (m >> 30) + ((m & ((1ULL << 30) - 1)) << 31) +
            al * bl;
    v = (v & ((1ULL << 61) - 1)) + (v >> 61);
    v = (v & ((1ULL << 61) - 1)) + (v >> 61);
    return v;
  }

 public:
  RollingHash(const std::string &S)
      : hashes((int)S.size() + 1, 0), pows((int)S.size() + 1, 0) {
    int sz = static_cast<int>(S.size());
    pows[0] = 1;
    for (int i = 0; i < sz; i++) {
      pows[i + 1] = mul(pows[i], base);
      hashes[i + 1] = add(mul(hashes[i], base), S[i]);
    }
  }

  u64 slice(int l, int r) const {
    return sub(hashes[r], mul(hashes[l], pows[r - l]));
  }

  // LCP (Longest Common Prefix)
  int lcp(const RollingHash &rh, int l1, int r1, int l2, int r2) {
    int len = std::min(r1 - l1, r2 - l2);
    int lo = -1, hi = len + 1;
    while (lo < hi) {
      int mi = (lo + hi + 1) >> 1;
      if (slice(l1, l1 + mi) == rh.slice(l2, l2 + mi)) {
        lo = mi;
      } else {
        hi = mi - 1;
      }
    }
    return lo;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  RollingHash rh(S);
  int lo = 0, hi = N + 1;
  while (lo < hi) {
    int mi = (lo + hi + 1) >> 1;

    bool flag = false;
    map<u64, int> mp;
    for (int i = 0; i + mi < N + 1; i++) {
      u64 x = rh.slice(i, i + mi);
      if (mp.count(x)) {
        if (i - mp[x] >= mi) {
          flag = true;
          break;
        }
      } else {
        mp[x] = i;
      }
    }

    if (flag)
      lo = mi;
    else
      hi = mi - 1;
  }
  cout << lo << '\n';
  return 0;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	int **A = new int*[n+1];
	for(int i=0; i < n+1; i++){
		A[i] = new int[m+1];
	}

	int *B = new int[m+1];
	int *C = new int[n+1];
	int temp=0;

	for(int r=1; r<=n; r++){
		for(int c=1; c<=m; c++){
			cin >> A[r][c];
		}
	}

	for(int r=1; r<=m; r++){
		cin >> B[r];
	}

	for(int i=1; i<=n; i++){
		temp = 0;
		for(int j=1; j<=m; j++){
			temp += A[i][j]*B[j];
		}
		C[i] = temp;
	}

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

	return 0;
}

Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    string s, t;

    cin >> s >> t;
    
    ll dp[3010][3010] = {0};

    rep(scnt, 0, s.length()){
        rep(tcnt, 0, t.length()){
            if (s[scnt] == t[tcnt]) chMax(dp[scnt+1][tcnt + 1], dp[scnt][tcnt]+ 1);
            chMax(dp[scnt+1][tcnt+1],dp[scnt+1][tcnt]);
            chMax(dp[scnt+1][tcnt+1],dp[scnt][tcnt+1]);
        }
    }

    string ans = "";

    ll sSize = s.size();
    ll tSize = t.size();
    while(sSize > 0 && tSize > 0){
        if (dp[sSize][tSize] == dp[sSize-1][tSize]){
            --sSize;
        }
        else if (dp[sSize][tSize] == dp[sSize][tSize-1]){
            --tSize;
        }
        else{
            ans = s[sSize-1] + ans;
            --sSize;
            --tSize;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 71040
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
    
      ios
      ll r;
      cin >> r;
  	  const double pi=acos(-1.0);
      double c = (2*pi*r);
      cout << setprecision(20) <<fixed<< c <<"\n";
      return 0;
     
}
/* 6.28318530717958623200 */

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

int main()
{
	vector<int> n(3);

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

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

	rep(i, 3)
	{
		cout << n[i]; 
			if (i < 2)
				cout << " ";
	}
	cout << endl;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  string s[200];
  ll n,l;
  cin >> n >> l;
  rep(i,n)cin >> s[i];
  sort(s,s+n);
  rep(i,n)cout << s[i];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    int N;
    cin>>N;
    vector<int> ans;

    int a,b;
    for(int i=0;i<N;i++){
        cin>>a>>b;
        if(a==b)
            ans.push_back(1);
        else ans.push_back(0);
    }

    int idx=0;
    int f=0;
    while(idx<N){
        int count=0;

        int val=ans[idx];
        if(val){
            count=1;
            int next=idx+1;
            while(ans[next]==ans[idx]){
                next++;
                count++;
            }
            if(count>=3){
                f=1;
                break;
            }
            idx=next;
        }
        else idx++;
    }
    if(f)
        cout<<"Yes\n";
    else cout<<"No\n";

}


Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc156/tasks/abc156_d>
 問題文============================================================
 D - Bouquet
 =================================================================
 解説=============================================================
 
 ================================================================
 */

const ll MOD = 1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}

template<class Type>
Type solve(Type res = Type()){
    ll n,a,b; cin >> n >> a >> b;
    
    ll S = powmod(2,n) - 1;
    ll A,B;
    {
        A = 1;
        for(ll i = 1; i <= a; i++){
            (A *= inversemod(i))%=MOD;
            (A *= (n-i+1))%=MOD;
        }
    }
    {
        B = 1;
        for(ll i = 1; i <= b; i++){
            (B *= inversemod(i))%=MOD;
            (B *= (n-i+1))%=MOD;
        }
    }
    
    res = ((S-A-B)%MOD + MOD)%MOD;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
  cin >> N >> M;
  if(N <= M)cout << "unsafe" << endl;
  else cout << "safe" << endl;
}

Measured memory_bytes: 3704
N, K = map(int, input().split())

A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse = True)

def calc(x): #全てx以下にするために何回変える必要があるか
    tmp = 0
    for a, f in zip(A, F):
        tmp += max(0, a - (x // f))
    return tmp

ng = -1
ok = 10 ** 18
while ok - ng > 1:
    mid = (ok + ng) // 2
    if calc(mid) <= K:
        ok = mid
    else:
        ng = mid

print (ok)

Measured memory_bytes: 114108
#include<cstdio>
#include<cstring>
#include<map>
#include<queue>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    char a[205];
    int l;
    scanf("%s",a +1);
    l = strlen(a + 1);
    for(int i = 1; ;i++){
        l = l - 1;
        if(l%2==1)
            l=l-1;
        for(int j = 1;j <= l/2;j++){
            if(a[j]!=a[l/2+j]){
                break;
            }
            if(j == l / 2){
                printf("%d",l);
                return 0;
            }
        }
    }
}


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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

ll n;

string bfs()
{
    queue<string> q;
    for(char ch = '1'; ch<='9'; ch++)
    {
        string s = "";
        s += ch;
        q.push(s);
    }

    while (q.size())
    {
        n--;
        string s = q.front();
        if (n == 0) return s;
        q.pop();

        if (s.back() > '0')
        {
            string str = s + s.back();
            str.back()--;
            q.push(str);
        }
        string str = s+s.back();
        q.push(str);
        if (s.back() < '9')
        {
            string str = s + s.back();
            str.back()++;
            q.push(str);
        }
    }
}

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

    cin >> n;

    cout << bfs() << "\n";


    return 0;
}

Measured memory_bytes: 11776
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
h = inl()
if n==1:
    print('Yes')
    exit()

for i in range(n-2,-1,-1):
    if h[i] > h[i+1]+1:
        print('No')
        exit()
    elif h[i] == h[i+1]+1:
        h[i] -= 1

print('Yes')


Measured memory_bytes: 14692
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    ll k = s.size();
    ll cnt = 0;
    rep(i, k) if(s[i] == 'x') cnt++;
    (cnt >= 8) ? NO() : YES();
}

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

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

  int ans = K;
  for(int i=0;i<N-1;i++){
    ans *= K - 1;
  }

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


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

using namespace std;

int a[100100], b[100100], c[100100];
int n;
int dp[3][100100];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i] >> c[i];
	dp[0][1] = a[1], dp[1][1] = b[1], dp[2][1] = c[1];
	for (int i = 2; i <= n; i++) {
		dp[0][i] = max(dp[1][i - 1] + a[i], dp[2][i - 1] + a[i]);
		dp[1][i] = max(dp[0][i - 1] + b[i], dp[2][i - 1] + b[i]);
		dp[2][i] = max(dp[1][i - 1] + c[i], dp[0][i - 1] + c[i]);
	}
	cout << max(max(dp[0][n], dp[1][n]), dp[2][n]);
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
long long  A[1000005],B[1000005];
int main()
{
  long long i,c=0,n;
  scanf("%lld",&n);
  for(i=1;i<=n;i++)
  {
      scanf("%lld",&A[i]);
      B[i]=B[i-1]+A[i];
  }
  for(i=1;i<=n;i++)
  {
   c+=(A[i]*((B[n]-B[i])%1000000007));
   c%=1000000007;
  }

printf("%lld\n",c);
return 0;
}


Measured memory_bytes: 6956
#include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define ALL(x) (x).begin(),(x).end()
#define CASET2 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d:\n", case_n++) : 0), ___T-- > 0)
#define CASET1 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d: ", case_n++) : 0), ___T-- > 0)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define WRI(argv...) while (RI(argv) != EOF)
#define DWRI(x...) int x; WRI(x)
#define RS(x) scanf("%s",x)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define V(x) vector<x >

typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;

void print(int i) { printf("%d", i); }
template<class T> void PI(T i) { print(i); puts(""); }
template<class T> void PIS(T i) { print(i); printf(" "); }

template<class T>
void PV(T const &v, int N) {
    REP(i, N) {
        print(v[i]);
        printf("%c", i == N-1 ? '\n' : ' ');
    }
}

template<class T> void PV(T const &v) { PV(v, SZ(v)); }

template<class T, class S> bool has_bit(T mask, S i) { return (mask >> i) & 1; }
long long shift(int i) { return 1ll << i; }

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
int popcount(int x) { return __builtin_popcount(x); } 
int popcount(long long x) { return __builtin_popcountll(x); } 

#include <unordered_set>
#include <unordered_map>
#define EB emplace_back
#define RL(x) scanf("%lld", &(x))
#define PL(x) printf("%lld\n", x)
#define DRL(x) LL x; RL(x)

char S[100005];

int main() {
  RS(S);
  int ans = 0;
  REPL(i, S) {
    if (S[i] != S[i+1]) {
      ans++;
    }
  }
  PI(ans-1);
  return 0;
}


Measured memory_bytes: 384