akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sax(x) cout << "!!!!!!!!!!! " << #x << " = " << x << '\n'
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)
#define one(x) x.insert(x.begin(), 0);
#define TCT template <class T>
#define TCT12 template <class T1, class T2>
#define IS istream
#define OS ostream
#define OP operator

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//tree_order_statistics_node_update> imsi;

TCT IS& OP>>(IS &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; /*O << '\n';*/ return O;}
TCT OS& OP<<(OS &O, const unordered_set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT IS& OP>>(IS &I, deque<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const deque<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, priority_queue<T> v) {while (!v.empty()) {O << v.top() << ' '; v.pop();} return O;}
TCT OS& OP<<(OS &O, stack<T> v) {while (!v.empty()) {O << v.top() << '\n'; v.pop();} return O;}
TCT OS& OP<<(OS &O, queue<T> v) {while (!v.empty()) {O << v.front() << ' '; v.pop();} return O;}
TCT12 IS& OP>>(IS &I, pair<T1,T2>& p) {return I >> p.first >> p.second;}
TCT12 OS& OP<<(OS &O, const pair<T1,T2>& p) {return O << '(' << p.first << ' ' << p.second << ')';}
TCT12 OS& OP<<(OS &O, const unordered_map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
TCT12 OS& OP<<(OS &O, const map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
typedef pair<int,int> pii;
typedef vector<int> vi;




void _main() {
        int n; cin >> n;
        vector<int> b(n - 1); cin >> b;
        vector<int> a(n, - 1);
        for (int i = 0; i + 1 < n; i++) {
                if (a[i] == -1) a[i] = a[i + 1] = b[i];
                else a[i] = min(a[i], b[i]), a[i + 1] = b[i];
        }

        cout << accumulate(all(a), 0);
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n;
    ll k,t;
    cin>>k>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(rall(v));
    ll maxi=v[0];
    ll sum=accumulate(all(v),(ll)0);
    sum=v[0]-(sum-v[0])-1;
    if(sum<0) cout<<0<<endl;
    else cout<<sum<<endl;
    return 0;
}


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

using namespace std;

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

const int vx[9] = { -1, -1, 0, 1, 1, 1, 0, -1, 0 }, 
          vy[9] = { 0, 1, 1, 1, 0, -1, -1, -1, 0 };

int main() {
	ll H, W;
	int N;
	ll ans[10]{};

	map<P, int> cnt;

	cin >> H >> W >> N;
	for (int i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		for (int j = 0; j < 9; j++) {
			ll nx = a + vx[j], ny = b + vy[j];
			if (nx < 1 || ny < 1 || nx >= H - 1 || ny >= W - 1)continue;
			cnt[P(nx, ny)]++;
		}
	}
	ll tmp = (H - 2) * (W - 2);
	for (auto it = cnt.begin(); it != cnt.end(); it++) {
		ans[(*it).second]++;
		tmp--;
	}
	cout << tmp << endl;
	for (int i = 1; i <= 9; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 58496
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod = 1000000007;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    int n;
    cin  >> n;
    vector<int> a;
    for(int i=0; i<n; i++){
        ll x;
        cin >> x;
        a.push_back(x);
    }

    int flag = 0;

    // どのn-1個についても０ならおk
    ll tmp=0;
    for(int i=0; i<n; i++){
        tmp ^= a[i];
    }

    // 出力
    if(tmp != 0) cout << "No" << "\n";
    else if(tmp == 0) cout << "Yes" << "\n";
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
// 区間加算にも対応した BIT
template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

vector<ll> x;
bool cmp(ll i, ll j){
  return x[i] < x[j];
}

int main(){
  ll n,d,a; cin >> n >> d >> a;
  vector<ll> h(n),ids(n),nx(n),nh(n);
  x.resize(n);
  rep(i,n){
    cin >> x[i] >> h[i];
    ids[i] = i;
  }
  sort(ids.begin(),ids.end(),cmp);
  rep(i,n) nx[i] = x[ids[i]],nh[i] = h[ids[i]];
  x = nx, h = nh;
  
  BIT<ll> b(n+10);
  rep(i,n) b.add(i+1,i+2,h[i]);
  
  ll ans = 0;
  
  rep(i,n){
    ll cur = b.sum(i+1,i+2);
    if(cur <= 0) continue;
    ll need = (cur + a - 1)/a;
    ll right = x[i] + d * 2;
    int pos = upper_bound(x.begin(),x.end(),right) - x.begin();
    b.add(i+1,pos+1, -need * a);
    ans += need;
  }
  
  cout << ans << endl;

  
  return 0;
}

Measured memory_bytes: 11136
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
const double PI = 3.14159265358979323846;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
int main() {
	int N;
	scanf("%d", &N);
	vector<int> A(N), k(N + 2, 0);
	A[0] = 0;
	rep(i, 1, N)scanf("%d", &A[i]), k[A[i]]++;
	rep(i, 0, N) {
		printf("%d\n", k[i + 1]);
	}
	return 0;
}

Measured memory_bytes: 4360
import sys
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    u-=1;v-=1
    g[u].append([v,w])
    g[v].append([u,w])
ans = [-1]*n
def dfs(x,y):
    for i,j in g[x]:
        if ans[i] == -1:
            ans[i] = (y+j)%2
            dfs(i,y+j)
dfs(0,0)
for i in ans:
    print(i)

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

#define rep(i, n) for(int i = 0; i < (n); i++)

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

    int M, D; cin >> M >>D;

    int ans = 0;
    for (int m = 4; m <= M; m++) {
        for (int d = 22; d <= D; d++) {
            int d1 = d%10;
            int d2 = d/10;
            if (d1 >= 2 && d2 >= 2 && m == d1 * d2) {
                ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    x, y = input().split()
    table = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6}
    x = table[x]
    y = table[y]
    if x < y:
        print("<")
    elif x == y:
        print("=")
    else:
        print(">")


if __name__ == "__main__":
    main()


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

int main(){
	int n, k;
	cin>>n>>k;
	int a[n];
	for (int i=0;i<n;i++)
		cin>>a[i];
	sort(a, a+n);
	long long int dp[k+1];
	dp[0] = 0;
	for (int i=1;i<=k;i++){
		if (i < a[0]) 
			dp[i] = 0;
		else {
			for(int j=0;j<=n;j++){
				if (j == n){
					dp[i] = 0;
					break;
				}
				if (i >= a[j]) {
					if (!dp[i - a[j]]){
						dp[i] = 1;
						break;
					}
				}
				else
					break;
			}
		}
	}
	if (dp[k] == 1) 
		cout<<"First";
	else
		cout<<"Second";
}

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

int main(void){
  int x; cin >> x;
  for(int i = -118; i <= 119; i++){
    for(int j = -118; j <= 119; j++){
      if(pow(i,5)-pow(j,5) == x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  cout << "草" << endl;
  return 0;
}


Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <map>
using namespace std;
const int maxn = 2e5 + 10;

map < char , int > a;
int n , k;
int r , s , p;
string ss;
int sum , m [ maxn ];

int main ( void )
{
	cin >> n >> k;
	cin >> r >> s >> p;
	a [ 'r' ] = p;
	a [ 's' ] = r;
	a [ 'p' ] = s;
	cin >> ss;
	for ( int i = 0 ; i < ss.size ( ) ; i++ ) {
		if ( i >= k ) {
			if ( ss [ i ] != ss [ i - k ] ) {
				sum += a [ ss [ i ] ];
				m [ i ] = 1;
			} else if ( ss [ i ] == ss [ i - k ] ) {
				if ( m [ i - k ] == 1 ) {
					m [ i ] = 0;
				} else if ( m [ i - k ] == 0 ) {
					m [ i ] = 1;
					sum += a [ ss [ i ] ];
				}
			}
		} else { 
			sum += a [ ss [ i ] ];
			m [ i ] = 1;
		} 
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

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

    int ans_a, ans_b;

    for(int a = -200; a < 200; a++){
        bool flag = false;
        for(int b = -200; b < 200; b++){
            int64_t a5 = 1, b5 = 1;
            rep(tmp, 5){
                a5 *= a;
                b5 *= b;
            }
            if(a5 - b5 == x){
                ans_a = a;
                ans_b = b;
                flag = true;
                break;
            } 
        }
        if(flag) break;
    }

    OUT:
    cout << ans_a << ' ' << ans_b << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<vector>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=5050,P=1e9+7;
int n,u,v,g[N],fa[N],sz[N],f[N][N];
vector<int>ve[N];
void add(int u,int v){ve[u].push_back(v);}
void dfs(int u){
	sz[u]=1;f[u][1]=1;
	for(int v:ve[u])if(v!=fa[u]){
		fa[v]=u,dfs(v);sz[u]+=sz[v];
		ROF(j,sz[u],1){
			f[u][j]=1ll*f[u][j]*f[v][0]%P;
			FOR(k,max(1,j+sz[v]-sz[u]),min(j,sz[v]))
				(f[u][j]+=1ll*f[u][j-k]*f[v][k]%P)%=P;
		}
	}
	FOR(i,1,sz[u]) (f[u][0]+=P-1ll*f[u][i]*g[i]%P)%=P;
	//cout<<u<<':';FOR(i,0,sz[u]) cout<<f[u][i]<<' ';cout<<'\n';
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);g[0]=1;
	FOR(i,2,n) g[i]=1ll*g[i-2]*(i-1)%P;
	FOR(i,2,n) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	dfs(1);
	cout<<(P-f[1][0])%P<<'\n';
} 

Measured memory_bytes: 98688
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN 2000
#define MOD 1000000007

using namespace std;

int S;
int dp[MAXN];

signed main()
{
	IO;
	cin >> S;
	for (int i = 3; i <= S; i++) {
		dp[i] = 1;
		for (int j = i - 3; j >= 3; j--) {
			dp[i] = (dp[i] + dp[i - j]) % MOD;
		}
	}
	cout << dp[S] << endl;
	return 0;
}



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

#define ll long long
#define all(x) x.begin(),x.end()
#define MAX 10000005

ll d[MAX];

int main()
{
    for(int i=1;i<MAX;i++)
    {
        for(int j=i;j<MAX;j+=i)
        {
            d[j]++;
        }
    }

    ll n;
    cin >> n;

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

    cout << alll << endl;


    return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N,Y; cin >> N >> Y;
	int a = 0, b = 0, c = 0;
	int t = Y/1000;

	for (b = 0;10*N-5*b >= t;b++){
		for (c = 0;10*N-5*b-9*c >= t;c++){
			if(t == 10*N-5*b-9*c && N >= b+c){
				a = N-b-c;
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1\n";

	return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean judge = x == 0;
        int result = judge ? 1 : 0;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35448
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.nextLine();
		int k = sc.nextInt();
		for (int i = 0; i < k; i++) {
			if (a >= b) {
				b = b*2;
			} else if (b >= c) {
				c = c*2;
			}
		}
		if (b > a && c> b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 35636
#include<iostream>
#include<cmath>
using namespace std;
int n;
main()
{
	while(cin>>n,n)
	{
		int cnt=0;
		for(int i=0;i*i<=n;i++)
		{
			for(int j=i;i*i+j*j<=n;j++)
			{
				for(int k=j;i*i+j*j+k*k<=n;k++)
				{
					int l=sqrt(n-i*i-j*j-k*k);
					cnt+=k<=l&&i*i+j*j+k*k+l*l==n;
				}
			}
		}
		cout<<cnt<<endl;
	}
}



Measured memory_bytes: 3080
#include<cstdio>
const int N=2e5+3;
int n,m,f,k;char s[N*3];
inline int Out(int k){
	for(int i=1;i<=n;i++){
	  if(f)s[i+k]=s[i+k]=='A'?'B':'A';
	  putchar(s[i+k]);
	}
	puts("");
	return 0;
}
int main(){
	scanf("%d%d%s",&n,&m,s+1);
	for(int i=1;i<=n+n;i++)s[i+n]=i&1?'B':'A';
	for(int i=1;i<=n+n;i++){
	  if(f&&s[1+k]=='B'||!f&&s[1+k]=='A')s[1+k]=s[1+k]=='A'?'B':'A';
	  else ++k,f^=1;
	  if(m==i)return 0*Out(k);
	}
	if(~n&1)return 0*Out(k);
	if(m-(n+n)&1)s[1+k]=s[1+k]=='A'?'B':'A';
	return 0*Out(k);
}

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

int N, n;
pair<int, int>p[300000];
bool ok(int t) {
	priority_queue<int>Q; ll sum = 0;
	for (int i = n - 1; i >= n - t + 1; i--) {
		Q.push(p[i].second); sum += p[i].second;
	}
	if (p[n - t].first*(ll)t >= (ll)sum + p[n - t].second)return 1;
	for (int i = n - t; i > 0; i--) {
		if (!Q.empty() && Q.top() > p[i].second) {
			sum -= Q.top() - p[i].second; Q.pop();
			Q.push(p[i].second);
		}
		if (p[i - 1].first*(ll)t >= (ll)sum + p[i - 1].second)return 1;
	}
	return 0;
}
int main() {
	scanf("%d", &n);
	rep(i, n) {
		int a, b; scanf("%d%d", &a, &b);
		p[i] = { b,a };
	}
	sort(p, p + n);
	int a = 0, b = n;
	while (a != b) {
		int t = (a + b) / 2;
		if (b - a == 1)t = b;
		if (ok(t))a = t;
		else b = t - 1;
	}
	printf("%d\n", a);
}

Measured memory_bytes: 8240
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] w = new int[n];
        int[] v = new int[n];
        for(int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        long[][] dp = new long[2][k + 1];
        for(int i = 0; i < n; i++) {
            dp[1][0] = 0L;
            if(i == 0) {
                for(int j = 1; j <= k; j++) {
                    if(j >= w[i]) {
                        dp[0][j] = v[i];
                    }
                }
                continue;
            }
            for(int j = 1; j <= k; j++) {
                if(j >= w[i]) {
                    dp[i % 2][j] = Math.max(dp[(i - 1) % 2][j], dp[(i - 1) % 2][j - w[i]] + v[i]);
                }
                else {
                    dp[i % 2][j] = dp[(i - 1) % 2][j];
                }
            }
        }
        System.out.println(dp[(n - 1) % 2][k]);
    }
}


Measured memory_bytes: 24776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll d, t, s;
 	cin >> d >> t >> s;
 	if (d <= s * t) {
 		cout << "Yes" << endl;
 	}   
 	else {
 		cout << "No" << endl;
 	}
	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define debug(x) cerr<<#x<<":"<<x<<endl;

signed main() {
  int n,m;cin>>n>>m;
  vector<int> a(n),sm(n+1,0);

  for(int i=0;i<n;++i) {
    cin>>a[i];
    // mod Mで累積和をとる
    a[i]%=m;
    (sm[i+1] += sm[i] + a[i]) %= m;
  }

  // mod Mで分類してカウント
  map<int,int> mp;
  for(int i=0;i<n;++i) ++mp[sm[i+1]];

  int ans = 0;
  for(auto &&mi: mp){
    // 要素が0の時は別
    if(mi.first==0){
      ans += max((1+mi.second)*mi.second/2, 0LL);
    }else{
      ans += max((1+mi.second-1)*(mi.second-1)/2, 0LL);
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 5760
import math
import fractions
import collections
import itertools
A,B,C,D=map(int,input().split())
tairyoku=[A,C]
cnt=0
while min(tairyoku)>0:
    if cnt%2==0:
        tairyoku[1]=tairyoku[1]-B
    if cnt%2==1:
        tairyoku[0] = tairyoku[0] - D
    cnt=cnt+1
if tairyoku[0]<=0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 77384
N = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1
t = [ac, wa, tle, re]        
for i in range(4):
    if i == 0:
        print('AC x ' + str(ac))
    if i == 1:
        print('WA x ' + str(wa))                    
    
    if i == 2:
        print('TLE x ' + str(tle))
    if i == 3:
        print('RE x ' + str(re))     

Measured memory_bytes: 80196
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(Integer.parseInt(S.substring(0, 2)) < 13 && Integer.parseInt(S.substring(2, 4)) < 13 && Integer.parseInt(S.substring(0, 2)) > 0 && Integer.parseInt(S.substring(2, 4)) > 0) {
			System.out.println("AMBIGUOUS");
		} else if(Integer.parseInt(S.substring(0, 2)) < 13 && (Integer.parseInt(S.substring(2, 4)) > 12 || Integer.parseInt(S.substring(2, 4)) == 0) && Integer.parseInt(S.substring(0, 2)) > 0) {
			System.out.println("MMYY");
		} else if((Integer.parseInt(S.substring(0, 2)) > 12 || Integer.parseInt(S.substring(0, 2)) == 0) && Integer.parseInt(S.substring(2, 4)) < 13 && Integer.parseInt(S.substring(2, 4)) > 0) {
			System.out.println("YYMM");
		} else {
			System.out.println("NA");
		}
	}
}


Measured memory_bytes: 22740
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int m,n,cnt;
  string s[55]={},t[55]={};
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    cin >> s[i];
  }
  for(int i=0; i<m; i++) {
    cin >> t[i];
  }
  for(int i=0; i<n-m+1; i++) {
    for(int j=0; j<n-m+1; j++) {
      if(s[i][j]==t[0][0]) {
        cnt=0;
        for(int k=0; k<m; k++) {
          for(int l=0; l<m; l++) {
            if(t[k][l]==s[i+k][j+l]) {
              cnt++;
            }
          }
        }
        if(cnt==m*m) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}


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



int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL); 
    long long int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++){
        long long int f=n/i;
        sum+=i*(f*(f+1))/2;
    }
    cout<<sum<<endl;
  
  
}
  
    






  
  
  





Measured memory_bytes: 3632
import math

n = int(input())

r = [0] * (n + 1)

def rr(i, j, k, s):
    if i == j and j == k:
        r[s] = r[s] + 1
    elif i == j or j == k or k == i:
        r[s] = r[s] + 3
    else:
        r[s] = r[s] + 6

for i in range(1, n + 1):
    ii = i * i
    if ii > n:
        break
    for j in range(1, i + 1):
        jj = j * j
        ij = i * j
        if ii + jj + ij > n:
            break
        for k in range(1, j + 1):
            kk = k * k
            ik = i * k
            jk = j * k

            ss = ii + jj + kk + ij + jk + ik
            if ss > n:
                break

            rr(i, j, k, ss)


for i in range(1, n + 1):
    print(r[i])

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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007

void solve()
{
	ll k,ans=0;
	cin>>k;
	for(ll i=1;i<=k;i++)
	{
		for(ll j=1;j<=k;j++)
		{
			for(ll l=1;l<=k;l++)
			{
				ans+=__gcd(__gcd(i,j),l);
			}
		}
	}
	cout<<ans;
}

int main() 
{
	FAST
	ll t=1;	
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}
    

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))

cnt=0
for i in range(n):
  a=list(map(int,input().split()))
  total=0
  for a_,b_ in zip(a,b):
    total+=a_*b_
  if 0 < total+c:
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
def prime(n):
    N=[1 for i in range(n+1)]
    N[0],N[1]=0,0
    for i in range(4,n+1,2):N[i]=0
    for i in range(3,int(n**0.5)+1):
        if N[i]==1:
            for j in range(i*2,n+1,i):
                N[j]=0
    return [i for i,j in enumerate(N) if j==1]


n=int(input())
num=prime(55555)
cnt,A=0,[]
for i in num:
    if i%5==1:
        A.append(i)
        cnt +=1
    if cnt==n:
        print(*A);exit()

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

using namespace std;

#define ll long long int

ll dp[100056][4];
int n;
ll arr[100056][4];

ll solve(ll idx, ll prev) {
    if (idx > n) {
        return 0;
    }

    if (dp[idx][prev] != -1) {
        return dp[idx][prev];
    }

    ll ans = 0;
    for (int i = 1; i <= 3; i++) {
        if (i != prev) {
            ans = max(ans, solve(idx+1, i) + arr[idx][i]);
        }
    }
    return dp[idx][prev] = ans;
}

int main() {
    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> arr[i][1] >> arr[i][2] >> arr[i][3];
    }

    memset(dp,-1,sizeof(dp));

    ll ans = 0;

    ans = max(ans, solve(2,1) + arr[1][1]);
    ans =  max(ans, solve(2,2) + arr[1][2]);
    ans = max(ans,solve(2,3) + arr[1][3]);

    cout << ans << endl;

    return 0;
}
    

Measured memory_bytes: 12800
def main():
    s = input()
    t = input()

    n = len(s)

    charmap = dict()
    usedchar = set()

    for i in range(n):
        if s[i] not in charmap:
            if t[i] in usedchar:
                print('No')
                return
            charmap.update({s[i]: t[i]})
            usedchar.add(t[i])
        elif charmap[s[i]] != t[i]:
            print('No')
            return

    print('Yes')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(obj) (obj).begin(), (obj).end() //イテレータの簡略化（コンテナじゃないと使えない）
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 100100100;

// 最大公約数
int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

// 最小公倍数
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

/* 二分探索 */

//indexが条件を満たすかどうか
bool isOK(int index, int key, vector<int> a) {
    if (a[index] >= key) return true;
    else return false;
}

//汎用的な二分探索のテンプレ
int meguru_binary_search(int key, vector<int> A){
    int ng = -1; // lowerの時は-1, upperの時は(int)A.size() //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)A.size(); // lowerの時は(int)A.size(), upperの時は-1 // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if(isOK(mid, key, A)) ok = mid;
        else ng = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている(lowerだと) */
    return ok;
}
/* lower_boundとかでイテレータから配列の添え字を求めたいとき(lower_bound(v.begin(),v.end(),hoge)-v.begin())というようにする */
//distanceも使える

//三項演算子 ?:

int main(void)
{   int n ;
    cin >> n;
    string s;
    cin >> s;
    vector<int> sb(n), sw(n);
    if(s[0] == '.'){
        sb[0] = 0;
        sw[0] = 1;
    }
    else{
        sb[0] = 1;
        sw[0] = 0;
    }
    FOR(i, 1, n){
        if(s[i] == '.'){
            sb[i] = sb[i - 1];
            sw[i] = sw[i - 1] + 1;
        }
        else{
            sb[i] = sb[i - 1] + 1;
            sw[i] = sw[i - 1];
        }
    }
    int ans = sw[n - 1];
    REP(i, n) ans = min(ans, sb[i] + sw[n - 1] - sw[i]);
    cout << ans << endl;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define debug(x) cerr << #x << ": " << x << "\n";
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=(int) 1e5;
static const int MOD=(int) 1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int N,M,a,b,cunt,max_bridge=-1;
P A[MAX+2];

bool comp(P l,P r){
    if(l.second != r.second) return l.second < r.second;
    return l.first  < r.first;
}

void solve(){
    sort(A,A+M,comp);
    for(int i=0;i<M;i++){
        if(A[i].first > max_bridge){
            max_bridge = A[i].second - 1;
            cunt++;
        }
    }
    cout << cunt <<"\n";
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i=0;i<M;i++) {
        cin >> a >> b;
        A[i] = make_pair(a,b);
    }
    solve();
    
    return 0;
}


Measured memory_bytes: 1024
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m, d = ns()
    if d == 0:
        l = n
    else:
        l = 2 * (n - d)
    tmp = l * (m - 1) / pow(n, 2)
    print(tmp)


if __name__ == '__main__':
    main()


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

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int count=0;
    int countb=0;
    for(int i=0;i<n;i++){
        if(s[i]=='a'){
            count++;
            if(count<=a+b){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        else if(s[i]=='b'){
            if(countb<b){
                count++;
            }
            if(countb<=b){
                countb++;
            }
            if(count<=a+b&&countb<=b){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        else{
            cout << "No" << endl;
        }
    }
}

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

int main()
{
    string s;
    cin >> s;
    rep(i, s.size())
    {
        if (i % 2 == 0 && s[i] == 'L')
        {
            cout << "No" << endl;
            return 0;
        }
        if (i % 2 == 1 && s[i] == 'R')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
// Written By NewbieChd
#include <iostream>
#include <iomanip>
#include <cmath>
// #define double long double
using namespace std;

const int maxN = 100003;
const double eps = 1e-10;
inline double absolute(double x) { return x >= 0 ? x : -x; }
inline double square(double x) { return x * x; }

struct Vector {
    double x, y;
    Vector() {}
    Vector(double x, double y) : x(x), y(y) {}
    friend Vector operator+(const Vector& a, const Vector& b) { return Vector(a.x + b.x, a.y + b.y); }
    friend Vector operator-(const Vector& a, const Vector& b) { return Vector(a.x - b.x, a.y - b.y); }
    friend Vector operator*(const Vector& a, const double& b) { return Vector(a.x * b, a.y * b); }
    friend Vector operator/(const Vector& a, const double& b) { return Vector(a.x / b, a.y / b); }
    inline double length() { return sqrt(square(x) + square(y)); }
    inline void read() { cin >> x >> y; }
    inline void write() { cout << fixed << setprecision(10) << x << ' ' << y << '\n'; }
};
inline double distance(Vector a, Vector b) { return sqrt(square(b.x - a.x) + square(b.y - a.y)); }
inline double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
inline double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }

inline Vector project(Vector a, Vector b, Vector c) {
    b = a - b;
    return b * (dot(b, c - a) / square(b.length())) + a;
}
inline Vector reflect(Vector a, Vector b, Vector c) {
    a = project(a, b, c);
    return a * 2 - c;
}

int main() {
    ios::sync_with_stdio(false);
    int Q;
    Vector a, b, c, d;
    for (cin >> Q; Q; --Q) {
        a.read(), b.read(), b = b - a, c.read(), d.read(), d = d - c;
        if (absolute(dot(b, d)) < eps) {
            printf("1\n");
            continue;
        }
        if (absolute(cross(b, d)) < eps) {
            printf("2\n");
            continue;
        }
        printf("0\n"); 
    }
    return 0;
}



Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <ctime>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    long long N,total,m;
    vector<ll> weights;
    cin >> N;
    total = 0;
    for(int i = 0;i<N;i++){
        ll w;
        cin >> w;
        total+= w;
        weights.push_back(w);
    }
    m = total;
    ll current = 0;
    for(auto w :weights){
        current += w;
        m = min(m,abs(total - 2 * current));
    }
    cout << m << endl;
    return 0;
}

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

char kagasan(char A,char B){
	if(A=='r'&&B=='g')return 'b';
	if(A=='r'&&B=='b')return 'g';
	if(A=='g'&&B=='r')return 'b';
	if(A=='g'&&B=='b')return 'r';
	if(A=='b'&&B=='g')return 'r';
	if(A=='b'&&B=='r')return 'g';
}

int main(){
	string STR;
	while(cin>>STR){
		if(STR=="0")break;
		map<string,int>time;
		queue<string>name;
		name.push(STR);
		time[STR]=1;
		int flag=1;
		while(name.empty()==0){
			int mini=1;
			string s=name.front();
			for(int i=0;i<s.size()-1;i++){
				if(s[i]!=s[i+1]){
					mini=0;
					string ka=s;
					ka[i]=kagasan(s[i],s[i+1]);
					ka[i+1]=kagasan(s[i],s[i+1]);
					if(time[ka]==0){
						time[ka]=time[s]+1;
						name.push(ka);
						
					}
				}
			}
			if(mini){
				cout<<time[name.front()]-1<<endl;
				flag=0;
				break;
			}
			name.pop();
		}
		if(flag)cout<<"NA"<<endl;
	}
	return 0;
}


Measured memory_bytes: 2884
#include <iostream>
#include <bits/stdc++.h>
#define scanInt3(x, y, z) scanf("%d %d %d", &x, &y, &z)
using namespace std;

int main() {
	int n, x, t;
	scanInt3(n, x, t);
	
	if(n % x == 0)
		cout << (n / x) * t << endl;
	else
		cout << (int(n / x) + 1) * t << endl;
	
	return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main(){



    long long l,r,m = 2019,ans = 2e9+5;;
        cin>>l>>r;
    if(l%m >= r%m){
        cout<<0<<endl;
    }
   // else if((l%m)== 0 || (r%m) ==0 ){
     //   cout<<0<<endl;
   // }
    else if((r-l)<2019-1){
        for(int  i = l;i<=r;i++){
            for(int  j = l;j<=r;j++){
                if(i!=j)
                ans  = min( ((i%m)*(j%m))%m,ans);
            }
        }
        cout<<ans<<endl;
    }

else cout<<0<<endl;


return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    for(int i = 0; i < n; i++) {
    	cin >> s[i];
    }
    vector<vector<int>> l(n, vector<int>(m));
    vector<vector<int>> r(n, vector<int>(m));
    vector<vector<int>> u(n, vector<int>(m));
    vector<vector<int>> d(n, vector<int>(m));

    for(int i = 0; i < n; i++) {
    	for(int j = 0; j < m; j++) {
    		if(j == 0) {
    			if(s[i][j] == '.') l[i][j] = 1;
    			else l[i][j] = 0;
    		}
    		else {
    			if(s[i][j] == '.') l[i][j] = l[i][j - 1] + 1;
    			else l[i][j] = 0;
    		}
    	}
    }

    for(int i = 0; i < n; i++) {
    	for(int j = m - 1; j >= 0; j--) {
    		if(j == m - 1) {
    			if(s[i][j] == '.') r[i][j] = 1;
    			else r[i][j] = 0;
    		}
    		else {
    			if(s[i][j] == '.') r[i][j] = r[i][j + 1] + 1;
    			else r[i][j] = 0;
    		}
    	}
    }


    for(int j = 0; j < m; j++) {
    	for(int i = 0; i < n; i++) {
    		if(i == 0) {
    			if(s[i][j] == '.') u[i][j] = 1;
    			else u[i][j] = 0;
    		}
    		else {
    			if(s[i][j] == '.') u[i][j] = u[i - 1][j] + 1;
    			else u[i][j] = 0;
    		}
    	}
    }


    for(int j = 0; j < m; j++) {
    	for(int i = n - 1; i >= 0; i--) {
    		if(i == n - 1) {
    			if(s[i][j] == '.') d[i][j] = 1;
    			else d[i][j] = 0;
    		}
    		else {
    			if(s[i][j] == '.') d[i][j] = d[i + 1][j] + 1;
    			else d[i][j] = 0;
    		}
    	}
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
    	for(int j = 0; j < m; j++) {
    		if(s[i][j] == '.') {
    			ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
    		}
    	}
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 67328
#include <cstdio>

using namespace std;
using ld = long double;

ld probHeads[5000];

int main() {
	int n; scanf("%d", &n);
	probHeads[0] = 1;
	for (int i = 0; i < n; ++i) {
		ld p; scanf("%Lf", &p);
		// printf("%Lf\n", p);
		for (int ph = n; ph > 0; --ph) probHeads[ph] = (1-p)*probHeads[ph] + p*probHeads[ph-1];
		probHeads[0] *= 1-p;
	}
	ld ans = 0;
	for (int ph = 0; ph <= n; ++ph) if (ph > n - ph) ans += probHeads[ph];
	printf("%.10Lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define MOD 998244353
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,-1)

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}
//ll fact[]
//inline ll combi(int a, int b) {
//	return mmul(fact[a], mmul(fact_inv[b], fact_inv[a - b]));
//}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

/*int V;
vector<edge> G[MAX_V];
int d[MAX_V]:
void dijkstra(int s) {
priority_queue<P, vector<P>, greater<P>> q;
fill(d, d + V, INF);


}*/
//ll fact[100001], fact_inv[100001];
/*
*/

int h[1002000];
int cost[1002000];
vector<int> g[1002000];
int main() {
	int n;
	cin >> n;
	REP(i, n) {
		int last = -1, x, a, b, k;
		REP(j, n - 1) {
			cin >> k;
			if ((i + 1) < k) {
				a = i + 1;
				b = k;
			}
			else {
				a = k;
				b = i + 1;
			}
			x = (n + 1)*b + a;
			if (last != -1) {
				g[last].push_back(x);
				h[x]++;
			}
			last = x;
		}
	}
	stack<int> st;
	REP(i,1002000) {
		if ((h[i] == 0) && (g[i].size()>0)) st.push(i);
	}
	vector<int> sorted;
	while (!st.empty()) {
		int i = st.top();
		st.pop();
		sorted.push_back(i);
		for (int j : g[i]) {
			h[j]--;
			if (h[j] == 0) st.push(j);
		}
	}
	if (sorted.size() != (n - 1)*n / 2) cout << "-1" << endl;
	else {
		int result = 0;
		REP(i,1002000) cost[i] = 1;
		for (int v : sorted) {
			for (int vv : g[v]) {
				cost[vv] = max(cost[vv], cost[v] + 1);
				result = max(result, cost[vv]);
			}
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 49268
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|i| i.parse().ok().unwrap())
        .collect()
}

fn main() {
    let a_1n = read_vec::<i32>();
    let a_2n = read_vec::<i32>();
    let a_3n = read_vec::<i32>();
    let a = vec![a_1n, a_2n, a_3n];
    let n = read::<i32>();

    let mut bs: Vec<i32> = Vec::new();

    let mut board = vec![[false, false, false],
                        [false, false, false],
                        [false, false, false]];

    for _ in 0..n {
        let b: i32 = read();
        
        for i in 0..3 {
            for j in 0..3 {
                if a[i][j] == b {
                    board[i][j] = true;
                }
            }
        }
    }

    for i in 0..3 {
        if board[i][0] ==  true && board[i][1] == true && board[i][2] == true {
            println!("Yes");
            return;
        }
        if board[0][i] == true && board[1][i] == true && board[2][i] == true {
            println!("Yes");
            return;
        }
    }
    if board[0][0] ==  true && board[1][1] == true && board[2][2] == true {
        println!("Yes");
        return;
    }
    if board[2][0] ==  true && board[1][1] == true && board[0][2] == true {
        println!("Yes");
        return;
    }
    println!("No");
}

Measured memory_bytes: 4352
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}

ll f(ll x){
  ll res = 0;
  for(ll i = (x/4)*4; i <= x; i++){
    res = res ^ i;
  }
  return res;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll a, b;
  cin >> a >> b;
  ll res = f(b);
  if(a > 0)res = res ^ f(a-1);
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

const double g = 9.8;
const double EPS = 1.0e-6;

void kouhoth(int x, int y, int v, vector<double> &allTH)
{
	double K = 1.0*v*v/g;
	double d = K*K*x*x - x*x*(x*x+2*K*y);

	if(d<0) return;
	double kai1 = (K*x + sqrt(d)) / x / x;
	double kai2 = (K*x - sqrt(d)) / x / x;
	if(kai1+EPS>0) allTH.push_back(atan(kai1+EPS));
	if(kai1-EPS>0) allTH.push_back(atan(kai1-EPS));
	if(kai2+EPS>0) allTH.push_back(atan(kai2+EPS));
	if(kai2-EPS>0) allTH.push_back(atan(kai2-EPS));
}

double f(double th, int v, int x)
{
	double K = 1.0*v*v/g;
	double si = sin(th);
	double co = cos(th);
	double ta = tan(th);
	double alpha = -0.5*(1.0+ta*ta)/K;
	double beta = 0.5*K*si*si;
	double kakkononaka = 1.0*x - K*si*co;
	return alpha * kakkononaka*kakkononaka + beta;
}

int main(){
	int n;
	int v, x, y;
	pair<double, double> buf;
	while(cin>>n>>v>>x>>y){
		vector<int> allL;
		vector<int> allB;
		vector<int> allR;
		vector<int> allT;
		vector<double> allTH;
		for(int i=0; i<n; i++){
			int l, b, r, t;
			cin>>l>>b>>r>>t;
			// ³Ê
			if(x<l) continue;
			// ³ÊÈª»
			if(x<r) r = x;
			allL.push_back(l);
			allB.push_back(b);
			allR.push_back(r);
			allT.push_back(t);
			kouhoth(l, b, v, allTH);
			kouhoth(r, b, v, allTH);
			kouhoth(l, t, v, allTH);
			kouhoth(r, t, v, allTH);
		}
		kouhoth(x, y, v, allTH);

		// áQ¨ª éÆ«
		bool okflg = false;
		for(int i=0; i<allTH.size(); i++){
			double th = allTH[i];
			double mauey = f(th,v,x);
			// Oñð
			if(mauey < y){
				// »à»àÍ¢ÄÈ¢
				continue;
			}
			bool dameflg = false;
			for(int j=0; j<allL.size(); j++){
				// ÅÌÉ¨¢Ä MAX(allR[j]) == x ÆÈÁÄ¢éÌÅA
				// êª¯ªsvÉÈÁ½
				if(
					(f(th,v,allL[j])<allB[j]&&f(th,v,allR[j])<allB[j]) ||
					(f(th,v,allL[j])>allT[j]&&f(th,v,allR[j])>allT[j]) ){
						// Êß
						continue;
				} else {
					dameflg = true;
					break;
				}
			}

			// êSÊß·éÁÛ¢Æ«
			if(!dameflg){
				bool butukaruflg = false;
				for(int j=0; j<allL.size(); j++){
					if(allR[j]==x){
						if(y<allT[j] && allT[j]<mauey){
							butukaruflg = true;
							break;
						}
					}
				}
				if(!butukaruflg){
					okflg = true;
					break;
				}
			}
		}
		if(okflg){
			cout<<"Yes"<<endl;
		} else {
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main(void) {
	
	int a,b,c;
	cin >>a >>b >>c;
	
	int ans=0;
	if (c<=a+b+1) {
		ans+=(c+b);
	} else {
		ans+=(a+b+1);
		ans+=b;
	}
	
	cout <<ans <<endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
mx = 0
smx = 0
mxi = 0
for i in range(n):
  ai = int(input())
  if ai > mx:
    smx = mx
    mx = ai
    mxi = i
  elif ai > smx:
    smx = ai
for j in range(mxi):
  print(mx)
print(smx)
for j in range(mxi+1,n):
  print(mx)
    
  

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

int main() {
    
    std::string s;
    cin >> s;
    int count1 = 0, count2 = 0, count3 = 0;
    for(int i = 0; i < 3; i++) {
        if(s[i] == 'a') count1++;
        else if(s[i] == 'b') count2++;
       else if(s[i] == 'c') count3++;
   }
   if(count1 > 1 || count2 > 1 || count3 > 1) cout << "No" << endl;
   else cout << "Yes" << endl;

    return 0;
    }

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

def gcd(c, d):
    while d:
        c, d = d, c % d
    return c

lcm = c * d // gcd(c, d)
b_num = b - (b // c) - (b // d) + (b // lcm)
a_num = a - 1 - ((a - 1) // c) - ((a - 1) // d) + ((a - 1) // lcm)
print(int(b_num - a_num))

Measured memory_bytes: 38384