akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	int A, B, C;
	cin>>A>>B>>C;
	int ans = C - (A-B);
	if(ans < 0) ans = 0;
	cout<<ans<<endl;
}
 
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    const ll mod = 1e9 + 7;

    ll ans = 0;
    map<ll, ll> mp;
    for(int i = n - 1; i >= 0; i--) {
        rep(j, 60) {
            bool isone = (a[i] & (1LL << j)) > 0;
            if (isone)  {
                ans += ((1LL << j) % mod) * (n - i - mp[j] - 1);
                ans %= mod;
                mp[j]++;
            } else {
                ans += ((1LL << j) % mod) * mp[j];
                ans %= mod;
            }
        }
    }

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


Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007


//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}


int main(){
	int n, r;
	scanf("%d%d", &n, &r);
	if(n>=10) printf("%d\n", r);
	else{
		r += 100*(10-n);
		printf("%d\n", r);
	}
	//printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

using namespace std;

typedef long long int lli;

class UF {
public:
    vector<int> par;
    int cnt;
    UF(int n) : par(n), cnt(n) {
        REP (i, 0, n) par[i] = i;
    }
    int Find(int a) {
        return (par[a] == a ? a : par[a] = Find(par[a]));
    }
    void Union(int a, int b) {
        a = Find(a);
        b = Find(b);
        if (a == b) return;
        par[a] = b;
        cnt--;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    REP (i, 0, M) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    int ans = 0;
    REP (i, 0, M) {
        UF uf(N);
        REP (j, 0, M) {
            if (i == j) continue;
            uf.Union(a[j], b[j]);
        }
        ans += (uf.cnt != 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> v;
  REP(i, N) {
    int A;
    cin >> A;
    v.push_back(A);
  }
  sort(v.begin(), v.end());
  int ret = true;
  REP(i, N-1) {
    if(v[i] == v[i+1]) {
      ret = false;
      break;
    }
  }
  cout << (ret ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#define EPS 1e-10
using namespace std;

int n,m;

double add(double a,double b){
	if(fabs(a+b)<EPS*(a+b))return 0.0;
	return a+b;
}

struct Point{
	double x,y;
	Point(){}
	Point(double xx,double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(add(x,p.x),add(y,p.y));
	}
	Point operator -(Point p){
		return Point(add(x,-p.x),add(y,-p.y));
	}
	Point operator *(double d){
		return Point(x*d,y*d);
	}
	Point operator /(double d){
		return Point(x/d,y/d);
	}
};

struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};
typedef Point Vector;
typedef Segment Line;

typedef vector<Point> Polygon;

double norm(Vector a){
	return add(a.x*a.x,a.y*a.y);
}

double abs(Vector a){
	return sqrt(norm(a));
}

double dot(Vector a,Vector b){
	return add(a.x*b.x,a.y*b.y);
}

double cross(Vector a,Vector b){
	return add(a.x*b.y,-a.y*b.x);
}

Point getCrossPoint(Segment s1,Segment s2){
	Vector base=s2.p2-s2.p1;
	double d1=abs(cross(base,s1.p1-s2.p1));
	double d2=abs(cross(base,s1.p2-s2.p1));
	double t=d1/(d1+d2);
	return s1.p1+(s1.p2-s1.p1)*t;
}

int ccw(Point p0,Point p1,Point p2){
	Vector a=p1-p0;
	Vector b=p2-p0;
	if(cross(a,b)>EPS)return 1;
	if(cross(a,b)<-EPS)return -1;
	if(dot(a,b)<EPS)return 2;
	if(norm(a)<norm(b))return -2;
	return 0;
}

Polygon convex_cut(const Polygon& P,const Line& l){
	Polygon Q;
	for(int i=0;i<P.size();i++){
		Point A=P[i], B=P[(i+1)%P.size()];
		if(ccw(l.p1,l.p2,A)!=-1)Q.push_back(A);
		if(ccw(l.p1,l.p2,A)*ccw(l.p1,l.p2,B)<0){
			Q.push_back(getCrossPoint(Line(A,B),l));
		}
	}
	return Q;
}

double getArea(const Polygon& P){
	double A=0;
	for(int i=0;i<P.size();i++){
		A+=cross(P[i],P[(i+1)%P.size()]);
	}
	return A/2.0;
}

Point c[11];
Polygon l;
int main(void){
	while(1){
		scanf("%d %d",&n,&m);
		if(n+m==0)break;
		l.clear();
		for(int i=0;i<n;i++){
			double x,y;
			scanf("%lf%lf",&x,&y);
			l.push_back(Point(x,y));
		}
		for(int i=0;i<m;i++){
			scanf("%lf%lf",&c[i].x,&c[i].y);
		}
		for(int i=0;i<m;i++){
			Polygon li=l;
			for(int j=0;j<m;j++){
				if(i==j)continue;
				Point l1=(c[i]+c[j])/2.0;
				Vector base=c[j]-c[i];
				Vector base2=Vector(-base.y,base.x);
				Point l2=l1+base2;
				li=convex_cut(li,Line(l1,l2));
			}
			printf("%.10f\n",getArea(li));
		}
	}
	return 0;
}

Measured memory_bytes: 1096
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10, A = 1e6 + 10, mod = 998244353;

ll ctr[A], mu[A], f[A], fsum[A];

ll pwr(ll x, ll e);

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		int a; cin >> a;
		++ctr[a];
	}
	mu[1] = 1;
	for (int i = 1; i < A; ++i) {
		for (int j = 2 * i; j < A; j += i) {
			mu[j] -= mu[i];
		}
	}
	ll ans = 0;
	for (int g = A - 1; g >= 1; --g) {
		ll sum = 0, sq_sum = 0;
		for (ll d = g; d < A; d += g) {
			sum += d * ctr[d];
			sq_sum += d * d * ctr[d];
			sum %= mod; sq_sum %= mod;
		}
		fsum[g] = (sum * sum - sq_sum);
		fsum[g] %= mod;
		fsum[g] *= pwr(2, mod - 2);
		fsum[g] %= mod;
		for (int d = g; d < A; d += g) {
			f[g] += mu[d / g] * fsum[d];
			f[g] %= mod;
		}
		ans += f[g] * pwr(g, mod - 2);
		ans %= mod;
	}
	ans += mod; ans %= mod;
	cout << ans << endl;
}

ll pwr(ll x, ll e) {
	ll res = 1;
	while (e) {
		if (e & 1) {
			res = (res * x) % mod;
		}
		x = (x * x) % mod;
		e /= 2;
	}
	return res;
}

Measured memory_bytes: 31488
#include <stdio.h>
#include <vector>
#include <limits.h>
#include <queue>
#include <string.h>
#include <algorithm>
#include <functional>
using namespace std;

//total # of nodes
const int MAXN = 20005;

struct Maxflow {
	struct E {
		int x, inv, cap, flow;
		E(int t, int c, int z) : x(t), inv(z), cap(c), flow(0) {}
		int rest() const { return cap - flow; }
	};
	int V, d[MAXN], e_try[MAXN];
	vector <E> g[MAXN];
	Maxflow(int V) : V(V) {}
	void addedge(int a, int b, int a2b, int b2a = 0) {
		int as = g[a].size(), bs = g[b].size();
		g[a].push_back({ b, a2b, bs });
		g[b].push_back({ a, b2a, as });
	}
	bool bfs(int S, int T) {
		memset(d, -1, sizeof(d));
		queue <int> q; q.push(S);
		d[S] = 0;
		while (!q.empty()) {
			int x = q.front(); q.pop();
			for (auto &e : g[x]) {
				if (d[e.x] == -1 && e.rest() > 0) {
					d[e.x] = d[x] + 1;
					q.push(e.x);
				}
			}
		}
		return d[T] != -1;
	}
	int dfs(int x, int T, int flow) {
		if (x == T) return flow;
		for (int& i = e_try[x]; i < g[x].size(); i++) {
			E &e = g[x][i];
			if (e.rest() > 0 && d[e.x] == d[x] + 1) {
				int t = dfs(e.x, T, min(flow, e.rest()));
				if (t > 0) {
					E &re = g[e.x][e.inv];
					e.flow += t;
					re.flow = -e.flow;
					return t;
				}
			}
		}
		return 0;
	}
	int go(int S, int T) {
		int res = 0, t = 0;
		while (bfs(S, T)) {
			memset(e_try, 0, sizeof(e_try));
			do {
				t = dfs(S, T, numeric_limits<int>::max());
				res += t;
			} while (t);
		}
		return res;
	}
};
int N, M, sx, sy, tx, ty, n, c[105][105];
char S[105][105];
int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; i++) {
		scanf("%s", S[i] + 1);
		for (int j = 1; j <= M; j++) {
			if (S[i][j] == 'S') sx = i, sy = j, c[i][j] = ++n;
			if (S[i][j] == 'T') tx = i, ty = j, c[i][j] = ++n;
			if (S[i][j] == 'o') c[i][j] = ++n;
		}
	}
	Maxflow f(2 * n + 1);
	if (sx == tx || sy == ty) puts("-1");
	else {
		for (int i = 1; i <= n; i++) {
			if (i == c[sx][sy] || i == c[tx][ty]) continue;
			f.addedge(2 * i - 1, 2 * i, 1, 0);
		}
		f.addedge(2 * c[sx][sy] - 1, 2 * c[sx][sy], n, 0);
		f.addedge(2 * c[tx][ty] - 1, 2 * c[tx][ty], n, 0);
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= M; j++) {
				if (c[i][j]) {
					int x = c[i][j];
					for (int k = 1; k <= M; k++) {
						if (j == k) continue;
						if (c[i][k]) {
							int y = c[i][k];
							f.addedge(2 * x, 2 * y - 1, 1, 0);
						}
					}
					for (int k = 1; k <= N; k++) {
						if (i == k) continue;
						if (c[k][j]) {
							int y = c[k][j];
							f.addedge(2 * x, 2 * y - 1, 1, 0);
						}
					}
				}
			}
		}
		int res = f.go(2 * c[sx][sy] - 1, 2 * c[tx][ty]);
		printf("%d", res);
	}
}

