akhauriyash/Code-Regression huggingface dataset:
/* */
// #define XVENOM
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#define GETLINE(x) fgets(x,100,stdin);
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef pair< float, float > ff;
typedef pair< int, ii > iii;
typedef pair< int,string> is;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const ll inf=1e18;
ll n,m,x,y,wx,temp;
ll sp[1010];
ll w[1010][1010];
vii edjlis;
void bellford(){
	fill_n(sp,1010,inf);
	sp[1]=0;
	for(int i=0;i<n-1;i++)
		for(ii e:edjlis){
			int u=e.first;
			int v=e.second;
			sp[v]=min(sp[v],sp[u]+w[u][v]);
		}
	temp=sp[n];
	for(int i=0;i<n-1;i++)
		for(ii e:edjlis){
			int u=e.first;
			int v=e.second;
			sp[v]=min(sp[v],sp[u]+w[u][v]);
		}
	if(temp>sp[n])sp[n]=inf;
}
int main () { 
#ifdef XVENOM
	freopen("inp.txt", "r", stdin);
	freopen("oup.txt", "w", stdout);
#endif
	scanf("%lld %lld",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%lld %lld %lld",&x,&y,&wx);
		edjlis.push_back(ii(x,y));
		w[x][y]=-wx;
	}
	bellford();
	if(sp[n]==inf)printf("inf\n");
	else printf("%lld\n",-sp[n]);
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 410, LOG=20;

ll n, C, u, v, x, y, t, a, b, ans;
int A[MAXN], B[MAXN];
ll tav[MAXN][MAXN];
ll f[MAXN][MAXN];
ll dp[MAXN][MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	for (int i=1; i<MAXN; i++){
		tav[i][0]=1;
		for (int j=1; j<MAXN; j++) tav[i][j]=tav[i][j-1]*i%mod;
	}
	for (int i=1; i<MAXN; i++) for (int j=0; j<MAXN; j++) f[i][j]=(f[i-1][j] + tav[i][j])%mod;
	
	cin>>n>>C;
	for (int i=1; i<=n; i++) cin>>A[i];
	for (int i=1; i<=n; i++) cin>>B[i];
	dp[0][0]=1;
	for (int i=1; i<=n; i++){
		for (int j=0; j<=C; j++){
			for (int k=0; k<=j; k++){
				dp[i][j]=(dp[i][j] + dp[i-1][j-k]*(f[B[i]][k]-f[A[i]-1][k]))%mod;
			}
		}
	}
	ans=dp[n][C];
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
	
	return 0;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    ll A, B, N;
    cin >> A >> B >> N;

    ll x = min(N, B-1);
    cout << (A*x)/B << endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,s=0,ma=0;
char r;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		ma=max(ma,s);
		cin>>r;
		if(r=='I') s++;
		if(r=='D') s--;
	}
	if(s>ma) ma=s; 
	cout<<ma;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
ll N;

int main(){
	cin >> N;
	while(N > 0){
		int k = ceil((sqrt(1+8*N)-1)/2);
		cout << k << endl;
		N -= k;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = 1e9 + 5;

void solve() {
	int n, w;
	cin >> n >> w;
	vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));
	vector<vector<int>> arr(n, vector<int>(2));

	//inputs
	for (int i = 0; i < n; i++) {
		cin >> arr[i][0] >> arr[i][1];
	}
	
	//init
	for (int i = 0; i < w + 1; i++) {
		dp[0][i] = 0;
	}

	//init
	for (int i = 0; i < n + 1; i++) {
		dp[i][0] = 0;
	}

	//tabulation
	for (int i = 1; i < n + 1; i++) {
		int weight = arr[i-1][0];
		int price = arr[i-1][1];
		for (int j = 1; j < w + 1; j++) {
			if (j - weight < 0)	dp[i][j] = dp[i - 1][j];
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight] + price);
			}
		}
	}

	ll ans = 0;
	for (int j = 1; j < w + 1; j++) {
		ans = max(ans, dp[n][j]);
	}

	cout << ans;
}



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	solve();

	/*
	int t;
	cin >> t;
	while (t) {
		solve();
		cout << "\n";
		t--;
	}
	*/

}



Measured memory_bytes: 80256
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

