akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int power(int num)
{
    int p=1;
    for(;0<num;num--)p*=10;
    return p;
}
int main() {
    int n,m,a[3]={15,3,5};
    while(cin>>m>>n,n,m){
        string str,fb[3]={"FizzBuzz","Fizz","Buzz"};
        bool player[1000]={};
        for(int i=1,now=0,out=m;i<=n;i++,now=(now+1)%m){
			cin>>str;
			if(out>1){
				int num=0,co=-1;
				while(player[now])now=(now+1)%m;
				for(int j=0;j<3&&co<0;j++)if(i%a[j]<1)co=j;
				if(co<0)for(int j=0;j<str.size();j++)num+=(str[j]-'0')*power(str.size()-1-j);
				if(co>-1&&str!=fb[co]||co<0&&i!=num)player[now]=1;
				if(player[now])out--;
			}
		}
		for(int i=0,co=0;i<m;i++){
			if(!player[i]&&co>0)cout<<" ";
			if(!player[i]){
				cout<<i+1;
				co++;
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

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

    if (N == 3) {
        cout << 2 << " " << 5 << " " << 63 << endl;
    } else if (N == 4) {
        cout << 2 << " " << 5 << " " << 20 << " " << 63 << endl;
    } else if (N == 5) {
        cout << 2 << " " << 5 << " " << 20 << " " << 30 << " " << 63 << endl;
    } else {
        ll sum = 0;
        ll current = 2;
        vector <ll> vec;
        for (int i = 0; i < N; i++) {
            if (current % 6 == 1 || current % 6 == 5) {
                vec.push_back(current + 1);
                sum += (ll)(current + 1);
                current += 2;
            } else {
                vec.push_back(current);
                sum += (ll)(current);
                current++;
            }
        }

        if (sum % 6 == 2 || sum % 6 == 3) {
            vec.at((sum % 6) + 2) = -1;
            while (true) {
                if (current % 6 == 0) {
                    vec.push_back(current);
                    break;
                } else {
                    current++;
                }
            }
        } else if (sum % 6 == 5) {
            vec.at(5) = -1;
            while (true) {
                if (current % 6 == 4) {
                    vec.push_back(current);
                    break;
                } else {
                    current++;
                }
            }
        }

        for (int i = 0; i < vec.size(); i++) {
            if (vec.at(i) != -1) {
                cout << vec.at(i) << " ";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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 Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//組み合わせ計算用
const int MAX = 500000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;

	ll ans = 1;
	if (n < 3)
	{
		cout << 0 << endl;
		ret;
	}
	if (n < 6)
	{
		cout << 1 << endl;
		ret;
	}
	if (n == 6)
	{
		cout << 2 << endl;
		ret;
	}
	if (n == 7)
	{
		cout << 3 << endl;
		ret;
	}
	if (n == 8)
	{
		cout << 4 << endl;
		ret;
	}

	COMinit();

	for (int i = 2; i <= n / 3; i++)
	{
		ll ko = i;
		ll tmp = n - 3 * i;

		ans += COM(ko + tmp - 1, tmp);
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

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

int main(void){
 int n; cin >> n; ll a[n]; for(int i=0;i<n;i++) cin >> a[i]; 
 ll ans[2];
 for(int i=0;i<2;i++){
  ll s = 0; ans[i] = 0;
  for(int j=0;j<n;j++){
   s += a[j];
   if ((i+j)%2){
    if (s<=0) {ans[i] += 1-s; s = 1;}
   }else{
    if (s>=0) {ans[i] += s+1; s = -1;}
   }
  }
 }
 cout << min(ans[0], ans[1]) << endl;
 return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

template <typename T>
T gcd(T a, T b){
	T r;
	while(b > 0){
		r = a % b;
		a = b;
		b = r;
	}
	return a;
}
template <typename T>
inline T lcm(T a, T b){
	return a / gcd(a, b) * b;
}

int main(){
	int a,b,n,m;
	
	while( scanf("%d %d", &a, &b) != EOF){
		n = gcd(a,b);
		m = lcm(a,b);
		printf("%d %d\n", n , m);
	}

	return 0;
}

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

const int maxn = 2e5 + 100;

typedef long long ll;

ll bit[maxn];

void update(int idx, ll val)
{
    idx += 3;
    while(idx < maxn)
    {
        bit[idx] = max(bit[idx],val);
        idx += idx & (-idx);
    }
}


ll query(int idx)
{
    idx += 3;
    ll ans = 0;
    while(idx)
    {
        ans = max(ans,bit[idx]);
        idx -= idx & (-idx);
    }
    return ans;
}

int a[maxn], h[maxn];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n ; i++)
        scanf("%d",&h[i]);

    for(int i = 0; i < n ; i++)
        scanf("%d",&a[i]);
    
    for(int i = 0; i < n ; i++)
    {
        update(h[i],query(h[i] - 1) + a[i]);
    } 

    printf("%lld\n",query(n+1));

    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#define LL long long
#define PP std::pair<int,int>
int N, H;
int MA;
int ans;
std::set<int> num;
std::vector<int> thr;
int main() {
	std::cin >> N >> H;
	for (int i = 1; i <= N; i++) {
		int a, b;
		std::cin >> a >> b;
		MA = std::max(a, MA);
		thr.push_back(b);
	}
	std::sort(thr.rbegin(),thr.rend());
	int all = num.size();
	for (auto u : thr) {
		if (u > MA) {
			H -= u;
			ans++;
			if (H <= 0) {
				std::cout << ans << std::endl;
				return 0;
			}
		}
		else {
			break;
		}
	}
	if (H>0) {
		ans += (H / MA);
		if (H%MA)ans++;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 892
package main

import (
	"fmt"
)

func main() {
	var (
		n, a, max uint
		x, y      uint
	)
	fmt.Scan(&n)

	statements := make([][][2]uint, n)
	for i := uint(0); i < n; i++ {
		fmt.Scan(&a)

		s := make([][2]uint, a)
		for j := uint(0); j < a; j++ {
			fmt.Scan(&x, &y)
			s[j][0] = x - 1
			s[j][1] = y
		}
		statements[i] = s
	}

	for bit := uint(0); bit < 1<<n; bit++ {
		var (
			cnt uint
			ok  = true
		)

		for i := uint(0); i < n; i++ {
			if bit&(1<<i) == 0 {
				continue
			}
			cnt++

			for _, s := range statements[i] {
				_x, _y := s[0], s[1]
				if (bit>>_x)&1 != _y {
					ok = false
				}
			}
		}

		if ok && cnt > max {
			max = cnt
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 512
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
a, b, c, x, y = map(int, input().split())
ans = min((a + b) * min(x, y), c * min(x, y) * 2)
if x > y:
    ans += min(a * (x - y), c * (x - y) * 2)
else:
    ans += min(b * (y - x), c * (y - x) * 2)
print(ans)

Measured memory_bytes: 5032
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    int a,b,num;
    cin >> n;
    cin >> a >> b;
    int ca=0,cb=0,cc=0;
    // vector<int> p(n);
    rep(i,n){
        cin >> num;
        if(num <= a) ca++;
        else if(a+1 <= num&&num <= b)cb++;
        else cc++;
    }
    // cout << ca << "," << cb << "," << cc << endl;
    cout << min(ca,min(cb,cc)) << endl;



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	ll n;
	cin >> n;
	ll tmp;
	tmp = (n - 1) * (1 + n - 1);
	tmp /= 2;
	cout << tmp << endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int x,k,r[100010],q,a,t;
int main(){
	cin>>x>>k;
	r[0]=0;
	lol(i,k)cin>>r[i+1];
	cin>>q;
	int pnt=1;
	int left=0,right=x,nowleft=0,nowright=x;
	while(q--){
		cin>>t>>a;
		while(pnt<=k){
			if(r[pnt]>t)break;
			int move;
			if(pnt%2==0)move=+(r[pnt]-r[pnt-1]);
			if(pnt%2==1)move=-(r[pnt]-r[pnt-1]);
			nowleft+=move,nowright+=move;
			right-=max(0,nowright-x);
			left+=max(0,0-nowleft);
			if(left>right)left=right;
			nowleft=max(0,nowleft);
			nowleft=min(x,nowleft);
			nowright=max(0,nowright);
			nowright=min(x,nowright);
			//cout<<r[pnt]<<"#"<<pnt<<" "<<left<<" "<<right<<" "<<nowleft<<" "<<nowright<<endl;
			pnt++;
		}
		int lastref;
		if(a<=left)lastref=nowleft;
		if(left<a&&a<right)lastref=nowleft+a-left;
		if(right<=a)lastref=nowright;
		if(pnt%2==0)lastref+=(t-r[pnt-1]);
		if(pnt%2==1)lastref-=(t-r[pnt-1]);
		lastref=max(0,lastref);
		lastref=min(x,lastref);
		//cout<<"%"<<left<<" "<<right<<" "<<a<<" "<<nowleft<<" "<<nowright<<endl;
		cout<<lastref<<endl;
	}
	return 0;
}


Measured memory_bytes: 1536
import math

n = int(input())
x = list(map(int, input().split()))

# max_p = max(x)
# min_p = min(x)

avg = math.ceil(sum(x)/n)
avg2 = sum(x)//n

ans = min(sum([(X-avg)**2 for X in x]), sum([(X-avg2)**2 for X in x]))

print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    	Scanner sc = new Scanner(System.in);
	    	int n = sc.nextInt();
	    	int count = 0;
	    	for (int i = 0; i < 4; i++) {
			if (String.valueOf(String.valueOf(n).charAt(i)).equals("2")) {
				count++;
			}
		}
	    	System.out.println(count);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s, t;
  cin >> s >> t;
  ll count = 0;
  rep(i,sz(s)){
    if(s[i]!=t[i]){
      count++;
    }
  }
  print(count);
}

Measured memory_bytes: 3912
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
int color[100050];
int cnt;
vector<int> G[100050];
#define WHITE 0
#define GRAY 1
#define BLACK 2

class UnionFind{
 public:
  //親の番号を格納する。親だった場合は-(その集合のサイズ）
  vector<int> Parent;
  
  //作るときはParentの値を全て-1になる
  //こうするとすべてバラバラになる。
  UnionFind(int N){
   Parent = vector<int>(N+1,-1);
  }

  int root(int A){
   if(Parent[A] <0)return A;
   return Parent[A]=root(Parent[A]);
  }

  int size(int A){
   return - Parent[root(A)];//親をとっていきたい
  }

  //AとBをくっ付ける
  bool connect(int A, int B){
   //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
   A = root(A);
   B = root(B);
   if(A==B){
    return false;
   }
   //大きい方（A)に小さいほう（B)をくっ付けたい
   //大小が逆だったらひっくり返す。
   if(size(A) <size(B))swap(A,B);

   //Aのサイズを更新する。
   Parent[A] +=Parent[B];
   //Bの親をAに変更する
   Parent[B]=A;
   return true;
  }
};

int main(void){
 int N,M;
 cin>>N>>M;
 vector<int> A(M),B(M);
 for(int i=0; i<M; i++){
  cin>>A[i]>>B[i];
 }

 vector<long long int > ans(M);
 ans[M-1]=(long long int)N*(N-1)/2;
 
 UnionFind Uni(N);
 for(int i=M-1; i>=1; i--){
  ans[i-1]=ans[i];
  if(Uni.root(A[i])!=Uni.root(B[i])){
   ans[i-1]-=(long long int)Uni.size(A[i])*Uni.size(B[i]);
   Uni.connect(A[i],B[i]);
  }
 }

 for(int i=0; i<M; i++)cout<<ans[i]<<endl;

 return 0;
}

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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  if((x-2*z)%(y+z)>=y){
    cout << (x-2*z)/(y+z)+1;
  }else{
    cout << (x-2*z)/(y+z);
  }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
input_line = int(input())

Line = list(input())

# print(Line)

count = 0

for i in range(input_line - 2):
    if Line[i] == "A":
        if Line[i+1] == "B":
            if Line[i+2] =="C":
                count += 1

print(count)

Measured memory_bytes: 2940
l = [[0 for i in range(13)] for j in range(4)]
n = int(input())

g = {0:"S",1:"H",2:"C",3:"D"}
h = {"S":0, "H":1, "C":2, "D":3}

for i in range(n):
    s,r = input().split()
    l[h[s]][int(r)-1] = 1

for i in range(4):
    for j in range(13):
        if l[i][j] == 0:
            print(g[i],j+1)

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> cnt(m);
    for (int i=0;i<n;i++) {
        int k;
        cin >> k;
        for (int j=0;j<k;j++) {
            int A;
            cin >> A;
            A--;
            cnt[A]++;
        }
    }
    int ans =0;
    for(int i=0; i<m;i++) {
        if(cnt[i]==n){
            ans++;
        }
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
<?php  

fscanf(STDIN, "%d %d %d %d", $A,$B,$C,$D);

$x = array($A,$B);
$list = array();

foreach ($x as $x_c) {
    $a = $x_c * $C;
    $b = $x_c * $D;
    array_push($list, $a, $b);
}

echo max($list); 

Measured memory_bytes: 16224
#include<cstdio>
using namespace std;
int snu[105] = {};
int main(void)
{
	int n, k, i;
	scanf("%d %d", &n, &k);
	for (i = 1; i <= k; ++i)
	{
		int d;
		scanf("%d", &d);
		for (int j = 0; j < d; ++j)
		{
			int temp;
			scanf("%d", &temp);
			snu[temp]++;
		}
	}
	int ans = 0;
	for (i = 1; i <= n; ++i)
	{
		if (snu[i] == 0)
		{
			ans++;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
using std::swap;

int main() {
	int X, A;
	cin >> X >> A;
	if (X < A)cout << "0" << "\n";
	else cout << "10" << "\n";
	return 0;
}

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

const int N = 2e5 + 10;
int n, q, ans, A[N], ar[N], cnt[N];

void add(int x) {
	int l = max(0, x - cnt[x]);
	cnt[x]++;
	ar[l]++;
	if (ar[l] == 1)
		ans--;
}

void del(int x) {
	cnt[x]--;
	int l = max(0, x - cnt[x]);
	ar[l]--;
	if (!ar[l])
		ans++;
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> q;
	ans = n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		add(x);
		A[i] = x;
	}
	
	while (q--) {
		int indx, x;
		cin >> indx >> x;
		x--; indx--;
		del(A[indx]);
		A[indx] = x;
		add(x);
		
		cout << ans << '\n';
	}
}

Measured memory_bytes: 3840
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	digit := make(map[int]int)
	flag := false
	for i := 0; i < m; i++ {
		var s, c int
		fmt.Scan(&s, &c)
		if v, exist := digit[s-1]; exist {
			if v != c {
				flag = true
			}
		} else {
			digit[s-1] = c
		}
	}

	if flag {
		fmt.Println(-1)
		return
	}

	var ans int
	d0, exist := digit[0]
	if !exist {
		if n == 1 {
			ans = 0
		} else {
			ans = 1
		}
	} else if n != 1 && d0 == 0 {
		fmt.Println(-1)
		return
	} else {
		ans = d0
	}

	for i := 1; i < n; i++ {
		ans *= 10
		if v, exist := digit[i]; exist {
			ans += v
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    string s;
    cin >> s;
    int zero=0,one=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='0') zero++;
        else one++;
    }
    cout << min(zero,one)*2 << endl;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n,a,b,x,cnt1,cnt2,cnt3;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
#ifdef LOCAL_DEFINE
	ifstream cin("input.in");
#endif
	
	cin >> n >> a >> b;
	for(int i=1;i<=n;i++){
		cin >> x;
		if(x<=a) cnt1++;
		else if(x<=b) cnt2++;
		else cnt3++;
	}
	cout << min(cnt1,min(cnt2,cnt3));
	
#ifdef LOCAL_DEFINE
	cerr << "\nTime elapsed: " << 1.0*clock()/CLOCKS_PER_SEC << " \n";
#endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int cnt[123];

void make(int x) {
	for (int i = 2; i * i <= x; i++) {
		while (x % i == 0) {
			x /= i;
			cnt[i]++;
		}
	}
	if (x > 1) cnt[x]++;
}

bool check(vector<int> A, vector<int> B) {
	int ok = 1;
	for (int i = 0; i < (int)A.size(); i++)
		ok &= cnt[A[i]] >= B[i];
	return ok;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n; cin >> n;
	
	for (int i = 2; i <= n; i++) make(i);
	
	int ans = 0;
	
	for (int i = 0; i <= n; i++) ans += check({ i }, { 74 });
	
	for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) if (i != j) 
		ans += check({ i, j }, { 14, 4 }) + check({ i, j }, { 24, 2 });
		
	for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) for (int k = 0; k < j; k++)
		if (i != j && i != k && j != k) ans += check({ i, j, k }, { 2, 4, 4 });
		
	cout << ans << "\n";
	return 0;
}

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

int main()
{
  int n,m;cin>>n>>m;
  int sum=0;
  int t;
  for(int i=0;i<m;i++){cin>>t;sum+=t;}
  
  if(sum>n)cout<<-1<<endl;
  else
    cout<<n-sum<<endl;
  return 0;
}


Measured memory_bytes: 3616
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const int mod = ((int)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i_##mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin, (x).end()
// function
int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}

signed main(){
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	std::vector<pair<long long int ,long long int>> a(0);
	long long int n, m, s,t,u=0;
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> s >> t;
		a.push_back(make_pair(s, t));
	}
	sort(a.begin(),a.end());
	t = 0;
	for (int i = 0; i < n; ++i) {
		u += a[i].first * a[i].second;
		t += a[i].second;
		//cout << u << "\n";
		if (t >= m) {
			u -= a[i].first * (t - m);
			break;
		}
	}
	cout << u << "\n";
	return 0;	
}

Measured memory_bytes: 2420
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;


int main(){
    int n;
    cin >> n;
    int tmp = n %10;
    if(tmp == 3) {
        p("bon");
    } else if (tmp == 0 or tmp == 1 or tmp == 6 or tmp == 8){
        p("pon");
    }else {
        p("hon");
    }
    return 0;
}


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

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 110;

int ex, ey;

int n, m;
int g[maxn + 5][maxn + 5];

int sum[maxn + 5][maxn + 5];

int dp[2][maxn + 5][maxn + 5][maxn + 5];

inline int query(int u, int v, int x, int y)
{
	if (u >= x || v >= y) return 0;
	return sum[x][y] - sum[u][y] - sum[x][v] + sum[u][v];
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	static char s[maxn + 5];
	scanf("%d%d", &n, &m);
	REP(i, 0, n) 
	{
		scanf("%s", s);
		REP(j, 0, m)
		{
			if (s[j] == 'o') g[i][j] = 1;
			else 
			{
				g[i][j] = 0;
				if (s[j] == 'E') ex = i, ey = j;
			}
		}
	}
	REP(i, 0, n) REP(j, 0, m) sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + g[i][j];
	memset(dp, -oo, sizeof dp);
	dp[0][0][0][0] = 0;
	int ans = 0;
	REP(i, 0, n + 1) 
	{
		int cur = i & 1;
		REP(j, 0, n - i + 1) REP(k, 0, m + 1) REP(l, 0, m - k + 1) if (dp[cur][j][k][l] >= 0)
		{
			chkmax(ans, dp[cur][j][k][l]);
			if (i + j == n || k + l == m) continue;
			REP(u, 0, 4)
			{
				int up, down, left, right;
				int ii = i, jj = j, kk = k, ll = l;
				int val = dp[cur][j][k][l];
				if (u == 0) 
				{
					up = ii, down = ii + 1, left = kk, right = m - ll;
					++ii;
				}
				if (u == 1) 
				{
					++jj;
					up = n - jj, down = n - jj + 1, left = kk, right = m - ll;
				}
				if (u == 2) 
				{
					up = ii, down = n - jj, left = kk, right = kk + 1;
					++kk;
				}
				if (u == 3) 
				{
					++ll;
					up = ii, down = n - jj, left = m - ll, right = m - ll + 1;
				}
				chkmax(up, ex - jj);
				chkmin(down, ex + ii + 1);
				chkmax(left, ey - ll);
				chkmin(right, ey + kk + 1);
				val += query(up, left, down, right);
				chkmax(dp[ii & 1][jj][kk][ll], val);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

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

    cout << r * 2 * PI << endl;
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    int r;
    cin>>r;
    cout<<setprecision(2);
    cout<<fixed;
    cout<<r*6.28<<endl;
}


Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		int count = 0;
		int j = 1;
		int restricao = 0;

		for (int i = 0; i < S.length(); i++) {
			restricao++;
			if (S.substring(i, j).equals("x")) {
				count++;
			}
			j++;
		}
		
		if (restricao >= 1 && restricao <= 15) {
			if (count < 8) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}

	}

}

Measured memory_bytes: 21844
H, W = map(int, input().split())
metrics = [list(map(int, input().split())) for _ in range(H)]

ans = []
cnt = 0
for h in range(H):
    for w in range(W):
        if metrics[h][w] % 2 != 0:
            metrics[h][w] -= 1
            if w + 1 < W:
                metrics[h][w + 1] += 1
                ans.append([h + 1, w + 1, h + 1, w + 2])
                cnt += 1
            elif h + 1 < H:
                metrics[h + 1][w] += 1
                ans.append([h + 1, w + 1, h + 2, w + 1])
                cnt += 1
print(cnt)
for row in ans:
    print(*row)


Measured memory_bytes: 30292
// inputに入力データ全体が入る
function Main(input) {
	
	input = input.split(" ");
	
	//文字列から10進数に変換するときはparseIntを使います
	var A = parseInt(input[0], 10);
	var B = parseInt(input[1], 10);
  var C = parseInt(input[2], 10);
 
    var D = C - (A - B);
   
   if (D < 0){ var D  = 0;}
   console.log(D);               
               
     }
    
	
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
// https://atcoder.jp/contests/abc172/tasks/abc172_a

#include <stdio.h>
#include <math.h>

int main() {
    
    int a;
    printf("\n");
    scanf("%d", &a);
    
    int b= pow (a, 2);
    int c= pow (a, 3);

    printf("%d\n", a+b+c);
    
    return 0;
}

Measured memory_bytes: 2512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

struct Edge {
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

vector<bool> seen;
vector<int> color;
void dfs(const Graph &G, int v, int p_color) {
    seen[v] = true;
	int c_color = 0;

    for (auto next_v : G[v]) { 
        if (seen[next_v.to]) continue;
		c_color++;
		if (p_color == c_color) c_color++;
		color[next_v.weight] = c_color;
        dfs(G, next_v.to, c_color);
    }
}

void Main() {
	int N; cin >> N;
	Graph G(N);
	REP(i, N - 1) {
		int a, b; cin >> a >> b;
		--a; --b;
		G[a].push_back(Edge(b, i));
		G[b].push_back(Edge(a, i));
	}
	seen.assign(N, false);
	color.assign(N - 1, -1);
	dfs(G, 0, -1);
	// debug(color);
	set<int> st;
	REP(i, N - 1) {
		st.insert(color[i]);
	}
	cout << st.size() << endl;
	REP(i, N - 1) {
		cout << color[i] << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int cnt = 0;
	char tmp = s[0];
	for(int i = 1; i < s.size(); i++)
	{
		if(s[i] == tmp)
			cnt++;
		else
		{
			tmp = s[i];
			cnt = 0;
		}
		if(cnt == 2)
		{
			cout << "Yes" << endl;
			return 0;
		}

	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
def resolve():
    N, L = map(int, input().split())
    list = []
    for i in range(N):
        list.append(L+i)
    if L <= 0 and N >= (L*-1)+1:
        print(sum(list))
    elif min(list) > 0:
        print(sum(list) - min(list))
    else:
        print(sum(list) - max(list))
resolve()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n, t; cin >> n >> t;
    vector<int> a(n), b(n);
    vector<P> x(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
        x[i] = make_pair(a[i], b[i]);
    }
    sort(all(x));
    int dp[3030][3030];
    memset(dp, 0, sizeof(dp));
    rep(i, n) {
        for(int j = 0; j <= t; ++j) {
            dp[i + 1][j] = dp[i][j];
            if(j - x[i].fr >= 0) dp[i + 1][j] = max(dp[i][j], dp[i][j - x[i].fr] + x[i].sc);
        }
    }
    int ans = x[0].sc;
    rep1(k, n) {
        chmax(ans, dp[k][t - 1] + x[k].sc);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        m[a]++;
    }
    
    int ans = 0;
    for (auto i = m.begin(); i != m.end(); i++)
    {
        if (i -> first > i -> second) ans += i -> second;
        else if (i -> first < i -> second) ans += i -> second - i -> first;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4736
#include<iostream>
using namespace std;
long long costb[5000][5000],costw[5000][5000],N;
long long memo[5000][5000],barr[2500],warr[2500];

int main(){
	ios::sync_with_stdio(0);
	cin>>N;
	for(long long i=0;i<2500;++i){
		barr[i]=-1;
		warr[i]=-1;
	}
	for(long long i=0;i<2*N;++i){
		char c;
		long long a;
		cin>>c>>a;
		if(c=='W')warr[a]= i;
		else barr[a]=i;
	}
	for(long long i=0;i<=2*N;++i){
		costb[i][N]=0;
		for(long long j=N-1;j>=0;--j){
			costb[i][j]=costb[i][j+1];
			costb[i][j]+=(barr[j+1]<i&&barr[j+1]>=0);
		}
	}
	for(long long i=0;i<=2*N;++i){
		costw[i][N]=0;
		for(long long j=N-1;j>=0;--j){
			costw[i][j]=costw[i][j+1];
			costw[i][j]+=(warr[j+1]<i&&warr[j+1]>=0);
		}
	}
	for(long long i=0;i<=2*N;++i){
		for(long long j=0;j<=2*N;++j){
			memo[i][j]=1e9;
		}
	}
	memo[0][0]=0;
	for(long long i=0;i<=N;++i){
		for(long long j=0;j<=N;++j){
			if(i!=N){
				int x=costb[barr[i+1]][i+1];
				x+=costw[barr[i+1]][j];
				memo[i+1][j]=min(memo[i+1][j],memo[i][j]+x);
			}
			if(j!=N){
				int x=costw[warr[j+1]][j+1];
				x+=costb[warr[j+1]][i];
				memo[i][j+1]=min(memo[i][j+1],memo[i][j]+x);
			}
		}
	}
	cout<<memo[N][N]<<"\n";
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf 1e18
#define endl "\n"

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main()
{
    fastio
    ll n,i,ans=0,t;

    cin >> n ;
    t=n;
    ll ar[n];
    for(i=0; i<n; i++) cin >> ar[i];
    
    sort(ar,ar+n,greater<ll>());

    n = (t-2)/2;

    ans = ar[0];

    for(i=1; i<=n; i++)
        ans += ar[i]*2 ;

    if(t&1)
        ans += ar[n+1];
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5196
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

struct meh {
    int x, y, h;
};

int main()
{
    int n, k=0, ok;
    cin>>n;
    meh v[n];
    for(int i=0; i<n; i++){
        cin>>v[i].x>>v[i].y>>v[i].h;
    }
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            k=0;
            ok=0;
            for(int g=0; g<n; g++)
            if(v[g].h!=0){
                k=v[g].h+abs(v[g].x-i)+abs(v[g].y-j);
                break;
            }
            for(int g=0; g<n; g++){
                if(max(k-abs(v[g].x-i)-abs(v[g].y-j), 0)!=v[g].h)
                    ok=1;
            }
            if(ok==0){
                cout<<i<<" "<<j<<" "<<k;
                break;
            }
        }
        if(ok==0)
            break;
    }

    return 0;
}


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

using namespace std;

const int maxN = 100 * 1000 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n + 1);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    vector<int> dist(n + 1, 0), parent(n + 1, -1);
    queue<int> Q;
    Q.push(1);
    parent[1] = 0;
    while (!Q.empty()) {
        int current_vertex = Q.front();
        Q.pop();
        for (int next_vertex : edge[current_vertex]) {
            if (parent[next_vertex] == -1) {
                dist[next_vertex] = dist[current_vertex] + 1;
                parent[next_vertex] = current_vertex;
                Q.push(next_vertex);
            }
        }
    }
    for (int i = 2; i <= n; ++i) {
        if (dist[i] == 0) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for (int i = 2; i <= n; ++i) {
        cout << parent[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 10676
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
  cin>>n>>s;
  int k=0;
  for (int i=2; i<n; ++i)
    if (s[i]=='C' && s[i-1]=='B' && s[i-2]=='A') k++;
  cout<<k<<endl;
}

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

using namespace std;

int main(){
  int n,m, ans;
  int a,b,c;
  cin >> n;
  vector<int> sa;
  vector<int> k;
  vector<int> t;

  for(int i = 0 ; i < n ; i++){
    int p;
    cin >> p;
    k.push_back(p);
  }
  for(int i = 0 ; i < n ; i++){
    int p;
    cin >> p;
    k[i] -= p;
  }
  sort(k.begin(), k.end());
  ans = 0;
  for(int i = 0; i < n; i++){
    if(k[i] >= 0) ans += k[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);
    
    ll ans = 0;
    ll max = 0;
    rep(i, N){
        if(max<A.at(i)) max = A.at(i);
        if(max>A.at(i)) ans += max - A.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3980
//waz
#include <bits/stdc++.h>
  
using namespace std;
  
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
  
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
  
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
  
int F()
{
    char ch;
    int x, a;
    while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
    if (ch == '-') ch = getchar(), a = -1;
    else a = 1;
    x = ch - '0';
    while (ch = getchar(), ch >= '0' && ch <= '9')
        x = (x << 1) + (x << 3) + ch - '0';
    return a * x;
}
  
const int N = 1e6 + 10;
  
int n;
  
char s[N], t[N];
  
int q[N];
  
int main()
{
    int l = 1, r = 0;
    gi(n);
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    if (!strcmp(s + 1, t + 1))
    {
        puts("0");
        return 0;
    }
    int ans = 0;
    for (int i = n, j = n; i; --i)
    {	
 	    if (t[i] == t[i - 1]);
        else
        {	
            j = min(j, i);
            while (j && t[i] != s[j]) --j;
            if (!j) return puts("-1"), 0;
            while (l <= r)
            {	
                if (q[l] - (r - l) > i) ++l;
                else break;
            }	
            q[++r] = j;
            if (i != j) ans = max(ans, r - l + 1);
        }
    }
    printf("%d\n", ++ans);
    return 0;
	}




Measured memory_bytes: 6144
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int a[N];

bool solve(int a[], int n, int A, int B, int mid) {
  int64 sum = 0;
  for (int i = 0; i < n; ++i) {
    int64 cur = max(0LL, a[i] - (int64)B * mid);
    sum += (cur + (A - B - 1)) / (A - B);
  }
  return sum <= mid;
}

int main() {
  int n, A, B;
  scanf("%d%d%d", &n, &A, &B);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int low = 1, high = 1e9;
  while (low != high) {
    int mid = (low + high) / 2;
    if (solve(a, n, A, B, mid)) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  printf("%d\n", high);
  return 0;
}


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


int main()
{
int n;
int w;
cin>>n>>w;
int cost[n+1];
int profit[n+1];


for(int i=1;i<=n;i++)
{
	cin>>cost[i];
	cin>>profit[i];
}


long long int arr[n+1][w+1];


for(int i=0;i<=w;i++)
{
	arr[0][i]=0;
}
for(int i=1;i<=n;i++)
{
	for(int j=0;j<=w;j++)
	{
		if(cost[i]<=j)
		{
			arr[i][j]=max(arr[i-1][j],arr[i-1][j-cost[i]]+profit[i]);
		}
		else
		{
			arr[i][j]=arr[i-1][j];
		}
	}
}

cout<<arr[n][w];

	
	return 0;
}

Measured memory_bytes: 79104
#include "bits/stdc++.h"
    using namespace std;
     
    const long long infinity = 1e18;
     
    
     
    long long dp[100][100001];
    // dp[index][value] = minimum weight
     
    int main(){
    	int n,W;
    	cin>>n>>W;
    	int w[n];
   		int v[n];
    	for(int i=0;i<100;i++){
    		for(int j=0;j<=100000;j++){
    			dp[i][j] = infinity;
    		}
    	}
    	
    	for(int i=0;i<n;i++){
    		cin>>w[i]>>v[i];
    	}
    	
    	dp[0][0] = 0;
    	dp[0][v[0]] = w[0];
    	
    	for(int id=1;id<n;id++){
    		dp[id][0] = 0;
    		for(int j=1;j<=100000;j++){
    			
    			// Discard current object
    			dp[id][j] = dp[id-1][j];
    			
    			// Pick current object
    			if(j >= v[id])
    				dp[id][j] = min(dp[id][j], w[id] + dp[id-1][j-v[id]]);
    			
    		}
    	}
    	
    	long long answer;
    	
    	for(int val = 100000;val>=0;val--){
    		if(dp[n-1][val] <= W){
    			answer = val;
    			break;
    		}
    	}
    	
    	cout<<answer;
    	
    	return 0;
    }

Measured memory_bytes: 81756
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

vector<ll> search(ll i, vector<vector<ll>> &g){
    vector<ll> dist(g.size(), -1);
    queue<ll> que;

    dist[i] = 0;
    que.push(i);

    while(!que.empty()){
        ll v = que.front();
        que.pop();

        for(int nv : g[v]){
            if(dist[nv] != -1) continue;

            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    return dist;
}

int main(){
    ll n, x, y; cin >> n >> x >> y;
    vector<vector<ll>> g(n);
    rep(i, n-1){
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    g[x-1].push_back(y-1);
    g[y-1].push_back(x-1);

    vector<ll> hops(n, 0);
    for(ll i = 0; i < n; ++i){
        vector<ll> hop = search(i, g);
        for(auto i : hop){
            hops[i]++;
        }
    }
    rep(i, hops.size()){
        if(i == 0) continue;
        cout << hops[i]/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

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

int main(int argc, char const *argv[]) {
    int n = 4;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll ans = -LINF;

    rep(i,2) {
        for (int j = 2; j < n; ++j) {
            chmax(ans, a[i]*a[j]);
        }
    }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
	int s1,s2,s3;
  	cin >> s1;
  	s2 = s1 % 100;
  	s3 = s2 % 10;
  	s1 = s1 / 100;
  	s2 = s2 / 10;
  	s3 = s3 / 1;
  	cout << s1 + s2 + s3 << endl;
}

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

using namespace std;

typedef long long ll;
ll ans = 1;
int N,A,B;

int main() {
  cin >> N >> A >> B;
  if(A > B || (A < B && N == 1)) { cout << "0" <<endl; return 0; }
  if(N == 2 || (N == 1 && A == B)) {cout << "1" <<endl; return 0; }

  for(int i = 0; i < N-2; i++) ans += B - A;

  cout << ans <<endl;
}

    
  


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
vector<int>adj[M];
int a[M],vis[M];
int n,m,cur;
priority_queue<int,vector<int>,greater<>>pq[M+2];
void dfs(int u)
{
    vis[u]=1;
    pq[cur].push(a[u]);
    for(auto v:adj[u])
    {
        if(vis[v]==0)
        {
            dfs(v);
        }
    }
}
 main()

{
    fast
    cin>>n>>m;
    f(i,1,n)
    {
        cin>>a[i];
    }
    f(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        u++;v++;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(m==n-1)
    {
        cout<<"0"<<endl;return 0;
    }
    cur=0;
    f(i,1,n)
    {
        if(vis[i]==0)
        {
            cur++;
            dfs(i);
        }
    }
    int nd=2*(cur-1);
    if(n<nd)
    {
        cout<<"Impossible"<<endl;return 0;
    }
    int ses=0;
    f(i,1,cur)
    {
        ses+=pq[i].top();
        pq[i].pop();
    }

    f(i,1,cur)
    {
        while(!pq[i].empty())
        {
            pq[M].push(pq[i].top());
            pq[i].pop();
        }
    }
    f(i,1,cur-2)
    {
        ses+=pq[M].top();
        pq[M].pop();
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 16184