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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  ll n, m, k;
  cin >> n >> m >> k;
  combination C(n*m);

  mint ans = 0;

  for(int d = 1; d < n; ++d) {
    mint add = d;
    add *= n-d;
    add *= m*m;
    ans += add;
  }
  for(int d = 1; d < m; ++d) {
    mint add = d;
    add *= m-d;
    add *= n*n;
    ans += add;
  }

  ans *= C(n*m-2, k-2);

  cout << ans.x << endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  int n,k; cin >> n >> k;
  vector<int> x(n); rep(i,n) cin >> x[i];

  int min_dist = inf;
  rep(i,n+1-k){
    int min_side = min(abs(x[i+k-1]), abs(x[i]));
    min_dist = min(min_dist, x[i+k-1]-x[i]+min_side);
  }

  cout << min_dist << endl;
}


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

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<
double INF = 1e100;
double EPS = 1e-9;

double solve(pdd a,pdd b,double x){
  if(abs(a.first - b.first)<EPS){
    if(a.second<b.second){
      return INF;
    }else{
      return -INF;
    }
  }
  double xx = (double)(a.second-b.second)/(double)(a.first - b.first);
  return (x - a.first) * xx + a.second;
}

struct axy{
  double a, x, y;
};

int
main(void)
{
  cout.precision(22);
  while(true){
    LL W,H,N;
    cin >> W >> H >> N;
    if(W==0){
      break;
    }

    //x<=w, y<=h
    vector<pdd> xy;
    REP(i,2*N){
      LL x,y;
      cin>>x>>y;
      xy.push_back({x, y});
    }
    xy.push_back({W, 0});
    xy.push_back({W, H});

    //0<=<=H
    vector<double> points;
    points.push_back(0);
    points.push_back(H);

    REP(i,xy.size()){
      FOR(j,i+1,xy.size()){
        if(!(xy[i].first==xy[j].first)){
          double d = solve(xy[i], xy[j],0);
          if (0 <= d && d <= H)
          {
            points.push_back(d);
          }
        }
      }
    }

    SORT(points);

    vector<axy> ss;
    REP(i, points.size())
    {
      vector<double> dist;
      REP(j, xy.size())
      {
        if ((abs(0- xy[j].first) < EPS) && abs(points[i]-xy[j].second)<EPS){

        }
        else
        {
          double d = solve({0, points[i]}, xy[j], W);
          dist.push_back(d);
        }
      }
      SORT(dist);
      if(dist.size()%2==0){
      ss.push_back({points[i],dist[dist.size()/2-1], dist[dist.size()/2]});
      }else{
      ss.push_back({points[i],dist[dist.size()/2], dist[dist.size()/2+1]});
      ss.push_back({points[i],dist[dist.size()/2-1], dist[dist.size()/2]});
      }
    }

    REP(i,ss.size()){
      if(ss[i].x<0){
        ss[i].x = 0;
      }
      if(ss[i].x>H){
        ss[i].x = H;
      }
      if(ss[i].y<0){
        ss[i].y = 0;
      }
      if(ss[i].y>H){
        ss[i].y = H;
      }
      //cout << ss[i].a SP ss[i].x SP ss[i].y << endl;
    }

    double sum = 0;
    REP(i, ss.size() - 1)
    {
      sum += ((ss[i + 1].a - ss[i].a)/H) * ((ss[i + 1].y - ss[i + 1].x) + (ss[i].y - ss[i].x)) / (2*H);
    }
    cout << sum << endl;
  }
}



