akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()

int main() {
   int n,d;
   cin >> n >> d;
   cout << (n+d*2)/(d*2+1) << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<int> d(n);
    for(int i=0; i<n; i++){ 
        cin >> d[i];
    }
    ll heal=0;

    for(int i=0; i<n; i++) {
        for(int j=(i+1); j<n; j++) {
            heal+=d[i]*d[j];
        }
    }

    ll ans=0;
    cout<<heal<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int H,W;
string s[2000];
int ans;
int cnt[4][2000][2000];
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>s[i];
	for(int i=0;i<W;i++)cnt[0][0][i]=s[0][i]=='.';
	for(int i=1;i<H;i++)for(int j=0;j<W;j++)
	{
		if(s[i][j]=='#')cnt[0][i][j]=0;
		else cnt[0][i][j]=cnt[0][i-1][j]+1;
	}
	for(int i=0;i<H;i++)cnt[1][i][0]=s[i][0]=='.';
	for(int i=1;i<W;i++)for(int j=0;j<H;j++)
	{
		if(s[j][i]=='#')cnt[1][j][i]=0;
		else cnt[1][j][i]=cnt[1][j][i-1]+1;
	}
	for(int i=0;i<W;i++)cnt[2][H-1][i]=s[H-1][i]=='.';
	for(int i=H-1;i--;)for(int j=0;j<W;j++)
	{
		if(s[i][j]=='#')cnt[2][i][j]=0;
		else cnt[2][i][j]=cnt[2][i+1][j]+1;
	}
	for(int i=0;i<H;i++)cnt[3][i][W-1]=s[i][W-1]=='.';
	for(int i=W-1;i--;)for(int j=0;j<H;j++)
	{
		if(s[j][i]=='#')cnt[3][j][i]=0;
		else cnt[3][j][i]=cnt[3][j][i+1]+1;
	}
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		if(s[i][j]=='#')continue;
		ans=max(ans,cnt[0][i][j]+cnt[1][i][j]+cnt[2][i][j]+cnt[3][i][j]-3);
	}
	cout<<ans<<endl;
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    ll d = a + b + 1;
    cout << min(c, d) + b << endl;

}


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

int main(){
	int n,m,sum,w,i;
	
	long img[10000];
	img[0]=2;
	m=1;
	for(long t=3;m<=10000;t+=2){
		w=0;	
		for(i=0;(img[i]<=sqrt(t)) && (i<=m);i++){
			if(t % img[i]==0){
				w++;
			}
		}
		if(w==0){
			img[m]=t;
			m++;
		}
	}
		while(1){
			cin >> n;
			if(n==0){
				return 0;
			}
			sum=0;
		for(i=0;i<n;i++){
			sum+=img[i];
		}
			cout << sum << "\n";
		
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
	
typedef long long ll;
typedef unsigned long long ull;
typedef long double db;
	
#define MOD 1000000007
#define mi 18446744073709551615
#define ff first
#define ss second
#define pb push_back
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
	// cin>>T;
	while(T--)
	{
		int n,x,t;
		cin>>n>>x>>t;
		cout<<int(ceil((float(n))/x)*t);
	}  
	return 0;
}

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

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

    int n;
    while(cin >> n){
        if(!n) break;

        vector<int> s(n),t(n);
        map<int,int> memo;
        rep(i,n) cin >> s[i];

        int cnt = 0;
        bool ok = true;
        while(ok){
            memo.clear();
            rep(i,n) memo[ s[i] ]++;
            rep(i,n) t[i] = memo[ s[i] ]; 
            if(s == t) break;
            s = t; cnt++;
        }
        cout << cnt << endl;
        rep(i,n-1) cout << t[i] << " ";
        cout << t[n-1] << endl;
    }

    return 0;
}


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

