akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	string S;
	cin >> S;
	ll N = S.size();

	vll a(N + 2,0);
	repn(i, N) {
		a[i] = S[N - i] - '0';
		a[i] *= 9;
	}

	repn(i, N) {
		//cout << a[i];
		ll x = a[i];
		ll j = i;
		a[i] = 0;
		while (x > 0) {
			a[j] += x % 10;
			x /= 10;
			j++;
		}
	}

	ll num9 = 0;
	repn(i, N)if (a[i] == 9) { num9++; }

	//repn(i, N+1)cout << a[i];
	//cout << endl;

	ll ans = 0;
	for (ll i = N + 1; i >= 1; i--) {
		if (num9 == i) { ans++; break; }

		ans += a[i];
		ll x = a[1] + a[i];
		if (a[1] == 9) { num9--; }
		if (a[i] == 9) { num9--; }
		if (x % 10 == 9) { num9++; }
		a[1] = x;
		a[i] = 0;
		ll j = 1;
		while (a[j] > 9) {
			if (a[j + 1] == 9) { num9--; }
			a[j + 1] += a[j] / 10;
			if (a[j + 1] % 10 == 9) { num9++; }
			a[j] = a[j] % 10;
			
			j++;
		}

		//repn(k, N + 1)cout << a[k]<<" ";
		//cout << endl;
		//cout <<ans<< endl;
	}

	ans = (ans + 8) / 9;
	cout << ans << endl;

}