class Pot {
public:
	vector<double> S, H;
	double f(double k) {
		double ret = 0;
		dumpc(S);
		dumpc(H);
		rep(i, 0, S.size()) {
			if (k == 0)break;
			double h = min(k / S[i], H[i]);
			dump(h);
			k -= h*S[i];
			dump(k);
			ret += h;
			dump(ret);
		}
		return ret;
	}
};

#define MAX_N 210
#define MAX_M 210
double dp[MAX_N][MAX_M] = {};
vector<Pot> Pots;
double dfs(int i, int j) {
	if (i == 0)return 0;
	if (dp[i][j] != -1)return dp[i][j];
	rep(k, 0, j + 1) {
		dump(i - 1);
		dump(k);
		dump(Pots[i - 1].f(k));
		dp[i][j] = max(dfs(i - 1, j - k) + Pots[i - 1].f(k), dp[i][j]);
	}
	dump(i);
	dump(j);
	dump(dp[i][j]);
	return dp[i][j];
}

signed main() {
	cout << fixed << setprecision(8);
	fill(dp[0], dp[MAX_N], -1);
	int N, M; cin >> N >> M;
	Pots.resize(N);
	rep(i, 0, N) {
		int K; cin >> K;
		rep(j, 0, K) {
			double S, H; cin >> S >> H;
			Pots[i].S.emplace_back(S);
			Pots[i].H.emplace_back(H);
		}
	}
	cout << dfs(N, M) << endl;
	if(DBG)rep(i, 0, N + 1) {
		cout << dp[i][0];
		rep(j, 1, M+1) { cout << " " << dp[i][j]; }
		cout << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct BinaryIndexTree {
public:
    BinaryIndexTree() {}

    BinaryIndexTree(int n)
            : mN(n) {
        mPow = 1;
        while (mPow < n)
            mPow <<= 1;
        node.resize(n + 1);
        REP(i, n + 1) {
            node[i] = 0;
        }
    }

    ~BinaryIndexTree() {
        node.resize(0);
    }

    //! 1-index get
    ll sum(int index) {
        ll sum = 0;
        for (int i = index; i > 0; i -= i & (-i))
            sum += node[i];
        return sum;
    }

    //! 1-index add
    void add(int index, ll value) {
        for (int i = index; i <= mN; i += i & (-i))
            node[i] += value;
    }

    int lowerBound(ll value) {
        if (value <= 0)
            return 0;
        int x = 0;
        for (int k = mPow; k > 0; k >>= 1) {
            if (x + k <= mN && node[x + k] < value) {
                value -= node[x + k];
                x += k;
            }
        }
        return x + 1;
    }

private:
    vector<ll> node;
    ll mN;
    ll mPow;
};

BinaryIndexTree bit[30];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    REP(i, 27) {
        bit[i] = BinaryIndexTree(N + 5);
    }
    REP(i, N) {
        ll n = S[i] - 'a';
        bit[n].add(i + 1, 1);
    }
    ll Q;
    cin >> Q;
    REP(i, Q) {
        ll t;
        cin >> t;
        if (t == 1) {
            ll n;
            char c;
            cin >> n >> c;
            ll m = S[n - 1] - 'a';
            S[n - 1] = c;
            ll k = c - 'a';
            bit[m].add(n, -1);
            bit[k].add(n, 1);
        }
        else {
            ll l, r;
            cin >> l >> r;
            ll sum = 0;
            REP(j, 27) {
                ll s = bit[j].sum(r) - bit[j].sum(l - 1);
                if (s > 0)
                    sum++;
            }
            cout << sum << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 110296
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N, M;
int adj[201][201];
int dist[201][201];
int color[201];

bool dfs(int prev, int i, int c){
    if(color[i] != 0){
        return c == color[i];
    }
    color[i] = c;
    bool ret = true;
    REP(j, N){
        if(adj[i][j] == 1) ret &= dfs(i, j, -c);
    }
    return ret;
}

void floyd(){
    REP(k, N){
        REP(i, N){
            REP(j, N){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

signed main(){
    cin >> N;
    string str;
    REP(i, N){
        cin >> str;
        REP(j, N) adj[i][j] = str[j] - '0';
    }
    if(!dfs(-1, 0, 1)){
        PRINT("-1");
        return 0;
    }
    REP(i, N){
        REP(j, N){
            dist[i][j] = ((adj[i][j] == 1) ? 1 : INT32_MAX / 2);
        }
    }
    floyd();
    int ans = 0;
    REP(i, N){
        REP(j, N){
            if(i != j) ans = max(ans, dist[i][j]);
        }
    }
    PRINT(ans + 1);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int mxn = 1e4+5;
int dp[mxn];
void solve(){
	// int dp[]
	for(int i =1;i<1e2+1;i++){
		for(int j =1;j<1e2+1;j++){
			for(int k=1;k<1e2+1;k++){
				if((i+j)*(i+j) + (j+k)*(j+k) + (k+i)*(k+i)<(2*mxn) && ((i+j)*(i+j) + (j+k)*(j+k) + (k+i)*(k+i))%2==0)
					dp[((i+j)*(i+j) + (j+k)*(j+k) + (k+i)*(k+i))/2]++;
			}
		}
	}
	int n;
	cin >> n;
	for(int i =1;i<=n;i++){
		cout << dp[i] << endl;
	}
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main(){
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	int ans = 0;
	rep(i,110){
		int f = 0;
		rep(j, n) if (i == p[j]) f = 1;
		if (f == 1)
			continue;
		if (abs(ans - x) > abs(i - x)){
			ans = i;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  int c = 0, ans = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'S') ans = max(ans, c), c = 0;
    else c++;
  }
  ans = max(ans, c);
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 3692
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber , InputReader in , PrintWriter out){
            int q = in.nextInt() , p = in.nextInt() ,t = in.nextInt();
            out.println(Math.min(q+p , Math.min(q+t , p+t)));



        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

}

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


void solve(long long A, long long B){
    int cnt = 1;
    for(int i = 0; i < 20; ++i){
        if(i > 0){
            cnt = A * i - (i-1);
        }
        if(cnt >= B){
            cout << i << endl;
            break;
        }
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)


int main() {
	for (int n, w; n = in, w = in;) {
		vector<int> t(11);
		int m {};
		times(i, n) {
			int v {in};
			m = max(m, v / w);
			t[v / w]++;
		}
		int h = *max_element(begin(t), begin(t) + m + 1);
		double r {};
		for (int i: range(m))
			r += (double) (m - i) / m * t[i] / h;
		printf("%.10G\n", r + 0.01);
	}
}


Measured memory_bytes: 2568
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
imos=[0]*n
count=[-1]*n
for i in range(q):
    p,x=map(int,input().split())
    imos[p-1]+=x
stack=[(0,0)]
while len(stack)>0:
    now=stack.pop()
    x=now[0]
    y=now[1]
    c=y+imos[x]
    count[x]=c
    for i in G[x]:
        if count[i]==-1:
            stack.append((i,c))
for i in count:
    print(i,end='')
    print(' ',end='')


Measured memory_bytes: 109440
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

base = tuple([i for i in range(1, N+1)])

a = 0
b = 0
L = list(itertools.permutations(base))
for i, l in enumerate(L):
  if l == P:
    a = i
  if l == Q:
    b = i

print(abs(a-b))

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

int main(){
    int a;
    map<string,int> b;
    cin >> a;
    set<string> aa;
    for(int i = 0; i < a; i++){
        string s;
        cin >> s;
        if(b.count(s))
            b[s]++;
        else{        
            b[s] = 1;
            aa.insert(s);
        }
    }

    int c;
    map<string, int> d;
    cin >> c;
    for(int i = 0; i < c; i++){
        string s;
        cin >> s;
        if(d.count(s))
        d[s]++;
        else
        d[s] = 1;
    }
    for(auto value : aa){
        if(!(d.count(value)))
            d[value] = 0;
    }
int maxvalue = 0;
    for(auto ans : aa){
        maxvalue = max(maxvalue, b[ans] - d[ans]);
    }
    cout << max(maxvalue, 0) << endl;
}

Measured memory_bytes: 256
C = []
for i in range(3):
    C.append([int(c) for c in input().split()])

ans = "Yes"
tmp=C[0][0]

A=[0]*3
B=[0]*3
for i in range(3):
    B[i]=C[0][i]
for i in range(3):
    A[i]=C[i][0]-B[0]

for i in range(3):
    for j in range(3):
        if(C[i][j]!=A[i]+B[j]):
            ans = "No"
            
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    int v[2][n+1] = {0};
    fore(i,0,2) fore(j,1,n+1) {
        cin >> v[i][j];
        v[i][j] += v[i][j-1];
    }
    int mx = 0;
    fore(j,1,n+1) {
        int cnt = v[0][j]+(v[1][n]-v[1][j-1]);
        mx = max(mx, cnt);
    }
    cout << mx << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;
//order_of_key, find_by_order

#define ll long long
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
vector<int> arr[mxn];
int n, m, k, q;
string s, t;

void solve(){
    cin >> n >> m >> k;
    cout << (n + m - 1) / m * k << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 27084
N = int(input())
L = list(map(int, input().split()))
b = [0]*N
# enumerate関数は指定のリストにインデックス番号を振ることが可能
for i, num in enumerate(L):
    b[num-1] = i+1
# *はリストの個々の要素を取り出すことが可能
print(*b)

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

#define max(a,b) (a>b)?(a):(b)

int llintcmp(const void *a, const void *b) {
	long long c = *(long long *)a, d = *(long long *)b;
	if (c>d) return 1;
	else if (c==d) return 0;
	else return -1;
}

int digits(long long a) {
	long long p = a/10LL;
	int d = 1;
	
	while (p) {
		p /= 10LL;
		d++;
	}
	return d;
}

int main(void) {
	int d, flag=0, i, j, k;
	long long N, p, q;
	long long div[10000];
	scanf("%lld", &N);

	div[0] = 1LL;
	j = 1;
	for (p=2;p*p<=N;p++) {
		if (N%p == 0) {
			div[j++] = p;
			if (p*p == N) flag++;
		}
	}
//	for (i=0;i<j;i++) printf("%lld\t", div[i]);
	if (j == 1) {
		d = digits(N);
	} else if (flag) {
		for (k=j;k<2*j-1;k++) {
			div[k] = N/div[2*j-k-2];
		}
		qsort(div,2*j-1,sizeof(long long), llintcmp);
		d = digits(div[j-1]);
	} else {
		for (k=j;k<2*j;k++) {
			div[k] = N/div[2*j-k-1];
		}
		qsort(div,2*j,sizeof(long long), llintcmp);
		d = digits(max(div[j-1],div[j]));
	}

//	for (i=0;i<=2*j;i++) printf("%lld\t", div[i]);
	printf("%d\n", d);
	return 0;
}

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

int main() {
  int A, B, x, y, z;
  cin >> A >> B;
  x = A + B;
  y = A - B;
  z = A * B;
  if (x >= y && y >= z) {
    cout << x << endl;
  }
  else if (x >= z && z >= y) {
    cout << x << endl;
  }
  else if (y >= x && x >= z) {
    cout << y << endl;
  }
  else if (y >= z && z >= x) {
    cout << y << endl;
  }
  else if (z >= x && x >= y) {
    cout << z << endl;
  }
  else if (z >= y && y >= x) {
    cout << z << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, K;
const int MAX_K = 4010;
int black[MAX_K][MAX_K];
int sumB[MAX_K][MAX_K];
int areaB(int y1, int x1, int y2, int x2)
{
    int res = sumB[y2][x2] - sumB[y1 - 1][x2] - sumB[y2][x1 - 1] + sumB[y1 - 1][x1 - 1];
    assert(res >= 0);
    return res;
}
int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W')
        {
            y += K;
        }

        y %= (2 * K);
        x %= (2 * K);
        y++;
        x++;
        black[y][x]++;
        black[y + 2 * K][x]++;
        black[y][x + 2 * K]++;
        black[y + 2 * K][x + 2 * K]++;
        
    }

    for (int i = 1; i <= 4 * K; i++)
    {
        for (int j = 1; j <= 4 * K; j++)
        {
            sumB[i][j] += black[i][j];

            sumB[i][j] += sumB[i - 1][j];
            sumB[i][j] += sumB[i][j - 1];
            sumB[i][j] -= sumB[i - 1][j - 1];
            // assert(sumB[i][j] >= 0);
            // assert(sumB[i][j] <= N);
        }
    }

    int result = -INF;
    // cerr << N << endl;
    for (int i = 1; i <= 2 * K; i++)
    {
        for (int j = 1; j <= 2 * K; j++)
        {
            int res = 0;
            int y1, x1;
            y1 = i;
            x1 = j;
            res += areaB(y1, x1, y1 + K - 1, x1 + K - 1);
            int y2, x2;
            y2 = y1 + K;
            x2 = x1 + K;
            res += areaB(y2, x2, y2 + K - 1, x2 + K - 1);
            assert(res >= 0);
            result = max(result, res);
            // result = max(result, N - res);
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 125824
#include <bits/stdc++.h>
#include<chrono>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	int i;
	cin >> N>>i;
	cout << N - i + 1 << endl;
}


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

main() {
	int sx, sy, tx, ty;

	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	for (int i = 0; i < (ty - sy); i++) {
		cout << "U";
	}

	for (int i = 0; i < (tx - sx); i++) {
		cout << "R";
	}

	for (int i = 0; i < (ty - sy); i++) {
		cout << "D";
	}

	for (int i = 0; i < (tx - sx); i++) {
		cout << "L";
	}

	cout << "L";

	for (int i = 0; i <= (ty - sy); i++) {
		cout << "U";
	}

	for (int i = 0; i <= (tx - sx); i++) {
		cout << "R";
	}

	cout << "D";
	cout << "R";

	for (int i = 0; i <= (ty - sy); i++) {
		cout << "D";
	}

	for (int i = 0; i <= (tx - sx); i++) {
		cout << "L";
	}

	cout << "U" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, m;
  cin >> n >> m;
  vector<pii> v(n);
  rep(i, n) cin >> v[i].F >> v[i].S;
  sort(all(v), greater<>());

  priority_queue<int> q;
  ll ans = 0;
  for (int i = m; i >= 0; --i) {
    while (sz(v) && i + v.back().F <= m) {
      q.push(v.back().S);
      v.pop_back();
    }
    if (sz(q)) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////

int main(){
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n-1)cin>>a[i];
    ll mini=inf;
    ll ans=0;
    rep(i,0,n-1){
        if(mini>=a[i]){
            ans++;
            mini=a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<map>
#include<set>
using namespace std;
map<int,int>mmp;
set<int>ss;
int a[1000000]={0};
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		int num;
		scanf("%d",&num);
		mmp[num]++;
		ss.insert(num);
	}
	int max=-1;
	set<int>::iterator it=ss.begin();
	while(it!=ss.end())
	{
		int sum=mmp[*it]+mmp[*it-1]+mmp[*it+1];
		max=max> sum ? max:sum ;
		it++;
	 } 
	 printf("%d\n",max);
	return 0;
 } 

Measured memory_bytes: 7680
#include <iostream>

int main() {

    int a, b = 0;
    std::cin >> a >> b;
    
    if (a < b) {
        std::cout << "a < b" << std::endl;
    }
    
    if (a > b) {
        std::cout << "a > b" << std::endl;
    }
    
    if (a == b) {
        std::cout << "a == b" << std::endl;
    }
    
    return 0;

}


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

int main()
{
    string s , t ;
    int c = 0 ;
    cin >> s ;
    while(cin >> t)
    {
        if(t == "END_OF_TEXT") break ;
        else
        {
            for(int i = 0 ; i < t.length() ; i++)
            {
                if((int)t[i] >= 65 && (int)t[i] <= 90) t[i] = tolower(t[i]) ;
            }
            if(s == t) c++ ;
        }
    }
    cout << c << endl ;
}


Measured memory_bytes: 3216
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <map>
#include <array>
#include <cmath>

using namespace std;

vector<int> table;
vector<bool> a;

int PRIME = 1000000007;

vector<vector<int>> map_w;
vector<vector<int>> map_h;


int main(int argc, char* argv[]){
    long long N, P;
    cin >> N >> P;

    long long ret = 1;
    long long factor = 2;
    int counter = 0;

    while(P > 1){
        counter = 0;
        while(P % factor == 0){
            P /= factor;
            ++counter;
            if(counter == N){
                ret *= factor;
                counter = 0;
            }
        }
        ++factor;
        if(sqrt(P) < factor){
            if(N == 1){
                ret *= P;
            }
            break;
        }
    }

    cout << ret;

}


Measured memory_bytes: 256
def LunLun(k, count, base):
    nx = []
    n = len(base)
    if count + n >= k:
        ans = base[k - count - 1]
        return ans

    for x in base:
        count += 1
        p = x % 10
        x *= 10
        a = x + p - 1
        b = a + 1
        c = b + 1
        n = 3
        if p == 0:
            n -= 1
            nx.extend([b, c])
        elif p == 9:
            n -= 1
            nx.extend([a, b])
        else:
            nx.extend([a, b, c])

    return LunLun(k, count, nx)


def main():
    k = int(input())
    base = range(1, 10)
    ans = LunLun(k, 0, base)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18124
import collections
w = input()
w = sorted(w)

if len(w) % 2 != 0:
    print('No')
    exit()
C = collections.Counter(w)

C = list(C.values())


for i in range(len(C)):
    if C[i] % 2 != 0:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 64864
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
#define LINF 1e9+10
typedef long long ll;

using namespace std;

int dx[] = {1,-1, 0, 0};
int dy[] = {0, 0,-1, 1};
ll dp[1050][6000]; 

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll n,m,tmp; cin >> n >> m;
      vector<ll> a(m+1), b(m+1);
      vector<vector<ll>> c(m+1);
      map<ll,ll> mp;
      rep2(i,1,m+1){
            cin >> a[i] >> b[i];
            rep(j,b[i]){ cin >> tmp; mp[tmp]++; c[i].push_back(tmp);}
      }
      if(mp.size() != n){ cout << "-1" << endl; return 0;}
      
      rep(i,1050)rep(j,6000) dp[i][j] = LINF;
      
      dp[0][0] = 0;

      rep(i,m+1)for(int bit = 0; bit < (1<<n); bit++){
            int bit2 = bit;
            for(auto key: c[i]) if( (bit >> (key-1)) & 1) bit2 -= pow(2,key-1);
            if(i-1 >= 0) dp[i][bit] = min(dp[i-1][bit], dp[i-1][bit2] + a[i]);
      }
      cout << dp[m][ (1 << n) - 1] << endl;


      return 0;
}


Measured memory_bytes: 49664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <set>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef pair<int, int> P;

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b){
    return a / GCD(a, b) * b;
}

int main(){
    int n;
    cin >> n;
    vector<ll> t(n);
    for(int i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    ll ans = t[0];
    for(int i = 1; i < n; i++)
    {
        ans = LCM(ans, t[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
pair<char,int> A[maxn];
int CNT;
int main()
{
	string s;
	cin>>s;
	char pre='C';
	int cnt=0,sz=s.length();
	for(int i=0;i<sz;i++)
	{
		if(s[i]==pre)cnt++;
		else
		{
			if(pre!='C')
			A[CNT++]=make_pair(pre,cnt);
			pre=s[i],cnt=1;
		}
	}
	A[CNT++]=make_pair(pre,cnt);
	ll presum=0,ans=0;
	for(int i=0;i<CNT;i++)
	{
		if(A[i].first=='B')presum+=A[i].second;
		else ans+=1ll*presum*1ll*A[i].second;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1412
#include <stdio.h>
#include<math.h>
int main()
{
    long long int a,b,GCD,r,x,y;
    scanf("%lld %lld",&a,&b);
    x=a;
    y=b;
    while(b!=0)
    {
        r=a%b;
        a=b;
        b=r;

    }
    GCD=a;
    printf("%lld\n",GCD);
    return 0;
}


Measured memory_bytes: 2100
/*
    Stay motivated and keep working hard
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s, t;
    cin >> s >> t;
    ll m = s.length(), n = t.length();
    ll dp[m+1][n+1];
    for(ll i=0;i<=n;i++){
        dp[0][i] = 0;
    }
    for(ll i=0;i<=m;i++){
        dp[i][0] = 0;
    }
    for(ll i=1;i<=m;i++){
        for(ll j=1;j<=n;j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    ll i = m, j = n;
    string lcs;
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            lcs.push_back(s[i-1]);
            i--;
            j--;
        }
        else{
            if(dp[i-1][j] > dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    reverse(lcs.begin(), lcs.end());
    for(char c : lcs){
        cout << c;
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 73984
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a%b);}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d,e; cin >> a >> b >> c >> d; e = lcm(c,d);
    cout << (b - a + 1) - (b/c - a/c + (a%c == 0 ? 1 : 0)) - (b/d - a/d + (a%d == 0 ? 1 : 0)) + (b/e - a/e + (a%e == 0 ? 1 : 0)) << endl;
}

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

int main() {
	int b, i, j, n,
		S[13] = { 0,0,0,0,0,0,0,0,0,0,0,0,0 },
		H[13] = { 0,0,0,0,0,0,0,0,0,0,0,0,0 },
		C[13] = { 0,0,0,0,0,0,0,0,0,0,0,0,0 },
		D[13] = { 0,0,0,0,0,0,0,0,0,0,0,0,0 };
	char a;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a >> b;
		if (a == 'S') {
			S[b-1] = 1;
		}
		else if (a == 'H') {
			H[b-1] = 1;
		}
		else if (a == 'C') {
			C[b-1] = 1;
		}
		else {
			D[b-1] = 1;
		}
	}
	for (j = 0; j < 13; j++) {
		if (S[j] == 0) {
			cout << "S " << j+1<< "\n";
		}
	}
	for (j = 0; j < 13; j++) {
		if (H[j] == 0) {
			cout << "H " << j+1<< "\n";
		}
	}
	for (j = 0; j < 13; j++) {
			if (C[j] == 0) {
				cout << "C " << j+1<< "\n";
			}
		}
	for (j = 0; j < 13; j++) {
		if (D[j] == 0) {
			cout << "D " << j+1<< "\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define mod2 998244353
ll exp(ll taban, ll us) {
	if(us < 0) return 0;
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; cin>>n>>k;
	ll dp[k+1] = {};
	dp[0] = 1;
	vector<ll> pref(k+2, 1);
	for(int i = 0; i < n; i++){
		int sayi; cin>>sayi;
		for(int j = k; j > 0; j--){
			if(j-sayi-1 >= 0)dp[j] = (dp[j] + pref[j-1] - pref[j - sayi - 1] + 3LL*mod) % mod;
			else dp[j] = (dp[j] + pref[j-1] + mod) % mod;
		}
		for(int j = 1; j <= k; j++){
			pref[j] = (pref[j-1] + dp[j]) % mod;
		}
	}
	cout<<dp[k]<<endl;
}

Measured memory_bytes: 1792
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 305;
int N, a;
double dp[maxn][maxn][maxn];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>N;
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for(int i = 0; i<N;i++){
        cin>>a;
        if(a == 1)cnt1++;
        if(a == 2)cnt2++;
        if(a == 3)cnt3++;
    }
    
    double p = (double)1/N;    
    dp[0][0][0] = 0;
    
    for (int a = 0; a<=cnt3; a++) {
        for(int b = 0; b<=cnt3+ cnt2; b++){
            for(int c = 0; c<=cnt1+cnt2+cnt3; c++){
                if(a==0&&b==0&&c==0)continue;
                dp[a][b][c]=(1 + (a>0?((double)a/N)*dp[a-1][b+1][c]:0) + (b>0?((double)b/N)*dp[a][b-1][c+1]:0) + (c>0?((double)c/N)*dp[a][b][c-1]:0 ))/(1-(double)(N-a-b-c)/N);
            }
        }
    }
    cout<<fixed<<setprecision(10)<<dp[cnt3][cnt2][cnt1]<<endl;
    
    
    return 0;
}





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

long long MOD=1000000007LL;

long long dp[1000010][13];

int main(){
	string S;
	cin >> S;
	int L=S.size();
	
	for(int i=0;i<100010;i++)for(int j=0;j<13;j++)dp[i][j]=0;
	
	dp[0][0]=1;
	for(int i=0;i<L;i++){
		if(S[i]=='?'){
			for(int j=0;j<13;j++){
				for(int k=0;k<10;k++){
					dp[i+1][(j*10+k)%13]+=dp[i][j];
					dp[i+1][(j*10+k)%13]%=MOD;
				}
			}
		}
		else{
			for(int j=0;j<13;j++){
				int k=S[i]-'0';
				dp[i+1][(j*10+k)%13]+=dp[i][j];
				dp[i+1][(j*10+k)%13]%=MOD;
			}
		}
	}
	cout << dp[L][5] << endl;
	return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+1000;
ll t,k,mod;
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>k;
    ll c=1,r=7%k;
    while(c<=k){
        if(r==0){
            cout<<c<<endl;
            return 0;
        }
        r=(r*10+7)%k;
        c++;
    }cout<<-1<<endl;
    return 0;
}


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

int main(){
    int n, l, ans=0;  cin >> n;
    vector<int> v;
    for (int i = 0; i < 2*n; i++){
        cin >> l;
        v.emplace_back(l);
    }
    sort(v.begin(), v.end());
    for (auto it = v.begin(); it != v.end(); it+=2)
        ans += *it;
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int m=in();int c=in();
	vector<int> b(m);
	trav(i,b){i=in();}
	
	vector<int> a(m);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		trav(i,a){i=in();}
		int tmp=c;
		for(int j=0;j<m;j++)
		{
			tmp+=a[j]*b[j];
		}
		if(tmp>0)ans++;
	}
	cout<<ans<<"\n";
	
}

Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define FOR(i,a,b) for (size_t i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (size_t i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define INF 1e7

int N, M;
map<int, int> mp;

int main()
{
  cin>>N>>M;
  REP(i,M) {
    int a, b;
    cin>>a>>b;
    if (mp[a] > b || mp[a] == 0) mp[a] = b;
  }

  int l, r = INF, ans = 0;
  FOR(l,1,N+1) {
    if (mp[l] != 0) {
      r = min(mp[l], r);
    }
    //cout<<l<<" "<<r<<endl;

    if (l>=r) {
      ans++;
      r = mp[l] == 0 ? INF : mp[l];
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;

int main(){
    int N;cin>>N;
    long long X;cin>>X;
    
    long long count_P[60];    //Pの個数
    count_P[0]=1;
    for(int i=1;i<=N;i++)
        count_P[i]=1+2*count_P[i-1];
    
    long long leng[60];      //バーガーの長さ
    leng[0]=1;
    for(int i=1;i<=N;i++)
        leng[i]=3+2*leng[i-1];
    
    long long ans=0;
    int i=N-1;
    while(i>=0){
        if(X>=2+leng[i]){
            ans+=1+count_P[i];
            X-=2+leng[i];
        }
        else X--;
        i--;
    }
    if(X>0)
        ans++;
    
    cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll INF=(ll)(1e18);

ll wei[105];
ll val[105];
ll dp[3002][3002];
//ll sol[100005][105];
ll n0,w0,v0;
string s1,s2;
string tmp="";
ll lenLCS(ll n,ll m)
{
    if(n==s1.length()||m==s2.length()) return 0;
    if(n>s1.length())
    return -1000000;
    if(m>s2.length())
    return -1000000;
    if(dp[n][m]!=-1) return dp[n][m];
    if(s1[n]==s2[m]) dp[n][m]= 1+lenLCS(n+1,m+1);
    else
    {
    dp[n][m]= max(lenLCS(n+1,m),lenLCS(n,m+1));
    }
    return dp[n][m];
}
/*
ll lenLCS2(ll n,ll m)
{
    ll d1[105][105];
    
    memset(d1,-1,sizeof(d1));
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0||j==0) d1[i][j]=0;
            else if(s1[i-1]==s2[j-1]) 
            {
                d1[i][j]=1+d1[i-1][j-1];
                //cout<<s1[i-1];
            }
            else d1[i][j]=max(d1[i][j-1],d1[i-1][j]);
            
        }
    }
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cout<<d1[i][j]<<" ";
            
        }
        cout<<"\n";
    }
    
    
    cout<<"\n";
return d1[n][m];
    
}
*/

int main()
{
    ll a,b,c,k,d,e,f,n,mx,t;
    
    //string s1,s2;
    memset(dp,-1,sizeof(dp));
    cin>>s1>>s2;
    a=lenLCS(0,0);
    
    /*
    for(int i=0;i<=s1.size();i++)
    {
        for(int j=0;j<=s2.size();j++)
        {
            cout<<dp[i][j]<<" ";
            
        }
        cout<<"\n";
    }
    */
    ll i=0,j=0;
    k=0;
    char a12[a+1];
    
    while(i<=s1.size()&&j<=s2.size())
    {
        if(s1[i]==s2[j])
        {
            a12[k]=s1[i];
            k++;
            i++;
            j++;
        }
        else if(dp[i+1][j]>dp[i][j+1]) i++;
        else j++;
    }
    a12[k]='\0';
    
    
    
    cout<<a12;
    
    return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];//|v| = 2500
bool visited[limit];//a point is whether visited or not

void dfs(int v) {
	visited[v] = true;//v is visited 
	for (int v2 = 0; v2 < n; ++v2) {
		if (graph[v][v2] == false) continue;
		if (visited[v2] == true) continue;//v,v2 are connected and search v2
		dfs(v2);
	}
}

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

	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;//a[i],b[i] is connected
	}

	int ans = 0;

	for (int i = 0; i < m; ++i) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

		for (int j = 0; j < n; ++j) visited[j] = false;

		dfs(0);

		bool bridge = false;//Is (a[i],b[i]) bridge?
		for (int j = 0; j < n; ++j) if (visited[j] == false) bridge = true;//some points were not visited
		if (bridge) ans += 1;

		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;//graph is restored to original one
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256