akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 2*1e5;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    V<ll> dp(4); //_数, A数, AB数, ABC数
    dp[0] = 1;
    rep(i,n)
    {
        V<ll> dp2(4, 0);
        // auto dp2 = dp;
        // cout << dp << endl;
        if(s[i] == 'A')
        {
            rep(j,4) dp2[j] += dp[j];
            dp2[1] += dp[0];
        }
        if(s[i] == 'B')
        {
            rep(j,4) dp2[j] += dp[j];
            dp2[2] += dp[1];
        }
        if(s[i] == 'C')
        {
            rep(j,4) dp2[j] += dp[j];
            dp2[3] += dp[2];
        }
        if(s[i] == '?') //今までに出来た**文字列が全て3倍になる
        {
            rep(j,4) dp2[j] = dp[j] * 3;
            // dp2[0] += dp[0];
            dp2[1] += dp[0];
            // dp2[1] += dp[1];
            dp2[2] += dp[1];
            // dp2[2] += dp[2];
            dp2[3] += dp[2];
            // dp2[3] += dp[3];
        }
        rep(j,4) dp2[j] %= MOD;
        swap(dp, dp2);
    }
    // cout << dp << endl;
    cout << dp[3] % MOD << endl;
    return 0;
}

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

#define NMAX 101

using namespace std;

int code, digit, prevDigit;
bool flag;

