akhauriyash/Code-Regression huggingface dataset:
use std::io;

fn main() {
	let mut num = String::new();

	io::stdin().read_line(&mut num)
		.ok()
		.expect("Failed to read line");

	let number: i32 = num.trim().parse().ok().unwrap();

	if number % 2 == 0 {
		println!("0.5");
	} else {
		let answer: f32 = ((number / 2 + 1) as f32) / number as f32;
		println!("{}", answer);
	}
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

template< typename Monoid >
struct SegmentTree {
    using F = function< Monoid(Monoid, Monoid) >;
    
    int sz;
    vector< Monoid > seg;
    
    const F f;
    const Monoid M1;
    
    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }
    
    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }
    
    void build() {
        for(int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }
    
    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while(k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }
    
    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = f(L, seg[a++]);
            if(b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }
    
    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
    
    template< typename C >
    int find_subtree(int a, const C &check, Monoid &M, bool type) {
        while(a < sz) {
            Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
            if(check(nxt)) a = 2 * a + type;
            else M = nxt, a = 2 * a + 1 - type;
        }
        return a - sz;
    }
    
    template< typename C >
    int find_first(int a, const C &check) {
        Monoid L = M1;
        if(a <= 0) {
            if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
            return -1;
        }
        int b = sz;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) {
                Monoid nxt = f(L, seg[a]);
                if(check(nxt)) return find_subtree(a, check, L, false);
                L = nxt;
                ++a;
            }
        }
        return -1;
    }
    
    template< typename C >
    int find_last(int b, const C &check) {
        Monoid R = M1;
        if(b >= sz) {
            if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
            return -1;
        }
        int a = sz;
        for(b += sz; a < b; a >>= 1, b >>= 1) {
            if(b & 1) {
                Monoid nxt = f(seg[--b], R);
                if(check(nxt)) return find_subtree(b, check, R, true);
                R = nxt;
            }
        }
        return -1;
    }
};

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

    int n, q;
    cin>>n>>q;
    SegmentTree<ll> st(n, [](ll a, ll b){ return min(a, b); }, (1ll<<31)-1);

    rep(i, q) {
        ll c, x, y;
        cin>>c>>x>>y;

        if (c == 0) {
            st.update(x, y);
        }
        else {
            cout<<st.query(x, y + 1)<<endl;
        }
    }
}


Measured memory_bytes: 4824
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl            '\n'
#define mem(a, n)       memset(a, n, sizeof(a))
#define repeat(n)       for(int i=0; i<n; i++)
#define Unique(n)       (n).erase(unique(all(n)), (n).end())
#define isPowerOfTwo(n) (n && !(n & (n - 1)))
#define NumofDigits(n)  ((int)log10(n)+1)
#define all(a)          a.begin(), a.end()

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
    #ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    int h, a; cin >> h >> a;
    cout << h/a + (h%a!=0);

    return 0;
}

unsigned long long pow(long long base, long long power){
    if(power==0) return 1;
    if(power==1) return base;

    unsigned long long ans = pow(base, power/2);
    ans *= ans; /// ans = (ans%mod)*(ans%mod);

    if(power&1) return ans*base; /// (ans%mod)*(base%mod);
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(n+1)
        if(isPrime[i]) c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
long long int fan(long long int x, long long int y, string s) {
	int len = s.length();
	if (y == len)return s[0] - '0';
	if (y == len - 1) {
		return x + s[y - 1] + s[y] - 2 * '0' + 10 * (x + s[y - 1] - '0') + s[y] - '0';
	}
	else {
		return pow(2, len - y - 1)*(x + s[y - 1] - '0')+fan(0,y+1,s) + fan((x + s[y - 1] - '0') * 10, y + 1, s);
	}
}
int main() {
	string s;
	cin >> s;
	cout << fan(0, 1, s);
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

bool check(const int score, const vector<int> &A, const vector<int> &F, int K) {
  for (int i = 0; i < A.size(); i++) {
    if (A[i] * F[i] > score) {
      int tmp = score / F[i];
      K -= A[i] - tmp;
      if (K < 0) {
        return false;
      }
    }
  }
  return true;
}

void solve() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N), F(N);
  for (int &a : A) {
    cin >> a;
  }
  for (int &f : F) {
    cin >> f;
  }

  sort(A.begin(), A.end());
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());

  int begin = -1, end = A[N - 1] * F[0];
  while (begin != end - 1) {
    int piv = (end - begin) / 2 + begin;
    if (check(piv, A, F, K)) {
      end = piv;
    } else {
      begin = piv;
    }
  }
  cout << end << endl;
}

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