Measured memory_bytes: 7724
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    vector<vector<int> > dp(N+1, vector<int>(N+1, 0));
    for(int i=N-1; i >= 0; i--){
        for(int j=N-1; j > i; j--){
            if(S[i] == S[j]){
                dp[i][j] = max(dp[i][j], dp[i+1][j+1] + 1);
                ans = max(ans, min(dp[i][j], j-i));
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n, x, f;
  cin >> n;
  x = n;
  f = 0;
  for(int i = 0; i < 8; i++){
    if(x > 0){
      f += x % 10;
      x = x / 10;
    }else{
      break;
    }
  }
  if(n % f == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;
long long n,i,val,ans;
vector<long long> seg;
long long h[200005];
long long a[200005];
long long query(long long stt, long long drt, long long st, long long dr, long long p)
{
    if(stt>drt)
        return 0;
    if(stt==st && drt==dr)
        return seg[p];

    int mij=(st+dr)/2;

    if(drt<=mij)
        return query(stt, drt, st, mij, 2*p);
    if(stt>mij)
        return query(stt, drt, mij+1, dr, 2*p+1);

    return max(query(stt, mij, st, mij, 2*p), query(mij+1, drt, mij+1, dr, 2*p+1));
}
void upd(long long i, long long val, long long st, long long dr, long long p)
{
    if(st==dr)
    {
        seg[p]=val;
        return;
    }

    int mij=(st+dr)/2;

    if(i<=mij)
        upd(i, val, st, mij, 2*p);
    else
        upd(i, val, mij+1, dr, 2*p+1);

    seg[p]=max(seg[2*p], seg[2*p+1]);
}
int main()
{
    cin>>n;
    seg.resize(4*n+4);
    for(i=1;i<=n;i++)
        cin>>h[i];
    for(i=1;i<=n;i++)
        cin>>a[i];

    for(i=1;i<=n;i++)
    {
        val=query(1, h[i]-1, 1, n, 1)+a[i];
        ans=max(ans, val);
        //cout<<i<<' '<<val<<'\n';
        upd(h[i], val, 1, n, 1);
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 12716
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h>
#include<queue>
using namespace std;
int main()
{int a,b,c,x,y,m;cin>>a>>b>>c>>x>>y;
int n=c*2*max(x,y);
if(x>y) m=(x-y)*a+y*2*c;
else m=(y-x)*b+x*2*c;
int g=a*x+b*y;
cout<<min(n,min(m,g));
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

vector<int> A;
int dfs(int i, int m) {
    if (i==A.size()-1) {
        if (m==A[i] || m==0) return true;
        return false;
    }
    return dfs(i+1,m) || dfs(i+1,m-A[i]);
}
int main() {
    int N;
    cin >> N;
    A.resize(N);
    rep(i,N) cin >> A[i];
    int q;
    cin >> q;
    int m;
    rep(i,q) {
        cin >> m;
        cout << (dfs(0,m) ? "yes" : "no") << endl;
    }
   return 0;
}


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

using namespace std;

int n, m;
int t[110], h[110];
int tsum, hsum;

void solve() {
	int minSum = (int)1e9;
	int tg = -1, hg = -1;
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (tsum - t[i] + h[j] == hsum - h[j] + t[i]) {
				if (minSum > t[i] + h[j]) {
					minSum = t[i] + h[j];
					tg = t[i];
					hg = h[j];
				}
			}
		}
	}
	
	if (tg == -1) cout << -1 << endl;
	else {
		cout << tg << " " << hg << endl;
	}
}

int main() {
	while (1) {
		cin >> n >> m; if (n == 0 && m == 0) break;
		
		tsum = hsum = 0;
		for (int i = 0; i < n; i++) {
			cin >> t[i];
			tsum += t[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> h[i];
			hsum += h[i];
		}
		
		solve();
	}	
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using i64 = long long;

int main() {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}


struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main()
{
    ll n,m ; cin >> n >> m;

    vector<P_ii> v(m);

    REP(i,m) cin >> v[i].first >> v[i].second,v[i].first--,v[i].second--;
    reverse(all(v));

    UnionFind uf(n);
    vector<ll> ans;
    ll cur = n*(n-1)/2;
    REP(i,m) {
        ans.push_back(cur);

        if(uf.issame(v[i].first,v[i].second)) continue;

        cur -= (ll)uf.size(v[i].first) * (ll)uf.size(v[i].second);
        uf.merge(v[i].first,v[i].second);
    }
    reverse(all(ans));

    REP(i,ans.size()) pl(ans[i])
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pl;

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

int main(){

  int N,K;
  cin >> N>>K;

  ll ans=0;

  ans=K*pow((K-1),(N-1));

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 5e6 + 5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

vector<int> v[N];
int DP[N];

void solve()
{
	int t;
	cin >> t;
	if(t >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
}
 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

ll A[1001], B[1001], C[1001];
int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  REP(i, X) cin >> A[i];
  REP(i, Y) cin >> B[i];
  REP(i, Z) cin >> C[i];

  sort(A, A + X, greater<ll>());
  sort(B, B + Y, greater<ll>());
  sort(C, C + Z, greater<ll>());

  vector<ll> s;
  REP(i, X) {
    REP(j, Y) {
      REP(k, Z) {
        if ((i + 1) * (j + 1) * (k + 1) <= K) s.push_back(A[i] + B[j] + C[k]);
      }
    }
  }
  sort(s.begin(), s.end(), greater<ll>());
  REP(i, K) cout << s[i] << endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        double a = scan.nextDouble();
        double cir = 2 * Math.PI *a;
        double area = Math.PI * a *a;
        System.out.printf("%.5f ",area);
        System.out.printf("%.5f %n", cir);
    }
}



Measured memory_bytes: 28288
#include <iostream>
 #include <algorithm>
 #include <utility>
 #include <vector>
 #include <string>
 
 using namespace std;
 typedef long long ll;
 typedef pair<int, int> pii;
 typedef pair<ll, ll> pll;
 #define REP(i, n) for (int i = 0; i < (n); i++)
 #define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
 #define FOR(i, a, b) for (int i = (a); i < (b); i++)
 #define RFOR(i, a, b) for (int i = (a); i > (b); i--)
 #define ALL(a) (a).begin(), (a).end()
 
 int main() {
     string S;
     cin >> S;
     int ans = 0;
     REP(i, S.size()) {
         if (S[i] == 'R') ans++;
         else {
             if (ans > 0) break;
         }
     }
     cout << ans << endl;
     return 0;
 }

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);  
  }
  int ans=0;
  
  for (int i = 0; i < N; i++) {
    if(i%2==0){
      if(a.at(i)%2 == 1){
        ans++;
      }  
    }
  }
 
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set
const ll  MOD=1e9+7;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; ll c;
    cin >> n >> c;
    vector<Pll> v(n),w(n);
    rep(i,n){
        cin >> v[i].fi >> v[i].se;
        w[i].fi=c-v[i].fi; w[i].se=v[i].se;
    }
    ll ans=0;
    ll res=0;
    vector<ll> L(n),R(n);
    rep(i,n){
        res+=v[i].se;
        chmax(ans,res-v[i].fi);
        L[i]=ans;
    }
    ll ans2=0;
    res=0;
    rrep(i,n){
        res+=w[i].se;
        chmax(ans2,res-w[i].fi);
        R[i]=ans2;
    }
    chmax(ans,ans2);
    res=0;
    rep(i,n-1){
        res+=v[i].se;
        chmax(ans,res-2*v[i].fi+R[i+1]);
    }
    res=0;
    for(int i=n-1;i>0;i--){
        res+=w[i].se;
        chmax(ans,res-2*w[i].fi+L[i-1]);
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define MOD 1'000'000'007
#define N 212345

ll pw(ll a, ll b){
	ll c=1, d=a;
	while(b){
		if(b&1) c*=d, c%=MOD;
		d*=d, d%=MOD;
		b/=2;
	}
	return c;
}
inline ll dv(ll a, ll b){
	a%=MOD;
	b%=MOD;
	return a*pw(b, MOD-2)%MOD;
}
ll fct[N]={1};
inline ll cmb(ll a, ll b){
	return dv(dv(fct[a], fct[b]), fct[a-b]);
}
ll clc(ll n, ll m, ll k){
	ll ret = 0;
	FOR(i, 1, m){
		ll tmp = i;
		// tmp*=cmb(m, 2);
		// tmp%=MOD;
		tmp*=m-i;
		tmp%=MOD;

		ret += tmp;
		ret %= MOD;
	}
	ret*=k*(k-1);
	ret%=MOD;
	ret*=n*n;
	ret%=MOD;
	ret*=dv(fct[n*m-2], fct[n*m-k]);
	ret%=MOD;
	return ret;
}

int main(){
	FOR(i, 1, N) fct[i]=fct[i-1]*i%MOD;
	ll n, m, k; scanf("%lld%lld%lld", &n, &m, &k);
	ll ans = clc(n, m, k) + clc(m, n, k);
	ans %= MOD;
	printf("%lld\n", dv(ans, fct[k]));
}


Measured memory_bytes: 1920
using System;
using System.Collections.Generic;

class ABC070D
{
	static public void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		List<int>[] dest = new List<int>[N+1];
		for(int i=1; i<=N; i++)
		{
			dest[i] = new List<int>();
		}
		List<long>[] cost = new List<long>[N+1];
		for(int i=1; i <= N; i++)
		{
			cost[i] = new List<long>();
		}

		int a, b;
		long c;
		string[] vals;
		for(int i=1; i <= N-1; i++)
		{
			vals = Console.ReadLine().Split(' ');
			a = int.Parse(vals[0]);
			b = int.Parse(vals[1]);
			c = long.Parse(vals[2]);
			dest[a].Add(b);
			cost[a].Add(c);
			dest[b].Add(a);
			cost[b].Add(c);
		}
		int Q,K;
		vals = Console.ReadLine().Split(' ');
		Q = int.Parse(vals[0]);
		K = int.Parse(vals[1]);
		long[] distance = new long[N+1];
		distance[K] = 0;
		Queue<int> q = new Queue<int>();
		q.Enqueue(K);
		int t;
		while(q.Count > 0)
		{
			t = q.Dequeue();
			for(int i=0; i < dest[t].Count; i++)
			{
				if(distance[dest[t][i]] > 0)
					continue;
				distance[dest[t][i]] = distance[t] + cost[t][i];
				q.Enqueue(dest[t][i]);
			}
		}
		int[,] query = new int[Q, 2];
		for(int i=0; i < Q; i++)
		{
			vals = Console.ReadLine().Split(' ');
			query[i,0] = int.Parse(vals[0]);
			query[i,1] = int.Parse(vals[1]);
		}
		for(int i=0; i < Q; i++)
		{
			Console.WriteLine(distance[query[i,0]] + distance[query[i,1]]);
		}
	}
}


Measured memory_bytes: 43112
#include <bits/stdc++.h>
using namespace std;
long long n, m; char c;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
long long dp[n+1][m+1];
memset(dp,0,sizeof(dp));
dp[1][1]=1;
for (int i=1; i<=n; i++){
	for (int j=1; j<=m; j++){
		cin >> c;
		if (c=='.' && (i!=1 || j!=1))
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007LL;
	}
} cout << dp[n][m];
return 0;
}


Measured memory_bytes: 11476
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(){
	//X:椅子の長さが
	//Y椅子の幅
	//Z間に空ける幅
	int X, Y, Z;
	int a, b;
	scanf("%d %d %d", &X, &Y, &Z);
	a = X / (Y + Z);
	b = X % (Y + Z);
	if(b < Z){
		a = a - 1;
	}
	printf("%d", a);
	return 0;
}



Measured memory_bytes: 128
import sys
from math import ceil
def input(): return sys.stdin.readline().strip()


def main():
    a, b, c = map(int, input().split())
    K = int(input())
    for i in range(1 << (K*2)):
        A, B, C = a, b, c
        for j in range(7):
            if not i & (1 << (2*j)) and not i & (1 << (2*j+1)):
                continue
            elif i & (1 << (2*j)) and not i & (1 << (2*j+1)):
                A *= 2
            elif not i & (1 << (2*j)) and i & (1 << (2*j+1)):
                B *= 2
            else:
                C *= 2
        if A < B and B < C:
            print("Yes")
            return
    print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 68024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2000+10,mod=1e9+7;
ll f[maxn][maxn];
ll s[maxn*maxn+10],invs[maxn*maxn+10];
int n,m;
inline void read(int &x){
	char c=getchar();
	int f=1;
	x=0;
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	x*=f;
}
inline long long ksm(ll x,int y){
	ll sum=1;
	while(y){
		if(y&1){sum=(sum*x)%mod;}
		y/=2;
		x=(x*x)%mod;
	}
	return sum%mod;
}
inline ll cal(int x,int y){
	//cout<<s[x]<<" "<<s[y]<<endl;
	ll sum2=1,sum1=1,sum=0;
	//for(register int i=1;i<=y;i++)sum1=(sum1*i)%mod;
	//for(register int i=x-y+1;i<=x;i++)sum2=(sum2*i)%mod;
	//sum2=s[x];sum1=(s[x-y]*s[y])%mod;
	//sum=(sum2*ksm(sum1,mod-2))%mod;
	sum=((s[x]*invs[y])%mod*invs[x-y])%mod;
	//cout<<sum<<endl;
	return sum%mod;
}
int main(){
	int i,j,k;
	read(n);read(m);
	//cout<<n<<" "<<m<<endl;
	if(m==1){cout<<1<<endl;return 0;}
	f[0][0]=1;
	s[0]=1;
	//for(register int i=1;i<=n;i++)f[i][0]=1;
	for(register int i=1;i<=maxn*maxn;i++){s[i]=(s[i-1]*i)%mod;}
	invs[maxn*maxn]=ksm(s[maxn*maxn],mod-2);
	for(register int i=maxn*maxn-1;i>=0;i--)invs[i]=(invs[i+1]*(i+1))%mod;
	for(register int i=1;i<=n;i++)
		for(register int j=0;j<=i;j++){
			if(!j)f[i][j]=f[i-1][j]%mod;
			else f[i][j]=(f[i-1][j]+((f[i][j-1]*(n-j+1))%mod*cal(n*m-(j-1)*(m-1)-i-1,m-2)))%mod;
		}
	cout<<f[n][n]<<endl;
	return 0;
}

Measured memory_bytes: 94848
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/
 
const int mx=200010;
const ll mod=1e9+7;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  rep(i,n)rep(j,10) cin >> f[i][j];
  vector<vector<ll>> p(n, vector<ll>(11));
  rep(i,n)rep(j,11) cin >> p[i][j];

  ll ans = -longinf;
  for(int i=1; i<1024; i++){
    ll res = 0;
    rep(j,n){
      int cnt = 0;
      rep(k,10)if(f[j][k]==1 && bit(i,k)) cnt++;
      res += p[j][cnt];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    if (n - m) printf("No\n");
    else printf("Yes\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,k;
  cin >> n >> k;
  double answer = 0.0;
  FOR(i,1,n+1) {
    double v = i;
    double tmp = 1.0;
    while(v<k) {
      v*=2;
      tmp /= 2;
    }
    answer += tmp;
  }
  answer /= n;
  cout << setprecision(20) << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);

int main() {
  int n,m; cin >> n >> m;
  vector<int> a(m);
  rep(i,m) cin >> a[i];
  int s = 0;
  rep(i,m) {
    s += a[i];
  }
  if (n-s >= 0) cout << n-s << endl;
  else cout << -1 << endl;
  return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n,k;
    cin>>n>>k;
    
    int arr[n];
    
    for(int i=0;i<n;i++)
    cin>>arr[i];
    
    sort(arr,arr+n);
    
    long long int sum=0;
    
    for(int i=0;i<k;i++)
    {
      sum+=arr[i];   
    }
    
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3652
#使用ワードを格納していく配列
wordlist = []
#最後に使った単語の最後の文字を格納
last = ""
#使用単語数を入れる
num = gets.to_i

#単語数分ループを回し精査
for i in 1..num do
	#発言単語取得
  	word = gets.chomp #改行する
  	#初登場の単語か？
  	if wordlist.include?(word)
            puts "No"
            exit
        end
  #初登場でないなら配列に格納
  wordlist.push(word)
  #2回目以降から最後の文字と合ってるか？
  if i > 1
  	if word[0] != last
            puts "No"
            exit
    end
  end
  #２つの審査に通ればlast変数に最後の文字を入れる
  last = word[-1]
end

puts "Yes"


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

long long gcd(long long a, long long b) {
  long long _max = a > b ? a : b;
  long long _min = a > b ? b : a;
  if (!(_max%_min)) return _min;
  else return gcd(_min, _max%_min);
}
 
long long lcm(long long a, long long b) {
  return a/gcd(a,b)*b;
}


void solve(long long N, std::vector<long long> A){
    double ans=0.0;
    for(auto a:A){
        ans += 1.0/(double)a;
    }
    printf("%.6lf\n", 1.0/ans);
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 


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

i64 N; cin >> N;
VI A(N); invec(A);

for(int a: A){
    if (a % 2 == 0){
        if (a % 3 && a % 5) {
            cout << "DENIED\n";
            return 0;
        }
    }
}

cout <<"APPROVED\n";

return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NK = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long result = 0;
            for(int j = 0; j < NK[0]; j++)
            {
                if (j == 0)
                {
                    result = NK[1];
                }
                else
                {
                    result *= (NK[1] - 1);
                }
            }
            Console.WriteLine(result);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 28024
#include <bits/stdc++.h>
#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
using namespace std;
int main(){
    IOS;
    int x,y;
    cin>>x>>y;
    if(x>=y){
    cout<<"No\n";
    return 0;
    }
    if(x<=(y/2)&&(y%2)==0&&y<=(x*4))
    cout<<"Yes\n";
    else
    cout<<"No\n";
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int L,z;
    cin >> L;
    int count = 0;
    for(int i = 1; i <= L; i++){
        cin >> z;
        if(i != z){
            count++;
            if(count > 2){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <ctime>
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<ll,ll> abcd;

const int N=1000010;

int n,p[N];
ll a[N],b[N],c[N];
map<ll,int> vis,ct,Sqrt;
map<ll,ll> op;

inline void Pre(){
  for(int i=2;i<=1000000;i++){
    if(!p[i]) p[++*p]=i;
    for(int j=1;j<=*p && 1LL*p[j]*i<=1000000;j++){
      p[p[j]*i]=1; if(i%p[j]==0) break;
    }
  }
  for(int i=1;i<=*p;i++) Sqrt[1LL*p[i]*p[i]]=p[i];
}

vector<abcd> v;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

inline void read(ll &x){
  char c=nc(); x=0;
  for(;c>'9'||c<'0';c=nc());for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
}

inline void read(int &x){
  char c=nc(); x=0;
  for(;c>'9'||c<'0';c=nc());for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
}

int ans;

inline void work(int i){
  b[i]=1; c[i]=1;
  for(int j=1;j<=*p && 1LL*p[j]*p[j]<=a[i] && p[j]<=2200;j++)
    if(a[i]%p[j]==0){
      int cnt=0; while(a[i]%p[j]==0) a[i]/=p[j],cnt++;
      cnt%=3; for(int k=1;k<=cnt;k++) c[i]*=p[j];
      if(cnt) for(int k=cnt+1;k<=3;k++) b[i]*=p[j];
    }
  if(Sqrt[a[i]])
    c[i]*=a[i],b[i]*=Sqrt[a[i]];
  else
    c[i]*=a[i],b[i]*=a[i]*a[i];
  ct[c[i]]++;
  if(c[i]>b[i]) swap(b[i],c[i]);
  op[c[i]]=b[i];
}

int main(){
  read(n); Pre();
  for(int i=1;i<=n;i++) {
    read(a[i]),work(i);
  }
  for(auto c : op){
    if(c.fi==c.se) ans++;
    else ans+=max(ct[c.fi],ct[c.se]);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 42880
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, l);
    vector<string> s; s.resize(n);
    scn(n, s);
    sort(all(s));
    rep(i, n)cout << s[i];
    kara;

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>

int main(void) {
  int value;
  char color[50];
  scanf("%d", &value);
  scanf("%s", color);
  if ( value < 3200 ) {
    printf("red\n");
  } else {
    printf("%s\n", color);
  }
  return 0;
}

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

bool a[1000][1000];
int h = 0;
int w = 0;

struct item{
    int i;
    int j;
    int d;
    item(int i, int j, int d){
        this->i = i;
        this->j = j;
        this->d = d;
    }
};

queue<item> q;

void addq(int i, int j, int d){
    if(!a[i][j] && 0 <= i && 0 <= j && i < h && j < w){
        a[i][j] = true;
        q.push(item(i, j, d));
    }
}

int main(){
    scanf("%d %d", &h, &w);

    for(int i = 0; i < h; i++){
        char c[1000];
        scanf("%s", c);
        for(int j = 0; j < w; j++){
            a[i][j] = (c[j] == '#');
            if(a[i][j]){
                q.push(item(i, j, 0));
            }
        }
    }

    int d = 0;
    while(!q.empty()){
        item t = q.front();
        q.pop();
        addq(t.i - 1, t.j, t.d + 1);
        addq(t.i, t.j - 1, t.d + 1);
        addq(t.i + 1, t.j, t.d + 1);
        addq(t.i, t.j + 1, t.d + 1);
        d = t.d;
    }
    printf("%d", d);
}

Measured memory_bytes: 13328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    a=100*a+10*b+c;
    if(a%4==0)
    {
    	cout<<"YES"<<endl;
    	return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}

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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e6;
const ld pi = acos(-1);
const int mod = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
    fr(i, 0, (int)A.size()) out << A[i] << " ";
    return out;
}


int32_t main() {IOS 
    int n,m,k,cnt=0;  cin>>n>>m>>k;
    char A[n][m];   fr(i,0,n)   fr(j,0,m)   cin>>A[i][j];
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<(1<<m);j++){
            int ans = 0;
            for(int row=0;row<n;row++){
                for(int col = 0;col<m;col++){
                    if(A[row][col] == '#' and ((1<<row)&i) and ((1<<col)&j))  
                        ans++;
                }
            }
            if(ans == k) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int L=-1,R=100001,l,r,n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>l>>r;
		L=max(L,l);
		R=min(R,r);
	}
	cout<<max(R-L+1,0);
    return 0;
}


Measured memory_bytes: 3660
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

string S;
ll X;

int Main() {
    cin >> X;
    ll amount = 100;
    ll cnt = 0;
    while(amount < X) {
        cnt++;
        amount *= 1.01;
    }
    
    cout << cnt << endl;
    
    return 0;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3616
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ps <- getIntList
    print $ solve (head ps) ps

solve min (p : []) = if min >= p then 1 else 0
solve min (p : ps) = if min >= p then 1 + solve p ps else solve min ps


Measured memory_bytes: 4476
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#define REP(i,n) for (long long i=0;i<(n);i++)
using namespace std;
template<typename V,typename Weight>
class Dijekstra {
private:
	struct edge {
		Weight dist;V node;V prev;
		bool operator<(edge const& a) const {
			return dist < a.dist;
		}
		bool operator>(edge const& a) const {
			return dist > a.dist;
		}
	};
	//vector<V> trace;
	vector<vector<pair<V,Weight>>> E;
	V const sz;
public:
	Weight const inf = numeric_limits<Weight>::max();
	vector<Weight> D;
	Dijekstra(V v) :
		E(v),sz(v),D(v,inf) {}

	void inline addEdgeDirected(V from,V to,Weight dis){
		E[from].emplace_back(make_pair(to,dis));
	}
	void inline addEdgeUndirected(V from,V to,Weight dis){
		E[from].emplace_back(make_pair(to,dis));
		E[to].emplace_back(make_pair(from,dis));
	}

	V size() {return sz;}
	Weight & operator[] (V n) { if (0 <= n && n < sz) return D[n];} 

	void dijekstra(V start){
		priority_queue<pair<Weight,V>,vector<pair<Weight,V>>,greater<pair<Weight,V>>> que;
		D[start] = 0;
		que.push(make_pair(0,start));
		while(!que.empty()){
			pair<Weight,V> cur = que.top();que.pop();
			Weight d = cur.first;
			V v = cur.second;
			if (D[v] < d) continue; //既により最適が見つかっている
			for(V i = 0;i < E[v].size();i++){
				V next = E[v][i].first;
				Weight newCost = d + E[v][i].second;
				if (D[next] > newCost) {
					D[next] = newCost;
					que.push(make_pair(newCost,next));
				}
			}
		}
	}
/*
	vector<V> show_trace(V start,V goal){ // startからgoalの最短距離上のノード
		vector<V> ret;
		for (V node = goal;node != start;node = trace[node]) ret.push_back(node);
		ret.push_back(start);
		return ret; // 配列の先頭がgoal,末尾がstart
	}
*/
};

int main(void){
	cin.tie(0);
    ios::sync_with_stdio(false);
	long V,E,R;
	long s,t,d;
	cin >> V >> E >> R;
	Dijekstra<long,long> dij(V);

	REP(i,E){
		cin >> s >> t >> d;
		dij.addEdgeDirected(s,t,d);
	}
	dij.dijekstra(R);
	REP(i,V) {
		if (dij[i] == dij.inf) cout << "INF" << endl;
		else cout << dij[i] << endl;
	}

	return 0;
}





Measured memory_bytes: 19408
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    s=list(input())
    s[K-1]=s[K-1].lower()
    print(*s,sep="")





if __name__ == "__main__":
    main()

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

#define ll long long
#define endl '\n'
#define pb push_back
#define READ(file) freopen(FILE, "r", stdin)
#define WRITE(file) freopen(FILE, "w", stdout)
#define loop(i, s, e) for (ll i = s; i < e; i++)

using namespace std;

// #define cases

void test(size_t t)
{
}

void solve()
{
    int a, b;
    cin >> a >> b;

    cout << (a + b) % 24 << endl;
}

int main()
{
    // ios::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

#ifdef cases
    size_t T;
    cin >> T;
    for (size_t t = 1; t < T + 1; t++)
        test(t);
#else
    solve();
#endif

    int c;
    cin >> c;
    return 0;
}


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

int main() {
  int X,Y;
  cin >> X >> Y;
  
  for(int i=0;i<=X;i++){
  int t = X-i;
    int asi = 2*i + 4*t; 
      if(asi == Y){
  cout << "Yes" << endl;
  return 0;
  }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int main()
{
	long long int N, M, A, sumOfA = 0;
	cin >> N >> M;
	for(int i = 0; i < M; i++)
	{
		cin >> A;
		sumOfA += A;
		if(sumOfA > N)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << N - sumOfA << endl;
	return 0;
}

Measured memory_bytes: 3628
N=parse(Int,readline())
K=-ones(Int,N)
for _=1:N
	A=parse(Int,readline())
	L=0
	R=N
	while R-L>1
		M=div(L+R,2)
		if K[M]<A
			R=M
		else
			L=M
		end
	end
	K[R]=A
end
id=1
while id<N&&K[id+1]>=0
	id+=1
end
println(id)


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

using namespace std;
typedef unsigned long long ll;
const int INF = 1e9;
const ll mod = 1e9 + 7;

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

int main(){
setup();
	ll T = 1;
	//cin >> T;	
	while (T--){
		string s; cin >> s;
		ll tot = 0;
		for (int i = 0; i<s.size(); i++){
			ll num = (int) s[i] - '0';
			tot+=num;
		}
		if (tot%9 == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 3728
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int n; cin >> n;
    vector<vector<int> > a(2, vector<int>(n));
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }

    //下に降りるポイントをずらしていく
    int ans = 0;
    for(int i = 0; i < n; i++){
        int candies = 0;
        for(int j = 0; j <= i; j++){
            candies += a[0][j];
        }
        for(int k = i; k < n; k++){
            candies += a[1][k];
        }

        chmax(ans, candies);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
//using
using namespace std;
/*using vi = vector <int>;
using vs = vector <string>;
using vc = vector <char>;*/
//vector<vector<char> > hyou(N, vector<char>(N));
//define
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
//グローバル変数宣言
int a=0,b=0,c=0,d=0,n,k;

signed main(){
    cin>>n>>k;
    vector<int>x(n);
    rep(i,n)cin>>x[i];
    rep(i,n)
    {
        if(x[i]>k)a=x[i]-k; else a=k-x[i];
        b=min(a,x[i]);
        c+=2*b;
    }
    print(c);
}


Measured memory_bytes: 3580
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<string.h>
#include<map>
#include<cmath>
#include<stack>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define pb push_back
//#define int long long
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const double Rad_to_deg=45.0/atan(1.0);
inline ll floor(const ll&a,const ll&b){return a/b;}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
const ll INF=4223372036854775807,max_n=100010,mod=998244353;
inline int cal(int x){int res=0;while(x){x/=10;res++;}return res;}
inline ll ceil(const ll&a,const ll&b){if(a%b==0)return a/b;return a/b+1;};
inline ll pow(ll a,ll b,ll 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;}
inline int mul(int a,int b){return (ll)a*b%mod;}
int b[max_n];
int a[max_n];
ll ans;
int main()
{
	b[0]=0x3f3f3f3f;
	int n;cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		cin>>b[i];
	}
	a[n]=b[n-1];
	ans+=a[n];
	for(int i=n-1;i>=1;i--)
	{
		a[i]=min(b[i],b[i-1]);
		ans+=a[i];
	}
	cout<<ans;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n;
    long long ans=0;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for (int i=0; i<n; i++){
        if (i>0 && a[i-1]%2==1 && a[i]>0){
            a[i]--;
            ans++;
        }
        ans+=a[i]/2;
    }
    printf("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 512