akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int const INF = 1000000;
int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    a=a*100;
    b=b*100;
    
    
    
    vector<int> va;
    vector<int> vb;
    set<int> mizu;
    for(int i=1;i*a<=f;i++){
        va.push_back(i*a);
        mizu.insert(i*a);
    }
    for(int i=1;i*b<=f;i++){
        vb.push_back(i*b);
        mizu.insert(i*b);
    }
    rep(i,va.size()){
        rep(j,vb.size()){
            if(va[i]+vb[j]<=f){
                mizu.insert(va[i]+vb[j]);
            }
        }
    }
    
    
    vector<int> v;
    for(set<int>::iterator itr = mizu.begin();itr!=mizu.end();itr++){
        v.push_back(*itr);
    }
    
    double mx=0;
    int a1=0,a2=0;
    for(int i=0;i<v.size();i++){
        double fg=(double)(v[i]/100.0)*e;
        
        for(int k=0;k<=fg;k++){
            for(int j=0;k*c+j*d<=fg;j++){
                
                if(k*c+j*d<=fg){
                    double nd=(100.0*(k*c+j*d))/((k*c+j*d)+v[i]);
                    if(nd>=mx&&k*c+j*d+v[i]<=f){
                        mx=nd;
                        a1=v[i]+k*c+j*d;
                        a2=k*c+j*d;
                    }
                }
                
            }
        }
        
        
    }
    
    
    
    
    /* for(set<int>::iterator itr = mizu.begin();itr!=mizu.end();itr++){
     cout<<*itr<<endl;
     }*/
    cout<<a1<<" "<<a2<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
K,N = map(int, input().split())
AN = max = i = j = 0
c = []

A = [int(N) for N in input().split()]
while i+1 != N:
    c.append(A[i+1] - A[i])
    if c[i] > max:
        max = c[i]
    i = i+1

c.append(A[0] - 0 + K - A[N-1])

if A[0] - 0 + K - A[N-1] > max:
    max = A[0] - 0 + K - A[N-1]

while j != N:
    AN = AN + c[j]
    j = j + 1

AN = AN - max

print(AN)


Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    rep(i, 0, a){cin >> p[i];}
    rep(i, 0, b){cin >> q[i];}
    rep(i, 0, c){cin >> r[i];}
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    vi d;
    rep(i, 0, x) d.pb(p[i]);
    rep(i, 0, y) d.pb(q[i]);
    rep(i, 0, c) d.pb(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    rep(i, 0, x+y) ans += d[i];
    cout << ans << endl;
}

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

int N, M, ans = 0;
int que[10], aa[9][9];

int dfs(int a, int step)
{
	if (step == N) { ++ans; return 0; }
	for (int i = 1; i <= N; ++i) {
		if (aa[a][i] == 1 && que[i] == 0) {
			que[i] = 1;
			dfs(i, step + 1);
			que[i] = 0;
		}
	}

	return 0;
}

int main(int argc, char **argv)
{
	int a, b;
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> a >> b;
		aa[a][b] = aa[b][a] = 1;
	}
	que[1] = 1;
	dfs(1, 1);
	cout << ans << endl;

	return 0;
}

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

using namespace std;



#define MAXN 100001
vector<int> g[MAXN];
int dfs(int u, int p) {
  int ret = 0;
  for (auto v : g[u]) {
    if (v==p) continue;
    ret ^= dfs(v, u)+1;
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n-1; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  cout << (dfs(1, 0) ? "Alice" : "Bob") << endl;
  return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	vector<vector<int>> a(3, vector<int>(3));
	vector<vector<bool>> ok(3, vector<bool>(3));
	rep(i, 3) rep(j, 3) cin >> a[i][j];
	int n;
	cin >> n;
	vector<int> b(n);
	rep(i, n) {
		cin >> b[i];
		rep(j, 3) {
			rep(k, 3) {
				if (b[i] == a[j][k]) {
					ok[j][k] = true;
				}
			}
		}
	}
	bool ans = false;
	rep(i, 3) {
		bool c = true;
		rep(j, 3) {
			if (!ok[i][j]) c = false;
		}
		if (c) ans = true;
	}
	rep(j, 3) {
		bool c = true;
		rep(i, 3) {
			if (!ok[i][j]) c = false;
		}
		if (c) ans = true;
	}
	if (ok[0][0] && ok[1][1] && ok[2][2]) ans = true;
	if (ok[0][2] && ok[1][1] && ok[2][0]) ans = true;
	cout << (ans ? "Yes" : "No") << endl;
}

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

#define forn(e,n,s) for(int i = e; i < n;i += s)
#define forr(e,n,s) for(int i = e; i >= n; i -= s)
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout<<fixed;
  cout<<setprecision(20);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
}