Measured memory_bytes: 83072
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    ll x[1010], y[1010], z[1010];
    imfor(i, n) {
        cin >> x[i] >> y[i] >> z[i];
    }
    ll ans = -1;
    for (int i = -1; i <= 1; i += 2) {
        for (int j = -1; j <= 1; j += 2) {
            for (int k = -1; k <= 1; k += 2) {
                vector<ll> vec;
                imfor(l, n) {
                    vec.push_back(i * x[l] + j * y[l] + k * z[l]);
                }
                sort(vec.begin(), vec.end(), greater<ll>());
                ll tmp = 0;
                imfor(l, m) {
                    tmp += vec[l];
                }
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }



int main() {
    ll n;
    cin >> n;
    VL a(n);
    REP(i,n) a[i] = in();
    VL s(n+1);
    REP(i,n) s[i+1] = s[i] + a[i];

    VL mil(n+1), mal(n+1), mir(n+1), mar(n+1);
    FOR(i,2,n){
        ll t = s[i] - s[0];
        int x = lower_bound(ALL(s), (t + 1) / 2) - s.begin();
        ll tmp = 0;
        if (x < i) tmp = max(tmp, min(s[x], t - s[x]));
        x--;
        if (x > 0) tmp = max(tmp, min(s[x], t - s[x]));
        mil[i] = min(tmp, t - tmp);
        mal[i] = max(tmp, t - tmp);
    }
    REP(i,n-1){
        ll t = s[n] - s[i];
        int x = lower_bound(ALL(s), s[i] + (t + 1) / 2) - s.begin();
        ll tmp = 0;
        if (x > i && x < n) tmp = max(tmp, min(s[n] - s[x], t - s[n] + s[x]));
        x--;
        if (x > i && x < n) tmp = max(tmp, min(s[n] - s[x], t - s[n] + s[x]));
        mir[i] = min(tmp, t - tmp);
        mar[i] = max(tmp, t - tmp);
    }

    ll ans = 1e18;
    FOR(i,2,n-2){
        ll tmp = max(mal[i], mar[i]) - min(mil[i], mir[i]);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;

string app() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  return ((c-1)/b<=(a-1)/d)?"Yes":"No";
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3624
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

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

fn digits(x: u64) -> Vec<char> {
    x.to_string().chars().collect()
}

fn dfs(x: u64, upper: u64) -> u64 {
    if x > upper {
        return 0;
    }
    let mut count = 0;

    let d = digits(x);
    //    debug!(&d);
    if d.contains(&'3') && d.contains(&'5') && d.contains(&'7') {
        count += 1;
    }

    for &i in &vec![3, 5, 7] {
        count += dfs(10 * x + i, upper);
    }

    count
}

fn main() {
    let n = read!(u64);

    println!("{}", dfs(0, n));
}


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

void solve(long long N, std::vector<long long> A) {
  long long ans = A[0];
  for(int i = 0 ; i < N ; i++){
    ans = __gcd(ans, A[i]);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 1024
const main = (inputs) => {
  var array = inputs[0].split(" ");
  var array2 = inputs[1].split(" ");

  var K = Number(array);
  var A = Number(array2[0]);
  var B = Number(array2[1]);


  var num = K * Math.floor(B / K)


  if (num >= A && num <= B) {
    console.log('OK');
  } else {
    console.log('NG');
  }

}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

Measured memory_bytes: 29632
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream &operator<<(ostream &os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i];
    return os;
}
const bool debug = 1;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    V<int> a(n);
    F(i,n) cin>>a[i];
    int cost = 0;
    bool poss = (a[0] == 0);
    D(i,n) {
        if (i+1<n && a[i+1] > a[i]+1)
            poss = false;
        if (i+1 == n || a[i] > a[i+1]-1)
            cost += a[i];
    }
    if (!poss) cost = -1;
    cout<<cost<<"\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N, K;
    cin >> N >> K;
    long long mul = K;
    int ans = 1;
    while (N >= mul) {
        ans++;
        mul *= K;
    }

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

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int N, A, B, C;
int l[8];
const int INF = 1000000000;

int dfs(int n, int a, int b, int c)
{
    if (n == N) return min(a, min(b, c)) > 0 ? abs(A - a) + abs(B - b) + abs(C - c) - 30 : INF;
    int ret0 = dfs(n + 1, a, b, c);
    int ret1 = dfs(n + 1, a + l[n], b, c) + 10;
    int ret2 = dfs(n + 1, a, b + l[n], c) + 10;
    int ret3 = dfs(n + 1, a, b, c + l[n]) + 10;
    return min(ret0, min(ret1, min(ret2, ret3)));
}

int main()
{
    cin >> N >> A >> B >> C;
    REP(i, N) cin >> l[i];

    cout << dfs(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
aa = math.ceil(a/10)*10
bb = math.ceil(b/10)*10
cc = math.ceil(c/10)*10
dd = math.ceil(d/10)*10
ee = math.ceil(e/10)*10
lista = [a, bb, cc, dd, ee]
listb = [aa, b, cc, dd, ee]
listc = [aa, bb, c, dd, ee]
listd = [aa, bb, cc, d, ee]
liste = [aa, bb, cc, dd, e]
suma = sum(lista)
sumb = sum(listb)
sumc = sum(listc)
sumd = sum(listd)
sume = sum(liste)
print(min(suma, sumb, sumc, sumd, sume))




Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MAX = 100000;
const int INF = 1<<29;
vector<int> G[MAX];
list<int> out;
int n;
bool V[MAX];
int indeg[MAX];
void bfs(int s){
  queue<int>q;
  q.push(s);
  V[s]=true;
  while(!q.empty()){
    int u=q.front();q.pop();
    out.push_back(u);
    r(i,G[u].size()){
      int v=G[u][i];
      indeg[v]--;
      if(!indeg[v]&&!V[v]){
        V[v]=true;
        q.push(v);
      }
    }
  }
}
void Tsort(){
  r(u,n)r(i,G[u].size())indeg[G[u][i]]++;
  r(u,n)if(!indeg[u]&&!V[u])bfs(u);
  for(list<int>::iterator it=out.begin();it!=out.end();it++)
    cout<<*it<<endl;
}
int main(){
  int s,t,m;
  cin>>n>>m;
  r(i,m){
    cin>>s>>t;
    G[s].push_back(t);
  }
  Tsort();
}

Measured memory_bytes: 6188
#include<bits/stdc++.h>
using namespace std;
    int main(){
  string s,t;
  cin>>s>>t;
  if(s.size() != t.size()-1)
  {
      cout<<"No";
      return 0;
  }
  for(int i=0;i<s.size();i++){
    if(s[i] != t[i]){
        cout<<"No";
        return 0;
    }
  }
  cout<<"Yes";
}


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

typedef long long ll;
using namespace std;

int main() {
  string S, T;
  cin >> S;
  cin >> T;
  int count = 0;
  for (int i = 0; i < (int)S.size(); i++) {
    if (S[i] != T[i]) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3836
n = int(input())
dic = {}
max = 1
for i in range(n):
    # print(dic)
    s = input()
    if not s in dic.keys():
        dic[s] = 1
    else:
        dic[s] += 1
        if dic[s] > max:
            max = dic[s]

# print(dic)
keys = [k for k, v in dic.items() if v == max]
print(("\n").join(sorted(keys)))

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

int main(){
	int n;
	cin >> n;
	int i=1;
	while(++i<=n){
		int x=i;
		if(x%3==0){
			cout <<' '<< i;
			continue;
		}
	
		while(x){
			if(x%10==3){
				cout <<' '<< i;
				break;
			}x/=10;
		}
	}cout << endl;
}


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

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

    int n;
    cin >> n;
    vector<ll> x(n), y(n), p(n);
    rep(i, n) cin >> x[i] >> y[i] >> p[i];

    const ll INF = 1ll << 60;
    vector<ll> res(n+1, INF);
    vector<int> xs, ys, no;
    for(ll i = 0; i < pow(3, n); ++i){
        xs.clear();
        ys.clear();
        no.clear();
        ll dig = i;
        rep(j, n){
            if(dig % 3 == 0) no.push_back(j);
            if(dig % 3 == 1) xs.push_back(j);
            if(dig % 3 == 2) ys.push_back(j);

            dig /= 3;
        }

        ll cost = 0;
        for(int j: no){
            ll dist = min(abs(x[j]), abs(y[j]));
            for(int k: xs) dist = min(dist, abs(x[k]-x[j]));
            for(int k: ys) dist = min(dist, abs(y[k]-y[j]));

            cost += dist * p[j];
        }

        int cnt = xs.size() + ys.size();
        res[cnt] = min(res[cnt], cost);
    }

    rep(i, n+1) cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 3972
from itertools import product

N, M = map(int, input().split())
B = [list(map(int, input().split())) for i in range(M)]
P = input().split()

ans = 0

for switch in product([True, False], repeat=N):
    for b, p in zip(B, P):
        if sum([switch[b[i]-1] for i in range(1, len(b))]) % 2 == int(p):
            pass
        else:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int INF = 10000000;
int main()
{
	int n;
	while(scanf("%d", &n), n){
		vector<pii> doll(n);
		rep(i, n){
			scanf("%d%d", &doll[i].first, &doll[i].second);
			doll[i].first *= -1;
		}
		
		int m;
		scanf("%d", &m);
		doll.resize(n+m);
		rep(i, m){
			scanf("%d%d", &doll[n+i].first, &doll[n+i].second);
			doll[n+i].first *= -1;
		}
		
		sort(doll.begin(), doll.end(), greater<pii>());
		vi dp(n+m, INF);
		rep(i, n+m){
			int id = distance(dp.begin(), lower_bound(dp.begin(), dp.end(), doll[i].second));
			dp[id] = doll[i].second;
		}
		
		int ans;
		for(int i=n+m-1; i>=0; --i){
			if(dp[i] != INF){
				ans = i + 1;
				break;
			}
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        vector<ll> a(n),b(n,0),c(n,0);
        for(int i=0;i<n;i++)
        cin>>a[i];
        while(k--)
        {
            for(ll i=0;i<n;i++)
            {
                b[max(i-a[i],0LL)]++;
                if(min(i+a[i],n-1)!=n-1)
                {
                    b[min(i+a[i],n-1)+1LL]--;
                }
            }
            for(int i=1;i<n;i++)
            b[i]+=b[i-1];
            if(a==b)
            break;
            a=b;
            b=c;
        }
        for(int i=0;i<n;i++)
        cout<<a[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 7928
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"


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




int main() {
	while (1) {
		vector<bool>exists(26);
		UnionFind uf(26);
		vector<vector<int>>edges(26), revedges(26);;
		int N; cin >> N;
		if (!N)break;
		for (int i = 0; i < N; ++i) {

			string st; cin >> st;
			edges[st[0] - 'a'].push_back(st.back() - 'a');
			revedges[st.back() - 'a'].push_back(st[0] - 'a');
			exists[st[0] - 'a'] = true;
			exists[st.back() - 'a'] = true;
			uf.unionSet(st[0] - 'a', st.back() - 'a');
		}
		int aroot;
		for (int i = 0; i < 26; ++i) {
			if (exists[i]) {
				aroot = uf.root(i);
				break;
			}
		}
		bool aok = true;
		for (int i = 0; i < 26; ++i) {
			if (exists[i]) {
				if (aroot != uf.root(i)) {
					aok = false;
				}
			}
		}
		for (int i = 0; i < 26; ++i) {
			if (edges[i].size() == revedges[i].size()) {

			}
			else {
				aok = false;
			}
		}
		if (aok)cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

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

int n, k;
string s;

int main() {

	cin >> n >> k >> s;
	if (s[k - 1] == 'A') s[k - 1] = 'a';
	else if (s[k - 1] == 'B') s[k - 1] = 'b';
	else if (s[k - 1] == 'C') s[k - 1] = 'c';
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <functional>
#include <set>
#include <iomanip>
#include <tuple>
typedef  long long ll;
using namespace std;

int main(void) {
	string o, e;
	cin >> o >> e;

	for (int i = 0; i < o.size() + e.size(); i++)
	{
		if(i % 2 == 0) cout << o[i / 2];
		else cout << e[i / 2];
	}


	

	return 0;
}

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

using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;	
	char n = 'a';
	while (true) {
		if (n == 'a') {
			if (a.size() == 0) {
				cout << 'A' << endl;
				return 0;
			}
			else {
				n = a[0];
				a = a.substr(1, a.size() - 1);
			}
		}
		else if (n == 'b') {
			if (b.size() == 0) {
				cout << 'B' << endl;
				return 0;
			}
			else {
				n = b[0];
				b = b.substr(1, b.size() - 1);
			}
		}
		else {
			if (c.size() == 0) {
				cout << 'C' << endl;
				return 0;
			}
			else {
				n = c[0];
				c = c.substr(1, c.size() - 1);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
// AT.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
int main()
{
	int x;
	cin >> x;
	int res = 0;
	while (x >= 500)
	{
		res += 1000;
		x -= 500;
	}
	while (x >= 5)
	{
		res += 5;
		x -= 5;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum=INT_MAX,t,mk,top,k;

vector<int> v[N];

ll f(int ind,int back,int len)
{
	if(len>k/2)
		top++;
	// if(len==k/2)
	// {
	// 	if(ind!=back)
	// 	mk=max(mk,(ll)v[ind].size()-1ll);
	// 	else
	// 		mk=max(mk,(ll)v[ind].size());
	// }
	ll tp=0;
	if(len==k/2+1)
		tp++;
	for(int i=0;i<v[ind].size();i++)
	{
		int x=v[ind][i];
		ll y=0;
		if(x!=back)
			y=f(x,ind,len+1);
		tp+=y;
		if(ind==back)
			mk=max(mk,y);
	}
	return tp;
}

int main()
{
	fast;
	cin>>n>>k;
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	if(k==1)
		return cout<<n-2,0;
	for(int h=1;h<=n;h++)
	{
		mk=0;
		top=0;
		int ind=h;
		f(ind,ind,0);
		// cout<<top<<sp<<mk<<endl;
		if(k%2==1)
			top-=mk;
		sum=min(sum,top);
		// if(top==5)
		// 	cout<<h<<sp<<mk<<endl;

	}
	cout<<sum<<endl;

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 25088
#include<iostream>
#include<vector>
#include<algorithm>

#define Triangle(s1,s2,s3) if(s1*s1+s2*s2==s3*s3)
using namespace std;

int main()
{
	int n;
	int h[3];
	vector<int> side;
	int i;
	
	cin >> n;
	
	for(i=0;i<n;i++)
	{
		side.clear();
		
//		vector<int>::iterator it=side.begin();
		
		for(int j=0;j<3;j++)
		{
			cin >> h[j];
			side.push_back(h[j]);
//			cout << "side: " << side[j] << endl;
		}
		
		sort(side.begin(),side.end());
		
//		it=side.begin();
		
//		cout << endl;
		
//		for(;it!=side.end();it++)
//			cout << *it << " " ;
		
//		cout << endl;
		
//		cout << "side1:" << side[0]*side[0] << " side2:" << side[1]*side[1] << " side3:" << side[2]*side[2] << endl;
		
		Triangle(side[0],side[1],side[2])
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

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

long long counter(string s){
    long long count = 0;
    for(long long i = 0; i < s.size()-1; i++){
        if(s[i] == 'A' and s[i+1] == 'B'){
            count++;
        }
    }
    return count;
}

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

    long long count_a = 0;
    long long count_b = 0;
    long long count_ab = 0;

    long long count = 0;
    for(long long i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s[0] == 'B'){
            count_b++;
        }
        if(s[s.size()-1] == 'A'){
            count_a++;
        }

        if(s[0] == 'B' and s[s.size()-1] == 'A'){
            count_ab++;
        }

        count += counter(s);
    }

    //printf("in ab %lld\n", count);
    //printf("count_a %lld count_b %lld count_ab %lld\n", count_a, count_b, count_ab);

    
    count_a -= count_ab;
    count_b -= count_ab;
   

    if(count_ab == 0){
        count += min(count_a, count_b);
        cout << count << endl;

        return 0;
    }

    if(count_a == 0 and count_b == 0){
        count += count_ab-1;
        cout << count << endl;
        return 0;
    }

    count += count_ab-1+2 + min(count_a-1, count_b-1);

    cout << count << endl;
    return 0;

}

Measured memory_bytes: 384
N, M = map(int, input().split())
src = [tuple(map(int, input().split())) for i in range(M)]
P = list(map(int, input().split()))

ans = 0
for b in range(1<<N): #スイッチon offの全ての状態を列挙
  for i in range(M): # M個の電球に対して
    c = 0
    for s in src[i][1: ]: # つながっているそれぞれのスイッチが
      if b&(1<<(s-1)): # onになっているかどうか
        c += 1 # onになっていればcountを+1
    if c%2 != P[i]: break # countの偶奇を判定して、一致しなければ次の電球を調べる
  else: # そうでなければans+=1
    ans += 1

print(ans)

Measured memory_bytes: 3064
/**
*    author:  Dooloper
*    created: 27.06.2020 20:55:26
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
    int a,b,c,n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        if(a*a==c*c+b*b||b*b==c*c+a*a||c*c==a*a+b*b)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  if(n/10==9||n%10==9){
    cout  << "Yes" << endl;
  }else{
    cout  << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#define R register
#define ll long long
inline int read(){
	R int x; R bool f; R char c;
	for (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');
	for (x=c^'0'; (c=getchar())>='0'&&c<='9'; x=(x<<3)+(x<<1)+(c^'0'));
	return f?-x:x;
}
#define MN 30005
bool used[MN];
int n,sum;
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
	n=read();R int i,j;
	for (i=j=1; i<=30000&&j<n; ++i)
		if (i%2==0||i%3==0){
			used[i]=1;
			sum+=i;
			++j;
		}
	for (i=1; i<=30000; ++i)
		if (!used[i]&&(sum+i)%2==0&&(sum+i)%3==0)
			if (gcd(sum,i)>1){
				used[i]=1;
				break;
			}
	for (i=1; i<=30000; ++i) if (used[i]) printf("%d ",i);
	return 0;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
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;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int X, Y;
    cin >> X >> Y;
    cout << X+Y/2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char ch;
    int b[500];
    
    for(int i=0;i<500;i++){
        b[i] = 0;
    }
    while(scanf("%c",&ch) != EOF){
        if(ch>='A' && ch<='Z'){
            ch +='a'-'A';
        }
        b[ch]++;
    }
    for(int i='a';i<='z';i++){
        printf("%c : %d\n",i,b[i]);
    }
    return 0;
}



Measured memory_bytes: 2056
#include<stdio.h>
#include<stdlib.h>
int main(void){
int n;
  scanf("%d",&n);
  int p[2][n];						//0行目:pの数列
  									//1行目:qの数列
   
  for(int i=0;i<n;i++){
    scanf("%d",&p[0][i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d",&p[1][i]);
  }
  int pq[2]={0,0},order=0,kai=1;
  for(int g=0;g<2;g++){//111
    for(int i=0;i<n-1;i++){//222
      //printf("%d桁目---",i+1);
	for(int j=i+1;j<n;j++){//333
      if(p[g][i]>p[g][j])order++;
    }//333
      //printf("%d番目の大きさ\n",order);
      if(order>0){//555
      for(int k=n-i-1;k>=1;k--){//444
        kai*=k;
      }//444
      //printf("階乗%d\n",kai);
      pq[g]+=order*kai;
      order=0;
      kai=1;
      }//555
  }//222
}//111
printf("%d",abs(pq[0]-pq[1]));
return 0;
}

Measured memory_bytes: 128
from fractions import gcd
from functools import reduce

n,x_ = map(int, input().split())
x = list(map(int, input().split()))

def func(x,n):
    x.sort()
    y = [abs(x[i+1]-x[i]) for i in range(n-1)]
    kotae = reduce(lambda a,b:gcd(a,b),y)
    print(kotae)

if x_ in x:
    func(x,n)
else:
    x.append(x_)
    func(x,n+1)

Measured memory_bytes: 16304
#include "iostream"
#include "cmath"
#include "iomanip"
using namespace std;

int main(int argc, char const *argv[])
{
	double x1, y1, x2, y2=0;

	cin >> x1 >> y1 >> x2 >> y2;

	// printf("%.10f\n", sqrt( pow(x1 - x2, 2) + pow(y1 - y2, 2) ));
	cout << setprecision(10) << sqrt( pow(x1 - x2, 2) + pow(y1 - y2, 2) ) <<endl;
	return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;

using namespace std;

#define ll  long long

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef unordered_map<int,int> um;
typedef unordered_set<int> us;
typedef priority_queue<int> pq;
typedef deque<int> dq;
typedef queue<int> q;
typedef stack<int> st;

#define f first
#define s second
#define pb push_back
#define mp make_pair

#define rep(i,a,b) for (auto i = a; i < b; i++)

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

int MAX = 100005;

std::vector<ll> edges[100005];
std::vector<ll> dist(MAX,0);
std::vector<ll> indegree(MAX,0);
std::vector<bool> visited(MAX,false);


void dfs(ll i){
	visited[i]=true;
	for(ll c: edges[i]){
		dist[c] = max(dist[c], dist[i]+1);
		--indegree[c];
		if(!indegree[c]){
			dfs(c);
		}
	}
}

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	
	ll n,m;
	cin>>n>>m;

	while(m--){
		ll a,b;
		cin>>a>>b;
		edges[a].pb(b);

		indegree[b]++;
	}

	rep(i,1,n+1){
		if(!visited[i] && !indegree[i]){
			dfs(i);
		}
	}

	ll res=0;
	rep(i,1,n+1){
		res = max(res,dist[i]);
	}

	cout<<res;

	return 0;
	}

		

Measured memory_bytes: 10496
#include <bits/stdc++.h>
struct Istream {
	template <class T> 
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}
	template <class T>
	operator T() {
		static T x;
		*this>>x;
		return x;
	}
}is;
struct Ostream {
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}
	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}
}os;
const int MAXN=500000+11;
struct Range {
	long long l,r;
	Range(long long const &l,long long const &r):l(l),r(r) {}
	friend bool operator &(Range const &lhs,Range const &rhs) {	return lhs.r>=rhs.l && lhs.l<=rhs.r; }
};
int main() {
	int n=(int)is-2;
	long long a=is,b=is,c=is,d=is;
	bool tak=0;
	Range blow(b-d,b-c),bup(b+c,b+d);
	for(int i=0;i<=n;++i) {
		Range go(a+i*d-(n-i)*c,a+(i*c)-(n-i)*d);
		if(go.l>go.r) std::swap(go.l,go.r);
		if((go & blow) || (go & bup)) {
			tak=1;
			break;
		}
	}
	std::cout<<(tak?"YES":"NO")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    rep(i, M) cin >> A.at(i);

    int cnt_l = 0;
    rep(i, M) {
        if(A.at(i) < X) cnt_l++;
        else break;
    }
    int cnt_r = M - cnt_l;

    cout << min(cnt_l, cnt_r) << endl;
}

Measured memory_bytes: 256
n = int(input())
L = [None]+list(input().split())
even = []
odd = []
if n % 2 == 0:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    ans = even[::-1] + odd
else:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    ans = odd[::-1] + even
for i in range(n-1):
    print(ans[i],end=' ')
print(ans[n-1])

Measured memory_bytes: 24768
#include<vector>
#include<iostream>
#include<set>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
int n, x=0, m;
set<int>s1, s2, s3;
vector<int>v;
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	x = 0;
	for (int i = 0; i < m; i++)
		x += v[i];
	cout << x;
}

Measured memory_bytes: 3588
N = int(input())
A = sorted([int(i) for i in input().split()])

if max(A) < 0:
    print(max(A)-sum(A[:-1]))
    c = max(A)
    for i in range(N-1):
        print(c, A[i])
        c -= A[i]

elif min(A) >= 0:
    print(sum(A[1:])-min(A))
    c = min(A)
    for i in range(1, N-1):
        print(c, A[i])
        c -= A[i]
    print(max(A), c)

else:
    print(sum(abs(x) for x in A))
    c = min(A)
    d = max(A)
    for i in range(1, N-1):
        if A[i] < 0:
            print(d, A[i])
            d -= A[i]
        else:
            print(c, A[i])
            c -= A[i]
    print(d, c)
    


Measured memory_bytes: 62860
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool p[10500];
int sum[1500];
vector <int> prime;

void init(void)
{
	fill(p, p + 10500, true);
	p[0] = p[1] = false;
	for (int i = 2; i < 10500; i++){
		if (!p[i]) continue;
		prime.push_back(i);
		for (int j = i * 2; j < 10500; j += i){
			p[j] = false;
		}
	}
	
	for (int i = 1; i < prime.size(); i++){
		sum[i] = sum[i - 1] + prime[i - 1];
	}
}

int main(void)
{
	init();
	
	int n;
	while (cin >> n, n){
		int ret = 0;
		for (int i = 0; prime[i] <= n; i++){
			for (int j = i + 1; j <= prime.size(); j++){
				int a = sum[j] - sum[i];
				// cout << "* : " << a << endl;
				if (a == n) ret++;
				if (a >= n) {
					// cout << a << " >= " << n << endl;
					break;
				}
			}
		}
		cout << ret << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define lli long long int

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,i;
	vector<int> a;
	cin>>n;
	a.resize(n+1);
	for(i=0;i<n;i++)
		cin>>a[i+1];
	int j;
	int ans = 0;
	for(i=n;i>0;i--)
	{
		int sum = 0;
		for(j=i;j<=n;j=j+i)
			sum = sum + a[j];
		sum = sum % 2;
		sum = (sum + 2)%2;
		if(sum!=a[i])
			a[i] = 1 - a[i];
		if(a[i]==1)
			ans++;
	}
	cout<<ans<<'\n';
	for(i=1;i<=n;i++)
	{
		if(a[i])
			cout<<i<<" ";
	}
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define rep(i, x, n) for(int i=x;i<=n;i++)
#define pr make_pair
#define fi first
#define se second

const int MOD = int(1E9) + 7;
const int MAX = 420000;
const int HASHSIZE = 1000037;

inline int add(int x, int y) {x += y; return x >= MOD ? x - MOD : x;}
inline int sub(int x, int y) {x -= y; return x < 0 ? x + MOD : x;}
inline int mul(int x, int y) {return (int) (1LL * x * y % MOD);}
int mpow(int b, int p) {
	int r; for(r=1;p;p>>=1,b=mul(b,b))
		if( p & 1 ) r = mul(r, b);
	return r;
}

struct node{
	int x[40], cnt;
	int get() {
		int h = 0;
		for(int i=0;i<cnt;i++)
			h = (131LL*h + x[i]) % HASHSIZE;
		return h;
	}
	void print() {
		for(int i=0;i<cnt;i++)
			printf("%d%c", x[i], i + 1 == cnt ? '\n' : ' ');
	}
	bool equal(const node &b) {
		if( cnt != b.cnt ) return false;
		for(int i=0;i<cnt;i++)
			if( x[i] != b.x[i] ) return false;
		return true;
	}
}st[MAX + 5];
vector<pair<node, int> >h[HASHSIZE];
void insert(node a, int i) {h[a.get()].push_back(pr(a, i));}
int search(node a) {
	int x = a.get();
	for(unsigned i=0;i<h[x].size();i++)
		if( a.equal(h[x][i].fi) ) return h[x][i].se;
	return -1;
}

int l[75], tot, N, K;
void dfs(int s, node a, int x) {
	tot++, insert(st[tot] = a, tot);
	for(int i=x;i<=N&&l[i]<=s;i++)
		a.x[a.cnt++] = i, dfs(s - l[i], a, i), a.x[--a.cnt] = i;
}

int f[MAX + 5], fct[505], ifct[505], c[505][505];
void init() {
	rep(i, 0, 500) rep(j, 0, i)
		c[i][j] = (j == 0 ? 1 : add(c[i - 1][j], c[i - 1][j - 1]));
	fct[0] = 1; rep(i, 1, 500) fct[i] = mul(fct[i - 1], i);
	ifct[500] = mpow(fct[500], MOD - 2);
	for(int i=499;i>=0;i--) ifct[i] = mul(ifct[i + 1], i + 1);
	
	l[1] = 2; rep(i, 2, N) l[i] = (i - 1) << 1; dfs(N, (node){}, 1);
	rep(i, 1, tot) {
		int a = 1, b = 0, t = 1, p = 1;
		rep(j, 1, st[i].cnt - 1) {
			if( st[i].x[j] != st[i].x[j-1] )
				t = mul(t, ifct[p]), p = 1;
			else p++;
		}
		t = mul(t, ifct[p]);
		rep(j, 0, st[i].cnt - 1) {
			b += l[st[i].x[j]];
			if( st[i].x[j] != 1 ) a += 2;
		}
		f[i] = mul(mul(fct[st[i].cnt], t), c[N + a - 1][a + b - 1]);
	}
//	printf("%d\n", tot);
}

int tg[75], q[75]; char s[75];
int main() {
	scanf("%d%d%s", &N, &K, s + 1), N++, init();
	
	int ans = 0;
	rep(i, 1, tot) {
		int cnt1 = 0, pos = -1;
		rep(j, 0, st[i].cnt - 1) {
			if( st[i].x[j] != 1 ) {
				pos = j;
				break;
			} else cnt1++;
		}
		
		int hd = 1, tl = 0, p = st[i].cnt - cnt1;
		rep(j, 1, K) tg[j] = -1;
		for(int j=1;p&&j<=K;j++) {
			if( s[j] == 'r' ) q[++tl] = j;
			else if( hd <= tl ) tg[q[hd++]] = 0, tg[j] = 1, p--;
		}
		
		int cnt[2] = {}; bool flag = true;
		for(int j=K;j>=1;j--) {
			if( tg[j] == -1 ) cnt[s[j] == 'r' ? 0 : 1]++;
			else if( tg[j] == 1 ) {
				int tmp = st[i].x[pos] - 2;
				while( cnt[1] && tmp ) cnt[1]--, tmp--;
				while( cnt[0] && tmp ) cnt[0]--, tmp--;
				if( tmp ) {
					flag = false;
					break;
				}
				pos++;
			}
		}
		
		if( flag && cnt[0] >= cnt1 && p == 0 ) ans = add(ans, f[i]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 169552
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N;
  int tmp; 
  int *a; 
  
  cin >> N; 

  a = new int[N+1];
  
  for(int i=0;i<N;i++){
    cin >> tmp;
    a[tmp] = i; 
  }
  
  for(int i=1; i<N+1; i++){    
    cout << a[i]+1;
    cout << " "; 
  }
  
  return 0;
}


Measured memory_bytes: 1152
readlines.each{|line|
  x1,y1,x2,y2,xq,yq = line.split(",").map(&:to_f)
  x2 -= x1
  y2 -= y1
  r2 = Math.sqrt(x2**2+y2**2)
  xq -= x1
  yq -= y1
  rqct = (x2*xq+y2*yq)/r2
  xt = rqct*x2/r2
  yt = rqct*y2/r2
  puts "%.6f %6f" % [2 * xt - xq + x1, 2 * yt - yq + y1]
}

Measured memory_bytes: 8808
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int x=sc.nextInt();
    int l[]=new int[n];
    for (int i=0;i<n;i++) {
      l[i]=sc.nextInt();
    }

    int d[]=new int[n+2];
    d[1]=0;

    int count=1;

    for (int i=0;i<n;i++) {
      d[i+1]=d[i]+l[i];
      if (d[i+1]<=x) {
        count++;
      }
    }


    System.out.println(count);
  }
}


Measured memory_bytes: 22612