int main()
{
    cin >> code;
    if(code < 100)
    {
        cout << "Bad\n";
        exit(0);
    }
    prevDigit = code % 10;
    code /= 10;
    digit = code % 10;
    while(code)
    {
        if(prevDigit == digit)
            flag = 1;
        code /= 10;
        prevDigit = digit;
        digit = code % 10;
    }
    if(prevDigit == digit)
        flag = 1;
    cout << (flag == 1 ? "Bad\n" : "Good\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll P[100], L[100];
ll f(ll n, ll x) {
	if (n != 0 && x == 1) {
		return 0;
	}
	if (n == 0) {
		return 1;
	}
	if (L[n] == x) {
		return P[n];
	}
	if (L[n] / 2 + 1 > x) {
		return f(n - 1, x - 1);
	} else if (L[n] / 2 + 1 == x) {
		return P[n - 1] + 1;
	}
	return f(n - 1, x - (L[n] / 2 + 1)) + P[n - 1] + 1;
}
ll solve() {
	var(ll, n, x);
	P[0] = L[0] = 1;
	rep(i, 1, 51) {
		P[i] = P[i - 1] * 2 + 1;
		L[i] = L[i - 1] * 2 + 3;
	}
	ll ans = f(n, x);
	return ans;
}
int main() {
	print(solve());
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N;
    cin>>N;
    vector<pair<int,int>> P(N);
    rep(i,N){
        int a,b;
        cin>>a>>b;
        P[i]={b,a};
    }
    sort(ALL(P));

    ll time=0;
    rep(i,N){
        time+=P[i].second;
        if(time>P[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 1792
def check(listx,s):
	num = (listx[-2]+listx[1])%2
	if num!=listx[0] and s[0]=="o": return True
	elif num==listx[0] and s[0]=="x": return True
	else: return False
n = int(input())
s = input()
x,flag,ans = [[1,1],[1,0],[0,1],[0,0]],False,""
for i in range(4):
	for j in range(1,n):
		if (s[j]=="o" and x[i][-1]==1) or (s[j]=="x" and x[i][-1]==0): x[i].append(x[i][-2])
		else: x[i].append(1-x[i][-2])
	if x[i][0]==x[i][-1] and check(x[i],s):
		flag = True
		break
if flag:
	for k in x[i][:n]:
		if k==1: ans+="S"
		else: ans+="W"
	print(ans)
else: print(-1)

Measured memory_bytes: 7180
h,w =map(int,input().split())
s = [input() for i in range(h)]
dx = [1,1,1,0,0,-1,-1,-1]
dy = [1,-1,0,1,-1,1,-1,0]
s_out =["" for i in range(h)]
for i in range(h):
    for j in range(w):
        count = 0
        if s[i][j] == "#":
                s_out[i] += "#"
                continue
        for k in range(8):
            x = i + dx[k]
            y = j + dy[k]
            
            if x >= 0 and x <= h-1 and y >= 0 and y<= w-1 and s[x][y]=="#":
                count += 1
        s_out[i] += str(count)
for i in s_out:
    print(i)

Measured memory_bytes: 3064
def eratosthenes(N):
    is_prime = {i: True for i in range(2, N+1)}
    primes = []
    for i in range(2, N+1):
        if is_prime[i]:
            primes.append(i)
            if i**2 <= N:
                for j in range(i**2, N+1, i):
                    is_prime[j] = False
    return primes


def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    allgcd = A[0]
    primes = eratosthenes(1000)
    divs = set()
    pairwise_coprime = True
    for a in A:
        if allgcd > 1:
            allgcd = gcd(allgcd, a)
        if not pairwise_coprime:
            continue
        for p in primes:
            if a % p == 0:
                if p in divs:
                    pairwise_coprime = False
                while a % p == 0:
                    a //= p
                divs.add(p)
            if a == 1:
                break
        if a != 1:
            if a in divs:
                pairwise_coprime = False
            divs.add(a)
    if pairwise_coprime:
        print("pairwise coprime")
    else:
        if allgcd == 1:
            print("setwise coprime")
        else:
            print("not coprime")


if __name__ == "__main__":
    main()


Measured memory_bytes: 181432
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll A, B, C;
    cin >> A >> B >> C;
    if ((A == B && A != C && B != C) || (B == C && B != A && C != A) || (A == C && A != B && C != B))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  cout<<'A'<<b[0]<<'C'<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long get_pK1(long long N, long long k) {
    // search for max q: N % (K**q) == 0
    while (N % k == 0) {
        N /= k;
    }
    return N;
}
int main() {
    long long N;
    cin >> N;

    long long ans = 0;
    // exist p.q. (pK + 1) K**q == N
    // q == 0
    {
        long long pK = N - 1;
        if (N > 2) {
            ans = 1; // K == N-1
        }
        for (long long i=2; i*i <= pK; i++) {
            if (pK % i == 0) {
                if (pK / i == i) {
                    ans++;
                    //cerr << i << endl;
                }
                else {
                    ans += 2;
                    //cerr << i << " " << pK/i << endl;
                }
            }
        }
    }

    // q > 0
    // Kの候補
    for (long long ki = 1; ki*ki <= N; ki++) {
        if (N % ki == 0) {
            if (ki >= 2 && ki*ki != N) {
                long long pK1 = get_pK1(N, ki);
                if (pK1 % ki == 1) {
                    //cerr << pK1 << "*" << ki << "^q" << endl;
                    ans++;
                }
            }
            long long pK1 = get_pK1(N, N/ki);
            if (pK1 % (N/ki) == 1) {
                //cerr << pK1 << "*" << ki << "^q" << endl;
                ans++;
            }
        }
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    ll a = 1, b = 1, c = 1;
    rep(i, n){
        a *= 10;
        a %= 1000000007;
        b *= 9;
        b %= 1000000007;
        c *= 8;
        c %= 1000000007;
    }
    cout << ((a + 1000000007 - (b * 2) % 1000000007) % 1000000007 + c) % 1000000007 << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

int c1, c2, c3;

bool check(int x) {
    int c = x % 10, c2;
    while (x /= 10) {
        c2 = x % 10;
        if (abs(c - c2) > 1) {
            return 0;
        }
        c = c2;
    }
    return 1;
}

int next(int x) {
    x++;
    if (check(x)) return x;

    c1 = x % 10;
    x /= 10;
    if (c1 == 0) x--;
    x = next(x);
    c1 = x % 10;
    x *= 10;
    if (c1 > 0) c1--;
    x += c1;
    return x;
}

main() {
    int k;
    cin >> k;
    int cur = 0;
    while (k--) {
        cur = next(cur);
    }
    cout << cur << '\n';
}

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


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

  ll n;
  cin >> n;
  if(n%2LL==1){
    cout << 0 << endl;
    return 0;
  }
  ll ans=0;
  ll div=10;
  while(n>0&&div<2e18){
    ans+=n/div;
    div*=5;
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT32_MAX;

ll i,j;





int main(){
   ll N;
   cin>>N;
   if(N==1)cout<<"Hello World"<<endl;
   else{
      ll A,B;
      cin>>A>>B;
      cout<<A+B<<endl;
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int main(void)
{
	int N; cin >> N;
	vector<int> A(N);
	vector<vector<int>> x(N), y(N);
	rep(i, 0, N) {
		cin >> A[i];
		x[i].resize(A[i]); y[i].resize(A[i]);
		rep(j, 0, A[i])cin >> x[i][j] >> y[i][j];
	}

	int ans = 0;
	for (int bit = 0; bit < (1 << N); bit++) {
		vector<int> B(N, -1);
		bool flag = true;
		rep(i, 0, N) {
			if (bit&(1 << i)) {//if i is honor
				rep(a, 0, A[i]) {
					if ((y[i][a] == 0 && (bit & (1 << x[i][a] - 1))) ||
						(y[i][a] == 1 && !(bit & (1 << x[i][a] - 1))))flag = false;

				}
			}
		}

		if (flag) {
			int tmp = 0;
			rep(i, 0, N)if (bit&(1 << i))tmp++;
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
	string s;

	cin >> s;


	if(s == "Sunny") cout << "Cloudy\n";
	if(s == "Cloudy") cout << "Rainy\n";
	if(s == "Rainy") cout << "Sunny\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N, M;
vector<string> a, b;

int main(void){
    
    scanf("%d %d", &N, &M);
    for(int i = 0; i < N; ++i){ string s; cin >> s; a.push_back(s); }
    for(int i = 0; i < M; ++i){ string s; cin >> s; b.push_back(s); }
    
    for(int i = 0; i <= N - M; ++i){
        for(int j = 0; j <= N - M; ++j){
            vector<string> v;
            for(int y = 0; y < M; ++y){
                string s;
                for(int x = 0; x < M; ++x) s.push_back(a[i + y][j + x]);
                v.push_back(s);
            }
            if(v == b){ printf("Yes\n"); return 0; }
        }
    }
    printf("No\n");
    
    return 0;
}

Measured memory_bytes: 256
// AOJ 0572: Card Game is Fun
// 2017.10.29 bal4u@uu

#include <stdio.h>

int a[5003], b[5003];

char buf[25105], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int la, lb, i, j, ans;

	fgets(p=buf, 16, stdin), la = getint(), p++, lb = getint();
	fgets(p=buf, 25100, stdin);
	for (i = 0; i < la; i++) a[i] = getint(), p++;
	fgets(p=buf, 25100, stdin);
	for (i = 0; i < lb; i++) b[i] = getint(), p++;

	for (ans = 0, i = 0; i < lb; i++) {
		int t = i, k = 0;
		for (j = 0; t < lb && j < la; j++) if (a[j] == b[t]) t++, k++;
		if (k > ans) ans = k;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1880
#include <stdio.h>
int main(){
    int n;
    int x;
    int i = 1;
    scanf("%d", &n);
    while(i<n+1){
      x = i;
        if(x%3==0){
            printf(" %d", i);
        }else{
          while(x>0){
          if(x%10==3){
            printf(" %d", i);
            break;
          }else{
            x /= 10;
          }
        }
      }
      i++;
    }
    printf("\n");
    return 0;
}


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

int main() {
	int A, B;
	int a, b, c;
	cin >> A >> B;
	a = A+B;
	b = A-B;
	c = A*B;
	cout << max({a,b,c}) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    vector<ll> arr({1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51});
    ll k;
    cin >> k;
    cout << arr[k-1] << endl;
    return 0;
}


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

using namespace std;

int main(){

    int N, A, B;
    cin >> N >> A >> B;
    
    string S;
    cin >> S;

    int c = 0, f = 0;
    for (int i = 0; i < S.length(); i++){
        bool flag = false;
        if (S[i] == 'a'){
            if (c < A + B){
                flag = true;
                c ++;
            }
        }else if(S[i] == 'b'){
            if(c < A + B && f < B){
                flag = true;
                c ++;
                f ++;
            }
        }

        if (flag == true){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 896
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if (500*i + 100*j + 50*k == x):
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e3+5;
typedef long long ll;
const int mod=1e9+7;
ll dp[maxn][maxn],sum[maxn][maxn];
int n,m;
int s[maxn],t[maxn];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&t[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i]==t[j])
			{
				dp[i][j]=sum[i-1][j-1]+1;
				dp[i][j]%=mod;
			}
			else
			dp[i][j]=0;
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j];
			sum[i][j]%=mod;
		}
	}
	sum[n][m]++;sum[n][m]%=mod;
	sum[n][m]+=2ll*mod;sum[n][m]%=mod;
	cout<<sum[n][m]<<endl;
 } 

Measured memory_bytes: 62976
import java.util.Scanner;
 
/**
 *
 * @author shota
 */
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();
        
        int distance = s * t;
        
        if(distance >= d ) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35656
#include<stdio.h>
#define NMAX 100000
int bit[NMAX+1];
int input(void);
void add(int i, int x, int n);
int sum(int i);
int main(void)
{
  int command, i, n, q, s, t;
  n = input();
  q = input();
  for (i = 0; i < q; i++) {
    command = input();
    if (!command) {
      s = input();
      t = input();
      add(s, t, n);
    } else {
      s = input();
      t = input();
      printf("%d\n", sum(t) - sum(s - 1));
    }
  }
}

int input(void)
{
  int n = 0, c = getchar_unlocked();
  if (c == '-') {
    c = getchar_unlocked();
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return -n;
  } else {
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return n;
  }
}

void add(int i, int x, int n)
{
  while (i <= n) {
    bit[i] += x;
    i += i & (-i);
  }
}

int sum(int i)
{
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & (-i);
  }
  return s;
}


Measured memory_bytes: 2184
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int n,y;
int flag=0;
std::cin >> n>>y;


for (int t = 0; t <= n; t++) {
  if(flag==1)break;
  for (int f = 0; n >= t+f; f++) {
    if(flag==1)break;
    for (int h = 0; n >= t+f+h; h++) {
      if(t*1000+f*5000+h*10000>y)break;
      if(t*1000+f*5000+h*10000==y && t+f+h==n){
        std::cout <<h<<" "<<f<<" "<<t<<'\n';
        flag=1;
        break;
      }
    }
  }
}

if(flag==0)std::cout << "-1 -1 -1" << '\n';

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int,int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int lc = c * d / __gcd(c, d);
    int ans = b - (a - 1) - (b / c) + ((a - 1) / c) 
        - (b / d) + ((a - 1) / d) + (b / lc) - ((a - 1) / lc);
    cout << ans << "\n";
}

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

#define ll long long

using namespace std;
const int MX = 200'000 + 5; // check bounds!

int n, m;
int h[MX];
vector<int> g[MX];

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        cin >> h[i];

    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int sol = 0;
    for (int i = 1; i <= n; ++i) {
        bool ok = true;
        for (auto nei : g[i])
            if (h[nei] >= h[i])
                ok = false;
        if (ok)
            sol++;
    }

    cout << sol;
    return 0;
}


Measured memory_bytes: 11464
import heapq
N = int(input())
T = [[] for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    T[a].append([b, 1])
    T[b].append([a, 1])


def dijkstra(x):
    d = [float('inf')] * N
    d[x] = 0
    visited = {x}

    # d, u
    hq = [(0, x)]

    while hq:
        u = heapq.heappop(hq)[1]
        visited.add(u)

        for node, cost in T[u]:
            if (node not in visited) and d[node] > d[u] + cost:
                d[node] = d[u] + cost
                heapq.heappush(hq, (d[u]+cost, node))
    return d


B = dijkstra(0)
W = dijkstra(N - 1)

result = [("B" if b <= w else "W") for b, w in zip(B, W)]
print("Fennec" if result.count("B") - result.count("W") > 0 else "Snuke")


Measured memory_bytes: 54944
from collections import Counter
n ,k, q = map(int,input().split())
al = []
for _ in range(q):
    al.append(int(input()))

if k > q:
    for _ in  range(n):
        print('Yes')
    exit()

Ca = Counter(al)

for i in range(1,n+1) :
    if Ca[i] >= q-k + 1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 16384
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

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

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A'){
            int size = 0;
            for(int j = s.size(); j > i; j--){
                if(s[j] == 'Z'){
                    size = j - i + 1;
                    break;
                }
            }
            ans = max(ans, size);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import itertools
from collections import defaultdict
import collections
import math
import sys
import queue
sys.setrecursionlimit(200000)
mod = 1000000007

n, m = map(int, input().split())

graph = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

tf = [False] * (n + 1)
sirube = [0] * (n + 1)
def bfs(v):
    q = queue.Queue()
    q.put([v,0])
    tf[v] = True
    while not q.empty():
        sub = q.get()
        now = sub[0]
        before = sub[1]
        for next in graph[now]:
            if tf[next]:
                continue
            tf[next] = True
            if sirube[next] == 0:
                sirube[next] = now
            q.put([next, now])

bfs(1)
for i in range(2, n + 1):
    if sirube[i] == 0:
        print("No")
        exit()

print("Yes")
for i in range(2, n + 1):
    print(sirube[i]) 

Measured memory_bytes: 48172
fun main() {
    val (n, d) = readLine()!!.split(' ').map { it.toInt() }
    val d2 = 1L * d * d
    val ans = (0 until n).count {
        val (x, y) = readLine()!!.split(' ').map { it.toLong() }
        x * x + y * y <= d2
    }
    println(ans)
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RREP(i,n) RFOR(i,0,n)

const int _N = 3e5 + 100;

int n;

int d[_N];
int main(){
	cin >> n;
	REP(i, n){
		cin >> d[i];
		d[i] /= 10;
	}

	int i=0, cango=0;
	for(;i <= min(cango, n-1);i++){
		cango = max(cango, i+d[i]);
	}
	if(cango<n){
		cout << "no" << endl;
		return 0;
	}

	i=0;cango=0;
	for(;i <= min(cango, n-1);i++){
		cango = max(cango, i+d[n-1-i]);
	}
	if(cango<n){
		cout << "no" << endl;
		return 0;
	}

	cout << "yes" << endl;
}

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

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

	ll res = 1e18;
	res = min(res, a * b * (c % 2));
	res = min(res, a * c * (b % 2));
	res = min(res, b * c * (a % 2));

	cout << res << endl;

	return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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


int main()
{
int n;
cin>>n;
vector<int> a(n,0);
REP(i,n) cin>>a[i];
sort(a.begin(),a.end());
int nn=a[n-1];
int cnt=abs(2*a[0]-nn);
int r=a[0];
for(int i=0; i<n; i++)
{
    if(cnt>abs(2*a[i]-nn))
    {
        r=a[i];
        cnt=abs(2*a[i]-nn);
    }
}
cout<<nn<<" "<<r<<endl;
 }

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int digits(int num) {
    if (num < 10) return 1;
    int count = 1;
    num = num / 10;
    while(num != 0) {
        count++;
        num = num / 10;
    }
    return count;
}

int main() {

    string str;
    while(getline(cin, str)) {
        vector<string> splited = split(str, ' ');
        int a = stoi(splited[0].c_str());
        int b = stoi(splited[1].c_str());
        cout <<  to_string(digits(a + b)) << endl;
    }

    return 0;
}

Measured memory_bytes: 3216
// Contest: AtCoder Beginner Contest 155 (https://atcoder.jp/contests/abc155)
// Problem: F: Perils in Parallel (https://atcoder.jp/contests/abc155/tasks/abc155_f)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

vector<bool> vis;
vi d, cut;
vector<vpi> adj;

void dfs(int v, int p, int e) {
    vis[v] = true;
    for (auto pa : adj[v]) {
        int v2, e2; tie(v2, e2) = pa;
        if (vis[v2]) continue;
        dfs(v2, v, e2);
    }
    if (d[v] && p != -1)
        cut.emplace_back(e), d[v] ^= 1, d[p] ^= 1;
}

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

    int n, m; cin >> n >> m;
    vpi ab(n);
    trav(p, ab) cin >> p.first >> p.second;
    sort(all(ab));
    d.resize(n+1), adj.resize(n+1), vis.resize(n+1);
    rep(i, n)
        d[i] ^= ab[i].second, d[i+1] ^= ab[i].second;

    rep(i, m) {
        int l, r; cin >> l >> r;
        int x = lower_bound(all(ab), pi(l, 0)) - begin(ab);
        int y = upper_bound(all(ab), pi(r, 1)) - begin(ab);
        adj[x].emplace_back(y, i);
        adj[y].emplace_back(x, i);
    }


    rep(i, n+1) {
        if (vis[i]) continue;
        dfs(i, -1, -1);
        if (d[i] == 1)
            cout << "-1\n", exit(0);
    }

    sort(all(cut));
    cout << sz(cut) << '\n';
    trav(e, cut)
        cout << (e + 1) << ' ';
    cout << '\n';

    return 0;
}

Measured memory_bytes: 16252
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
struct flac{
  int p,q;
  flac(int p,int q) : p(p),q(q){}
};

flac sumf(flac f, flac g){
  return flac(f.p*g.q+f.q*g.p, f.q*g.q);
}
bool operator == (flac f, flac g){
  return (f.p*g.q==f.q*g.p);
}
bool operator < (flac f, flac g){
  return (f.p*g.q<f.q*g.p);
}


int solve(flac sum, int& a, int n, flac& target, int bf){
  if(sum==target) return 1;
  if(target<sum) return 0;
  if(n==0) return 0;
  int para = sum.q;
  int ret = 0;
  FOR(i,bf,a){
    if(i*para>a) break;
    ret += solve(sumf(sum,flac(1,i)), a, n-1, target,i);
  }
  return ret;
}

int main(void){
  int p,q,a,n;
  while(cin>>p>>q>>a>>n){
    if(!p&&!q&&!a&&!n) break;
    flac tar = flac(p,q);
    cout<<solve(flac(0,1),a,n,tar,1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 864
#include<bits/stdc++.h>
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main()
{
  int a,b,c;
  while(cin>>a && a){
    cin>>b>>c;
    int x,t = 0,ans = 0;
    FOR(i,0,a-1){
      cin>>x;
      if(c<=x)t = b;
      if(0<t)ans++;
      t--;
    }
    cin>>x;
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3096
import numpy as np

N = int(input())
a = np.zeros((N,3))
for i in range(N):
  a[i][0],a[i][1],a[i][2] = map(int,input().split())

ans = 0

# dpテーブル
dp = np.zeros((N+1,3))

for i in range(N):
  for x in range(3):
    for y in range(3):
      if x == y:
        continue
      dp[i+1][y] = max(dp[i+1][y],dp[i][x]+a[i][y])


print(int(max(dp[N][0],dp[N][1],dp[N][2])))

Measured memory_bytes: 31184
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(long[]);
    writeln(tmp[0] < tmp[2] && tmp[2] < tmp[1] || tmp[0] > tmp[2] && tmp[2] > tmp[1] ? "Yes" : "No");
}



Measured memory_bytes: 256
n=int(input()) 
cnt=0
ans=0

for i in range(n):
    a,b=map(int, input().split())
    if a==b:
        cnt+=1
        if ans < cnt:
            ans = cnt
    else:
        cnt=0

if ans >=3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
def main():
    n = int(input())

    table = [0] * 100
    for i in range(n+1):
        i_str = str(i)
        table[int(i_str[0]) * 10 + int(i_str[-1])] += 1

    num = 0
    for i in range(1, 10):
        for j in range(1, 10):
            num += table[i*10 + j] * table[j*10 + i]

    print(num)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

const int N = 500;

typedef pair<int, int> P;
typedef pair<P, P> Point;

int h, w;
char data[N][N];
Point pos[26];
bool used[26];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

bool check(P p){
  if(p.first < 0 || p.first >= h) return false;
  if(p.second < 0 || p.second >= w) return false;
  return true;
}
     
bool check(char c, P s, P t, int d){
  P n = s;
  n.first += dy[d];
  n.second += dx[d];
  bool f = false;
  while(check(n)){
    if(data[n.first][n.second] == '.'){
      f = true;
    }else if(data[n.first][n.second] != c){
      f = false;
      break;
    }
    if(n == t) break;
    n.first += dy[d];
    n.second += dx[d];
  }
  return f;
}

bool erase(char c){
  P a = pos[c-'A'].first;
  P b = pos[c-'A'].second;
  P s = a, t = b;
  int d;
  bool f = false;
  if(a.first == b.first){
    if(a.second < b.second) d = 1;
    else d = 3;
    if(check(c, s, t, d)) f = true;
  }else if(a.second == b.second){
    if(a.first < b.first) d = 2;
    else d = 0;
    if(check(c, s, t, d)) f = true;
  }else{
    if(data[a.first][b.second] == '.'){
      s = a;
      t = P(a.first, b.second);
      if(a.second < b.second) d = 1;
      else d = 3;
      bool f1 = check(c, s, t, d);
      s = b;
      if(a.first < b.first) d = 0;
      else d = 2;
      bool f2 = check(c, s, t, d);
      if(f1 && f2) f = true;
    }
    if(data[b.first][a.second] == '.'){
      s = b;
      t = P(b.first, a.second);
      if(a.second < b.second) d = 3;
      else d = 1;
      bool f1 = check(c, s, t, d);
      s = a;
      if(a.first < b.first) d = 2;
      else d = 0;
      bool f2 = check(c, s, t, d);
      if(f1 && f2) f = true;
    }
  }
  if(f){
    used[c-'A'] = false;
    data[a.first][a.second] = '.';
    data[b.first][b.second] = '.';
  }
  return f;
}

main(){
  cin >> h >> w;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      cin >> data[i][j];
      if(data[i][j] != '.'){
        if(used[data[i][j]-'A']){
          pos[data[i][j]-'A'].second = P(i, j);
        }else{
          pos[data[i][j]-'A'].first = P(i, j);
          used[data[i][j]-'A'] = true;
        }
      }
    }
  }
  bool f = true;
  int ans = 0;
  while(f){
    f = false;
    for(int i=0;i<26;i++){
      if(used[i]){
        if(erase(i+'A')){
          f = true;
          ans += 2;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

  ll x;
  cin >> x;

  cout << (x / 500) * 1000 + ((x % 500) / 5) * 5 << '\n';

  return (0);
}


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

int main() {
  int N;
  
  cin >> N;
  
  if ( N % 1110 < 10 || N % 1000 % 111 == 0)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}

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

using namespace std;

int pow(int a, int b){
	int result = 1;
	for (int i = 0; i < b; i++){
		result *= a;
	}
	return result;
}

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

	int flag = false;

	if(X==1){
		cout << "1" << endl;
		return 0;
	}

	for (int i = X; i >= 1; i--){

		for (int j = 2; j <= sqrt(i); j++){
			for (int k = 2; true; k++){
				int temp = pow(j, k);	
				
				if(temp == i){
					cout << i << endl;
					return 0;
				}
				if(temp > X){
					break;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s = s.trim().to_string();
    s = s.clone() + &s;

    let mut t = String::new();
    io::stdin().read_line(&mut t).unwrap();
    let t = t.trim();

    let ans = match &s.find(t) {
        &Some(_) => "Yes",
        _ => "No"
    };

    println!("{}", ans);
}



Measured memory_bytes: 5032
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <time.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vd p;
vvi g;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		p=vd(n);
		g=vvi(n);
		vi a(n);
		for(int i=0;i<n;i++){
			int m;
			cin>>p[i]>>m;
			g[i]=vi(m);
			for(int j=0;j<m;j++){
				int v;
				cin>>v;
				v--;
				g[i][j]=v;
				a[v]++;
			}
		}
		double res=1;
		queue<int> q;
		for(int i=0;i<n;i++) if(!a[i]){
			q.push(i);
			res*=(1-p[i]);
		}
		while(!q.empty()){
			int v=q.front();
			q.pop();
			for(int i=0;i<g[v].size();i++){
				int u=g[v][i];
				if(a[u]){
					a[u]=0;
					q.push(u);
				}
			}
		}
		for(int i=0;i<n;i++) if(a[i]){
			q.push(i);
			double tmp=1;
			a[i]=0;
			while(!q.empty()){
				int v=q.front();
				tmp*=p[v];
				q.pop();
				for(int j=0;j<g[v].size();j++){
					int u=g[v][j];
					if(a[u]){
						a[u]=0;
						q.push(u);
					}
				}
			}
			res*=(1-tmp);
		}
		cout<<syosu(9)<<res<<endl;
	}
}

Measured memory_bytes: 3276
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;
map<ll,ll> mpa;

ll powt(ll target,ll repeat){
    ll result=1;
    for(int i=0;i<repeat;i++)result*=target;
    return result;
}

int main(){
    cin>>n>>m;
    z=0;
    /*
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int ij=1;ij<=n;ij++){
                if((i+j)%m==0 and (i+ij)%m==0 and (j+ij)%m==0){
                    C '['<<i<<':'<<j<<':'<<ij<<']';
                    z++;
                }
                
            }
        }
    }
    C z E;
    */
    
    if(m%2){
        C powt(n/m,3) E;
        return 0;
    }
    a=0;b=0;

    for(int i=1;i<=n;i++){
        if(i%(m/2)==0){
            //C i E;
            if(i/(m/2)%2==1)a++;
            else b++;
        }
    }
    //C a<<" "<<b E;
    C powt(a,3)+powt(b,3) E;
    //if()

    //else C powt(n/m,3) E;
    
}



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

using namespace std;

int N;

void solve() {
    int num = 0;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            if (i * 4 + j * 7 == N) {
                num++;
                break;
            }
        }
    }
    if (num > 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

}

int main() {
    cin >> N;
    solve();
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
using ll = long long int;

const int R_MAX = 3005;
const int C_MAX = 3005;
ll dp[R_MAX][C_MAX][4];
ll tre[R_MAX][C_MAX];

int main(){
    int r, c, k;
    cin >> r >> c >> k;
    memset(tre, 0, sizeof(tre));
    for(int i = 0; i < k; i++){
        int ri, ci, vi;
        cin >> ri >> ci >> vi;
        tre[ri][ci] = vi;
    }
    memset(dp, 0, sizeof(dp));
    for(int i = 1; i <= r; i++){
        for(int j = 1; j <= c; j++){
            dp[i][j][0] = max({dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3], dp[i][j-1][0]});
            if (tre[i][j] == 0){
                for(int l = 1; l <= 3; l++){
                    dp[i][j][l] = dp[i][j-1][l];
                }
            }
            else{
                dp[i][j][1] = max({dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3], dp[i][j-1][0]}) + tre[i][j];
                dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][1]);
                for(int l = 2; l <= 3; l++){
                    dp[i][j][l] = max(dp[i][j-1][l-1]+tre[i][j], dp[i][j-1][l]);
                }
            }
        }
    }
    cout << max({dp[r][c][0], dp[r][c][1], dp[r][c][2], dp[r][c][3]});
    return 0;
}

Measured memory_bytes: 355856
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    set<string>P;
    string s;
    cin>>s;
    int k;
    cin>>k;
    string ssans="zzzzzz";
    if(s.size()>5){
        for(int i=0;i<s.size()-4;i++){
            string ss=s.substr(i,5);
            if(ss<ssans)ssans=ss;
        }
        //cout<<ssans<<endl;
    }
    else ssans=s;
    for(int i=0;i<ssans.size();i++){
        for(int j=ssans.size()-i;j>=1;j--)
        P.insert(ssans.substr(i,j));
    }
    int l=1;
    for(auto x:P){
    if(k==l){cout<<x<<endl;return 0;}
    l++;}
}


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


using namespace std;


int main()
{
  int n, k, x, sumv=0;

  cin >> n;
  cin >> k;
  for (int i=0; i<n; i++){
    cin >> x;
    sumv += 2*min(k-x, x);
  }
  cout << sumv << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
using namespace std;

#define Rep(i,l,r) for (int i = (l); i <= (r); ++ i)
#define RepD(i,r,l) for (int i = (r); i >= (l); -- i)
#define RepG(i,x) for (int i = hd[x]; i; i = e[i].nxt)

int a[200000+3], n;  
bool small(int i, int j, int k) {return a[i]<=k && a[j]<=k;}  
bool big(int i, int j, int k) {return a[i]>k && a[j]>k;}  
bool judge(int k)  
{  
    for(int i=0; i<n-1; ++i)  
    {  
        if(big(n+i, n+i+1, k) || big(n-i, n-i-1, k)) return false;  
        if(small(n+i, n+i+1, k) || small(n-i, n-i-1, k)) return true;  
    }  
    return small(1,1,k);  
}  
int main()  
{  
    scanf("%d",&n);  
    for(int i=1; i<n<<1; ++i)  
        scanf("%d",&a[i]);  
    int l=1, r=(n<<1)-1, mid;  
    while(l < r)  
    {  
        mid = l+r>>1;  
        if(judge(mid))  
            r = mid;  
        else  
            l = mid + 1;  
    }  
    printf("%d\n",r);  
    return 0;  
}  


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
int64_t INF = 1LL<<60;



int main() {
  int64_t N,M; cin>>N>>M;
  dsu tree(N);
  rep(i,M){
    int64_t a,b; cin>>a>>b;
    a--;
    b--;
    tree.merge(a,b);
  }
  set<int64_t> S;
  rep(i,N) S.insert(tree.leader(i));
  cout<<S.size()-1; 
}


Measured memory_bytes: 7728
(() => {

    var lines = [];

    require('readline').createInterface({
        input: process.stdin,
    }).on('line', (line) => {
        lines.push(Number(line));
    });

    process.stdin.on("end", () => {
        console.log(fib(lines[0]));
    });

    const memoize = function(proc){
        const cache = {};

        const helper = (n) => {
            if(!cache[n]){
                cache[n] = proc(n);
            }
            return cache[n];
        }

        return helper;
    }

    const fib = memoize((n) => {
        if(n < 2){
            return 1;
        }
        return fib(n - 1) + fib(n - 2);
    });

})();


Measured memory_bytes: 16236
#include<stdio.h>
#include<math.h>
signed main(void)
{
  int A,B,H,M;
  if(~scanf("%d %d %d %d",&A,&B,&H,&M))
  {
    double theta=(60*H-11*M)*M_PI/360.0,x=A-B*cos(theta),y=B*sin(theta);
    return printf("%.20lf",pow(x*x+y*y,0.5)),0;
  }
}

Measured memory_bytes: 2656
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
char s[100005];
int ans[100005];
int main(void){
	scanf("%d%s",&n,s);
	rep(i,n){
		if(s[i]=='x')s[i]=1;
		else s[i]=0;
	}
	rep(p,2)rep(q,2){
		ans[0]=p; ans[1]=q;
		reg(i,0,n-1-2){
			ans[i+2]=ans[i]^ans[i+1]^s[i+1];
		}
		if((ans[n-2]^ans[n-1]^ans[0]==s[n-1]) &&
		(ans[n-1]^ans[0]^ans[1]==s[0])){
			rep(i,n){
				putchar(ans[i]?'W':'S');
			}
			puts("");
			return 0;
		}
	}
	puts("-1");
	return 0;
}






Measured memory_bytes: 768