akhauriyash/Code-Regression huggingface dataset:
t=list(input())
pre_p=False
for i,tt in enumerate(t):
  if tt == 'P':
    pre_p=True
  elif tt == 'D':
    pre_p=False
  elif pre_p:
    t[i] = 'D'
  elif i < len(t)-1:
    if t[i+1] == 'D':
      t[i] = 'P'
    else:
      t[i] = 'D'
  else:
    t[i] = 'D'
    
print(''.join(t))

Measured memory_bytes: 10964
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int a,b,c;

	scanf("%d%d",&a,&b);

	if(a>9 || b>9){
		printf("-1");
		return EXIT_SUCCESS;
	}

	c = a*b;

	printf("%d",c);

	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<pair<int, int>>>;
vector<int> color;
/////black: 1, white: 0, undecided: -1

void dfs(const Graph &G, int u, int this_color){
    color[u] = this_color;
    for (auto next: G[u]){
        int w = next.second;
        int next_u = next.first;
        if (color[next_u] != -1) continue;
        if (w % 2 == 1) dfs(G, next_u, 1 - this_color);
        else dfs(G, next_u, this_color);
        // color[next_u] = this_color;
        // dfs(G, next_u, u, this_color);
    }
}

int main() {
    int N;
    cin >> N;
    Graph G;
    G.assign(N, vector<pair<int, int>>());
    for (int i = 1; i < N; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    color.assign(N, -1);
    dfs(G, 0, 1);
    for (auto c: color) cout << c << endl;
    return 0;
}

Measured memory_bytes: 11140
use std::io::{self, Read, Write};

#[rustfmt::skip] #[macro_use] #[allow(unused_macros)]
mod rwc {
    macro_rules! rd { ($buf:ident, $t:ty)       => { $buf.next().unwrap().parse::<$t>().ok().unwrap() }; }
    macro_rules! wt { ($out:ident, $($arg:tt)*) => { write!($out, $($arg)*).ok()                      }; }
    macro_rules! cv { ($n:expr, $fn:expr)       => { (0..$n).map($fn).collect::<Vec<_>>()             }; }
}

fn main() {
    let (mut _buf, mut _out) = (String::new(), io::stdout());
    let (mut _buf, mut _out) = {
        io::stdin().read_to_string(&mut _buf).ok();
        (_buf.split_whitespace(), io::BufWriter::new(_out.lock()))
    };

    let n = rd!(_buf, i32);
    let m = rd!(_buf, usize);
    let x = cv!(m, |_| rd!(_buf, i32)).into_iter().sum::<i32>();

    if n - x < 0 {
        wt!(_out, "-1\n");
    } else {
        wt!(_out, "{}\n", n - x);
    }
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,ans=0;
    cin>>a>>b;
    if(a<=5)
    cout<<0<<endl;
    else if(a<=12)
    cout<<b/2<<endl;
    else
    cout<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]


jobs = [[] for _ in range(m)]
for a, b in ab:
    if a <= m:
        jobs[a - 1].append(-b)

ans = 0
available = []
for job in jobs:
    for jo in job:
        heappush(available, jo)

    if available:
        ans -= heappop(available)

print(ans)


Measured memory_bytes: 81880
import fractions


def lcm(a, b):
    return a * b // fractions.gcd(a, b)


def f(x, a, b):
    return x - x // a - x // b + x // lcm(a, b)


def main():
    a, b, c, d = map(int, input().split())
    print(f(b, c, d) - f(a - 1, c, d))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5180
#include<bits/stdc++.h>
#include <vector>
#include <iostream>
using namespace std;
typedef pair<int,int>PP;
int Max(int a,int b){
  if(a>b){
    return(a);
  }else{
    return(b);
  }
}
int main(){
  int n,a;
  cin>>n>>a;
  string s;
  cin>>s;
  int lg=s.size();
  int seg[lg+1];
  seg[0]=0;
  if(s[0]=='A'&&s[1]=='C'){
    seg[0]=1;
  }
  for(int i=1;i<lg-1;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      seg[i]=seg[i-1]+1;
    }else{
      seg[i]=seg[i-1];
    }
  }
  int l,r;
  for(int i=0;i<a;i++){
    cin>>l>>r;
    if(l==1){
      cout<<seg[r-2]<<endl;
    }else{
      cout<<seg[r-2]-seg[Max(l-2,0)]<<endl;
    }
  }
  return(0);
}


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

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, 1, n+1){
        ll t;
        cin >> t;
        if(i == t){
        cerr << i << endl;
            ans++;
            if(i != n) cin >> t;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

bool erased[1000];

using Weight=long long;
struct Edge{
    int src,dst;
    Weight weight;
    Edge(int src,int dst,Weight weight):
    src(src),dst(dst),weight(weight){}
};

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else if(e.src!=f.src)return e.src<f.src;
    else return e.dst<f.dst;
}

using Edges=vector<Edge>;
using Graph=vector<Edges>;

pair<Weight,int>sweep(int p,int v,const Graph &g){
    pair<Weight,int> r(0,v);
    for(auto e:g[v]){
        if(e.dst!=p){
            pair<Weight,int> t=sweep(v,e.dst,g);
            t.first+=e.weight;
            if(r.first<t.first)r=t;
        }
    }
    return r;
}

Weight double_sweep(const Graph &g,int s){
    pair<Weight,int> r=sweep(-1,s,g);
    pair<Weight,int> t=sweep(-1,r.second,g);
    return t.first;// (r.second, t.second) is farthest pair.
}

int main(){
    int n;
    cin>>n;
    Graph g(n);
    for(int i=1;i<n;++i){
        int s,t;
        Weight w;
        cin>>s>>t>>w;
        g[s].emplace_back(s,t,w);
        g[t].emplace_back(t,s,w);
    }
    cout<<double_sweep(g,0)<<endl;
    return 0;
}

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

int main(){
	int N;
  	cin>>N;
  	vector<string> s(N);
  	for(int i=0;i<N;++i)cin>>s[i];
	for(int i=0;i<N-1;++i){
    	for(int j=1;j<N-i;++j)if(s[i]==s[i+j]){cout<<"No"<<endl;return 0;}
	}
  for(int i=0;i<N-1;++i)if(s[i].back()!=s[i+1].front()){cout<<"No"<<endl;return 0;}
  	cout<<"Yes"<<endl;return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto S = RD!string;

	auto p1 = new bool[](10);
	auto p2 = new bool[](100);
	auto p3 = new bool[](1000);
	foreach (c; S)
	{
		auto x = [c].to!long;
		foreach (i; 0..p2.length)
		{
			if (p2[i])
			{
				auto y = i*10 + x;
				p3[y] = true;
			}
		}
		foreach (i; 0..p1.length)
		{
			if (p1[i])
			{
				auto y = i*10 + x;
				p2[y] = true;
			}
		}
		p1[x] = true;
	}

	long ans;
	foreach (e; p3)
	{
		if (e) ++ans;
	}
	
	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 764
N=int(input())
from collections import defaultdict
dic=defaultdict(int)
import math
mod=1000000007
for _ in range(N):
    A,B=map(int,input().split())
    if A<0:
        A,B=-A,-B
    if A==0:
        if B==0:
            dic[(0,0)]+=1
        else:
            dic[(0,-1)]+=1
    elif B==0:
        dic[(1,0)]+=1
    else:
        gcd=math.gcd(A,B)
        A,B=A//gcd,B//gcd
        dic[(A,B)]+=1

ans=1
N-=dic[(0,0)]
for k,v in dic.items():
    if k==(0,0) or k==(0,1):
        continue
    a,b=k
    if not (b,-a) in dic:
        continue
    v_dash=dic[(b,-a)]
    ans*=((pow(2,v,mod)-1)+(pow(2,v_dash,mod)-1)+1)
    ans%=mod
    N-=v+v_dash
ans*=pow(2,N,mod)
ans+=dic[(0,0)]-1
ans%=mod
print(ans)


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

int main() {
    int A, B, C, X, Y;
    std::cin >> A >> B >> C >> X >> Y;

    const int cost1 = A * X + B * Y;

    int cost2 = 0;
    if (X < Y) {
        cost2 = C * 2 * X;
        cost2 += (Y - X) * B;
    } else {
        cost2 = C * 2 * Y;
        cost2 += (X - Y) * A;
    }

    const int cost3 = std::max(X, Y) * 2 * C;

    std::cout << std::min({cost1, cost2, cost3}) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define inf 1e10
#define mod 1000000007
#define mii map<int,int>
#define pii pair<int,int>
#define setbits(x) __builtin_popcountll(x)
#define lcm(x,y)  (x*y)/__gcd(x,y)

int  fact(int n)
{
	if (n == 0 || n == 1)
		return 1;
	else
		return n * fact(n - 1);
}
int nCr(int n, int r)
{
	if (r == 0)
		return 1;
	else
		return fact(n) / (fact(n - r) * fact(r));
}
int floorRoot5(int n)
{
	// Base cases
	if (n == 0 || n == 1)
		return n;

	// Initialize result
	int res = 0;

	// Keep incrementing res while res^5 is
	// smaller than or equal to n
	while (res * res * res * res * res <= n)
		res++;

	// Return floor of 5'th root
	return res - 1;
}

int32_t main()
{
	//c_p_c();
	int n, m;
	cin >> n >> m;
	int i, ans = 0;
	int a[n + 1], b[n + 1];
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
		b[i] = 0;
	}
	for (i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		b[x] = max(b[x], a[y]);
		b[y] = max(b[y], a[x]);

	}
	// for (i = 1; i <= n; i++)
	// 	cout << a[i] << " " << b[i] << endl;

	for (i = 1; i <= n; i++)
	{
		ans += (a[i] > b[i]);
	}
	cout << ans;
}



Measured memory_bytes: 5172
#include <cstdio>
#include <complex>
#include <vector>
#include <cmath>

using namespace std;

#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++)

typedef complex<double> P;
typedef vector<P> VP;
const double EPF = 1e-2;

#define X real()
#define Y imag()
#define EQ(x,y) (abs(x-y) < EPF)
#define LE(x,y) (x < y + EPF)
#define GE(x,y) (x + EPF > y)

double dot(P a, P b) {
  return (conj(a)*b).X;
}
double cross(P a, P b) {
  return (conj(a)*b).Y;
}
int isparallel(P a, P b, P c, P d) {//ab,cd
  return EQ(cross(a-b, c-d),0);
}
double distPP(P a, P b) {
  return sqrt(dot(a-b,a-b));
}
int relationCC(P c1, double r1, P c2, double r2) {//0..not overlap, 1..intersect, 2..2isin1, -2..1isin2
  double d = distPP(c1,c2);
  if(d > r1+r2) return 0;
  else if(r1 > d+r2) return 2;
  else if(r2 > d+r1) return -2;
  else return 1;
}
P intersection(P a, P b, P c, P d) {//ac , bd
  double d1 = cross(d-b,b-a);
  double d2 = cross(d-b,c-a);
  if(EQ(d1,0) & EQ(d2,0)) return a;
  if(EQ(d2,0)) return a;
  return a + (c-a)*d1/d2;
}
P normal_vector(P a) {
  P b(-a.Y, a.X);
  return b;
}
P polar(double r, double theta) {
  P a(r*cos(theta),r*sin(theta));
  return a;
}


int main() {
  int n;
  scanf("%d",&n);
  REP(i,n) {
    double x,y,r1,r2;
    scanf("%lf %lf %lf", &x, &y, &r1);
    P a(x,y);
    scanf("%lf %lf %lf", &x, &y, &r2);
    P b(x,y);
    printf("%d\n", relationCC(a,r1,b,r2));
  }
  return 0;
}

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

int main()
{
	int m,n,i = 1;
	int ret = 0;
	scanf("%d %d",&m,&n);
	AAA:while(((i <= n)||(i < 0))&&(ret < m))
	{
		i *= 2;
		ret += 1;
	}
	for(;ret < m;)
	{
		if(i <= n)
			goto AAA;
			i = i + n;
			ret += 1;
			if(i < 0)
				goto AAA;
	}
	printf("%d\n",i);
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    
    double w,h,x,y;
    cin >> w >>h>>x>>y;
    double ans=w*h/2;
    //ans = ans *max(min(x, w - x) / w, min(y, h - y) / h);

    //cout << std::setprecision(100)<< ans << " ";
    cout << ans << " ";
    //lint aaa = min(x, w - x) * max(y, h - y), bbb = max(x, w - x) * min(y, h - y);
    //if ((w / 2 == x && h / 2 == y) || abs((min(x, w - x) / w) - (min(y, h - y) / h)) < 0.000001)
    if (((w / 2.0) == x && (h / 2.0) == y))
    {
        cout << 1 << "\n";
    }else{
        cout << 0 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    if S[-1] == 's':
        print(S+'es')
    else:
        print(S+'s')
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int key = 0;
  for(int i=1;i<b;i++){
    if(a*i%b == c){
      cout << "YES" << endl;
      key = 1;
      break;
    }
  }
  if(key == 0)
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#n=int(input())
a, v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ans="NO"
if a<b:
    a+=v*t;b+=w*t
    if a>=b:
        ans="YES"
else:
    a-=v*t;b-=w*t
    if a<=b:
        ans="YES"

print(ans)

Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll n,a,b;
    cin>>n>>a>>b;
    auto d = abs(a-b);
    if(d%2 == 0){
        pr(d/2);
    }else{
        // auto l = n - a;
        // auto r = b - 1;
        // auto ans = min(l,r);
        // pr(ans);

        auto l = n - b;
        auto r = a - 1;
        auto ans = min(l,r);
        ans++;
        d--;
        pr(ans + d/2);

    }

 

}


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

int N, M;
vector<int> G[200010];
int used[200010];

void dfs(int cur) {
  used[cur]++;
  for (int &nxt : G[cur]) {
    if (used[nxt]) continue;
    dfs(nxt);
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int L;
      cin >> L;
      L--;
      G[i].emplace_back(N + L);
      G[N + L].emplace_back(i);
    }
  }

  dfs(0);
  for (int i = 0; i < N; i++) {
    if (used[i]) continue;
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;

  return 0;
}

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

int main()
{
	ll N,M;
	cin >>N>>M;
	vector<int> v;
	for(int i = 0; i<N;i++)
	{
		int temp;
		cin >> temp;
		v.push_back(temp);
	}
	double sum = 0;
	for(auto it:v)
		sum+= it;
	sum = sum/(4*M);
	for(auto it:v)
	{
		if(it >= sum)
			M--;
	}
	if(M<=0)
		cout << "Yes"<<endl;
	else
	{
			cout<<"No"<<endl;
	}
	

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>//sort
#include <vector>
#include <string>
#include <map>//pair
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  string S;
  cin >> S;
  if(S == "BBB" || S == "AAA")cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
void solve()
{
	int n;
	cin>>n;
	if(n<30)
	{
		cout<<"No"<<endl;
	}
	else
		cout<<"Yes"<<endl;
}
signed main()
{
	int t=1; 
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<long long int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MB 1000000007
#define NB 1000000000
#define ll long long int
double H;

int main()
{

	cin >> H;
	int a = log2(H);
	a++;
	double ans = 0;
	REP(i,a){
		ans += pow(2,i);
	}
	cout << fixed << setprecision(0)<<ans;

}






Measured memory_bytes: 384
n, x, y = map(int, input().split())
ans = [0 for _ in range(n)]

for i in range(1, n+1):
    for j in range(i+1, n+1):
        a = min(abs(i-j), abs(x-i)++abs(j-y)+1, abs(y-i)+abs(j-x)+1)
        ans[a] += 1
for i in range(1, n):
    print(ans[i])


Measured memory_bytes: 9284
;; D - Xor Sum 4

(defparameter *modulus* (+ (expt 10 9) 7))
(defparameter *max-bits* 60)

(defun add-bits-to-vector (n vec index)
  "配列vecに整数nの2進各桁を加える"
  (declare (optimize (speed 3) (safety 0) (debug 0)))
  (unless (zerop n)
    (multiple-value-bind (m b) (floor n 2)
      (unless (zerop b) (incf (aref vec index)))
      (add-bits-to-vector m vec (1+ index)))))

(defun solve (N)
  (let ((vec (make-array *max-bits* :initial-element 0)))
    ; 各数を2進数に変換したときの各桁の1の個数を求める
    (loop repeat N do (add-bits-to-vector (read) vec 0))
    ; 各桁を集約
    (reduce #'(lambda (l h) (mod (+ l (ash h 1)) *modulus*))
      ; 2進各桁のXORの総和 (= 1の個数 * 0の個数)
      (map 'vector #'(lambda (m) (* m (- N m))) vec)
      :from-end t)))

(defun main ()
  (print (solve (read)))
  (fresh-line))

(main)


Measured memory_bytes: 57956
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
typedef  long long ll;
const int  maxn =110000;
const int mod = 1000000007;
using namespace std;
ll n, m;
ll dp[110000][100];
char a[110000];
int main()
{
	scanf("%s", a);
	ll len = strlen(a);
	ll len2 = 10;
	if (a[len - 1] == '?')
	{
		for (int i = 0; i <= 9; i++)
			dp[len - 1][i] = 1;
	}
	else
	{
		dp[len - 1][a[len - 1] - '0'] = 1;
	}
	for (ll i = len-2; i >= 0; i--)
	{
		if (a[i] == '?')
		{
			for (int j = 0; j <= 9; j++)
			{
				ll yu = (j * len2)%13;
				for (int k = 0; k < 13; k++)
				{
					ll now = (yu + k) % 13;
					dp[i][now] = (dp[i][now] + dp[i + 1][k]) % mod;
				}
			}
		}
		else
		{
			ll tt = a[i] - '0';
			ll yu = (tt * len2) % 13;
			for (int k = 0; k < 13; k++)
			{
				ll now = (yu + k) % 13;
				dp[i][now] = dp[i+1][k];
			}
		}
		len2 = (len2 * 10)%13;
	}
	printf("%lld", dp[0][5]);
}

Measured memory_bytes: 80128
program main;
var
	num, i, sum : int64;
begin
	read(num);
    
    sum := 0;
    
    for i := 1 to num do begin
    	if (frac(i/3) = 0) or (frac(i/5) = 0)
        	then sum := sum + 0
        	    else sum := sum + i;
    end;
 	writeln(sum);
end.

Measured memory_bytes: 1384
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VI vector<int>
#define VL vector<long long>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
 
template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=1e2+5;
LL t,n,m,q,ans;
LL MOD=1e9+7,inf=0x3f3f3f3f;
db eps=1e-5;

LL f[111][111],a[1111],b[1111],c[1111];

int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0,u,v,w;
	cin>>n>>m;
	repu(i,1,n)repu(j,1,n)f[i][j]=(i==j?0:inf);
	repu(i,1,m){
		cin>>a[i]>>b[i]>>c[i];
		f[a[i]][b[i]]=min(f[a[i]][b[i]],c[i]);
		f[b[i]][a[i]]=min(f[b[i]][a[i]],c[i]);
	}
	repu(k,1,n) repu(i,1,n) repu(j,1,n)
		f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	
	repu(i,1,m){
		k=0;
		repu(j,1,n){
			if(f[j][b[i]]==f[j][a[i]]+c[i])
				k=1;
		}
		ans+=k;
	}
	ans=m-ans;
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<ll>l(n);
  rep(i,0,n) cin >> l[i];
  sort(l.begin(),l.end());
  rep(i,0,n-2){
    rep(j,i+1,n-1){
      rep(k,j+1,n){
        if(l[k] < l[i]+l[j]){
          if(l[i] == l[j]) continue;
          if(l[j] == l[k]) continue;
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;
#define ll long long

const int N = 1e5 + 5;
ll INF = 1e9 + 7;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    ll ten = 1;
    ll nine = 1;
    ll eight = 1;

    for(int i=0;i<n;i++)
    {
        ten = (ten * 10)%INF;
        nine = (nine * 9)%INF;
        eight = (eight * 8)%INF;
    }

    nine = (2 * nine)%INF;

    ll ans = ( ten - nine + eight);

    ans = (ans + INF)%INF;
    cout<<ans<<endl;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int h, w;
char s[25][25];
void solve() {
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> s[i][j];

    int ans = 0;
    rep(i, h) rep(j, w) {
        if (s[i][j] == '#') continue;
        priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<>> que;
        vector<vector<int>> d(h, vector<int>(w, iinf));
        constexpr int dx[] = { 1,0,-1,0 };
        constexpr int dy[] = { 0,1,0,-1 };
        que.emplace(0, i, j);
        d[i][j] = 0;
        while (!que.empty()) {
            pair<int, int> p;
            p.first = get<1>(que.top());
            p.second = get<2>(que.top());
            que.pop();

            rep(i, 4) rep(j, 4) {
                auto nx = p.first + dx[i];
                auto ny = p.second + dy[i];

                if (nx < 0 || nx >= h || ny < 0 || ny >= w || s[nx][ny] == '#') continue;
                if (d[nx][ny] > d[p.first][p.second] + 1) {
                    d[nx][ny] = d[p.first][p.second] + 1;
                    que.emplace(d[nx][ny], nx, ny);
                }
            }
        }

        rep(k, h) rep(l, w) if (d[k][l] != iinf) maxs(ans, d[k][l]);

    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		Main main = new Main();
		List<Point> targetList = new ArrayList<Point>();
		char c[][] = new char[H][W];
		for (int i = 0; i < H; i++) {
			String s = sc.next();
			char temp[] = s.toCharArray();
			for (int j = 0; j < W; j++) {
				c[i][j] = temp[j];
				if (c[i][j] == '#') {
					Point p = main.new Point();
					p.x = i;
					p.y = j;
					targetList.add(p);
				}
			}
		}
		int count =0;
		while (targetList.size()>0) {
			List<Point> temp = new ArrayList<Point>();
			for (Point p :targetList) {
				if (p.y>0) {
					if (c[p.x][p.y-1]=='.') {
						c[p.x][p.y-1] = '#';
						Point t = main.new Point();
						t.x = p.x;
						t.y = p.y-1;
						temp.add(t);
					}
				}
				if (p.x>0) {
					if (c[p.x-1][p.y]=='.') {
						c[p.x-1][p.y] = '#';
						Point t = main.new Point();
						t.x = p.x-1;
						t.y = p.y;
						temp.add(t);
					}
				}
				if (p.x<H-1) {
					if (c[p.x+1][p.y]=='.') {
						c[p.x+1][p.y] = '#';
						Point t = main.new Point();
						t.x = p.x+1;
						t.y = p.y;
						temp.add(t);
					}
				}
				if (p.y<W-1) {
					if (c[p.x][p.y+1]=='.') {
						c[p.x][p.y+1] = '#';
						Point t = main.new Point();
						t.x = p.x;
						t.y = p.y+1;
						temp.add(t);
					}
				}
			}
			targetList = temp;
			if (temp.size()>0) {
				count++;
			}
		}
		System.out.println(count);
	}

	public class Point {
		int x;
		int y;
	}
}

Measured memory_bytes: 79432
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    string res = "##############";
    int l = 0;
    for(int i = 0; i < s.length();i++){
        if(s[i] == 'B'){
            l = max(0,l - 1);
        }else{
            res[l] = s[i];
            l++;
        }
    }
    cout << res.substr(0,l) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

const ll mod = 1000000007;

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

int main() {
  string str;
  cin >> str;

  size_t N = str.length();

  ll dp[N + 1][4];

  dp[0][0] = 1;
  dp[0][1] = 0;
  dp[0][2] = 0;
  dp[0][3] = 0;
  for (size_t i = 1; i <= N; i++) {
    if (str[i - 1] == 'A') {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = dp[i - 1][1] + dp[i - 1][0];
      dp[i][2] = dp[i - 1][2];
      dp[i][3] = dp[i - 1][3];
    } else if (str[i - 1] == 'B') {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = dp[i - 1][1];
      dp[i][2] = dp[i - 1][2] + dp[i - 1][1];
      dp[i][3] = dp[i - 1][3];
    } else if (str[i - 1] == 'C') {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = dp[i - 1][1];
      dp[i][2] = dp[i - 1][2];
      dp[i][3] = dp[i - 1][3] + dp[i - 1][2];
    } else {
      dp[i][0] = mul(3, dp[i - 1][0]);
      dp[i][1] = mul(3, dp[i - 1][1]) + dp[i - 1][0];
      dp[i][2] = mul(3, dp[i - 1][2]) + dp[i - 1][1];
      dp[i][3] = mul(3, dp[i - 1][3]) + dp[i - 1][2];
    }
    dp[i][0] = take_mod(dp[i][0]);
    dp[i][1] = take_mod(dp[i][1]);
    dp[i][2] = take_mod(dp[i][2]);
    dp[i][3] = take_mod(dp[i][3]);
  }

  cout << dp[N][3] << endl;

  return 0;
}

Measured memory_bytes: 3584
n=int(input())
a=list(map(int,input().split()))
counts=[0]*60
for b in a:
    for i in range(60):
        counts[i]+=b%2
        b//=2
ans=0
mod = 10**9+7
for i in range(60):
    c=counts[i]
    comb=c*(n-c)
    ans=(ans+(1<<i)*comb)%mod
print(ans)

Measured memory_bytes: 122936
#include<bits/stdc++.h>
#define mod 1000000007
#define p pair<int,int>
using namespace std;
bool comparator(p &A,p &B){
	if(A.first==B.first)
		return A.second<=B.second;
	return A.first<=B.first;
}
int main(){
	int n,m;
	cin>>n>>m;
	int x=-1;
	int y=n+1;
	int t1,t2;
	for(int i=0;i<m;i++){
		cin>>t1>>t2;
		x=max(x,t1);
		y=min(y,t2);
	}
	int res=y-x+1;
	res=res<0?0:res;
	cout<<res;
	return 0;
}

Measured memory_bytes: 384
require 'prime'

n = gets.to_i
h = Hash.new(0)
2.upto(n) do |i|
    Prime.prime_division(i).each do |a|
        h[a[0]] += a[1]
    end
end

ans = 1
mod = 10 ** 9 + 7
h.each_value do |v|
    ans = ans * (v + 1) % mod
end

puts ans

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

using namespace std;

long long k, x[50];

int main() {
	scanf("%lld", &k);
	printf("50\n");
	for (int i = 0; i < 50; i++)
		x[i] = 50 + k / 50;
	for (int i = 0; i < (50 - k % 50); i++)
		for (int j = 0; j < 50; j++)
			if (i == j)
				x[j] -= 50;
			else
				x[j]++;
	for (int i = 0; i < 50; i++)
		printf("%lld%c", x[i], i == 49 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  lint i,n;cin>>n;llint money=0;
  vint a(n+2);a[0]=0;a[n+1]=0;
  for(i=1;i<=n;i++){
    cin>>a[i];
    money+=abs(a[i]-a[i-1]);
  }
  money+=abs(a[n+1]-a[n]);
  for(i=1;i<=n;i++){
    if((a[i+1]>=a[i])&&(a[i]>=a[i-1])){
      cout<<money<<endl;
    }else if((a[i+1]<=a[i])&&(a[i]<=a[i-1])){
      cout<<money<<endl;
    }else{
      cout<<(money+abs(a[i+1]-a[i-1])-abs(a[i+1]-a[i])-abs(a[i]-a[i-1]))<<endl;
    }
  }
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
int main()
{
	char n[18];
	int i,j,k,l,sum;
	scanf("%s", n);
	l=strlen(n);
	if(l==1)
	{
		printf("%d\n", n[0]-48);
		return 0;
	}
	for(i=1; i<l;i++)
	{
		if(n[i]!='9')
		{
			sum=-1;
			break;
		}
	}
	if(i==l)
		sum=0;
	sum+=9*(l-1)+n[0]-48;
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 888
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        int[] n=System.Console.ReadLine().Trim().Split(' ').Select(x=>int.Parse(x)).ToArray();
        if(n[0]+n[1]>n[2]+n[3])
        System.Console.WriteLine("Left");
        else if(n[0]+n[1]==n[2]+n[3])
        System.Console.WriteLine("Balanced");
        else
        System.Console.WriteLine("Right");
    }
}


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

c = [[0]*10 for _ in range(10)]

for i in range(1,N+1):
    i = str(i)
    l = int(i[0])
    r = int(i[-1])
    c[l][r] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]

print(ans)

Measured memory_bytes: 3064
def solve(N, D):
    if N % (D * 2 + 1) == 0:
        return N // (D * 2 + 1)
    else:
        return N // (D * 2 + 1) + 1

def main():
    A, B = [int(x) for x in input().split()]
    print(solve(A, B))


main()


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

#define HAS_TEST_CASE 0

namespace rG{

typedef long long ll;

const int N=5e5;

int n,m,k,a[N+10];
char s[N+10];

inline void main(){
	int d,t,s;
	scanf("%d%d%d",&d,&t,&s);
	if(t*s>=d)puts("Yes");
	else puts("No");
}

} // namespace rG

int main(){
#if defined(LOCAL)&&HAS_TEST_CASE
	freopen("tmp.out","w",stdout);
#endif
#if HAS_TEST_CASE
	int T;
	scanf("%d",&T);
	while(T--)rG::main();
#else
	rG::main();
#endif
	return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define int long long
/*
計算量気にしなければ貪欲に消せばいい
はみ出しているのがあったら消去
非連結になったらはみ出し確認
明らかに計算量が死ぬ
*/
//BEGIN CUT HERE
struct UnionFind{
  int num;//連結成分の数
  vector<int> r,p,w;//そのグループのサイズ,自分の親っぽいやつ
  UnionFind(){}
  UnionFind(int n):num(n),r(n,1),w(n),p(n,0){iota(p.begin(),p.end(),0);}

  int find(int x){//どのグループに所属するか
    return (x==p[x]?x:p[x]=find(p[x]));//xがグループの名前と一致するまでxを親にする
  }

  void init(vector<int> v){
    w=v;
  }

  bool same(int x,int y){//同じグループかどうか
    return find(x)==find(y);
  }

  void unite(int x,int y){//xとyを同じグループにする
    x=find(x);y=find(y);//xとyのグループの名前をどっちかが変える
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);//サイズが大きい方をxとする
    r[x]+=r[y];//yの親をxにする（今までyだったグループ名がxになる）
    p[y]=x;
    w[x]+=w[y];
    num--;
  }

  int size(int x){//グループの大きさ
    return r[find(x)];
  }

  int weight(int x){
    return w[find(x)];
  }

  int count() const{//グループの数
    return num;
  }
};

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

signed main(){
  int N,M;cin>>N>>M;
  vector<int> w(N);
  for(int i=0;i<N;i++)cin>>w[i];
  vector<PP> e(M);
  vector<P> edge[N];
  for(int i=0;i<M;i++){
    int a,b,c;cin>>a>>b>>c;a--;b--;
    e[i]=PP(P(c,0),P(a,b));
    edge[a].push_back(P(b,c));
    edge[b].push_back(P(a,c));
  }
  sort(e.begin(),e.end());
  UnionFind uf(N);
  uf.init(w);
  for(int i=0;i<M;i++){
    int W=e[i].first.first,U=e[i].second.first,V=e[i].second.second;
    uf.unite(U,V);
    if(W<=uf.weight(U))e[i].first.second=1;
  }
  sort(e.rbegin(),e.rend());
  set<P> s;
  for(int i=0;i<M;i++){
    int W=e[i].first.first,A=e[i].first.second,U=e[i].second.first,V=e[i].second.second;
    if(s.count(P(U,V)))continue;
    if(A==0)continue;
    s.count(P(U,V));
    queue<int> que;
    que.push(U);
    que.push(V);
    while(que.size()){
      int p=que.front();que.pop();
      for(auto q:edge[p]){
        int t=q.first,WE=q.second;
        if(s.count(P(min(p,t),max(p,t))))continue;
        if(WE>W)continue;
        s.insert(P(min(p,t),max(p,t)));
        que.push(t);
      }
    }
  }
  cout<<M-s.size()<<endl;
}

/*
解説AC
こんなの解けるわけなくない？って言って解説読んだら解けるんですねってなった
ポイントとしてはまず「辺はなるべく外したくないってところ」
辺は問題の目的的にも外したくないし、辺を外さない方が外さなくてよくなる辺は増えるので
だからまずはどの辺は外さなくて済むかを考えるべきだった
あとは連結成分の中で一番重みが大きい辺だけをチェックする気持ちになれば割と良さそう？
連結成分を確認するのには辺をつけて言ってUnionFindってのは典型なのでそう

最終的に残る辺は(1)連結成分の中で最も重いものと(2)そうでないものの2種類で、
重み低い順に見ていくことで(1)が見つかって、
(1)から構成をすることで自動で(2)が網羅できる

残る辺の役割について考えられなかったのとUnionFindのアイデアを発展させられなかったのがダメ
*/


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

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;
ll MOD = 2019;

int
main() 
{

  ll w, h, x, y;
  cin >> w >> h >> x >> y;

  double ans = (double)w * h / 2;
  if((double)w / 2 == x && (double)h / 2 == y){
    printf("%f 1\n", ans);
  } else {
    printf("%f 0\n", ans);
  }

}



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

int n, m, num, cnt;
vector<int> a, b;

void kill() {
	cout << "Impossible";
	exit(0);
}

void add(int l) {
	if(l)
		b.push_back(l);
}

void print() {
	for (int num: a)
		cout << num << ' ';
	cout << '\n' << b.size() << '\n';
	for (int num: b)
		cout << num << ' ';
}

void solve_odd() {
	if(cnt > 1)
		kill();
	for (int i = 0; i < m; i++)
		if(a[i] & 1)
			swap(a[i], a[m - 1]);
	for (int i = 0; i < m; i++)
		if(i == 0)
			add(a[i] + 1);
		else if(i == m - 1)
			add(a[i] - 1);
		else
			add(a[i]);
	print();
}

void solve_even() {
	if(cnt > 2)
		kill();
	for (int i = 0; i < m; i++)
		if(a[i] & 1)
			swap(a[i], a[0]);
	for (int i = 1; i < m; i++)
		if(a[i] & 1)
			swap(a[i], a[m - 1]);
	for (int i = 0; i < m; i++)
		if(i == m - 1)
			add(a[i] - 1);
		else if(i == 0)
			add(a[i] + 1);
		else
			add(a[i]);
	print();
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> num;
		cnt += (num & 1);
		a.push_back(num);
	}
	if(m == 1) {
		if(n % 2 == 1)
			add(n >> 1), add((n + 1) >> 1);
		else
			add(n / 2 + 1), add(n / 2 - 1);
		print();
	}
	else if(n & 1)
		solve_odd();
	else
		solve_even();
	return 0;
}

Measured memory_bytes: 256
import java.awt.*;
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        double l= sc.nextDouble();
        double ans=(l*l*l)/(3*3*3);
        System.out.println(ans);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
using namespace std;
int main(void)
{
    int n, m;
    cin >> n >> m;
    int L[m];
    int R[m];
    int l_max = 0;
    int r_min = n;
    for (int i = 0; i < m; i++)
    {
        cin >> L[i] >> R[i];
        if (l_max < L[i])
            l_max = L[i];
        if (r_min > R[i])
            r_min = R[i];
    }
    int temp = r_min - l_max + 1;
    if (temp >= 0)
        cout << temp;
    else
        cout << '0';
}

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

const int MAX = 100001;
int main() {
	int N, A[MAX];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> A[i];
	A[N] = 0;
	int64_t ans = 0;
	for (int i = 0;i < N;++ i) {
		ans += A[i] >> 1;
		A[i] &= 1;
		ans += min(A[i], A[i + 1]);
		A[i + 1] -= min(A[i], A[i + 1]);
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

小さい整数から愚直にペアを作ると良い
勿論、自分自身でペアを作れるなら真っ先に作るべし
*/

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
template <class T> void chmin(T& x, T y) { if (x > y) x = y; }
Int dp[5010][5010];
const Int INF = 1e18;
int main() {
    int N, A, B; cin >> N >> A >> B;
    vector<int> P(N); for (auto &p : P) cin >> p;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = A;
    dp[0][P[0]] = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j <= N; j++) {
            if (j >= P[i + 1]) {
                chmin(dp[i + 1][j], dp[i][j] + B);
            } else {
                chmin(dp[i + 1][P[i + 1]], dp[i][j]);
                chmin(dp[i + 1][j], dp[i][j] + A);
            }
        }
    }
    Int ans = INF;
    for (int j = 0; j <= N; j++) {
        chmin(ans, dp[N - 1][j]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 195968
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
    
int main(){
    char s[4];
    cin>>s;
    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0',sum=0;
    

    for(int bit=0;bit<(1<<4);bit++){
        vector<string> t(3,"+");
        for(int i=0;i<4;i++){
            
            if(bit & (1<<i)){
                sum += (int)(s[i]-'0');
                
            }else{
                sum -= (int)(s[i]-'0');
                if(i != 0) t.at(i-1) = "-";
            }
            
        }
        if(sum==7) {
            cout<<a<<t[0]<<b<<t[1]<<c<<t[2]<<d<<"=7"<<endl;
            return 0;
        }
        sum=0;
        
    }
    
    return 0;
}

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

int dfs(int, int, int, int, int, int, int, int, int *);
int index_count = 0;
int INF = 1000000000;

int main(){
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	int l[N];
	for (int i = 0; i < N; i++){
		cin >> l[i];
	}
	cout << dfs(0, 0, 0, 0, A, B, C, N, l) << endl;
}

int dfs(int index_count, int a, int b, int c, int A, int B, int C, int N, int l[]){
	if (index_count == N){
		return (min(min(a, b), c) > 0) ? abs(a - A) + abs(b - B) + abs(c - C) - 30 : INF;		
	}else{
		int res0 = dfs(index_count + 1, a, b, c, A, B, C, N, l);
		int res1 = dfs(index_count + 1, a + l[index_count], b, c, A, B, C, N, l) + 10;
		int res2 = dfs(index_count + 1, a, b + l[index_count], c, A, B, C, N, l) + 10;
		int res3 = dfs(index_count + 1, a, b, c + l[index_count], A, B, C, N, l) + 10;
		return min(min(res0, res1), min(res2, res3));
	}
}

Measured memory_bytes: 384
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    a: i64,
    }
    let mut ans = 0;
    if a == 0 {
      ans = 1
    }else if a == 1 {
      ans = 0
    }

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


Measured memory_bytes: 2172
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
a,b,c = map(int, input().split())

if b>=c:
    answer=b+c
elif a+b<c:
    answer=2*b+a+1
else:
    answer = b+c

print(answer)


Measured memory_bytes: 21548
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){
    long long int n;
    cin >> n;

    if((n%((n/1000000000)+((n/100000000)%10)+((n/10000000)%10)+
    ((n/1000000)%10)+((n/100000)%10)+((n/10000)%10)+
    ((n/1000)%10)+((n/100)%10)+((n/10)%10)+n%10))==0){
        cout << "Yes" << endl;

    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 888