Measured memory_bytes: 3456
import java.util.Scanner;
public class Main {
private static Scanner s = new Scanner(System.in);
static tree[] t;
static StringBuilder sb =   new StringBuilder();
public static void main(String[] args) {
	int x,root = 0,h;
	int n = s.nextInt();
	t = new tree[n];
	int[] c = new int[n+1];

	for(int i = 0;i < n;i++) {
		x = s.nextInt();
		if(i == 0) {
			root = x;
		}
		t[x] = new tree(x);
		for(int j = 0;j < 2;j++) {
			h = s.nextInt();
			if(j == 0) {
				t[x].setl(h);
			}else {
				t[x].setr(h);
			}
			if(h == -1)h = n;
			c[h] = 1;
		}
	}
	for(int i = 0;i < n;i++) {
		if(c[i] != 1) root = i;
	}
	rk(root,-1);
	sb.append("Preorder\n");
	preorder(root);
	sb.append("\nInorder\n");
	inorder(root);
	sb.append("\nPostorder\n");
	postorder(root);
	System.out.println(sb.toString());
}

static void preorder(int n) {
	sb.append(" " + t[n].getnode());
	if(t[n].getl() != -1) preorder(t[n].getl());
	if(t[n].getr() != -1) preorder(t[n].getr());
}

static void inorder(int n) {
	if(t[n].l != -1) inorder(t[n].l);
	sb.append(" " + t[n].node);
	if(t[n].r != -1)inorder(t[n].r);
}

static void postorder(int n) {
	if(t[n].l != -1) postorder(t[n].l);
	if(t[n].r != -1) postorder(t[n].r);
	sb.append(" " + t[n].node);
}

static void rk(int n,int p) {
	t[n].p = p;
	if(t[n].d  == 0)return;
	if(t[n].l != -1) rk(t[n].l,n);
	if(t[n].r != -1) rk(t[n].r,n);
}
}

class tree{
	int node,p,n,i,l,r,d = 0;

	tree(int node){
		this.node = node;
	}

	int getnode() {
		return node;
	}

	void setl(int a) {
		l = a;
		if(l != -1) {
			d++;
		}
	}

	int getl() {
		return l;
	}

	void setr(int a) {
		r = a;
		if(r != -1) {
			d++;
		}
	}

	int getr() {
		return r;
	}

	void setp(int a) {
		p = a;
	}

	int getp() {
		return p;
	}

	int getd() {
		return d;
	}
}


Measured memory_bytes: 26400
import sys
input = sys.stdin.readline

from bisect import bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

AA = [0]
for a in A:
    AA.append(AA[-1]+a)
BB = [0]
for b in B:
    BB.append(BB[-1]+b)

ans = 0
for i, aa in enumerate(AA):
    if aa > K: break
    ind = bisect_right(BB, K-aa)-1
    ans = max(ans, ind+i)

print(ans)