int main(){
    ll n, k, q;
    cin >> n >> k >> q;
    map<ll, ll> point;
    ll tmp;
    ll cnt = 0;
    rep(i, 0, q){
        cin >> tmp;
        if (point.count(tmp) == 0) point[tmp] = 1;
        else point[tmp] ++;
        cnt ++;
    }
    rep(i, 0, n){
        ll s = k - cnt + point[i+1];
        if (s <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define CL(a,b) memset(a,b,sizeof a)
#define pb push_back
#define fi first
#define sc second
#define pi pair<int,int>
#define pii pair<int,pair<int,int>>
int main()
{
    char c;
    cin>>c;
    printf("%c",c+1);
    return 0;
}



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

int main() {
    int n;
    cin>>n;
    int P[n],Q[n];
    ll aaa=0,bbb=0;
    rep(i,n){
        cin>>P[i];
        aaa+=P[i];
        aaa*=10;
    } 
    rep(i,n){
        cin>>Q[i];
        bbb+=Q[i];
        bbb*=10;
    } 

  vector<int> order(n);
    rep(i,n) order[i] = i+1;

    int count=0,a,b;
    do {
        count++;
        ll temp = 0;
        rep(i,n){
            temp += order[i];
            temp *= 10;
        }
        if(temp==aaa) a=count;
        if(temp==bbb) b=count;
    } while (next_permutation(order.begin(), order.end()));

    cout <<  abs(a-b) << endl;

}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

// 負の数にも対応した % 演算
long long mod(long long val, long long m)
{
    long long res = val % m;
    if (res < 0)
        res += m;
    return res;
}

// a^n modを計算する
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    // nを2進数表示して1が埋まっている桁に関してはa^mをかけていく
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod)
{
    return modpow(a, mod - 2, mod);
}

int main()
{
    char a, b;
    cin >> a >> b;
    int a_num = a - '0';
    int b_num = b - '0';
    string x, y;
    for (int i = 0; i < b_num; i++) {
        x += a;
    }
    for (int i = 0; i < a_num; i++) {
        y += b;
    }

    if (x <= y) {
        cout << x << endl;
    } else {
        cout << y << endl;
    }
}

Measured memory_bytes: 256
//let's do it
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001

int main()
{
    boost1;boost2;
    ll n,x,lo,mid,hi,y;
   
    cin>>n;
    lo=0;
    hi=inf;
    while(hi-lo>1)
    {
        mid=(lo+hi)/2;
        x=(mid+2-1)/2;
        y=mid-x;
        if(x*6*1LL+y*5*1LL>=n)
        hi=mid;
        else
        lo=mid;
    }
    cout<<hi;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	double w, h, x, y; cin >> w >> h >> x >> y;
	cout << w * h / 2 << " ";
	if (w / 2 == x && h / 2 == y)cout << "1" << endl;
	else cout << "0" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

int main() {
	int N, M; scanf("%d%d", &N, &M); int k = M - N;
	vector<int> X; 

	FOR(i, 0, M) { int x; scanf("%d", &x); X.push_back(x); }
	sort(X.begin(), X.end());

	vector<int> Y;
	FOR(i, 0, M - 1) {
		Y.push_back(X[i + 1] - X[i]);
	}

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

	if (k <= 0) printf("0\n");
	else {
		int ans = 0; FOR(i, 0, k) ans += Y[i];
		printf("%d\n", ans);
	}

	return 0;
}

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

ll n, x;

// 辺の長さが a, b の平行四辺形を通る光の軌跡の長さ
ll len(ll a, ll b) {
    if(b == 0)  return -a;
    return len(b, a % b) + (a/b) * (2*b);
}

int main() {
    cin >> n >> x;
    ll ans = x + (n - x);
    ans += len(max(x, n-x), min(x, n-x));
    cout << ans << endl;
}

Measured memory_bytes: 256
N=gets.to_i;A=gets.split.map &:to_i;D=[*0..10**6];s=0;2.upto(N-2){|i|s+=A[i];1.upto(A[i]){|j|D.unshift(D[j*2-1])}};gets.to_i.times{p (D[x=gets.to_i]||x-s)+A[0]-A[1]}

Measured memory_bytes: 50060
package main

import (
	"fmt"
)

func main() {
	var len int = 0
	fmt.Scan(&len)
	ints := make([]int, len)
	for i := range ints {
		fmt.Scan(&ints[i])
	}
	status := "DENIED"
	exists := false

	for _, i := range ints {
		if i%2 == 0 {
			exists = true
			break
		}
	}
	if !exists {
		fmt.Println("APPROVED")
		return
	}

	for _, i := range ints {
		if i%2 == 0 {
			if i%3 == 0 || i%5 == 0 {
				status = "APPROVED"
			} else {
				status = "DENIED"
				break
			}
		}
	}

	fmt.Println(status)
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = 1e9 + 7;

ll h, w;
ll ans = 0;

ll t = 0;
ll gy, gx;
ll y[4] = { 0,1,-1,0 };
ll x[4] = { 1,0,0,-1 };
ll qx[200001] = {};
ll qy[200001] = {};
char m[401][401] = {};
char p[401][401] = {};
bool v[401][401] = {};

void maze(ll sy, ll sx) {
	rep(i, 0, 200001) {
		qx[200001] = 0;
		qy[200001] = 0;
	}
	ll cnt_b = 0;
	ll cnt_w = 0;

	ll st = 0;
	ll en = 0;

	v[sy][sx] = true;
	qy[en] = sy;
	qx[en] = sx;
	en++;

	bool nextW = true;

	while (st < en) {
		ll cy = qy[st];
		ll cx = qx[st];
		st++;
		if (m[cy][cx] == '#') {
			cnt_b++;
		}
		else if (m[cy][cx] == '.') {
			cnt_w++;
		}

		rep(i, 0, 4) {
			ll nx = cx + x[i];
			ll ny = cy + y[i];

			if (ny >= 0 && ny < h && nx >= 0 && nx < w && !v[ny][nx]) {
				if (m[cy][cx] == '#' && m[ny][nx] == '.') {
					qy[en] = ny;
					qx[en] = nx;
					v[ny][nx] = true;
					en++;
				}
				else if (m[cy][cx] == '.' && m[ny][nx] == '#') {
					qy[en] = ny;
					qx[en] = nx;
					v[ny][nx] = true;
					en++;
				}
			}
		}
	}
	ans += cnt_b * cnt_w;
}

int main() {
	cin >> h >> w;
	rep(i, 0, h) cin >> m[i];
	rep(i, 0, h)rep(j, 0, w) {
		if (!v[i][j] && m[i][j] == '#') {
			maze(i, j);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3072
from sys import stdin
a = [True]*1000000
for i in range(2,1000000):
    if a[i]:
        for j in range(i+i, 1000000)[::i]:
            a[j] = False

b = [None]*1000000
b[0] = b[1] = 0
for i in range(2,1000000):
    if a[i]:
        b[i] = b[i-1] + 1
    else:
        b[i] = b[i-1]

while True:
    try:
        print(b[int(input())])
    except:
        break


Measured memory_bytes: 23448
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	cin >> N;
	multiset<int> S;
	rep(i, 0, N) {
		int a; cin >> a; a *= -1;
		auto it = S.lower_bound(a + 1);
		if(it == S.end()) {
			S.insert(a);
		}
		else {
			S.erase(it);
			S.insert(a);
		}
		// debug(vi(all(S)));
	}
	cout << sz(S) << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

typedef long long ll;
const int mod=1000000007,N=100100,M=200100,inf=INT_MAX;
int ksm(ll a,int b,int c=1){
	for(;b;b/=2,a=a*a%mod)
		if(b&1)c=c*a%mod;
	return c;
}

struct edge{
	int x,y,z;
	bool operator < (const edge&a)const{return z<a.z;}
}e[M];
int fa[N],sz[N],up[N],val[M],cnt;
ll sum,X;
int n,m;
int find(int x){return fa[x]==x?x:find(fa[x]);}

int main(){
#ifdef ONLINE_JUDGE
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#endif
	cin>>n>>m>>X;cnt=sum=0;
	for(int i=1;i<=m;++i)cin>>e[i].x>>e[i].y>>e[i].z;
	sort(e+1,e+m+1);
	if(n<=2){
		cout<<0<<'\n';
		return 0;
	}
	for(int i=1;i<=n;++i)fa[i]=i,sz[i]=1,up[i]=inf;
	for(int i=1;i<=m;++i){
		int u=find(e[i].x),v=find(e[i].y);
		if(u!=v){
			if(sz[u]<sz[v])swap(u,v);
			sz[u]+=sz[v];fa[v]=u;up[v]=e[i].z;
			sum+=e[i].z;
		}else{
			int mx=0;
			for(int j=e[i].x,k=e[i].y;k!=j;mx=max(mx,up[k]),k=fa[k])
				if(up[k]>up[j])swap(k,j);
			val[++cnt]=e[i].z-mx;
		}
	}
	if(sum==X){
		int ans=2;
		for(int i=1;i<=cnt;++i)
			if(val[i])ans=ans*2%mod;
		cout<<(ksm(2,m)-ans+mod)%mod<<'\n';
	}else{
		int ans=2,ret=0;
		for(int i=1;i<=cnt;++i)
			if(sum+val[i]>X)ans=ans*2%mod;
			else if(sum+val[i]==X)++ret;
		ans=(ll)ans*(ksm(2,ret)-1)%mod;
		cout<<ans<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int64_t mod=1000000007;
int64_t pw(int64_t x,int64_t y){
  int64_t z;
  if(y==0) return 1;
  else{
    z=pw(x,y/2)*pw(x,y/2)%mod;
    if(y%2==1) z=z*x%mod;
    return z;
  }
}
int64_t gcd(int64_t x,int64_t y){
  int64_t r;
  if(x>y) swap(x,y);
  r=y%x;
  while(r>0){
    y=x;
    x=r;
    r=y%x;
  }
  return x;
}
int main() {
  int64_t n,a,b,i,n0=0,c,d,ans;
  map<pair<int64_t,int64_t>,pair<int64_t,int64_t>> m;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a>>b;
    if(a==0 && b==0) n0++;
    else if(b==0){
      if(m.count(make_pair(1,0))) m.at(make_pair(1,0)).first++;
      else m[make_pair(1,0)]=make_pair(1,0);
    }
    else if(a==0){
      if(m.count(make_pair(1,0))) m.at(make_pair(1,0)).second++;
      else m[make_pair(1,0)]=make_pair(0,1);
    }
    else{
      if(a<0) {a*=-1; b*=-1;}
      c=max(b,-b);
      d=gcd(a,c);
      a/=d;
      c/=d;
      if(b>0){
        if(m.count(make_pair(a,c))) m.at(make_pair(a,c)).first++;
        else m[make_pair(a,c)]=make_pair(1,0);
      }
      else if(b<0){
        if(m.count(make_pair(c,a))) m.at(make_pair(c,a)).second++;
        else m[make_pair(c,a)]=make_pair(0,1);
      }
    }
  }
  if(m.size()>0){
    ans=1;
    for(auto pp:m){
      auto p1=pp.second.first;
      auto p2=pp.second.second;
      ans=ans*((pw(2,p1)+pw(2,p2)-1)%mod)%mod;
    }
    ans=(ans-1+n0+mod)%mod;
  }
  else ans=n0;
  cout<<ans<<endl;
}

Measured memory_bytes: 18984
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second 

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

// End of template code!
int main() 
{
    buff();
    int n;
    cin >> n;
    vector< vector<int> > g(n);
    vector<int> ssz(n, 1); 
    deque<bool> mrk(n, false); 
    for(int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        g[p - 1].push_back(i);
    }
    
    for(int i = 0; i < n; ++i) {
        cout << sz(g[i]) << '\n';
    }
    

    return 0;
}



Measured memory_bytes: 15052
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    auto f = [](ll x) {
        return (((x + 1) / 2) & 1) ^ (x & 1 ? 0 : x);
    };
    cout << (f(b) ^ f(a - 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b = map(int, input().split())
s = input()
ap=0
bp=0
for i in range(n):
    if s[i]=='a' and ap+bp<a+b:
        ap+=1
        print('Yes')
    elif s[i]=='b' and ap+bp<a+b and bp<b:
        bp+=1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4016
from collections import deque
K=int(input())
table=[[] for i in range(K)]
for i in range(K):
    table[i].append([1,(i+1)%K])
    t = (10*i)%K
    if t!=i:
        table[i].append([0,t])
dij=deque()
visit=[False]*K
val=[10**9]*K
val[1]=0
dij.append([0,1])
while dij:
    d,x=dij.popleft()
    if val[x]<d:
        continue
    for q,y in table[x]:
        if val[y]>val[x]+q:
            val[y]=val[x]+q
            if q==1:
                dij.append([val[y],y])
            else:
                dij.appendleft([val[y],y])
print(val[0]+1)

Measured memory_bytes: 77488
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n,k;
    cin>>n>>k;
    ll ans = 0;
    ll next = n;
    while(next>=k){
        next/=k;
        ans++;
    }

    if(n!=0)ans++;
    cout<<ans<<endl;



    
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
 
int main()
{
  double w, h, x, y;
  int b;
  cin >> w >> h >> x >> y;
  double a;
  a=w*h/2;
  if ((x==(w/2))&&(y==(h/2)))	b=1;
  else b=0;
  cout << a <<' '<< b;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int binary_search(int* p, int n, int key,int num)
{
    int low, high, middle;

    low = 0;
    high = n - 1;

    while (low <= high)
    {
        middle = (low + high) / 2;
        if (gcd(num,p[middle])==1)
            return middle;
        else 
            high = middle - 1;
    }
}

int main()
{
    int N, L, M, K;
    int A, B, C, D;
    vector<string> data;
    string str;
    int ans = 1;

    cin >> N;

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

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

    for (int i = 1; i < N; i++)
    {
        if (data[i] != data[i - 1])
            ans++;
    }

    cout << ans;
}



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

ll solve(vector<int> &weight, vector<int> &value, int w) {
  int n = value.size();
  vector<ll> dp(w + 1, 0);
  for (int j = 0; j < n; ++j) {
    for (int wt = w; wt - weight[j] >= 0; --wt) {
      dp[wt] = max(dp[wt], value[j] + dp[wt - weight[j]]);
    }
  }
  ll ans = 0;
  for (int i = 1; i <= w; ++i) {
    ans = max(ans, dp[w]);
  }
  return ans;
}

int main() {
  int n, w;
  cin >> n >> w;
  vector<int> value(n, 0);
  vector<int> weight(n, 0);
  for(int i = 0; i < n; ++i) {
    cin >> weight[i];
    cin >> value[i];
  }
  cout << solve(weight, value, w) << '\n';
  return 0;
}


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

int main() {
  int ans=0;
  int N;
  cin >> N;
  vector<map<int,int>> list(N,map<int,int>());
  for (int i=0;i<N;i++) {
    int A;
    cin >> A;
    for (int j=0;j<A;j++) {
      int person, judge;
      cin >> person >> judge;
      list.at(i)[person-1]=judge;
    }
  }
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<15> s(tmp);
    //cout << s << endl;
    int flag=0;
    // ビット列を出力
    for (int i=0;i<N;i++) {
      for (auto p: list.at(i)) {
        if (s.test(i)) {
          if(s.test(p.first) != bool(p.second)) {
            flag=1;
            //cout << i << endl;
            break;
          }
        }
      }
      if(flag) {
        break;
        //cout << N << endl;
      }
    }
    if(!flag) {
      ans = max(ans,int(s.count()));
      //cout << s << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String... args){
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();
        int n = scan.nextInt();

        int list[] = new int[w];
        for(int i = 0;i < w;i++)list[i] = i+1;
        
        for(int i = 0;i < n;i++){
            String s = scan.next();
            int conma = s.indexOf(",");
            int a1 = Integer.parseInt(s.substring(0, conma))-1;
            int a2 = Integer.parseInt(s.substring(conma+1, s.length()))-1;
            int x = list[a1];
            list[a1] = list[a2];
            list[a2] = x;
        }
 
        for(int i = 0;i < w;i++)System.out.println(list[i]);

        scan.close();
    }

    

}


Measured memory_bytes: 26172
#include <stdio.h>

int main(void) {

  int car;
  int cars[10];

  int top=0;

  while(scanf("%d",&car)!=EOF) {

    if(car==0) {
      
      top--;
      printf("%d\n",cars[top]);

    }
      
    else {
      
      cars[top]=car;
      top++;

    }

  }

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) a[i] = i;
    vector<pii> v;
    double ans = 0;
    ll k = 0;
    rep(i, n)
    {
        ll x, y; cin >> x >> y; v.pb({x, y});
    }
    do{
        k++;
        double tmp = 0.0;
        rep(i, n-1)
        {
            ll x = a[i], y = a[i+1];
            tmp = sqrt( (v[x].ft-v[y].ft)*(v[x].ft-v[y].ft) + (v[x].sd-v[y].sd)* (v[x].sd-v[y].sd)  );
            ans += tmp;  //cout <<tmp << " ";
        }
    }
    while(next_permutation(a, a+n));
    cout << ans / k;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String t = scan.next();
        char[] d = t.toCharArray();
        int ans = 0;
        for (int i = 0; i < d.length; i++) {
            ans += ((int) (d[i] - '0')) % 9;
            ans %= 9;
        }
        if (ans == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 40800
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define mod %
#define E =
#define EE ==
int mx=9999999;
/**  '' "\n" - ^ **/

void yes()
{
    cout<<"Yes\n";
}

void no()
{
    cout<<"No\n";
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void bin(int n)
{
    cout<<n<<endl;
    while(n>0)
    {
        cout<<n%2;
        n/=2;
    }
}
int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    ll sum=a/(b+c);
    a=a%(b+c);
    if(a>b)
        a=b;
    sum=sum*b;
    cout<<sum+a;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int[] array = new int [n];
			int res = 0;
			for(int i = 0;i<n;i++) {
				array[i] = sc.nextInt();
			}
			int max = array[0];
			for(int numb:array) {
				if(numb>=max) {
					res++;
					max = numb;
				}
			}
			System.out.println(res);
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}


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

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

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 n;
  cin >> n;
  priority_queue<u32> a(n, 0);

  rep(i, n) {
    u32 ai;
    cin >> ai;
    a.push(ai);
  }

  u64 ans = 0;
  ans += a.top();
  a.pop();
  n--;
  n--;
  while (n > 0) {
    if (n >= 2) {
      ans += 2 * a.top();
      a.pop();
      n -= 2;
    } else {
      ans += a.top();
      a.pop();
      n -= 1;
    }
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 4836
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [h, w] <- map read.words <$> getLine :: IO [Int]
    m <- B.concat <$> replicateM h B.getLine
    print $ solve h w m

inf :: Int
inf = 0x3f3f3f3f

solve :: Int -> Int -> B.ByteString -> Int
solve h w bs
    | dist == inf = -1
    | otherwise = h * w - numBlock - dist
  where
    numBlock = B.length $ B.filter (== '#') bs
    isOK (x, y) = B.unsafeIndex bs (x * w + y) == 46 -- chr 46 == '.'
    idx ::Int -> Int -> Int
    idx x y = x * w + y
    {-# INLINE idx #-}
    inGrid (x, y) = 0 <= x && x < h && 0 <= y && y < w
    neighbors x y = filter (\xy -> isOK xy && inGrid xy) [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]
    dist = runST $ do
        d <- UM.replicate (h*w) inf
        let bfs ((x,y):fs) rs = do
                dxy <- UM.unsafeRead d (idx x y)
                nexts <- flip filterM (neighbors x y) $ \(nx,ny) -> do
                    dnxny <- UM.unsafeRead d (idx nx ny)
                    if dxy + 1 < dnxny
                    then do
                        UM.unsafeWrite d (idx nx ny) $ dxy + 1
                        return True
                    else return False
                bfs fs (nexts ++ rs)
            bfs [] [] = return ()
            bfs [] rs = bfs (reverse rs) []
        UM.unsafeWrite d (idx 0 0) 1
        bfs [(0,0)] []
        UM.unsafeRead d (idx (h-1) (w-1))



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	//ll x;
	//ll n;
	ll a, b;
	ll ans = 0;

	cin >> a >> b;

	ans = 0;
	ll sum = 1;
	while (sum < b) {
		sum += a - 1;
		ans++;
	}

	cout << ans << "\n";
}

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

	solve_abc_b();

	return 0;
}

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

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

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=400005;
vector<pi>vec;
set<int>p;
int cur=0;
unordered_map<int,int>id;
int tre[4*M][2];
void build(int pos,int l,int r,int typ)
{
    if(l==r)
    {
        tre[pos][typ]=inf;
        return ;
    }
    int mid=(l+r)>>1;
    build(2*pos,l,mid,typ);
    build(2*pos+1,mid+1,r,typ);
    tre[pos][typ]=min(tre[2*pos][typ],tre[2*pos+1][typ]);
}
void update(int pos,int l,int r,int I,int J,int val,int typ)
{
    if(l>J || r<I)return ;
    if(I<=l && J>=r)
    {
        tre[pos][typ]=min(tre[pos][typ],val);
        return ;
    }
    int mid=(l+r)>>1;
    update(2*pos,l,mid,I,J,val,typ);
    update(2*pos+1,mid+1,r,I,J,val,typ);
    tre[pos][typ]=min(tre[2*pos][typ],tre[2*pos+1][typ]);
}
int qry(int pos,int l,int r,int I,int J,int typ)
{   if(I>J)return inf;
    if(l>J || r<I)return inf;
    if(I<=l && J>=r)
    {
        return tre[pos][typ];
    }
    int mid=(l+r)>>1;
    int x=qry(2*pos,l,mid,I,J,typ);
    int y=qry(2*pos+1,mid+1,r,I,J,typ);
    return min(x,y);
}
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        int x,y;
        cin>>x>>y;
        vec.pb(mp(x,y));
        p.insert(x);
        p.insert(y);
    }
    for(auto x:p)
    {
        id[x]=++cur;
    }
    int ses=-inf;
    build(1,1,cur,0);
    build(1,1,cur,1);
    sort(vec.begin(),vec.end());
    for(auto z:vec)
    {
        int x=z.fi;
        int y=z.si;
        int u=x+y;
        int v=qry(1,1,cur,1,id[y],0);
        ses=max(ses,u-v);

        u=x-y;
        v=qry(1,1,cur,id[y],cur,1);
        ses=max(ses,u-v);

        update(1,1,cur,id[y],id[y],x+y,0);
        update(1,1,cur,id[y],id[y],x-y,1);
    }
    cout<<ses<<"\n";
    return 0;

}





































Measured memory_bytes: 58092
#include<bits/stdc++.h>
#define ll long long int
#include <iostream>
using namespace std;
int main() {
	ll r,c,t;
	t=1000000007;
	cin>>r>>c;
	vector<char> v[r];
	for(ll i=0;i<r;i++){
		for(ll j=0;j<c;j++){
			char temp;
			cin>>temp;
			v[i].push_back(temp);
		}
	}
	ll dp[r+1][c+1];
	memset(dp,0,sizeof(dp));
	for(ll i=0;i<=r;i++){
		for(ll j=0;j<=c;j++){
			if(i==0||j==0)dp[i][j]=0;
			else if(i==1&&j==1)dp[i][j]=1;
			else if(v[i-1][j-1]=='#')dp[i][j]=0;
			else{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%t;
			}
		}
	}
	cout<<dp[r][c];
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a[3];
    cin >> a[1] >> a[2] >> a[3]; 
    if (a[1] + a[2] + a[3] >= 22)
    {
        cout << "bust" << endl;
    }
    else 
    {
        cout << "win" << endl;
    }
    
    
}



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

struct Node {
int key;
Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
Node *y = NIL;
Node *x = root;
Node *z;
	
z = (Node *)malloc(sizeof(Node));
z->key   = k;
z->left  = NIL;
z->right = NIL;
	
while(x != NIL) {
y = x;
if(z->key < x->key) {
x = x->left;
} else {
x = x->right;
}
}
	
z->parent = y;
if(y == NIL) {
root = z;
} else {
if( z->key < y->key) {
y->left = z;
} else {
y->right = z;
}
}
}

void inorder(Node *u) {
if(u == NIL) return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node *u) {
if(u == NIL) return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
	
int main(void) {
int n, i, x;
string com;
scanf("%d",&n);
	
for(i=0;i<n;i++) {
cin >> com;
if(com == "insert") {
scanf("%d",&x);
insert(x);
} else if(com == "print") {
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}

	return 0;
}


Measured memory_bytes: 26748
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 300010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int nt[MAXN], n;

void sieveBase(int n) {
    FOR(i,2,n) {
        if (nt[i] == 0) {
            nt[i] = i;
            for (ll j = (ll) i * i; j <= n; j += i) nt[j] = i;
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    sieveBase(55555);
    for (int i = 9; i <= 55555; i += 10) {
        if (nt[i] == i) {
            cout << i << ' ';
            n--;
            if (n == 0) return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  string* S = new string[N];
  map<string, int> mp;
  for(int i=0; i<N; i++){
	cin >> S[i];
	mp[S[i]]++;
  }

  // scan all
  //単語の最大出現回数を調査
  int max_word_num=0;
  for(int i=0; i<N; i++){
	if(max_word_num < mp[S[i]]) max_word_num = mp[S[i]];
  }
  //cout << "hello?" << endl;
  // 最大出現回数の単語数を取得
  int num_of_max_word=0;
  //map<string, int> mp2;
  for(int i=0; i<N; i++){
	if(max_word_num == mp[S[i]]){
	  mp[S[i]] = -1;
	  //mp2[S[i]]++;
	  num_of_max_word++;
	}
  }

  //string *dic = new string[num_of_max_word];
  vector<string> dic(num_of_max_word);
  int t=0;
  //cout << "hell0" << endl;
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
	if(itr->second == -1){
	  dic[t] = itr->first;
	  t++;
	  //cout << itr->first << endl;
	}
  }
  //cout << "hell0" << endl;
  for(int i=0; i<num_of_max_word; i++){
	cout << dic[i] << endl;
  }
  
  sort(dic.begin(), dic.end());
  
  delete[] S;
  //delete[] dic;
  
  return 0;
}


Measured memory_bytes: 30336
import sys
import collections
import copy
import math
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
S = input()
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == "L":
            print("No")
            break
    else:
        if S[i] == "R":
            print("No")
            break
    if i == len(S)-1:
        print("Yes")


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    long long br=0,mx;
    cin >> n;
    vector<long long> v(n);
    for (int i=0;i<n;i++)
        cin >> v[i];
    mx=v[0];
    for (int i=1;i<n;i++)
    {
        br+=max(0ll,mx-v[i]);
        mx=max(mx,v[i]);
    }
    cout << br;
}


Measured memory_bytes: 4744
#include <iostream>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  unordered_map<string, int> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m[s]++;
  }
  vector<set<string>> ans(n + 1);
  for (auto i : m) {
    ans[i.second].insert(i.first);
  }
  for (int i = n; i >= 0; i--) {
    if (!ans[i].empty()) {

      for (auto j : ans[i]) {
        cout << j << endl;
      }
      return 0;
    }
  }
}


Measured memory_bytes: 42824
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;

struct time_c {
    int hour;
    int min;

    bool operator<(const time_c& right) const {
        return hour == right.hour ? min < right.min : hour < right.hour;
    }

    bool operator==(const time_c& right) const {
        return hour == right.hour && min == right.min;
    }
};

int main() {
    int n, m;
    cin >> n;
    vector<time_c> ns(n);
    for (int i = 0; i < n; i++) cin >> ns[i].hour >> ns[i].min;
    cin >> m;
    vector<time_c> ms(m);
    for (int i = 0; i < m; i++) cin >> ms[i].hour >> ms[i].min;

    vector<time_c> t;
    t.reserve(n + m);
    t.insert(t.end(), ns.begin(), ns.end());
    t.insert(t.end(), ms.begin(), ms.end());
    sort(t.begin(), t.end());
    t.erase(unique(t.begin(), t.end()), t.end());

    for (int i = 0; i < t.size(); i++) {
        if (i > 0) cout << " ";
        cout << t[i].hour << ":" << setw(2) << setfill('0') << t[i].min;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3080