Measured memory_bytes: 4320
#include<iostream>
using namespace std;
int main() {
  char s[5];
  int i;
  cin >> s;
  for(i=0;i<3;i++) {
    if(s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << 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 PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S,T;
    cin >> S >> T;
    cout << T << S << endl;



}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define MAX 200000

int main(void) {
	int R[MAX], n;
	int maxv = -2000000000;
	int minv;
	int i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		scanf("%d", &R[i]);
	}
	
	minv = R[0];
	
	for (i = 1; i < n; i++) {
		maxv = fmax(maxv, R[i] - minv);
		minv = fmin(minv, R[i]);
	}
	
	printf("%d\n", maxv);

	return 0;
}

Measured memory_bytes: 1380
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 1e3 + 10,M = 2e5 + 10;

struct node {
	int x,y;
}G[M];
int to[M],nex[M],beg[N],cnt[N][N],vis[N];
vector <int> Graph[N];
int e,n,m;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void add(int x,int y) {
	to[++e] = y,nex[e] = beg[x],beg[x] = e;
}

void dfs(int St,int cur,int To) {
	if(St == cur || vis[cur] == To || cnt[St][cur] >= 2) return;
	if(++cnt[St][cur] == 1) vis[cur] = To;
	For(i,0,Graph[cur].size() - 1) dfs(St,Graph[cur][i],To);
}

int main() {
	n = read(),m = read();
	For(i,1,m) {
		int x = read(),y = read();
		G[i] = (node){x,y};
		Graph[x].push_back(y);
	}

	For(i,1,n) {
		memset(vis,0,sizeof(vis));
		For(j,0,Graph[i].size() - 1) dfs(i,Graph[i][j],Graph[i][j]);
	}

	For(i,1,m) {
		if((cnt[G[i].x][G[i].y] >= 2) ^ (cnt[G[i].y][G[i].x] >= 1)) puts("diff");
		else puts("same");
	}
	return 0;
}

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

const int MAX_N = 102, MAX_V = 1e5+2;
int N, W;
int w[MAX_N], v[MAX_N];
ll dp[MAX_V];

void solve()
{
	memset(dp,0x3f,sizeof(dp));
	dp[0] = 0;
	for(int i=0;i<N;++i){
		for(int j=MAX_V;j>=v[i];--j){
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	for(int i=MAX_V-1;i>=0;--i)if(dp[i]<=W){
		cout << i << '\n';
		return;
	}
}

int main()
{
	cin >> N >> W;
	for(int i=0;i<N;++i){
		cin >> w[i] >> v[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 1024
/*

*/

#include <stdio.h>

void init(int data[]);
void display(int data[]);
void North(int data[]);
void South(int data[]);
void East(int data[]);
void West(int data[]);
void Right(int data[]);
void Left(int data[]);

int main()
{
	int n,i;
	int sum;
	int data[6] = {1,2,3,4,5,6};
	char order[101];
	while(1){
		scanf("%d", &n);
		if(n==0){
			break;
		}
		sum=1;
		init(data);
		for(i=0; i<n; i++){
			scanf("%s", order);
			if(order[0]=='N'){
				North(data);
			}
			else if(order[0]=='S'){
				South(data);
			}
			else if(order[0]=='E'){
				East(data);
			}
			else if(order[0]=='W'){
				West(data);
			}
			else if(order[0]=='R'){
				Right(data);
			}
			else{
				Left(data);
			}
			sum+=data[0];
		}
		printf("%d\n", sum);
	}
	return 0;
}

void init(int data[])
{
	int i;
	for(i=0; i<6; i++){
		data[i]=i+1;
	}
	return;
}

void display(int data[])
{
	int i;
	for(i=0; i<6; i++){
		printf("%d ", data[i]);
	}
	puts("");
	return;
}

void North(int data[])
{
	int work;
	work = data[0];
	data[0] = data[1];
	data[1] = data[5];
	data[5] = data[4];
	data[4] = work;
	return;
}

void South(int data[])
{
	int work;
	work = data[0];
	data[0] = data[4];
	data[4] = data[5];
	data[5] = data[1];
	data[1] = work;
	return;
}

void East(int data[])
{
	int work;
	work = data[0];
	data[0] = data[3];
	data[3] = data[5];
	data[5] = data[2];
	data[2] = work;
	return;
}

void West(int data[])
{
	int work;
	work = data[0];
	data[0] = data[2];
	data[2] = data[5];
	data[5] = data[3];
	data[3] = work;
	return;
}

void Right(int data[])
{
	int work;
	work = data[1];
	data[1] = data[2];
	data[2] = data[4];
	data[4] = data[3];
	data[3] = work;
	return;
}

void Left(int data[])
{
	int work;
	work = data[1];
	data[1] = data[3];
	data[3] = data[4];
	data[4] = data[2];
	data[2] = work;
	return;
}

Measured memory_bytes: 604
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>

using namespace std;
//namespace adaptor = boost::adaptors;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

long long Gcd(long long a, long long b) {
    if (b == 0) {
        return a;
    } else {
        return  Gcd(b, a % b); 
    }
}

long long Lcm(long long a, long long b) {
    long long d = Gcd(a, b);
    return a / d * b;
}

void Main()
{
    ll a, b;
    cin >> a >> b;
    cout << Lcm(a, b) << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    printf("%.8f\n", (double)t / x);

    return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<double> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n - 1; ++i)
	{
		double a = (v[i] + v[i + 1]) / 2.0;
		v[i + 1] = a;
	}
	cout << v[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);
vector<vector<int>> G;
void dfs(int now,int d,vector<int> &dist){
  for(auto nv:G[now]){
    if(dist[nv]>=0)continue;
    dist[nv]=dist[now]+1;
    dfs(nv,d+1,dist);
  }
}
int main(){
  int n,u,v;
  cin >> n >> u >> v;
  u--;
  v--;
  G.resize(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int>d1(n,-1),d2(n,-1);
  d1[u]=0;d2[v]=0;
  dfs(u,0,d1);
  dfs(v,0,d2);
  int ans=0;
  rep(i,n){
    if(d1[i]<d2[i]){
      ans = max(ans,d2[i]-1);
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct SegmentTree {
private:
    int n;
    vector<T> node;
    T def;
    function<T(T,T)> cmp;
    
public:
    SegmentTree(int _n, T _def, function<T(T,T)> _cmp) {
        n = 1;
        while(n < _n) n *= 2;
        def = _def; cmp = _cmp;
        node = vector<T>(2 * n - 1, def);
    }
    
    void update(int idx, T val) {
        idx += (n - 1);
        node[idx] = val;
        while(idx > 0) {
            idx = (idx - 1) / 2;
            node[idx] = cmp(node[idx * 2 + 1], node[idx * 2 + 2]);
        }
    }
    
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if ((r <= a) || (b <= l)) return def;
        if ((a <= l) && (r <= b)) return node[k];
        return cmp(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll chars = 'z' - 'a' + 1;
    ll n, q;
    string s;
    cin >> n >> s >> q;
    vector<SegmentTree<ll>> vst(chars, SegmentTree<ll>(n, 0, [](const ll &a, const ll &b){ return a + b; }));
    rep(i, n) {
        vst[s[i] - 'a'].update(i, 1);
    }
    rep(i, q) {
        ll com;
        cin >> com;
        if (com == 1) {
            ll idx;
            char c;
            cin >> idx >> c;
            idx--;
            vst[s[idx] - 'a'].update(idx, 0);
            vst[c - 'a'].update(idx, 1);
            s[idx] = c;
        }
        else {
            ll l, r;
            cin >> l >> r;
            l--;
            ll ans = 0;
            rep(j, chars) {
                ll cnt = vst[j].query(l, r);
                if (cnt > 0) ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 222108
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=1000;
int dp[maxn][maxn];
bool getans(int x,int y)
{
    if(dp[x][y]!=-1)
        return dp[x][y];
    bool ret=0;
    for(int i=2;i<=x;i+=2)
        if(!getans(x-i,y+i/2))
            ret=1;
    for(int i=2;i<=y;i+=2)
        if(!getans(x+i/2,y-i))
            ret=1;
    return dp[x][y]=ret;
}
int main()
{
    //memset(dp,-1,sizeof(dp));
	ll x,y;
    cin>>x>>y;
    if(x>y) swap(x,y);
    if(y-x<=1) cout<<"Brown\n";
    else cout<<"Alice\n";
    /*for(int x=0;x<50;x++)
    {
        for(int y=0;y<50;y++)
        {
            dbg(x,y,getans(x,y));
        }
    }*/

}

Measured memory_bytes: 256
def composite(d,n,s):
    for a in (2,3,5,7):
        probably_prime = False
        if pow(a,d,n) == 1:
            continue
        for i in range(s):
            if pow(a, 2**i * d, n) == n-1:
                probably_prime = True
                break
        return not probably_prime
    return False

def is_prime(n):
    if n == 2:
        return True
    elif n % 2 == 0:
        return False
    else:
        d,s = n-1, 0
        while not d%2:
            d, s = d>>1, s+1
        return not composite(d,n,s)

r = []
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n):
      if n not in r:
          r.append(n)

print(len(r))

Measured memory_bytes: 7756
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;cin>>s;
bool b = 0,c = 0,d = 0;
int n = s.length();
string t ;cin>>t;
int m = t.length();
char x[n+1];
char y[m+1];
strcpy(x,s.c_str());
strcpy(y,t.c_str());
for(int i=0;i<n;i++)
    if(x[i]>=65 || x[i]<=90)
        b = 1;
for(int i=0;i<m;i++)
    if(y[i]>=65 || y[i]<=90)
        c = 1;
if(b==1&&c==1&&n>=1&&n<=10&&m==n+1)
    for(int i=0;i<n;i++)
        if(x[i]!=y[i])
            d = 1;
if(d==0)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;

return 0;}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B, C;
  char X, Y;
  cin >> A >> X >> B >> Y >> C;
  
  if ( A > 2019 ){
    cout << "TBD" << endl;
  }
  else if ( A = 2019 && B > 4 ) {
    cout << "TBD" <<endl;
  }
  else {
    cout << "Heisei" << endl;
  }
}
  

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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;

const int MOD = 1e9+7;

int main() {
    FASTIO

    int s;
    cin >> s;
    if(s < 3) cout << "0\n";
    else if(s < 6 && s >= 3) cout << "1\n";
    else {
        vector<ll> dp(s+1,1);
        dp[0] = dp[1] = dp[2] = 0;
        for(int i=6; i<=s; i++) {
            for(int j=3; j<=i-3; j++) {
                dp[i] += dp[i-j];
                dp[i] %= MOD;
            }
        }
        cout << dp[s]%MOD << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int judge(int *array, int length);

int main(){
  int n, i, flag;
  int ball[10];
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d %d %d %d %d %d %d %d %d %d", &ball[0], &ball[1], &ball[2], &ball[3], &ball[4], &ball[5], &ball[6], &ball[7], &ball[8], &ball[9]);
    flag = judge(ball,10);
    if(flag == 1) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

int judge(int *array, int length){
  int i, big, small;
  big = 0; small = 0;
  for(i = 0; i < length; i++){
    if(big < array[i]) big = array[i];
    else if(small < array[i]) small = array[i];
    else return -1;
  }
  return 1;
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
//#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<=(int)n;i++)
#define REP1(j,n) for(int j=0;j<=(int)n;j++)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
using namespace std;

int main(void) {
	int N;
	cin >> N;
	int ans, i, j;
	for (i=0; i <= N / 7;i++) {
		for (j=0; j <= N / 4;j++) {
			if (N == i * 7 + j * 4) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n;
  cin >> n;

  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }

    ans += i;
  }

  cout << ans << ln;

  return 0;
}

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

int main(){
	int n,a;
	int mx=0,mx2,num;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		if(a>=mx){
			mx2=mx;
			mx=a;
			num=i;
		}
		else if(a>mx2) mx2=a;
	}
	for(int i=1;i<=n;i++){
		if(num==i) printf("%d\n",mx2);
		else printf("%d\n",mx);
	}
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		final String lb = System.getProperty("line.separator");
		StringBuilder sb = new StringBuilder();

		while(true){
			final String[] points = sc.nextLine().split(" ");
			final int mid = Integer.parseInt(points[0]);
			final int fin = Integer.parseInt(points[1]);
			final int ret = Integer.parseInt(points[2]);
			
			if(mid == -1 && fin == -1 && ret == -1) break;

			if(mid == -1 || fin == -1){
				sb.append("F").append(lb);
			} else if((mid + fin) >= 80){
				sb.append("A").append(lb);
			} else if((mid + fin) >= 65){
				sb.append("B").append(lb);
			} else if((mid + fin) >= 50){
				sb.append("C").append(lb);
			} else if((mid + fin) >= 30){
				if(ret >= 50){
					sb.append("C").append(lb);
				} else {
					sb.append("D").append(lb);
				}
			} else {
				sb.append("F").append(lb);
			}
		}
		System.out.print(sb.toString());
	}
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e3 + 5);
const int MAX_SIZE = (int)(MAX_N * MAX_N);

/////////////////////////////////////////////////////////////
// node in { 0, ... }
class TopologicalSort {
  using ts_graph = vector<vector<int>>;

 public:
  static const int MAX_N = (int)(8e5 + 100);

  int n;
  ts_graph graph;
  vector<int> topological_sorted;
  vector<int> flg;  // 0: not-visited, 1: done, -1, temporary

  bool no_loop;

  TopologicalSort(ts_graph graph, int n) {
    this->flg = vector<int>(n, 0);
    this->graph = graph;
    this->n = n;
    init();
  }

  void init() {
    topological_sort();
  }

  bool visit(int i) {
    if (flg[i] == -1) {
      return false;
    }

    if (flg[i] == 0) {
      flg[i] = -1;

      for (auto &e : graph[i]) {
        if (!visit(e)) {
          return false;
        }
      }

      flg[i] = 1;

      topological_sorted.push_back(i);

      return true;
    }

    return true;
  }

  void topological_sort() {
    for (int i = 0; i < n; ++i) {
      flg[i] = 0;
    }

    for (int i = 0; i < n; ++i) {
      if (flg[i] == 0) {
        if (!visit(i)) {
          no_loop = false;
          return;
        }
      }
    }

    reverse(topological_sorted.begin(), topological_sorted.end());

    no_loop = true;
    return;
  }

  bool contains_loop() {
    return !no_loop;
  }

  vector<int> &get_sorted() {
    return topological_sorted;
  }
};
/////////////////////////////////////////////////////////////

int n;

int tmp[MAX_N];
vector<vector<int>> graph(MAX_SIZE);
unordered_map<int, int> memo;

int make_key(int a, int b) {
  return min(a, b) * n + max(a, b);
}

int depth(int cur) {
  if (memo.find(cur) != memo.end()) return memo[cur];

  if (graph[cur].size() == 0) {
    return memo[cur] = 1;
  }

  int ret = -1;

  for (auto &e : graph[cur]) {
    ret = max(ret, depth(e));
  }

  ret += 1;

  return memo[cur] = ret;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= n - 1; ++j) {
      scanf("%d", &(tmp[j]));
      tmp[j] -= 1;
    }

    int last = make_key(i, tmp[1]);

    for (int j = 2; j <= n - 1; ++j) {
      int cur = make_key(i, tmp[j]);
      graph[last].push_back(cur);
      last = cur;
    }
  }

  // for (auto &e : graph) {
  //   printf("(%d, %d): ", e.first.first, e.first.second);
  //   for (auto &d : e.second) {
  //     printf("(%d, %d) ", d.first, d.second);
  //   }
  //   printf("\n");
  // }

  TopologicalSort ts(graph, MAX_SIZE);

  if (ts.contains_loop()) {
    printf("-1\n");
    return 0;
  }

  int ans = -1;

  for (int i = 0; i < MAX_SIZE; ++i) {
    ans = max(ans, depth(i));
  }

  printf("%d\n", ans);

  // for (auto &e : ts.get_sorted()) {
  //   printf("(%d, %d)\n", e.first, e.second);
  // }

  return 0;
}


Measured memory_bytes: 126580
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

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

int x,y,z,t1,t2,t3;

int num(string t)
{
	return t[0]*100+t[1]*10+t[2];
}

ll n, ans=0;

void dfs(ll x, ll a, ll b, ll c)
{
	if (x>n) return;
	if (a&&b&&c) ans++;
	dfs(x*10+3,1,b,c);
	dfs(x*10+5,a,1,c);
	dfs(x*10+7,a,b,1);
}

int main()
{
	FAST;

	cin >> n;
	dfs(0,0,0,0);
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<bool> forbidden(n+1,false);
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        forbidden[a]=true;
    }
    long long mod=1e9+7;
    vector<long long> count(n+1,0);
    count[0]=1;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=min(n,i+2);j++){
            if(forbidden[j])continue;
            count[j]+=count[i];
            count[j]%=mod;
        }
    }
    cout<<count[n]<<endl;
    return 0;
}

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

int main()
{
    int n,k,tmp,type=0,max=0;
    int a[200002]={0};
    int overflow;
    
    cin >> n >> k;
    REP(i,n)
    {
        cin >> tmp;
        a[tmp-1]++;
    }
    
    /*REP(i,10)
    {
        cout << "a["<< i << "] = "<< a[i] << endl;
    }*/
    
    REP(i,n)
    {
        if(a[i]>0)
        {
            type++;
            if(max < a[i])
            {
                max = a[i];
            }
        }
    }
    if(type <= k)
    {
        cout << "0" << endl;
    }
    else
    {
        overflow = type - k;
        //cout << "type = " << type << endl;
        //cout << "overflow = " << overflow << endl;
        int count = 0;
        REP(j,max)
        {
            REP(i,200000)
            {
                if(a[i] == j+1)
                {
                    count += j+1;
                    overflow--;
                    //cout << count << "work\n";
                }
                if(overflow == 0)
                {
                    //cout << "FINISH\n";
                    j=i=20000099;
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    long double a,b,n;

    long int ans;
    long double x;

    cin >> a >> b >> n;

    ans = int(a*min(n,b-1)/b)-a*int(min(n,b-1)/b);

    /*
    for(double i = b<n?b:n; i >0; i--) {
        ans = int(a*i/b)-a*int(i/b);
        if(max < ans){
            max=ans;
        }
    }
    */

    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 3724
use proconio::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        k: usize,
        a: [u32; n],
    }
    for i in k..n {
        let ans = if a[i] > a[i - k] {
            "Yes"
        } else {
            "No"
        };
        println!("{}", ans);
    }
}

fn main() {
    run();
}

Measured memory_bytes: 4820
#include <iostream>

using namespace std;

int main()
{
   int h,w;
   while (true){
  cin >> h >> w;

   if (h==0&&w==0)break;

   for(int i=0;i<h;++i){
           for(int j=0;j<w;++j){
    cout << "#";}
    cout <<endl;
   }
   cout << endl;

   }


}



Measured memory_bytes: 3080
num = input().split(" ")
N=int(num[0])
A=int(num[1])
B=int(num[2])

num = 0
for i in range(1,N+1):
    s = str(i)
    t=0
    for ii in s:
        t+=int(ii)
    if t>=A and t<=B:
        num+=i
print(num)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool is_prime(long long _Num){
    if(_Num < 2)return false;
    if(_Num % 2 == 0){
        if(_Num == 2)return true;
        else return false;
    }
    bool prime = true;
    for(long long i = 3; i <= sqrt(_Num); i += 2){
        if(_Num % i == 0){
            prime = false;
            break;
        }
    }
    return prime;
}

ll sum[100005];

int main() {
	int q;
	cin >> q;
	int l[q], r[q];
	rep (i, q) cin >> l[i] >> r[i];

	rrep (i, 100004) {
		if (is_prime(i) && is_prime((i + 1) / 2)) sum[i] = 1;
	}

	rrep (i, 100004) sum[i] += sum[i - 1];

	rep (i, q) {
		cout << sum[r[i]] - sum[l[i] - 1] << endl;
	}

	return 0;
}

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

int main() {
 string X, Y, Z;
 cin >> X >> Y >> Z;
  for (int i = 0; i < X.size(); i++) {
    cout << X.at(0);
	break;   
  }
  for (int i = 0; i < Y.size(); i++) {
    cout << Y.at(0);
    break;
  }
  for (int i = 0; i < Z.size(); i++) {
    cout << Z.at(0);
    break;
  }
}  




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int a[MAXN];
int b[MAXN];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m,k;
	cin >> n >> m >> k;
	FOR(i,0,n){
		cin >> a[i];
	}
	a[n]=k+1;
	FOR(i,0,m){
		cin >> b[i];
	}
	b[m]=k+1;
	
	ll sa = 0;
	int ca = 0;
	ll sb = 0;
	int cb = 0;
	FOR(i,0,n){
		if (sa+a[i]<=k){
			sa+=a[i];
			ca++;
		} else {
			break;
		}
	}
	FOR(i,0,m){
		if (sb+b[i]<=k){
			sb+=b[i];
			cb++;
		} else {
			break;
		}
	}
	
	int ia = 0;
	int ib = 0;
	int c = 0;
	while (ca-ia || cb-ib) {
		if (ca-ia > cb-ib) {
			k-=a[ia];
			sa-=a[ia];
			ia++;
			c++;		
		} else {
			k-=b[ib];
			sb-=b[ib];
			ib++;
			c++;
		}
		while(sa > k && ca){
			sa-=a[ca-1];
			ca--;
		}
		while(sb > k && cb){
			sb-=b[cb-1];
			cb--;
		}
	}
	cout << c << "\n";
}


Measured memory_bytes: 5216
#define _CRT_SECURE_NO_WARNINGS
#define __STDC_FORMAT_MACROS
#include <cinttypes>
#include <cstdio>

using namespace std;

int main()
{
    int64_t Q, H, S, D, N;
    if (scanf(
        "%" PRId64 "%" PRId64 "%" PRId64 "%" PRId64 "%" PRId64,
            &Q, &H, &S, &D, &N) < 5) return 0;

    if (2 * Q < H) H = 2 * Q;
    if (2 * H < S) S = 2 * H;
    if (2 * S < D) D = 2 * S;

    int64_t ans;

    ans = (N / 2) * D;

    int64_t mod = N % 2;

    if (mod > 0) ans += (mod / 1) * S;

    printf("%" PRId64 "\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){

  int N, a, b, c;

  cin >> N;
  while(N){
    cin >> a >> b >> c;
    if(a*a == b*b + c*c){
      cout << "YES\n";
    }
    else if(b*b == a*a + c*c){
      cout << "YES\n";
    }
    else if(c*c == a*a + b*b){
      cout << "YES\n";
    }
    else{
      cout << "NO\n";
    }
    N--;
  }

  return 0;
}

Measured memory_bytes: 1124
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	
		int D = sc.nextInt();
      	if(D==25){
        	System.out.println("Christmas");	
        }else if(D==24){
        	System.out.println("Christmas Eve");
        }else if(D==23){
        	System.out.println("Christmas Eve Eve");
        }else if(D==22){
        	System.out.println("Christmas Eve Eve Eve");
        }
      
    }
}

Measured memory_bytes: 21460
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

int const N = 1e5 + 1;
int a[101], n, k;
bool dp[N][2], vis[N][2];

bool solve(int cur, bool turn){
	if (cur < 0) return turn ^ 1;

	if (vis[cur][turn]) return dp[cur][turn];
	
	vis[cur][turn] = true;
	dp[cur][turn] = turn;

	if (turn){
		for (int i = 0; i < n; ++i)
			dp[cur][turn] = dp[cur][turn] && solve(cur - a[i], turn ^ 1);
	}
	else {
		for (int i = 0; i < n; ++i)
			dp[cur][turn] = dp[cur][turn] || solve(cur - a[i], turn ^ 1);
	}
	return dp[cur][turn];
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;

	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	bool an = solve(k, 0);

	cout << (an ? "First\n" : "Second\n");

	return 0;
}

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

int min(int a, int b){if(a <= b)return a;else return b;}
int max(int a, int b){if(a <= b)return b;else return a;}

int gcd(int a, int b){
    long long r,i,m;
    i = min(a, b);
    m = max(a, b);
    r = m % i;
    while(r != 0){
        m = i;
        i = r;
        r = m % i;
    }

    return i;
}

int tgcd(int a, int b, int c){
    long long i = gcd(a, b);
    return gcd(i, c);
}

int main(void){
    int k;
    long long sum = 0;
    cin >> k;

    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int l = 1; l <= k; l++){
                sum += tgcd(i, j, l);
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(){

  int n,m,i,j,c=0;

  char a[300][12];
  char b[300][12];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%s",a[i]);
  }


  scanf("%d",&m);

  for(j=1;j<=m;j++){
    scanf("%s",b[j]);
  }



  // for(i=1;i<=n;i++){
  // printf("%s\n",a[i]);
  //  }
  

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){

      if(strcmp(a[j],b[i])==0){
	c++;
	break;
      }
    }
    if(strcmp(a[j],b[i])!=0){
      printf("Unknown %s\n",b[i]);
    }
    else{
      if(c%2!=0&&c!=0){
	printf("Opened by %s\n",a[j]);
      }
      if(c%2==0&&c!=0){
	printf("Closed by %s\n",a[j]);
      }
    }
  }





  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <string.h>

int main(void) {
    char str[1200]={'\0'}, buf;
    int i;
    
    i=0;
    while ((buf = getchar()) != '\n') {
        str[i] = buf;
	i++;
    }
    for (i=0; i<=sizeof(str); i++) {
        if (str[i]<=122 && str[i]>=97) {
	    str[i]-=32;
	} else if (str[i]<=90 && str[i]>=65) {
	    str[i]+=32;
	}
    }
    printf("%s\n", str);
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int k = j+1; k < N; k++) {
        if (L[i] == L[j] || L[i] == L[k] || L[k] == L[j]) continue;
        if (L[i] < (L[j]+L[k]) && L[j] < (L[i]+L[k]) && L[k] < (L[i]+L[j])) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    int sum=0;
    for(int i=0;i<N-1;i++){
        sum+=p[i];
    }
    sum+=p[N-1]/2;
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, y;
  cin >> n >> y;

  REP(i, 2001){
    REP(j, 2001){
      ll k = n - i - j;
      if(k < 0) continue;
      ll m = 10000 * i + 5000 * j + 1000 * k;
      if(m == y){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}


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

void solve(long long N, std::vector<long long> p){
    sort(p.begin(), p.end());
    long long ans = 0;
    p[N - 1] /= 2;
    REP(i, N) ans += p[i];
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(){}
	Vec2(T _x, T _y) : x(_x), y(_y) {}

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	Vec2 operator*(T s) const { return Vec2(x*s, y*s); }
	Vec2 operator/(T s) const { return Vec2(x/s, y/s); }
	T dot(const Vec2& rhs) const { return x*rhs.x + y*rhs.y; }
	T cross(const Vec2& rhs) const { return x*rhs.y - y*rhs.x; }
	T sqlength() const { return x*x + y*y; }
	double length() const { return sqrt(sqlength()); }
	bool operator<(const Vec2& rhs) const
	{
		if (x != rhs.x) return x < rhs.x;
		return y < rhs.y;
	}

	T x;
	T y;
};

template<class T>
T cross(const Vec2<T> &O, const Vec2<T> &A, const Vec2<T> &B)
{
	return (A - O).cross(B - O);
}

int main()
{
	typedef Vec2<double> Vec;

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		Vec P[4];
		for (int j = 0; j < 4; j++) {
			cin >> P[j].x >> P[j].y;
		}

		double c1 = cross(P[0], P[1], P[2]);
		double c2 = cross(P[0], P[1], P[3]);
		Vec ans = P[2] + (P[3] - P[2])*c1 / (c1 - c2);
		printf("%.10f %.10f\n", ans.x, ans.y);
	}
	return 0;
}


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

int n, m;
vector<vector<int>> tree;
vector<int> dp;

void dfs(int node, int parent) {
    long long cnt = 1;
    for (int child : tree[node]) {
        if (child != parent) {
            dfs(child, node);
            cnt *= dp[child] + 1;
            cnt %= m;
        }
    }

    dp[node] = cnt;
}

void update(int node, int parent, int parent_contrib = 1) {
    int p = tree[node].size();
    vector<int> pref_prods, suff_prods;

    pref_prods.reserve(p + 1);
    pref_prods.push_back(parent_contrib);
    for (int i = 0; i < p; ++i)
        if (tree[node][i] != parent)
            pref_prods.push_back(1LL * pref_prods.back() * (dp[tree[node][i]] + 1) % m);

    suff_prods.reserve(p + 1);
    suff_prods.push_back(1);
    for (int i = p - 1; i >= 0; --i)
        if (tree[node][i] != parent)
            suff_prods.push_back(1LL * suff_prods.back() * (dp[tree[node][i]] + 1) % m);

    reverse(suff_prods.begin(), suff_prods.end());
    for (int i = 0, j = 0; i < p; ++i) {
        if (tree[node][i] != parent) {
            dp[tree[node][i]] = (((1LL * pref_prods[j] * suff_prods[j + 1] + 1) % m) * dp[tree[node][i]] % m);
            update(tree[node][i], node, (1LL * pref_prods[j] * suff_prods[j + 1] + 1) % m);
            ++j;
        }
    }
}

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

    cin >> n >> m;
    tree.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        tree[x - 1].push_back(y - 1);
        tree[y - 1].push_back(x - 1);
    }

    dp.resize(n);
    dfs(0, -1);
    update(0, -1);
    for (int i = 0; i < n; ++i)
        cout << dp[i] << "\n";

    return 0;
}


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

using namespace std;

int main() {
    
    long double x;
    scanf("%Lf", &x);
    int count = 0;
    for(long double i = 100 ; i < x ; count++) {
        i = i + floor(i / 100.0);
    }
    
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3752
until (size = gets.split.map(&:to_i)).max == 0 do
    min = 99999.9
    0.upto(2) do |i|
        min = [min, Math.sqrt(size[i]**2 + size[(i+1)%3]**2)].min
    end
    gets.to_i.times do
        puts gets.to_i*2 > min ? "OK" : "NA"
    end
end

Measured memory_bytes: 8584
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		List<Long> list = new ArrayList<>(N + 1);
		list.add(2L);
		list.add(1L);
		for (int i = 2; i <= N; ++i) {
			list.add(list.get(i - 1) + list.get(i - 2));
		}
		System.out.println(list.get(N));
	}
}


Measured memory_bytes: 23124
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;

}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;

}

int min(int a,int b){ 
	if(a<=b){return a;}
	else{return b;}
}
int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
	
	head = 1;
	tail = n + 1;
	
	while( head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps  += c;
		if(u.t > 0) enqueue(u);
		else{
			printf("%s %d\n",u.name,elaps);
		}
		
	}

  
  return 0;
}



Measured memory_bytes: 11888
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define endl "\n"
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n,k,s;
  cin>>n>>k>>s;
  vector<ll> ans;
  if(s!=1000000000){
    rep(i,0,k){
      ans.pb(s);
    }
    rep(i,0,n-k){
      ans.pb(1000000000);
    }
  }
  else{
    rep(i,0,k){
      ans.pb(1000000000);
    }
    rep(i,0,n-k){
      ans.pb(1);
    }
  }
  rep(i,0,ans.sz){
    cout << ans[i];
    if(i!=ans.sz-1)cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2164
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vector<int>>
const int INF = 1<<29;
typedef long long ll;

int main(){
  ll L, R;cin >> L >> R;
  if(R - L < 2019){
    ll minv = INF;
    for(ll i = L;i < R;++i){
      for(ll j = i + 1;j <= R;++j){
        minv = min(minv, (i * j)%2019);
      }
    }
    cout << minv;
  }else{
    cout << 0;
  }
}


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

using namespace std;

int Function(int n)
{
	int ans = 0;
	int tmp = 0;
	for (int i = 1; i <= sqrt(n); ++i)
	{
		if (i * i == n) {
			tmp = 1;
			break;
		}
		if (n % i == 0) ans++;
	}
	return ans * 2 + tmp;
}


int main() {

	int N;
	cin >> N;

	int ans = 0;
	for (int i = 1; i < N; ++i)
	{
		int buf = N - i;
		ans += Function(buf);
	}
	cout << ans;

	return 0;
}

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

int main(){
    ll ans = 0;
    int n; cin >> n;
    vector <int> A(n);

    rep(i, n) cin >> A.at(i);

    sort(A.begin(), A.end());
    ll num = A.at(0);
    if (n % 2 == 0 && num != 1){
        cout << ans << endl;
        return 0;
    }
    else if (n % 2 == 1 && num != 0){
        cout << ans << endl;
        return 0;
    }

    bool ng = false;
    rep(i, n){
        if (n % 2 == 0){
            if (i % 2 == 0){
                if (A.at(i) != i + 1){
                    ng = true;
                    break;
                }
            }
            else{
                if (A.at(i) != i){
                    ng = true;
                    break;
                }
            }
        }
        else{
            if (i == 0) continue;
            if (i % 2 == 1){
                if (A.at(i) != i + 1){
                    ng = true;
                    break;
                }
            }
            else{
                if (A.at(i) != i){
                    ng = true;
                    break;
                }
            }
        }
    }

    if(ng) cout << ans << endl;
    else{
        ans = 1;
        rep(i, n / 2){
            ans = ans * 2 % 1000000007;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 3700