Measured memory_bytes: 124840
#include <bits/stdc++.h>
using namespace std;
map<string, string> m;
int main() {
  string a; cin >> a;
  for (int i = 0; i < a.size(); i++) {
    if (i % 2) {
      if (a[i] == 'R') {cout << "No" << endl; exit(0);}
    } else {
      if (a[i] == 'L') {cout << "No" << endl; exit(0);}
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define repeat(i,n) for (int i = 0; i < (n); ++i)
#define repeat_from(i,m,n) for (int i = (m); i < (n); ++i)

int main() {
    ios_base::sync_with_stdio(false);
    while (true) {
        int N; cin >> N;
        if (N == 0) break;
        vector<string> group(N);
        vector<vector<string> > member(N);
        repeat (i,N) {
            string s; cin >> s;
            int k = 0;
            repeat (j,(int)s.length()) {
                if (s[j] == ':' or s[j] == ',') {
                    k ++;
                    member[i].push_back("");
                } else if (s[j] == '.') {
                    break;
                } else {
                    (k == 0 ? group[i] : member[i][k-1]) += s[j];
                }
            }
        }
        vector<string> & m = member[0];
        bool changed = true;
        while (changed) {
            changed = false;
            repeat (i,(int)m.size()) {
                repeat_from (j,1,(int)group.size()) {
                    if (m[i] == group[j]) {
                        changed = true;
                        m.erase(m.begin() + i);
                        m.insert(m.end(), member[j].begin(), member[j].end());
                        sort(m.begin(), m.end());
                        m.erase(unique(m.begin(), m.end()), m.end());
                    }
                }
            }
        }
        cout << member[0].size() << endl;
    }
    return 0;
}

Measured memory_bytes: 1332
use std::collections::VecDeque;
use std::io::*;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut chs: VecDeque<char> = itr.next().unwrap().chars().collect();

    let mut ans = 0;
    for _ in 0..n {
        let s: Vec<char> = chs.clone().into_iter().collect();
        // z algo
        let mut a: Vec<usize> = vec![0; s.len()];
        a[0] = s.len();
        let mut i = 1;
        let mut j = 0;
        while i < s.len() {
            while i + j < s.len() && s[j] == s[i + j] {
                j += 1;
            }
            a[i] = j;
            if j == 0 {
                i += 1;
                continue;
            }
            let mut k = 1;
            while i + k < s.len() && k + a[k] < j {
                a[i + k] = a[k];
                k += 1;
            }
            i += k;
            j -= k;
        }
        //
        for x in 0..a.len() {
            if x >= a[x] {
                ans = std::cmp::max(ans, a[x]);
            }
        }

        chs.pop_front();
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int ans = 10000;
    for(int i=0; i<s.size()-t.size()+1; i++)
    {
        int tmp = 0;
        for(int j=0; j<t.size(); j++)
        {
            if(t[j] != s[i+j]) tmp++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
int arr[100];
using namespace std ;
int main ()
{
	int k,x;
	cin>>k>>x;
	if(k==1)
	{cout<<x;
	return 0;}
	else 
	{
		for(int i=0;i<k-1;i++)
		{
			arr[i]=x+1;
			x++;
		}
		for(int i=0;i<k-1;i++)
		{
		x--;
		}
		arr[k-1]=x;
		for(int i=k;i<(k*2)-1;i++)
		{
			arr[i]=x-1;
			x--;
		}
		std ::sort(arr,arr+(k*2-1));
		for(int i=0; i<(k*2)-1;i++)
		cout<<arr[i]<<" ";
	}
}


	

Measured memory_bytes: 256
s = input()
ok = False

if s.startswith('keyence'):
    ok = True
if s.startswith('k') and s.endswith('eyence'):
    ok = True
if s.startswith('ke') and s.endswith('yence'):
    ok = True
if s.startswith('key') and s.endswith('ence'):
    ok = True
if s.startswith('keye') and s.endswith('nce'):
    ok = True
if s.startswith('keyen') and s.endswith('ce'):
    ok = True
if s.startswith('keyenc') and s.endswith('e'):
    ok = True
if s.endswith('keyence'):
    ok = True

if ok:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
typedef double f64;
 
const int SPQR = 128;
const f64 EPS = 1e-16, PI = acos(-1);
 
struct PTX {
    f64 x, y;
 
	PTX(f64 _x = 0, f64 _y = 0) { x = _x, y = _y; }

    void rot(double alpha) {
        f64 _x = x * cos(alpha) - y * sin(alpha);
        f64 _y = x * sin(alpha) + y * cos(alpha);
        x = _x;
        y = _y;
    }
 
    bool operator < (const PTX &arg) const {
        return (abs(x-arg.x)<EPS) ? (y < arg.y) : (x < arg.x);
    }
};
 
//PTX pts[SPQR];
//bool gws[SPQR];
//vector<pair<PTX, PTX> > vag[SPQR];
 
f64 ccw(const PTX &a, const PTX &b, const PTX &c) {
    return (a.x-b.x)*(c.y-b.y)-(a.y-b.y)*(c.x-b.x);
}
 
vector<PTX> make_hull(vector<PTX> ptr) {
    vector<PTX> hull, ue, le;
 
    sort(ptr.begin(), ptr.end());
 
    for(int i=0; i<ptr.size(); ++i) {
        while(ue.size()>=2 && ccw(ue[ue.size()-2], ue[ue.size()-1], ptr[i])>EPS)
            ue.pop_back();
        while(le.size()>=2 && ccw(le[le.size()-2], le[le.size()-1], ptr[i])<-EPS)
            le.pop_back();
        ue.push_back(ptr[i]);
        le.push_back(ptr[i]);
    }
    for(int i=0; i<ue.size(); ++i)
        hull.push_back(ue[i]);
    for(int i=le.size()-2; i>=0; --i)
        hull.push_back(le[i]);
	hull.push_back(hull[1]);
 
    return hull;
}
 
vector<PTX> pts, hull;
vector<f64> ant;
map<PTX, int> mp;

int main(void) {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif

    int n;
 
    cin >> n;
    pts.resize(n);
	ant.resize(n);
    for(int i=0; i<n; ++i) {
        cin >> pts[i].x >> pts[i].y;
		mp[pts[i]] = i; }
 
    hull = make_hull(pts);

	for (int i = 1; i < hull.size() - 1; ++i) {
		PTX act = hull[i];
		PTX x = PTX(hull[i - 1].x - hull[i].x, hull[i - 1].y - hull[i].y);
		PTX y = PTX(hull[i + 1].x - hull[i].x, hull[i + 1].y - hull[i].y);
		swap(x, y);


		f64 angle = atan2(y.y, y.x) - atan2(x.y, x.x);
		if (angle < 0)
            angle += 2 * PI;
        if (angle > PI)
            angle = 2 * PI - angle;

		int where = mp[hull[i]];
		ant[where] = (PI - angle) / (2 * PI); }

	cout << setprecision(7) << fixed;
	for (auto i: ant)
		cout << i << '\n';	

    return 0; }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
priority_queue<int> q;
#define ran 333333
int n;
int a[ran];
long long int sum1[ran],sum2[ran];
int main(){
	scanf("%d",&n);
	for(int i=1; i<=3*n; i++)
		scanf("%d",&a[i]);
	while(!q.empty())q.pop();
	for(int i=1; i<=3*n; i++){
		sum1[i] = sum1[i-1] + a[i];
		q.push(-a[i]);
		if(q.size() > n){
			sum1[i] += q.top();
			q.pop();
		}
	}
	while(!q.empty())q.pop();
	for(int i=3*n; i>=1; i--){
		sum2[i] = sum2[i+1] + a[i];
		q.push(a[i]);
		if(q.size() > n){
			sum2[i] -= q.top();
			q.pop();
		}
	}
	long long int res = -1000000000000000000LL;
	for(int i=n; i<=2*n; i++)
		res = max(res, sum1[i] - sum2[i+1]);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin>>N;
    vector<int> x(N);
    vector<vector<int>> tree(N);
    REP(i,N-1) {
        int p;
        cin>>p;
        tree[p-1].push_back(i+1);
    }
    cin>>x;

    function<int(int)> dfs=[&](int v) {
        int ret=0;
        vector<vector<bool>> dp(SZ(tree[v])+1,vector<bool>(x[v]+1,false));
        int idx=0;
        dp[0][0]=true;
        FORE(w,tree[v]) {
            int s=dfs(w);
            REP(j,x[v]+1) {
                if(dp[idx][j]) {
                    if(j+(s-x[w])<=x[v]) dp[idx+1][j+(s-x[w])]=true;
                    if(j+x[w]<=x[v]) dp[idx+1][j+x[w]]=true;
                }
            }
            ret+=s;
            idx++;
        }
        bool possible=false;
        int weight=0;
        REPR(i,x[v]) {
            if(dp[idx][i]) {
                possible=true;
                weight=x[v]-i;
                break;
            }
        }
        if(!possible) {
            cout<<"IMPOSSIBLE"<<endl;
            exit(0);
        }
        return ret+weight;
    };
    dfs(0);
    cout<<"POSSIBLE"<<endl;
    return 0;
}



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

int n;
int a[100001];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  ll one1=-1,two2=-1;
  bool flag1=1,flag2=1;
  for(int i=n-1;i>=1;){
    if(a[i]==a[i-1] && flag1){
      one1=a[i];
      i-=2;
      flag1=0;
    }else if(a[i]==a[i-1] && flag2){
      two2=a[i];
      break;
    }else i--;
  }
  if(one1==-1 || two2==-1){
    cout<<0<<endl;
    return 0;
  }
  cout<<one1*two2<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define pb push_back
#define eb emplace_back

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

template<class T>
void dcomb(T n,T m, string s){
    if(n==0) cout << s << endl;
    else {
        for(T i=0; i<m; ++i){
            dcomb(n-1,m,s+to_string(i));
        }
    }
}

int  INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int n,m;
    cin >> n >> m;
    graph g(n);
    vector<pair<int,int>> ab(m);
    rep(i,m){
        cin >> ab[i].first >> ab[i].second;
        ab[i].first--;
        ab[i].second--;
        g[ab[i].first].emplace_back(ab[i].second);
        g[ab[i].second].emplace_back(ab[i].first);
    }
    int ans = 0;
    rep(i,m){
        vector<int> d(n,-INF);
        queue<int> que;
        que.emplace(0);
        d[0] = 1;
        while(!que.empty()){
            int s = que.front();
            que.pop();
            rep(j,g[s].size()){
                if(d[g[s][j]]<0){
                    if(s==ab[i].first || s==ab[i].second){
                        if(g[s][j]==ab[i].first || g[s][j]==ab[i].second) continue;
                        else {
                            que.emplace(g[s][j]);
                            d[g[s][j]] = 1;
                        }
                    }else{
                        que.emplace(g[s][j]);
                        d[g[s][j]] = 1;
                    }
                } 
                else continue;
            }
        }
        rep(l,n){
            if(d[l]<0){
                ans++;
                break;
            }else continue;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = list(map(int, input().split(" ")))
Amax = max(A)
dp = np.ones(Amax, dtype=bool)
appear = np.zeros(Amax, dtype=int)
for a in A:
  appear[a-1] += 1

for i in range(1, len(dp)+1):
  if not dp[i-1]:
    continue
  if appear[i-1] != 0:
    j = 2
    while j * i <= Amax:
      dp[j * i - 1] = False
      j += 1
# print(dp)

app_set = set([])
dup_set = set([])
count = 0
for a in A:
  if appear[a-1] > 1:
    continue
  else:
    count += dp[a-1]
print(count -  len(dup_set))



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

int main(){
  ll N,ans=0;
  cin>>N;
  ll a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
    ans+=a[i]-1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int f;
char c, ans[11];
int main(){
  c=getchar();
  while(c!=10){
    if(c=='B'){
      if(f!=0){ans[--f]=0;}
    }else{
      ans[f++]=c;
    }
    c=getchar();
  }
  printf("%s\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string>
#include <map>
using namespace std;

long long YKRD(long a, long b) {
	int r = 0;
	r = b % a;
	if (r == 0) {
		return a;
	}

	YKRD(r, a);

}

int main() {
	long long A, B;
	cin >> A >> B;
	long long X = A;

	if (A > B) {
		A = B;
		B = X;
	}
	long long SK=0;
	SK = YKRD(A, B);
	cout <<  A * B / SK << endl;
}



Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        M: usize,
        cards: [(usize, usize); M],
    }

    let mut lmax = 0;
    let mut rmin = std::usize::MAX;
    for &(l, r) in cards.iter() {
        lmax = cmp::max(lmax, l);
        rmin = cmp::min(rmin, r);
    }
    println!("{}", (rmin+1).saturating_sub(lmax));

}

Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

ll dp[50010];

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

    ll a,b,ans=0;
    cin>>a>>b;
    while(a<=b){
        ans++;
        a*=2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextLong();
        long min = long.MaxValue;
        for (long i = 0; i*i <= N; i++) {
            if (i == 0) continue;
            if (N % i != 0) continue;
            long j = N / i;
            min = Min(min, i + j - 2);
        }
        if (min == long.MaxValue) {
            min = N - 1;
        }
        WriteLine(min);
        
    }

    IEnumerable<long> PrimeFactors(long n) {
        long i = 2;
        long tmp = n;
        while (i * i <= n) {
            if (tmp % i == 0) {
                tmp /= i;
                yield return i;
            } else {
                i++;
            }
        }
        if (tmp != 1) yield return tmp;
    }

}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int n,k,sum=0;
  cin >> n >> k;
  int l[51];
  for(int i=0; i<n; i++){
    cin >> l[i];
  }
  sort(l,l+n,greater<int>());
  for(int i=0; i<k; i++){
    sum += l[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
template<class T, class U> bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }

int main(){
    string s, t;
    cin >> s >> t;
    int ans = INF;
    for(int i = 0; i <= s.size() - t.size(); i++){
        chmin(ans, transform_reduce(t.begin(), t.end(), s.begin() + i, 0, plus(), not_equal_to()));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 998244353
#define MAX 100009
#define endl '\n'
#define mp make_pair
#define INF 1000000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define F first
#define S second
 
using namespace std;

bool isprime(ll n){			//to check whteher no is prime or not
	if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

ll power(ll a,ll n){
	ll ans=1;
	while(n){
		if(n%2!=0){
			ans=((ans%mod)*(a%mod))%mod;
			n--;
		}
		else{
			a=((a%mod)*(a%mod))%mod;
			n/=2;
		}
	}
	return ans;
}

int main(){
	fast
//	int t;
//	cin>>t;
//	while(t--){
		ll a,b,c,d,n,m;
		ld p,q,r,s;
		cin>>a>>b;
		if(b>=a)	cout<<"unsafe";
		else	cout<<"safe";
//	}
}



Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M, P;
  cin>>N>>M>>P;
  vector<vector<pair<int, int> > > edge(N), redge(N);
  int a, b, c;
  for(int i=0;i<M;++i) {
    cin>>a>>b>>c;
    a--;
    b--;
    c -= P;
    edge[a].push_back(mp(b, -c));
    redge[b].push_back(mp(a, -c));
  }
  bool reach0[N], reachN[N];
  for(int i=0;i<N;++i) {
    reach0[i] = false;
    reachN[i] = false;
  }
  queue<int> que;
  int state;
  que.push(0);
  while(!que.empty()) {
    state = que.front();que.pop();
    if(reach0[state]==true) continue;
    reach0[state] = true;
    for(int i=0;i<edge[state].size();++i) {
      if(reach0[edge[state][i].fi]) continue;
      que.push(edge[state][i].fi);
    }
  }
  que.push(N-1);
  while(!que.empty()) {
    state = que.front();que.pop();
    if(reachN[state]==true) continue;
    reachN[state] = true;
    for(int i=0;i<redge[state].size();++i) {
      if(reachN[redge[state][i].fi]) continue;
      que.push(redge[state][i].fi);
    }
  }
  ll dist[N];
  for(int i=0;i<N;++i) dist[i] = big;
  dist[0] = 0;
  bool ok = true;
  for(int i=0;i<N;++i) {
    for(int j=0;j<N;++j) {
      if(!reach0[j] || !reachN[j]) continue;
      for(int k=0;k<edge[j].size();++k) {
        if(!reach0[edge[j][k].fi] || !reachN[edge[j][k].fi]) continue;
        if(dist[edge[j][k].fi]>dist[j]+edge[j][k].se) {
          if(i==N-1) ok = false;
          dist[edge[j][k].fi] = dist[j]+edge[j][k].se;
        }
      }
    }
  }
  if(!ok) cout<<-1<<endl;
  else {
    ll zero = 0;
    cout<<max(zero, -dist[N-1])<<endl;
  }
}



Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <queue>

using namespace std;
using ll = long long;

ll cal(ll h, ll A, ll B, ll T)
{
    ll t = h - B * T;
    if(t <= 0)
    {
        return 0LL;
    }
    else if(t % (A - B) == 0)
    {
        return t / (A - B);
    }
    else
    {
        return t / (A - B) + 1;
    }
}

int main()
{
    ll N, A, B;
    vector<ll> h;

    ll ans = 0;
    cin >> N >> A >> B;

    h.resize(N);

    for (int i = 0; i < N;i++)
    {
        cin >> h[i];
    }

    sort(h.begin(), h.end(), greater<ll>());

    ll high = h[0] % B == 0 ? (h[0] / B) : (h[0] / B + 1);
    ll low = 1;

    while(low <= high)
    {
        ll T = (high + low) / 2;
        //cout << "high = " << high << " low = " << low << endl;
        //cout << "T = " << T << endl;
        ll n = 0;
        for (int i = 0; i < N;i++)
        {
            n += cal(h[i], A, B, T);
        }
        if(n <= T)
        {
            ans = T;
            //cout << "ans = " << ans << endl;
            high = T - 1;
        }
        else
        {
            low = T + 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc082/tasks/arc087_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  string s;
  ll target_x, target_y;
  cin >> s >> target_x >> target_y;

  VL ds(0);

  ll cur = 0;

  for (auto c : s) {
    if (c == 'T') {
      ds.push_back(cur);
      cur = 0;
    } else if (c == 'F') {
      cur++;
    }
  }

  ds.push_back(cur);

  VL xds(0);
  VL yds(0);

  rep(i, ds.size()) {
    if (i % 2 == 0) xds.push_back(ds[i]);
    if (i % 2 == 1) yds.push_back(ds[i]);
  }

  const ll base = 8000;

  V<V<bool>> xdp(xds.size() + 1, V<bool>(base * 2 + 1));
  V<V<bool>> ydp(yds.size() + 1, V<bool>(base * 2 + 1));

  xdp[0][base] = true;
  ydp[0][base] = true;

  auto fill = [&](V<V<bool>>& dp, VL& ds, bool first_direction_restricted) {
    rep(i, ds.size()) rep(t, base * 2 + 1) {
      unless(dp[i][t]) continue;

      ll d = ds[i];
      dp[i + 1][t + d] = true;

      if (i == 0 && first_direction_restricted) continue;
      dp[i + 1][t - d] = true;
    }
  };

  fill(xdp, xds, true);
  fill(ydp, yds, false);

  if (xdp.back()[base + target_x] && ydp.back()[base + target_y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main(){
  int N;
  cin >> N;
  vector<tuple<string,int,int>> rest(N);
  for(int i=0;i<N;i++){
    string city;
    cin >> city;
    int P;
    cin >> P;
    P = P*(-1);
    rest.at(i) = make_tuple(city,P,i+1);
  }
  sort(rest.begin(),rest.end());
  for(int i=0;i<N;i++){
    int K;
    K = get<2>(rest.at(i));
    cout << K << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
using namespace std;
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define fill(x, y)     memset(x, y, sizeof(y))
#define all(x)         (x).begin(), (x).end()
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;

const int INF = 1e9 + 5;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vi h(N+1);
  h[0] = INF;
  for (int i = 1; i <= N; i++) {
    cin >> h[i];
  }
  vi dp(N, INF);
  dp[0] = 0;
  dp[1] = 0;
  for (int i = 2; i <= N; i++) {
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[N] << "\n";
  
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        long A = scanner.nextLong();
        long B = scanner.nextLong();
        long K = scanner.nextLong();

        long AA  = Math.max(0, A - K);
        long BB = B;
        if(0 > A - K) {
            BB = Math.max(0, B + (A - K));
        }

        System.out.println(AA);
        System.out.println(BB);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==5&&b==5&&c==7 || a==5&&b==7&&c==5 || a==7&&b==5&&c==5) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	string s, t;
	cin >> s >> t;
	rep (i, s.size()) {
	  if (s[i] != t[i]) {
		cout << "No" << endl;
		return 0;
	  }
	}
	cout << "Yes" << endl;
    
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int INT_INF = 999999999;
const static llong INF = 1LL << 60;
const static double eps = 1e-6;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

vector<int> dist;
vector<bool> visited;
vector<vector<pair<int, int> > > G; // {connected vertex, cost}

void dfs(int v) {
    visited[v] = true;

    rep(i, (int)G[v].size()) {
        if (visited[G[v][i].first]) continue;
        dist[G[v][i].first] = dist[v] + G[v][i].second;
        dfs(G[v][i].first);
    }

    return;
}

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    G.resize(n);
    rep(i, n - 1) {
        int s, t;
        cin >> s >> t;
        --s, --t;
        G[s].push_back(make_pair(t, 1)), G[t].push_back(make_pair(s, 1));
    }

    dist.resize(n);
    visited.resize(n);
    rep(i, n) {
        dist[i] = 0;
        visited[i] = false;
    }
    dfs(0);

    int farthest_v, cmp = -1;
    rep(i, n) {
        if (dist[i] >= cmp) {
            farthest_v = i;
            cmp = dist[i];
        }
    }

    rep(i, n) {
        dist[i] = 0;
        visited[i] = false;
    }
    dfs(farthest_v);

    cmp = -1;
    int diameter;
    rep(i, n) {
        if (dist[i] >= cmp) {
            diameter = dist[i];
            cmp = dist[i];
        }
    }

    if (diameter % 3 == 1) cout << "Second" << endl;
    else cout << "First" << endl;

    return 0;
}

Measured memory_bytes: 21376
#include<vector>
#include<iostream>
#include<algorithm>
#define MAX_V 100
#define INF 1e9
using namespace std;
int cost[MAX_V][MAX_V];
int d[MAX_V];
int used[MAX_V];
int V;//頂点の数

void dijkstra(int s)
{
	d[s] = 0;
	while (true)
	{
		int v = -1;
		for (int u = 0; u < V; u++)
		{
			if (!used[u] && (v == -1 || d[u] < d[v]))
			{
				v = u;
			}
		}
		if (v == -1)
		{
			break;
		}
		used[v] = true;
		for (int u = 0; u < V; u++)
		{
			d[u] = min(d[u], d[v] + cost[v][u]);
		}


	}
}

int main()
{
	
	cin >> V;
	for (int i = 0; i < MAX_V; i++)

	{
		d[i] = INF;
		used[i] = false;

	
	
	
	}
	for (int i = 0; i < MAX_V; i++)
	{
		for (int j = 0; j < MAX_V; j++)

		{
			cost[i][j] = INF;
		}
	}





	for (int i = 0; i < V; i++)
	{
		int u;
		cin >> u;
		int k;
		cin >> k;
		for (int i = 0; i < k; i++)

		{
			int v_to;
			cin >> v_to;
			int c;
			cin >> c;
			cost[u][v_to] = c;

		}
	}
	dijkstra(0);
	for (int i = 0; i < V; i ++ )
	{
		cout <<i<<" "<< d[i] << endl;
	}

}



Measured memory_bytes: 3140
N = int(input())
L = list(map(int, input().split()))
L.sort()
wa = 0
import bisect
for i in range(N-1,1,-1):
    for j in range(i-1,0,-1):
        diff = L[i]-L[j]
        k = bisect.bisect_right(L, diff)
        wa += j-k if j-k > 0 else 0           
            
print(wa)

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

int main () {
  int N, K, d_sum = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (x <= K - x) 
      d_sum += x * 2;
    
    else {
      d_sum += (K - x) * 2;
    }
  }
  
  cout << d_sum << endl;
}    

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		for (long h = 1; h <= 3500; h++) {
			for (long n = 1; n <= 3500; n++) {
				long bunbo = 4 * h * n - N * n - N * h;
				if (bunbo == 0) {
					continue;
				}
				if ((N * h * n) % bunbo == 0) {
					long w = (N * h * n) / bunbo ;
					if (w <= 0) {
						continue;
					}
					System.out.println(h + " " + n + " " + w);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 22608
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

bool is(string str)
{
    auto t=str;
    reverse(begin(t),end(t));
    return str==t;
}

main()
{
    double l; cin>>l;
    cout << setprecision(10) << pow(l/3,3) << "\n";
}

Measured memory_bytes: 512
def main():
    N, P = (int(i) for i in input().split())
    A = [int(i) % 2 for i in input().split()]
    from collections import Counter
    c = Counter(A)
    ans = 0
    if P == 0:
        ans = 2**c[0]
        if 0 < c[1]:
            ans *= 2**(c[1]-1)
    else:
        if 0 < c[1]:
            ans = 2**(c[1]-1)
        ans *= 2**c[0]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#!/usr/local/gnu/bin/bash
read n
read -a p
s=(`echo ${p[@]}| tr ' ' '\n' | sort -n`)
c=0
for i in `seq 0 $((n-1))`
do
    ((p[i]!=s[i])) && c=$((c+1))
done
((c<3)) && echo YES || echo NO


Measured memory_bytes: 780
N =int(input())
a =[]
for _ in range(0,N):
    a.append(int(input()))
b =[0]*N
b[0]=1
f=0
for i in range(1,N):
    b[i]=a[b[i-1]-1]
    if b[i]==2:
        f=i
        break
if f>0:
    print(i)
else:
    print(-1)

Measured memory_bytes: 7852
def erase_first_zero_then_eval(lo, ro, ans)
	return false if ((lo.size >= 2) and lo[0] == "0") or ((ro.size >= 2) and ro[0] == "0")
	if lo.to_i + ro.to_i == ans.to_i
		return true
	else
		return false
	end
end

def has_answer?(formula)
	(0..9).to_a.each do |x|
		lo, ro, ans = formula.gsub("X", x.to_s).scan(/\d+/)
		return x if erase_first_zero_then_eval(lo, ro, ans)
	end
	false
end

readlines.each do |f|
	ans = has_answer?(f)
	if ans
		puts ans
	else
		puts "NA"
	end
end

Measured memory_bytes: 6140