int main(){
    go(); 

    // code here
    int n;cin>>n;
    cout<<!n;

}










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

using namespace std;

int main() { 
	double a,b;
	cin>>a>>b;
	for(double i=1.0;i<=1010.0;i+=1.0){
		if(int (i*0.08)==a&&int (i*0.1)==b){
			cout<<i;
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  scanf("%d",&n);
  string s,t;
  cin >> s >> t;
  REP(i,n) {
    cout << s[i] << t[i];
  }
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int index_1;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 1) {
            index_1 = i;
        }
    }

    int ans = N;
    int t;
    for (int l = max(index_1 - (K - 1), 0), r = l + (K - 1); r < N; l++, r++) {
        t = 1;
        t += ceil(l / (K-1.0));
        t += ceil((N - (r + 1)) / (K-1.0));
        ans = min(ans, t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
 
    x = x % p; // Update x if it is more than or  
                // equal to p
   
    if (x == 0) return 0; // In case x is divisible by p;
 
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
 
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 


int main()
{
 
  fastio();

ll int T=1;

while(T--)
{
    ll int n,m;
    cin>>n>>m;
    vector<ll int> gr[n+1];
    ll int i;
    for(i=0;i<m;i++)
    {
        ll int u,v;
        cin>>u>>v;
        gr[u].push_back(v);
        gr[v].push_back(u);
    }
    ll int vis[n+1]={0};
    ll int fans=0;
    for(i=1;i<=n;i++)
    {
        ll int tans=0;
        if(!vis[i])
        {
            vis[i]=1;
            queue<ll int> q;
            q.push(i);
            while(!q.empty())
            {
                ll int sz = q.size();
                
                while(sz--)
                {

                    ll int tp =q.front();
                    // cout<<tp<<endl;
                    for(auto el:gr[tp])
                    {
                        if(!vis[el])
                        {
                            vis[el]=1;
                            q.push(el);
                        }
                    }
                    q.pop();
                    tans++;
                }
                
            }
            fans=max(fans,tans);
            // cout<<tans<<endl;
        }

    }
    cout<<fans<<endl;
}



return 0;}

Measured memory_bytes: 18848
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int a[5];
    rep(i,5) cin >> a[i];
    sort(a,a+5);
    for(int i=4;i>=0;i--){
        if(i!=0) cout << a[i] << " ";
        else cout << a[i] << endl;
    }
}

Measured memory_bytes: 3128
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
Sx,Sy,Tx,Ty = map(int,input().split())

dx = Tx - Sx
dy = Ty - Sy
 
ans1 = "U"*dy + "R"*dx
ans2 = "D"*dy + "L"*dx
ans3 = "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
ans4 = "R" + "D"*(dy+1) + "L"*(dx+1) + "U"
 
print(ans1 + ans2 + ans3 + ans4)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int n,m;
	cin>>n>>m;
	vector<bool> ac(n,false);
	vector<int> pen(n,0);
	for(int i=0;i<m;i++){
		int x;
		string s;
		cin>>x>>s;
		if(s[0]=='A'){
			ac[x-1]=true;
		}
		else{
			if(!ac[x-1])
				pen[x-1]++;
		}
	}
	int a1=0,a2=0;
	for(int i=0;i<n;i++){
		if(ac[i]){
			a1++;
			a2+=pen[i];
		}
	}

	cout<<a1<<" "<<a2<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

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

using namespace std;

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

    int w, d;
    while (cin >> w >> d)
    {
        if (w == 0)
            break;
        int h[30] = {0};
        int res = 0;
        std::vector<int> x(w + 1), y(d + 1);
        for (int i = 0; i < w; i++)
        {
            cin >> x[i];
            h[x[i]]++;
            res += x[i];
        }
        for (int i = 0; i < d; i++)
        {
            cin >> y[i];
            if (h[y[i]] > 0)
            {
                h[y[i]]--;
            }
            else
                res += y[i];
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3044
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	var mat []int
	for i := 2; a/i >= 1 && b/i >= 1; i++ {
		if a%i == 0 && b%i == 0 {
			mat = append(mat, i)
		}
	}
	leng := len(mat)
	if leng+1 == k {
		fmt.Println(1)
		return
	}
	fmt.Println(mat[leng-k])
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
const int MAX_V=500,INF=1e8;
int G[MAX_V][MAX_V],V;
bool used[MAX_V];
void add_edge(int from, int to){
	G[from][to]=1;
	G[to][from]=1;
}
void erase_edge(int from, int to){
	G[from][to]=0;
	G[to][from]=0;
}
int dfs(int v,int t,int f){
	if(v==t) return f;
	used[v]=true;
	for(int i=0;i<V;i++){
		int &c=G[v][i];
		if(!used[i] && c>0){
			int d=dfs(i,t,min(f,c));
			if(d>0){
				c-=d;
				G[i][v]+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int flow=0;
	while(true){
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(f==0) return flow;
		flow+=f;
	}
}
void show_matrix(){
	rep(i,V){
		rep(j,V) cout<<G[i][j]<<" ";
		cout<<endl;
	}
}
int main(){
	int N,E,Q;
	cin>>N>>E>>Q;
	V=N;
	rep(i,E){
		int F,T;
		cin>>F>>T;
		add_edge(F-1,T-1);
	}
	int now=max_flow(0,N-1);
	rep(i,Q){
		int m,a,b;
		cin>>m>>a>>b;
		a--,b--;
		if(m==1){
			add_edge(a,b);
			now+=max_flow(0,N-1);
		}else{
			int ecap=G[a][b];
			erase_edge(a,b);
			if(ecap==2) swap(a,b);
			if(ecap!=1){
//				show(a);
//				show(b);
				memset(used,0,sizeof(used));
				int f=dfs(a,b,1);
				if(f==0){
					memset(used,0,sizeof(used));
					dfs(a,0,1);
					memset(used,0,sizeof(used));
					dfs(N-1,b,1);
					now--;
				}
			}
		}
		printf("%d\n",now);
//		show_matrix();
//		cout<<endl;
	}
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> p(N);
    rep(0, i, N)
    {
        cin >> p[i];
    }
    sort(all(p));
    int ans = 0;
    rep(0, i, N)
    {
        ans += p[i];
    }
    ans -= p[N - 1] / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b,fee=0;
    scanf("%d%d",&a,&b);
    if(6<=a &&a<=12){
        fee = b/2;
    }else if(a>12){
        fee = b;
    }
    printf("%d",fee);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;
umap<int,int>have;
int dfs(int val)
{
    if(!val)return 0;
    if(have[val])return have[val];
    int q[6]={val/2,val/2+1,val/3,val/3+1,val/5,val/5+1};
    int w[6]={2,2,3,3,5,5};
    int num=INF;
    fu(i,0,5)
    {
        if(q[i]<val)
        {
            num=min(num,dfs(q[i])+(int)min((ld)abs(val-q[i]*w[i])*a[1]+a[w[i]],(ld)(val-q[i])*a[1]));
        }
    }
    return have[val]=num;
}
main()
{
    IOS
    cin>>t;
    fut(o)
    {
        cin>>n;
        cin>>a[2]>>a[3]>>a[5]>>a[1];
        have.clear();
        out(dfs(n));
    }
    return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
    int n, m;
    string s;

    cin >> n >> m;

    cout << n + (m-n) * 2 << endl;;

    return 0;
}


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

int main(){
  string s,t;
  int n;
  int count=0;
  cin>>s;
  cin>>t;
  n=s.length();
  for(int i=0; i<n;i++)
    if(s[i]!=t[i])
      count++;

  cout<<count;
  return 0;
}


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

int main()
{
  int nNum, nKnum;
  cin >> nNum >> nKnum;

  int nComb = nKnum;
  for (int n = 2; n <= nNum; n++)
    nComb *= (nKnum - 1);

  cout << nComb << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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 comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


int H, W, K;
char mp[810][810];
int sy, sx;
int dist[810][810];
void dijkstra(){
  typedef pair<int, pair<int, int>> P;
  priority_queue<P, vector<P>, greater<P>> pque;
  pque.push({0, {sy, sx}});
  rep(i, 810)rep(j, 810) dist[i][j] = INF;
  dist[sy][sx] = 0;
  while(!pque.empty()){
    P p = pque.top();
    pque.pop();
    int y = p.s.f;
    int x = p.s.s;
    if(dist[y][x] < p.f) continue;
    rep(i, 4){
      int ny = y + dy[i];
      int nx = x + dx[i];
      if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
      if(mp[ny][nx] == '#') continue;
      if(dist[y][x] + 1 < dist[ny][nx]){
        dist[ny][nx] = dist[y][x] + 1;
        pque.push({dist[ny][nx], {ny, nx}});
      }
    }
  }
}
int main(){
  cin >> H >> W >> K;
  rep(i, H){
    rep(j, W){
      cin >> mp[i][j];
      if(mp[i][j] == 'S'){
        sy = i;
        sx = j;
      }
    }
  }
  dijkstra();
  int ans = INF;
  rep(i, H)rep(j, W)if(dist[i][j] <= K){
    ans = min(ans, 1 + (i+K-1)/K);
    ans = min(ans, 1 + (H-i-1+K-1)/K);
    ans = min(ans, 1 + (j+K-1)/K);
    ans = min(ans, 1 + (W-j-1+K-1)/K);
  }
  cout << ans << endl;
}


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

ans = "Yes"
for i in range(H-1):
  for j in range(W-1):
    if(C[i][j] == "#"):
      if(i != 0 and C[i-1][j] == "#"):
        continue
      if(i != H and C[i+1][j] == "#"):
        continue
      if(j != 0 and C[i][j-1] == "#"):
        continue
      if(j != W and C[i][j+1] == "#"):
        continue
      ans = "No"
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

struct segtree {
    long long int N;
    vector<long long int> v;

    segtree(long long int n) {
        N = 1;
        while(N < n) N *= 2;
        v = vector<long long int>(2 * N, 0);
    }
    // update k th element
    void update(long long int k, long long int a) {
        k += N-1; // leaf
        v[k] = a;
        while(k > 0) {
            k = (k - 1) / 2;
            v[k] = v[k*2+1] + v[k*2+2];
        }
    }
    // sum [a, b)
    long long int query(long long int a, long long int b) { return query(a, b, 0, 0, N); }
    long long int query(long long int a, long long int b, long long int k, long long int l, long long int r) {
        if(r <= a or b <= l) return 0;
        if(a <= l and r <= b) return v[k];
        long long int m = (l + r) / 2;
        return query(a, b, k*2+1, l, m) + query(a, b, k*2+2, m, r);
    }
};

int main()
{
	long long int n;
	cin >> n;
	long long int a[100001];
	for(long long int i = 0; i < n; i++){
		cin >> a[i];
	}
	if(n == 1){
		cout << a[0] << endl;
		return 0;
	}

	long long int l = 0, r = mod;
	while(r - l > 1){
		long long int mid = (l + r) / 2;
		// ある区間において中央値はmid以上になるか？
		// <-> ある区間において、mid以上の値の個数はmid未満の値の個数以上か？
		// cnt[i] = a[0]からa[i - 1]までの(mid以上の個数 - mid未満の個数)とすると、
		// 区間[l, r)において(mid以上の個数 - mid未満の個数)はcnt[r] - cnt[l]となる
		// (mid以上の個数 >= mid未満の個数)となるには cnt[r] - cnt[l] >= 0となればよい
		// つまりcnt[r] >= cnt[l]となるような[l, r)の個数を求め、これが(n * (n + 1) / 2) / 2以上であれば
		// 中央値の中央値はmid以上であるとわかる
		vector<pair<long long int, long long int> > cnt;
		cnt.push_back(make_pair(0, 0));
		long long int rangenum = 0;
		for(long long int i = 1; i <= n; i++){
			cnt.push_back(make_pair(cnt[i - 1].first + ((a[i - 1] >= mid) ? 1 : -1), i));
		}
		sort(cnt.begin(), cnt.end());
		segtree st(n + 1);
		for(long long int i = 0; i < n + 1; i++){
			// cout << cnt[i].first << " " << cnt[i].second << endl;
			st.update(cnt[i].second, 1);
			rangenum += st.query(0, cnt[i].second);
		}
		// cout << mid << " " << rangenum << endl;
		if(rangenum >= ((n * (n + 1)) / 2) / 2) l = mid;
		else r = mid;
	}
	cout << l << endl;
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N 200005
vector<int> adj[N];
int n,m;
int h[N];
int main(){
	FIO;
    cin >> n >> m;
    for(int i = 0 ; i < n ; i++) cin >> h[i];
    for(int i = 0 ; i < m ; i++){
        int u,v; cin >> u >> v;
        u--,v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }int ans =0 ;
    for(int i = 0 ; i < n ; i++){
        bool flag = 1;
        for(auto v : adj[i]){
            flag &= (h[i] > h[v]);
        }
        ans += flag;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11524
s = list(str(input()))
k = int(input())

n = len(s)

cur = s[0]
L = []
cnt = 0
for i in range(n):
    if cur == s[i]:
        cnt += 1
    else:
        L.append(cnt)
        cur = s[i]
        cnt = 1
else:
    L.append(cnt)
#print(L)

if s[0] != s[-1]:
    C = 0
    for i in range(len(L)):
        if L[i] >= 2:
            C += L[i]//2
    ans = C*k
else:
    if len(L) >= 2:
        C = 0
        for i in range(1, len(L)-1):
            if L[i] >= 2:
                C += L[i]//2
        ans = C*k
        ans += L[0]//2+L[-1]//2+((L[0]+L[-1])//2)*(k-1)
    else:
        ans = (L[0]*k)//2
print(ans)


Measured memory_bytes: 38256
<?php
fscanf(STDIN, '%d', $n);
$g = array_fill(0, $n, []);
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, '%d', $a);
    for ($j = 0; $j < $a; $j++) {
        fscanf(STDIN, '%d %d', $x, $y);
        $x--; // 添字 0から
        $g[$i][] = [$x, $y];
    }
}

// bit全探索
// 1: 正直者 0:不親切
$ans = 0;
for ($i = 2 ** $n - 1; $i >= 0; $i--) {
    $flag = true;
    for ($j = 0; $j < $n; $j++) {
        if (($i >> $j) & 1) {
            foreach ($g[$j] as $v) {
                if ($v[1] !== (($i >> $v[0]) & 1)) {
                    $flag = false;
                    break 2;
                }
            }
        }
    }
    $cnt = 0;
    if ($flag) {
        for ($j = 0; $j < $n; $j++) {
            if (($i >> $j) & 1) {
                $cnt++;
            }
        }
    }
    $ans = max($ans, $cnt);
}
echo $ans . PHP_EOL;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll a;
    string b;
    cin >> a >> b;
    ll ib;
    ib += b[3]-'0';
    ib += (b[2]-'0')*10;
    ib += (b[0]-'0')*100;
    //b *= 100;
    

    ll ans = a*ib;
    ans /= 100;
    
    cout << ans << endl;
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, K, C; cin >> N >> K >> C;
    string s; cin >> s;

    vector<i64> R(N, 0);
    vector<i64> L(N, 0);

    i64 cnt = 0;
    i64 prev = -2 * K;
    REP(i, N) {
        if (s[i] == 'x') continue;
        if (prev + C < i) {
            cnt++;
            R[i] = cnt;
            prev = i;
            if (cnt == K) break;
        }
    }

    cnt = 0;
    prev = N + 2 * K;
    RREP(i, N) {
        if (s[i] == 'x') continue;
        if (i < prev - C) {
            cnt++;
            L[i] = K - cnt + 1;
            prev = i;
            if (cnt == K) break;
        }
    }

    REP(i, N) {
        if (R[i] == 0 || L[i] == 0) continue;
        if (R[i] == L[i]) cout << (i + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 5012
X, Y, A, B, C=map(int, input().split())
p=list(map(int, input().split()))
p.sort()
q=list(map(int, input().split()))
q.sort()
r=list(map(int, input().split()))
r.sort(reverse=True)

i=-X
j=-Y
k=0
deru=0
while deru==0 and k<C and (r[k]>p[i] or r[k]>q[j]):
  if p[i]>q[j] and j<0:
    j+=1
    k+=1
  elif p[i]>q[j] and j>=0 and i<0 and p[i]<r[k]:
    i+=1
    k+=1
  elif p[i]<=q[j] and i<0:
    i+=1
    k+=1
  elif p[i]<=q[j] and i>=0 and j<0 and q[j]<r[k]:
    j+=1
    k+=1
  else:
    deru=1
    
if i==0:
  a=0
else:
  a=sum(p[i:])
  
if j==0:
  b=0
else:
  b=sum(q[j:])
  
if k==0:
  c=0
else:
  c=sum(r[:k])
  
print(a+b+c)

Measured memory_bytes: 23216
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln             PIC X(30).
01 N              PIC 9(10).
01 Q              PIC 9(10).
01 R              PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO N.
  DIVIDE N BY 10 GIVING Q REMAINDER R.
  IF R = 2 OR 4 OR 5 OR 7 OR 9
      DISPLAY "hon"
  ELSE IF R = 0 OR 1 OR 6 OR 8
      DISPLAY "pon"
  ELSE
      DISPLAY "bon"
  END-IF.
  STOP RUN.


Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;++i)
typedef long long ll;
struct Comb{//组合数的一些相关数组
    const ll p=1e9+7;
    void init(int n){
        fac.resize(n+1);
        fac_inv.resize(n+1);
        inv.resize(n+1);
        fac[0]=fac[1]=fac_inv[0]=fac_inv[1]=inv[1]=1;
        for(int i=2;i<=n;++i){
            inv[i]=(p-p/i)*inv[p%i]%p;
            fac[i]=i*fac[i-1]%p;
            fac_inv[i]=fac_inv[i-1]*inv[i]%p;
        }
    }
    vector<ll> fac,fac_inv,inv;
}C;
const ll p=1e9+7;
const int N=2e5+10;;
const int M=2e5+10;
int head[N],ver[2*M],nex[2*M],tot=1;
inline void add(int x,int y) {ver[++tot]=y,nex[tot]=head[x],head[x]=tot;}
ll ans[N],sz[N],cnt[N];//ans[i]以i为根的答案，sz[i]i子树大小，cnt[i]i子树答案
void dfs1(int x,int fa){//第一遍dfs求出以1为根的答案
    sz[x]=cnt[x]=1;
    for(int i=head[x];i;i=nex[i]){
        int y=ver[i];
        if(y==fa)continue;
        dfs1(y,x);
        sz[x]+=sz[y];
        cnt[x]=cnt[x]*C.fac_inv[sz[y]]%p*cnt[y]%p;
    }
    cnt[x]=cnt[x]*C.fac[sz[x]-1]%p;
}
int n;
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//求逆元
void dfs2(int x,int fa,ll s,ll c){//换根分别求出以所有点为根的答案
    ans[x]=cnt[x]*C.fac_inv[sz[x]-1]%p*C.fac[n-1]%p*C.fac_inv[s]%p*c%p;
    for(int i=head[x];i;i=nex[i]){
        int y=ver[i];
        if(y==fa)continue;
        ll tmp=ans[x]*C.fac_inv[n-1]%p*C.fac[n-sz[y]-1]%p*C.fac[sz[y]]%p*inv(cnt[y],p)%p;
        dfs2(y,x,n-sz[y],tmp);
    }
}
int main(){
    C.init(N);
    scanf("%d",&n);
    rep(i,1,n-1){
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);add(y,x);
    }
    dfs1(1,0);
    dfs2(1,0,0,1);
    rep(i,1,n)printf("%lld\n",ans[i]);
    return 0;
}


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

int getmd(int a,int b,int c,int d){
    return abs(a-c)+abs(b-d);
}

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

    if(a>=b+c)  puts("0");
    else{
        cout << c-(a-b) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		try {
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String buf = br.readLine();
            StringTokenizer st=new StringTokenizer(buf," ");
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
 
            if(a < b)
                System.out.println("a < b");
            else if(a > b)
                System.out.println("a > b");
            else if(a == b)
                System.out.println("a == b");
 
        } catch(IOException e) {
            System.err.println(e);
        }
		
	}

}

Measured memory_bytes: 24192
def candies(n,k,a): 
    mod=10**9+7
    dp=[[ 0 for _ in range(k+1) ] for _ in range(n+1)]
    for i in range(n+1):
        dp[i][0]=1
    for i in range(n):
        for j in range(1,k+1):
            if j-1-a[i]>=0: 
                dp[i+1][j]=( dp[i+1][j-1]+dp[i][j]-dp[i][j-1-a[i]] +mod ) % mod
            else:
                dp[i+1][j]=( dp[i+1][j-1]+dp[i][j] ) %mod
    print(dp[n][k])


def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    candies(n,k,a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 171144
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
using ll = long long;
typedef long long lint;

int main() {
  lint a,b,N;
  cin >> a >> b >> N;
  if(a <= N) {
    b = b - (N - a);
    a = 0;
    if(b < 0) b = 0;
  }
  else {
    a = a-N;
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
s = int(input())
a = [s]
i = 0
while True:
    i = i+1
    # 前回の値によって計算を変える。
    if a[i-1] % 2 == 0:
        n = a[i-1]//2
    else:
        n = 3*a[i-1]+1
    # 数列に同じ値が含まれているかどうか？
    if n in a:
	  	# 配列が0から始まるため、カウントアップ。
        print(i+1)
        break
    a.append(n)


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

int main(){
    int N;
    cin >> N;
    int A[100000];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    ll x = 0, y = 0, temp = 0;
    sort(A, A + N, greater<int>());
    for(int i=0;i<N;i++){
        if(temp == A[i]){   //2本目が見つかったとき
            if(x == 0){
                x = A[i];   //1組目とする
            }else{
                y = A[i];   //2組目とする
                cout << x*y << endl;
                return 0;
            }
            temp = 0;   
        }else{
            temp = A[i];
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 998244353;

int main(void){
    int n, s;
    cin >> n >> s;
    VI a(n);
    REP(i,n) a[i] = in();
    VVL dp(n + 1, VL(s + 1));
    dp[0][s] = 1;
    REP(i,n) REP(j,s+1){
        (dp[i + 1][j] += 2 * dp[i][j]) %= mod;
        if (j >= a[i]) (dp[i + 1][j - a[i]] += dp[i][j]) %= mod;
    }
    cout << dp[n][0] << endl;
    return 0;
}


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

#define ll long long int

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<ll>> C(26, vector<ll>());

    ll n  = s.size();
    for (ll i = 0; i < n; ++i) {
        char c = s[i] - 'a';
        C[c].emplace_back(i);
    }

    vector<ll> idx(26, 0);

    ll m = t.size();
    ll res = 0;
    ll cur = 0;
    char prev = '_';
    for (ll i = 0; i < m; ++i) {
        char c = t[i];
        ll j = c - 'a';
        if (c == prev) {
            ++cur;
        }

        auto iter = lower_bound(C[j].begin(), C[j].end(), cur);
        if (iter == C[j].end()) {
            if (iter == C[j].begin()) {
                res = -1;
                break;
            }
            ++res;
            cur = 0;
            iter = lower_bound(C[j].begin(), C[j].end(), cur);
        }
        cur = *iter;
        prev = c;

    }

    if (res == -1) {
        cout << -1 << endl;
        return 0;
    }
    cout << n * res + cur + 1 << endl;
}


Measured memory_bytes: 1724
(defun make-range (n x)
  (loop :as i
        :from (- x (- n 1))
        :to (+ x (- n 1))
        :collect i))
    
(defun insert-delimiter (delimiter list)
  (cons (car list)
        (if (null (cdr list))
            nil
            (cons delimiter
                  (insert-delimiter delimiter (cdr list))))))

(defun join (delimiter list)
  (apply #'concatenate (cons 'string (insert-delimiter delimiter list))))



(let ((n (read))
      (x (read)))
  (princ (join " " (mapcar #'princ-to-string (make-range n x)))))


Measured memory_bytes: 4580
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }
};

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    string s, t;
    cin >> s >> t;

    bool reso = false;
    for(int i=s.size()-t.size(); i>=0; i--){
        bool ok = true;
        rep(j, t.size()){
            //cout << s[i+j] << ' ' << t[j] << endl;
            if(!(s[i+j] == t[j] || s[i+j] == '?')){
                ok = false;
            }
        }
        if(ok){
            rep(j, t.size()){
                s[i+j] = t[j];
            }
            reso = true;
            break;
        }
    }

    if(!reso){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    rep(i, s.size()){
        if(s[i] == '?'){
            s[i] = 'a';
        }
    }

    cout << s << endl;
    
    return 0;
}



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

int getMaxCost(vector<vector<int>> A){
    if(A.size() < 2) return max(max(A[0][0], A[0][1]), A[0][2]);

    //vector<int> dp(A.size(), INT_MIN);

    //dp[0] = max(max(A[0], A[1]), A[2]);

    for(int i=1;i<A.size();i++){
        A[i][0] = max(A[i-1][1], A[i-1][2]) + A[i][0];
        A[i][1] = max(A[i-1][0], A[i-1][2]) + A[i][1];
        A[i][2] = max(A[i-1][0], A[i-1][1]) + A[i][2];

        //dp[i] = max(max(A[i][0], A[i][1]), A[i][2]);
    }

    return max(max(A[A.size()-1][0], A[A.size()-1][1]), A[A.size()-1][2]);

}

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

    vector<vector<int>> A(n, vector<int>(3, 0));
    int temp;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>temp;
            A[i][j] = temp;
        }
    }

    cout<<getMaxCost(A);
}


Measured memory_bytes: 14028
#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<vector>
#include<unordered_set>
#include<algorithm>

using namespace std;

namespace
{

}

#if 1
int main()
{
	std::vector<std::vector<int>> island;
	island.resize(100000 + 1);
	int n;
	int m;

	cin >> n;
	cin >> m;

	for (int i = 0; i < m; i++)
	{
		int a;
		cin >> a;
		int b;
		cin >> b;

		island[a].push_back(b);
		island[b].push_back(a);
	}

	int cutCount = 0;
	std::unordered_set<int> battling;
	for (int i = 1; i <= n; i++)
	{
		auto itr = battling.find(i);
		if (itr != battling.end())
		{
			++cutCount;
			battling.clear();
		}

		for (auto& v : island[i])
		{
			battling.insert(v);
		}
	}

	cout << cutCount << endl;

	return 0;
}
#endif


Measured memory_bytes: 7476
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
int main(){
  int N;
  cin >> N;
  int64_t power = 1;
  for(int i = 1; i <= N; i++){
    power *= i;
    power %= (1000000007);
  }
  cout << power << endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if((a%3 == 0) || (b%3 == 0) || ((a+b)%3 == 0)){
    cout << "Possible\n";
  }
  else{
    cout << "Impossible\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int a,b;
  
  cin >> a >> b;
  
  if((a+b)%3==0) cout << "Possible" << endl;
  else if(a%3==0 || b%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
   ll n,a,b;
   cin>>n>>a>>b;
   printf("%lld",min(a*n,b));
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=int;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

  1 2 3 4 5 //(now, start)
1 . # # # . (1, 1) (5, 5)
2 # . . . . (1, 1) (5, 5)
3 . # # . . (3, 1) (5, 5)
4 . # # # . (4, 1) (5, 5)

  1 2 3 4 5 //(now, start)
1 . # # . . (1,1) (4,4) (5,5)
2 # # # . . (4,4) (5,5)
3 . . . . # (4,4)
4 # # # # . (4,5)


*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll H, W;
  cin >> H >> W;
  
  set<pair<ll, ll>> pos;
  multiset<ll> score;
  rep(i, H){
//    cout<<"i:"<<i<<endl;
    ll A, B;
    cin >> A >> B;
    //初期入れ
    if (i == 0){
      for(ll j=1; j<=W; j++){
        if (j >= A && j <= B)
          continue;
        pos.insert({j,j});
        score.insert(0);
      }
    }
    else {
      if (score.empty()){
        cout << -1 << endl;
        continue;
      }
      auto itr1 = pos.lower_bound({A, 0});
      auto itr2 = pos.lower_bound({B+1, 0});
      if (B == W || (itr2 != pos.end() && (*itr2).first == B+1)){
        while (itr1 != itr2){
          score.erase(score.find((*itr1).first - (*itr1).second));
          pos.erase(itr1++);
        }
      }
      else{
        //B+1が存在するなら全部消す。
        //しないなら、B+1に最も近い1個だけ残して消す。
        while (itr1 != itr2){
          auto judge = itr2;
          judge--;
          if (itr1 == judge){
            ll v1 = (*itr1).first;
            ll v2 = (*itr1).second;
            score.erase(score.find(v1 - v2));
            score.insert(B+1 - v2);
            pos.erase(itr1++);
            pos.insert({B+1, v2});
          }
          else{
            score.erase(score.find((*itr1).first - (*itr1).second));
            pos.erase(itr1++);
          }
        }
      }
    }
    if (score.empty())
      cout << -1 << endl;
    else
      cout << *score.begin() + i + 1 << endl;
  }
}


Measured memory_bytes: 22356