akhauriyash/Code-Regression huggingface dataset:
import bisect

N,M=map(int,input().split())
d=[]
for i in range(1,int(M**0.5)+2):
    if M%i==0:
        d.append(i)
        d.append(M//i)
d.sort()
ind=bisect.bisect_right(d,M//N)
print(d[ind-1])

Measured memory_bytes: 38724
//
//  main.cpp
//  ABC166
//
//  Creatn 2020/05/03.
//  Copyright © 2020 エロやん. All rights reserved.
//

#include <iostream>
#include<string>
using namespace std;
int main(){
    int N,K;
    int d,a[101]={0};
    int space,counter=0;
    cin>>N>>K;
    for(int i=0;i<K;i++)
    {
        cin>>d;
        for(int j=0;j<d;j++)
        {
            cin>>space;
            a[space-1]++;
            
            
        }
        
        
        
    }
    for(int i=0;i<N;i++){
        if(a[i]==0)
            counter++;
        
    }
    
    cout<<counter<<endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) {
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	int N;
	map<ll, int> D;
	cin >> N;

	rep(i, N) {
		ll d;
		cin >> d;
		if(d!=0&&i==0) {
			cout << 0 << endl;
			return 0;
		}
		D[d] += 1;
	}

	ll result = 0;
	if (D[0] == 1) {
		result = 1;
		for(auto itr: D) {
			if (itr.first == 0) continue;

			int s = D[itr.first-1];
			for(int i = 1; i <= itr.second; i++) {
				result *= s;
				result %= 998244353;
			}
		}
	}

	cout << result << endl;
  return 0;
}


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

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

int main(){
	int N;
	cin >> N;
	vector<P> T(N);
	rep(i,N){ int a,b; cin >> a >> b; T[i]=P(b,a); }
	sort(T.begin(),T.end());

	ll time =0 ;
	bool f=true;
	rep(i,N){
		int cost = T[i].second; 
		int limit = T[i].first;
		time += cost;
		if(time>limit) { f=false; break;}
	}

	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;

}




Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,d;
   cin >> a >> b >> c;
   if(b<a){
       d = b ; b = a ; a = d ;
   }
   if(c<b){
       d = c ; c = b ; b = d ;
   }
   if(b<a){
       d = b ; b = a ; a = d ;
   }
   cout << a;
   cout << " ";
   cout << b;
   cout << " ";
   cout << c;
   cout << endl;
     
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


template<typename T>
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template<typename T>
using Edges = vector<edge<T> >;
template<typename T>
using WeightedGraph = vector<Edges<T> >;
using UnWeightedGraph = vector<vector<int> >;
template<typename T>
using Matrix = vector<vector<T> >;


template<typename G>
struct LowLink {
    const G &g;
    vector<int> used, ord, low;
    vector<int> articulation;
    vector<pair<int, int> > bridge;

    LowLink(const G &g) : g(g) {}

    int dfs(int idx, int k, int par) {
        used[idx] = true;
        ord[idx] = k++;
        low[idx] = ord[idx];
        bool is_articulation = false;
        int cnt = 0;
        for (auto &to : g[idx]) {
            if (!used[to]) {
                ++cnt;
                k = dfs(to, k, idx);
                low[idx] = min(low[idx], low[to]);
                is_articulation |= ~par && low[to] >= ord[idx];
                if (ord[idx] < low[to]) bridge.emplace_back(minmax(idx, (int) to));
            } else if (to != par) {
                low[idx] = min(low[idx], ord[to]);
            }
        }
        is_articulation |= par == -1 && cnt > 1;
        if (is_articulation) articulation.push_back(idx);
        return k;
    }

    virtual void build() {
        used.assign(g.size(), 0);
        ord.assign(g.size(), 0);
        low.assign(g.size(), 0);
        int k = 0;
        for (int i = 0; i < g.size(); i++) {
            if (!used[i]) k = dfs(i, k, -1);
        }
    }
};

int main() {
    int n, m;
    cin >> n >> m;

    UnWeightedGraph g(n);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    LowLink<UnWeightedGraph > lowLink(g);
    lowLink.build();
    cout << lowLink.bridge.size() << endl;
}

Measured memory_bytes: 256
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007



int main()
{
    IOS;
    ll n, i, j;
    double ans=0.0;
    cin>>n;
    vector<double> p(n), dp(n+1, 0.0);
    for(i=0;i<n;i++)
        cin>>p[i];
    if(n==1)
    {
        cout<<p[0]<<"\n";
        return 0;
    }
    dp[0] = (1-p[0]);
    dp[1] = p[0];
    // for(j=0;j<=n;j++)
    //     cout<<dp[j]<<"\t\n"[j==n];
    for(i=1;i<n;i++)
        {
            for(j=n;j>=0;j--)
                if(j==0)
                    dp[0] = dp[0]*(1-p[i]);
                else if(j<=i+1)
                    dp[j] = dp[j-1]*p[i] + dp[j]*(1-p[i]);
            // for(j=0;j<=n;j++)
            //     cout<<dp[j]<<"\t\n"[j==n];
        }
    for(i=n;i>n/2;i--)
        ans += dp[i];
    cout<<setprecision(15)<<ans<<'\n';
    return 0;
}

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

#define MAX 100000
#define MAX_E 100000

int par[MAX], rank_[MAX];

void init(int N)
{
    for (int i = 0; i < N; i++) {
	par[i] = i;
	rank_[i] = 0;
    }
}

int find(int x)
{
    if (par[x] == x) {
	return x;
    }
    return par[x] = find(par[x]);
}

void unite(int x, int y)
{
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (rank_[x] < rank_[y]) {
	par[x] = y;
    } else {
	par[y] = x;
	if (rank_[x] == rank_[y]) {
	    rank_[x]++;
	}
    }
}

bool same(int x,int y)
{
    return (find(x) == find(y));
}

struct edge{ int u, v, cost; };

bool comp(const edge &e1, const edge &e2)
{
    return e1.cost < e2.cost;
}

int V,E;
edge es[MAX_E];

int kruskal()
{
    sort(es, es+E, comp);
    init(V); // init union_find
    int res = 0;
    for (int i = 0; i < E; i++) {
	edge e = es[i];
	if (!same(e.u, e.v)) {
	    unite(e.u, e.v);
	    res += e.cost;
	}
    }
    return res;
}

int main()
{
    int s,t,w;
    cin >> V >> E;
    for (int i = 0; i < E; i++) {
	cin >> s >> t >> w;
        es[i]=(edge){s, t, w};
    }
    cout << kruskal() << endl;
    return 0;
}

Measured memory_bytes: 4344
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    string s;
    cin >> s;

    int ans = 0;

    for(int i = 0; i < n - 2; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
            ans++;
            i += 2;
        }
    }

    cout << ans << endl;
}

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

int main()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> h(N);
  for(int i=0; i<N; i++){
    scanf("%lld",&h[i]);
  }

  vector<ll> dp(N, 1e9);
  dp[0] = 0;
  for (int i=0; i<N-1; i++) {
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
    if (i >= N-2) continue;
    dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
  }
  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
n, m = map(int, input().split())
peaks = [0] + list(map(int, input().split())) # '0'はダミー

ans = [0] + [1 for _ in range(n)] # '0'はダミー

for i in range(m):
    x,y = map(int, input().split())
    if peaks[x] > peaks[y]:
        ans[y] = 0
    elif peaks[x] < peaks[y]:
        ans[x] = 0
    else:
        ans[x] = 0
        ans[y] = 0

print(sum(ans))

Measured memory_bytes: 19956
#include <stdio.h>
int main(void){
    int i,j,tmp, a[3];
    for(i=0; i<3; i++)
    scanf("%d", &a[i]);
    for(i=0; i<3; i++){
        for(j=i+1; j<3; j++){
            if(a[i]>a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    printf("%d %d %d", a[0], a[1], a[2]);
    printf("\n");
    return 0;
}


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

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

using namespace std;

char a[1001][1001];
int n,dp[1000][1000];

inline bool isValid(int x,int y) { return 0 <= x && x < n && 0 <= y && y < n; }

int main(){

  while( scanf("%d",&n), n ) {
    rep(i,n) rep(j,n) scanf(" %c",&a[i][j]);
    int maxi = 0;
    rep(i,n) rep(j,n) {
      if( a[i][j] == '.' ) {
        int mini = INT_MAX;
        mini = min(mini,isValid(j-1,i-1)?dp[i-1][j-1]:0);
        mini = min(mini,isValid(j,i-1)?dp[i-1][j]:0);
        mini = min(mini,isValid(j-1,i)?dp[i][j-1]:0);
        dp[i][j] = mini + 1;
      } else dp[i][j] = 0;
      maxi = max(maxi,dp[i][j]);
    }
    printf("%d\n",maxi);
  }
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

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(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  vll tmp(1E5+10, 0);
  ll N;
  IN(N);
  REP(i,N){
    ll A;
    IN(A);
    tmp[A]++;
  }
  ll Q;
  IN(Q);

  ll ans = 0;
  REP(i,1E5+10){
    ans += i*tmp[i];
  }

  REP(q,Q){
    ll B, C;
    IN(B,C);
    ans -= B*tmp[B];
    ans += C*tmp[B];
    tmp[C] += tmp[B];
    tmp[B] = 0;
    OUT(ans);
  }

  return 0;
}


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

fn main() {
  let s: Vec<char> = read::<String>().chars().collect();
  let ans = if s[0] == s[1] && s[1] == s[2] ||
    s[1] == s[2] && s[2] == s[3] {
      "Yes"
    } else {
      "No"
    };

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


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int x;

    cin >> x;

    int ans = 0;
    for (int i = 2; i <= 9; i++){
      for (int j = 1; i <= 31; j++){
        int n = pow(j, i);
        if (n > x) break;
        if (n > ans) ans = n;
      }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int N;
	cin>>N;
	int a[N];
	rep(i,N) cin>>a[i];

	int zero=0,two=0,four=0;
	rep(i,N){
		int tmp=0;
		while(!(a[i]%2)){
			a[i]/=2;
			tmp++;
		}
		if(!tmp) zero++;
		else if(tmp==1) two++;
		else four++;
	}
	if((N-two)%2==0){
		if(zero<=four) cout<<"Yes";
		else cout<<"No";
	}else{
		if(zero+1<=four || (two==0&&four+1==zero)) cout<<"Yes";
		else cout<<"No";
	}
	cout<<endl;
}

Measured memory_bytes: 640
while(True):
        h,w = [int(i) for i in input().split()]
        if h == 0 and w == 0:
                break
        for i in range(h):
                out = ''
                for j in range(w):
                        if j == 0 or j == (w-1) or i == 0 or i == (h-1):
                                out += '#'
                        else :
                                out += '.'
                print(out)
        print('')

Measured memory_bytes: 7688
#include<stdio.h>
int main()
{
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    A=A+B;
    C=C+D;
    if(A>C){
        printf("Left");
    }
    else if(A<C){
        printf("Right");
    }
    else{
        printf("Balanced");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int a[10005];

int main() {
  int b = 1;
  int c = 0;
  for (int i = 1;i > 0;b++){
    cin >> a[b];
    i = a[b];
    }
    b--;
    for (int i = 1;b > 1;b--){
    cout << "Case " << i << ":" << " " << a[i] << endl;
    i++;
  }
  return 0;
}


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

using namespace std;

char s[99];

int main()
{
    scanf("%s", s);

    if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
        printf("Yes\n");

    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define N 200001
#define MAX 1000

struct node_t {
	int key;
	struct node_t *pare;
	struct node_t *left;
	struct node_t *right;
};
typedef struct node_t Node;

Node *tree_insert(Node *top, Node *z) {
	Node *y, *x;
	x = top;
	y = NULL;
	while (x != NULL) {
		y = x;
		if (z->key < x->key) {	x = x->left;}
		else {	x = x->right;}
	}
	z->pare = y;
	if (y == NULL) {	top = z;}
	else if (z->key < y->key) {y->left = z;	}
	else {y->right = z;}
	return top;
}

Node *tree_find(Node *node, int key) {
	if (node == NULL){return NULL;}
	if (node->key == key){return node;}
	if (key < node->key){return tree_find(node->left, key);}
	return tree_find(node->right, key);
}

Node *tree_minimum(Node *x) {
	while (x->left != NULL) {x = x->left;}
	return x;
}

Node *tree_successor(Node *x) {
	Node *y;
	if (x->right != NULL) {return tree_minimum(x->right);}
	y = x->pare;
	while (y != NULL && x == y->right) {
		x = y;
		y = y->pare;
	}
	return y;
}

Node *tree_delete(Node *top, Node *z) {
	Node *y, *x;
	if (z->left == NULL || z->right == NULL) {y = z;}
	else {y = tree_successor(z);}
	if (z->left != NULL) {x = y->left;}
	else {x = y->right;}
	if (x != NULL) {x->pare = y->pare;}
	if (y->pare == NULL) {top = x;}
	else if (y == y->pare->left) {y->pare->left = x;}
	else {y->pare->right = x;}
	if (y != z) {z->key = y->key;}
	return top;
}

void inorder_walk(Node *node) {
	if (node->left != NULL) {inorder_walk(node->left);}
	printf(" %d", node->key);
	if (node->right != NULL) {inorder_walk(node->right);}
}

void preorder_walk(Node *node) {
	printf(" %d", node->key);
	if (node->left != NULL) {preorder_walk(node->left);}
	if (node->right != NULL) {	preorder_walk(node->right);}
}

int main(void) {
	char c[20];
	int i,n, key;

	Node *top = NULL, *p;
	scanf("%d ", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %d ", c, &key);
		if (c[0] == 'i') {
			p = malloc(sizeof(Node));
			p->key = key;
			p->pare = p->left = p->right = NULL;
			top = tree_insert(top, p);
		}
		else if (c[0] == 'f') {
			puts(tree_find(top, key) != NULL ? "yes" : "no");
		}
		else if (c[0] == 'd') {
			p = tree_find(top, key);
			if (p != NULL) {top = tree_delete(top, p);}
		}
		else {
			inorder_walk(top);
			putchar('\n');
			preorder_walk(top);
			putchar('\n');
		}
	}
	return 0;
}



Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using pb = pair<double,double>;

signed main(){
	ll n; cin>>n;
	map<ll,ll> mp;
	rep(i,0,n){
		char a; cin>>a;
		mp[a]++;
	}
	if(mp.size()==3)cout<<"Three"<<endl;
	else cout<<"Four"<<endl;

	return 0;
}


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

void swap(int &x, int &y) {
  int tmp;
  tmp = x;
  x = y;
  y = tmp;
}

int bubbleSort(int *a, int n) {
  int res = 0;
  bool flag = 1;
  while (flag) {
    flag = 0;
    for (int j=n-1; j>0; j--) {
      if (a[j-1] > a[j]) {
        swap(a[j], a[j-1]);
        flag = 1;
        res++;
      }
    }
  }
  return res;
}

int main() {
  int N, A[100], cnt;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  cnt = bubbleSort(A, N);

  for (int i=0; i<N; i++) {
    cout << A[i];
    if (i < N - 1) cout << " ";
  }
  cout << endl;
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <map>
#include<stack>
#include<fstream>

using namespace std;
const long long INF = 1LL << 60;  // どういう意味だろうか

const string write_file("");

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

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

int main() {
	int a[3] = {};
	int b[3] = {};
	int c[5] = {};
	int now_point;

	for(int i = 0; i < 3 ; i++){
		cin >> a[i] >> b[i];
		c[a[i]]++;
		c[b[i]]++;
	}

	int count = 0;
	for(int i = 1 ; i < 5; i++){
		if(c[i] == 0){
			cout << "NO" << endl;
			return 0;
		}
		else if(c[i] == 2){
			count++;
		}
	}
	if(count == 2){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}




}


Measured memory_bytes: 384
n,m = [int(i) for i in input().split()]
x = list(map(int, input().split()))

score = max(x) - min(x)

x.sort()

dist = []

for i in range(1,m):
    dif = x[i] - x[i-1]
    dist.append(dif)

dist.sort()

#distはながさm-1

if n >= m:
    score = 0
else:
    for i in range(1,n):
        reduce = dist[-i]
        score -= reduce
print(score)

Measured memory_bytes: 13968
#include<iostream>
using namespace std;
int main(){
  int S,h=0,m=0,s=0;
  cin >> S;
  if(S<0||86400<=S) return 0;
  h=S/3600;
  m=(S%3600)/60;
  s=(S%60);
  cout <<h<<":"<<m<<":"<<s<<endl;
  return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int x;
  cin>>x;
  cout<<48-x;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#define ll long long
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> v(100010);
	for(int i=0; i<N; ++i){
	    int a, b;
	    cin >> a >> b;
	    v[a].push_back(b);
	}
	int ans=0;
	priority_queue<int> pq;
	for(int i=1; i<=M; ++i){
	    for(int j=0; j<v[i].size(); ++j) pq.push(v[i][j]);
	    if(pq.size()>0){
	        ans += pq.top();
	        pq.pop();
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int solve(const int n, string s)
{
    int max_count = 0;
    for (size_t i = 1; i < n; ++i) {
        string str1 = s.substr(0, i);
        string str2 = s.substr(i, n);
        set<char> str1_set;
        set<char> str2_set;
        for (auto e : str1)
            str1_set.insert(e);
        for (auto e : str2)
            str2_set.insert(e);
        int count = 0;
        for (auto e : str1_set) {
            if (str2_set.count(e))
                ++count;
        }
        max_count = max(max_count, count);
    }
    return max_count;
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    cout << solve(n, s) << endl;
}


Measured memory_bytes: 256
import sys
import math
from collections import deque

input = sys.stdin.readline


def solve(n, x_y_list):
    radians = [(math.atan2(y, x), x, y) for x, y in x_y_list]
    radians.sort()
    radians = radians + radians

    max_square_distance = 0
    for start in range(n):
        sum_x = sum_y = 0
        for i in range(n):
            _, x, y = radians[start + i]
            sum_x += x
            sum_y += y
            square_distance = sum_x ** 2 + sum_y ** 2
            if max_square_distance < square_distance:
                max_square_distance = square_distance
    return math.sqrt(max_square_distance)


if __name__ == '__main__':
    n = int(input())
    x_y_list = [tuple(map(int, input().split())) for _ in range(n)]

    answer = solve(n, x_y_list)
    print(answer)


Measured memory_bytes: 3440
N = int(input())
A = list(map(int, input().split()))
C = [0, A.count(1), A.count(2), A.count(3)]
dp = [[[0.0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]

for k in range(C[3]+1):
    for j in range(C[3]+C[2]+1-k):
        for i in range(N+1-j-k):
            if i + j + k == 0:
                continue
            res = N
            if i > 0:
                res += i * dp[i-1][j][k]
            if j > 0:
                res += j * dp[i+1][j-1][k]
            if k > 0:
                res += k * dp[i][j+1][k-1]
            dp[i][j][k] = res / (i + j + k)
 
print(dp[C[1]][C[2]][C[3]])

Measured memory_bytes: 253832
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;
 
int main(){
 
  char a[3], b[3];
  
 
  for(int i=0; i<3; i++){
    cin >> a[i] >> b[i];
  }
 
  if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
 
 
  return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    vector<int> A(3);

    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());

    cout << A[2] * 10 + A[1] + A[0] << endl;
    return 0;
}

Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 2e5 + 5;
const int MOD = 1e9 + 7;

void iadd(int &dp, const int &val) {
    dp += val;
    if (dp >= MOD) {
        dp -= MOD;
    }
}

void ladd(int &dp, const LL &val) {
    dp = (dp + val) % MOD;
}

int n, ans, iv2[N];
vector<int> g[N];
int siz[N];

int dfs(int u = 1, int p = 0) {
    vector<int> vc;
    siz[u] = 1;
    for (int v : g[u]) {
        if (v != p) {
            vc.emplace_back(dfs(v, u));
            siz[u] += siz[v];
        }
    }
    vc.emplace_back(n - siz[u]);
    int y = 0, z = n;
    for (int x : vc) {
        z -= x;
        ladd(ans, (LL) (MOD + 1 - iv2[x]) * (MOD + 1 - iv2[y]) % MOD * iv2[z]);
        y += x;
    }
    return siz[u];
}

int main() {
    n = read();
    iv2[0] = 1;
    iv2[1] = (MOD + 1) / 2;
    for (int i = 2; i <= n; ++i) {
        iv2[i] = (LL) iv2[i - 1] * iv2[1] % MOD;
    }
    for (int i = 1; i < n; ++i) {
        int a = read(), b = read();
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dfs();
    cout << ans;
    return 0;
}


Measured memory_bytes: 29056
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int n = readint();

    int ans = 1;
    while (ans * 2 <= n) {
        ans *= 2;
    }
    writeln(ans);
}


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

int main() {
  
  // 変数定義
  int two_day = 48;
  int time;
  
  // 変数に入力値を代入
  cin >> time;
  
  // 足した値を出力
  cout << two_day - time << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b){
        if(b<c){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2056
use std::io;

fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str
}

fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}



fn main(){

    let v = read_t_in_line::<i64>();
    let (x, y) = (v[0], v[1]);
    let mut c = x;
    let mut cnt = 0;
    while c <= y {
        cnt += 1;
        c *= 2;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    int count =0;

    for (int x = a; x <= b; x++) {
      if(c%x==0){
        count++;
      }else{
        ;
      }
    }
    System.out.println(count);

  }
}



Measured memory_bytes: 26368
from collections import deque
h, w = map(int, input().split())

a = [[False]*(w+2)]
for y in range(h):
    a.append([False] + [x!='#' for x in input()] + [False])
a.append([False]*(w+2))

s = deque()
for i in range(1, h+1):
    for j in range(1, w+1):
        if not a[i][j]:
            s.append((i,j))

ans = -1
while s:
    ns = deque()
    for i, j in s:
        if a[i-1][j]:
            a[i-1][j] = False
            ns.append((i-1, j))
        if a[i+1][j]:
            a[i+1][j] = False
            ns.append((i+1, j))
        if a[i][j-1]:
            a[i][j-1] = False
            ns.append((i, j-1))
        if a[i][j+1]:
            a[i][j+1] = False
            ns.append((i, j+1))
        
    s = ns
    ans += 1
    
print(ans)

Measured memory_bytes: 106736
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdlib.h>
using namespace std;
int main()
{
	int a,b;
	char op;
	cin>>a>>op>>b;
	if(op=='+')
		cout<<a+b<<endl;
	else if(op=='-')
		cout<<a-b<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

int main() {
	vector<int> a(5);
	for (int i = 0; i < 5; i++) cin >> a[i];
	int k; cin >> k;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			if (a[j] - a[i] > k) {
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

H,W,K=map(int,input().split())
S=[list(map(int,list(input()))) for _ in range(H)]
ans=INF
for i in range(2**(H-1)):
    cnt=1+bin(i).count('1')
    tmp=cnt-1
    div=[0]*H
    for j in range(H-1):
        if (i>>j)&1:
            div[j+1]=div[j]+1
        else:
            div[j+1]=div[j]
    wc=[0]*cnt
    for x in range(W):
        tmp_wc=[0]*cnt
        f=False
        for y in range(H):
            if S[y][x]==1:
                tmp_wc[div[y]]+=1
                wc[div[y]]+=1
                if wc[div[y]]>K:
                    f=True
                if tmp_wc[div[y]]>K:
                    break
        else:
            if f:
                tmp+=1
                wc=tmp_wc
                tmp_wc=[0]*cnt
                f=False
            continue
        break
    else:
        ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 74624
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	string c; cin>>c;
	c = '@'+c;
	map<char,int>mp={{'R',0},{'G',1},{'B',2}};//0-R, 1-G, 2-B;
	vector<vector<int>>pref(n+1,vector<int>(3,0)); 
	for(int i=1;i<=n;i++){
		pref[i]=pref[i-1];
		pref[i][mp[c[i]]]++;
	}
	long long res=0;
	for(int i=1;i<=n-2;i++){
		set<int>st;
		st.insert(mp[c[i]]);
		for(int j=i+1;j<=n-1;j++){
			if(st.count(mp[c[j]])) 
				continue;
			st.insert(mp[c[j]]);
			int target=3-mp[c[i]]-mp[c[j]];
			res+=pref[n][target]-pref[j][target];
			if(j+j-i<=n && mp[c[j+j-i]]==target)
				res--;
			st.erase(mp[c[j]]);
		}
		st.erase(mp[c[i]]);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3816
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include<string.h>
#include <math.h>
#include <stack>
#define ll long long
using namespace std;

int main() {
	char a[100];
	char res[4][10];
	int point = 0;
	scanf("%s", a);
	strcpy(res[point++],strtok(a, "/"));
	while (1) {
		if (point == 3)
			break;
		strcpy(res[point++], strtok(NULL, "/"));
	}
	if (strcmp(res[0], "2019") < 0) {
		printf("Heisei\n");
		return 0;
	}
	else if (strcmp(res[1], "04") < 0 && strcmp(res[0], "2019") == 0) {
		printf("Heisei\n");
		return 0;
	}
	else if (strcmp(res[0], "2019") == 0 && strcmp(res[1], "04") == 0 && strcmp(res[2], "30") <= 0) {
		printf("Heisei\n");
		return 0;
	}
	else {
		printf("TBD\n");
		return 0;
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
pair<int,int> A[202020];
const ll mo=1000000007;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	int p=0;
	FOR(i,N) {
		cin>>x;
		A[i]={abs(x),x};
		if(x>0) p=1;
	}
	sort(A,A+N);
	
	ll ret=1;
	if(p==0 || K==N) {
		if(K%2==0) {
			FOR(i,K) (ret*=(mo+A[N-1-i].second))%=mo;
		}
		else {
			FOR(i,K) (ret*=(mo+A[i].second))%=mo;
		}
	}
	else {
		int pm=mo,mm=0;
		int s=0;
		FOR(i,K) {
			(ret*=(mo+A[N-1-i].second))%=mo;
			if(A[N-1-i].second>0) pm=A[N-1-i].second;
			if(A[N-1-i].second<0) mm=A[N-1-i].second, s^=1;
		}
		
		if(ret && s==1) {
			int p2=-1,m2=1,z=0;
			for(i=N-1-K;i>=0;i--) {
				if(A[i].second>0&&p2==-1) p2=A[i].second;
				if(A[i].second<0&&m2==1) m2=A[i].second;
				if(A[i].second==0) z++;
			}
			
			if((mm==0 || p2==-1) && (pm==mo||m2==1)) {
				if(z) ret=0;
			}
			else if(mm==0 || p2==-1) {
				(ret*=(m2+mo))%=mo;
				(ret*=modpow(pm))%=mo;
			}
			else if(pm==mo||m2==1) {
				(ret*=(p2))%=mo;
				(ret*=modpow(mm+mo))%=mo;
			}
			else if(1LL*p2*pm>=1LL*m2*mm) {
				(ret*=(p2))%=mo;
				(ret*=modpow(mm+mo))%=mo;
			}
			else {
				(ret*=(m2+mo))%=mo;
				(ret*=modpow(pm))%=mo;
			}
		}
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

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

  if (n / 10 == 9 || n % 10 == 9) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		
        Scanner scan = new Scanner(System.in);
        String str1 = scan.next();
        String str2 = scan.next();
		float a =Float.parseFloat(str1);
		float b =Float.parseFloat(str2);
		float c ;
		c = a/b;
		
		System.out.println(c);
    }
}

Measured memory_bytes: 22740
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

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

using Int = unsigned int;
using llong = long long;
using Llong = unsigned long long;
using ldouble = long double;
using intV = vector<int>;
using llongV = vector<long long>;
using llongVV = vector<vector<long long>>;
using Graph = vector<vector<long long>>;
using costGraph = vector<vector<pair<long long, long long>>>;

struct Edge {
    long long from;
    long long to;
    long long cost;
};

template<typename T>
using asc = less<T>();
template<typename T>
using desc = greater<T>();

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

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

    llong N, M, P;
    cin >> N >> M >> P;

    vector<Edge> edges;
    Graph G(N);
    Graph GR(N);

    FOR(i, M) {
        llong fr, to, cost;
        cin >> fr >> to >> cost;
        fr--; to--; cost -= P;
        edges.push_back({fr, to, -cost});
        G[fr].push_back(to);
        GR[to].push_back(fr);
    }

    vector<bool> canGo(N, false);
    vector<bool> canBack(N, false);

    stack<llong> st;
    st.push(0);
    while(!st.empty()) {
        llong now = st.top(); st.pop();
        for(llong to : G[now]) {
            if(!canGo[to]) {
                st.push(to);
                canGo[to] = true;
            }
        }
    }

    st.push(N - 1);
    while(!st.empty()) {
        llong now = st.top(); st.pop();
        for(llong to : GR[now]) {
            if(!canBack[to]) {
                st.push(to);
                canBack[to] = true;
            }
        }
    }

    llongV minDist(N, INF);
    minDist[0] = 0;

    FOR(i, N + 1) {
        for(Edge edge : edges) {
            if(minDist[edge.to] > minDist[edge.from] + edge.cost) {
                if(i == N) {
                    if(canGo[edge.to] && canBack[edge.to]) {
                        cout << "-1" << endl;
                        return 0;
                    }
                    continue;
                }
                minDist[edge.to] = minDist[edge.from] + edge.cost;
            }
        }
    }

    llong ans = -minDist[N - 1];
    if(ans < 0) ans = 0;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
int main(){
	int H;
	int W;
	int j;
	int i;
	for(H=1,W=1;;){
		cin>>H>>W;
		if(H==0&&W==0)break;
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				if(i%2 == 0 && j%2 == 0)cout<<"#";
				else if(i%2 == 1 && j%2 == 1)cout<<"#";
				else cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	
	int L[N];
	int ma = 0;
	int sum = 0;
	
	for(int i=0; i<N; i++) {
		cin >> L[i];
		ma = max(ma, L[i]);
		sum += L[i];
	}
	
	if (ma < sum -ma) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}


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

int main() {
  int h,n;
  cin>>h>>n;
  
  int s[n];
  for(int i=0; i<n; i++) cin >> s[i];
  int sum=0;
  
  for(int i=0; i<n; i++) sum+=s[i];
  
  if(h<=sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
<?php
// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%s", $S);
// fscanf(STDIN, "%d %d", $N, $K);
// $a = explode(" ", trim(fgets(STDIN)));

$array = str_split($S);
$count = count($array);
$bool = true;
$countC = 0;

for ($i = 0; $i < $count; $i++) {
	if (DEBUG) {
		echo $i . PHP_EOL;
	}

	if ($i == 0) {
		if ($array[$i] != 'A') {
			if (DEBUG) {
				echo "NOT FIRST A\n";
			}

			$bool = false;
		}
	} elseif ($i >= 2 && $i < $count - 1) {
		if (DEBUG) {
			echo "middle ";
		}

		if ($array[$i] == 'C') {
			$countC++;
		} elseif (strtoupper($array[$i]) == $array[$i]) {
			if (DEBUG) {
				echo "NOT lower\n";
			}
			$bool = false;
		}
	} else {
		if (strtoupper($array[$i]) == $array[$i]) {
			if (DEBUG) {
				echo "OTHER NOT lower\n";
			}

			$bool = false;
		}
	}
}

if ($countC != 1) {
	if (DEBUG) {
		echo "C COUNT NOT 1\n";
	}

	$bool = false;
}

echo $bool ? "AC" : "WA";


Measured memory_bytes: 4604
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	string s;
	cin >> s;
	int ans=1;
	for(int i=0; i<s.size(); i++){
		for(int j=i+1; j<s.size(); j++){
			if(s.at(i)==s.at(j)){
				ans=0;
				break;
			}
		}
	}
	if(ans){
		cout << "yes" << endl;
	}else{
		cout << "no" << endl;
	}
	return 0;
}

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

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

    vector<bool> p(55555, true);

    p[0] = p[1] = false;
    for (int i = 2; i < 55555; i++) {
        for (int j = i + i; j < 55555; j += i) {
            p[j] = false;
        }
    }

    vector<int> a;
    for (int i = 0; i < 55555; i++) {
        if (p[i] && i % 5 == 1) a.push_back(i);
    }

    for (int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int arr[N + 1];
    for (int i = 1 ; i <= N ; i++)
        cin >> arr[i];

    int ans = 0;
    for (int i = 1 ; i <= N ; i += 2){
        if (arr[i] & 1)
            ++ans;
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  double k, n, max = 0, sum = 0;
  cin >> n >> k;
  vector<double> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
    p.at(i) /= 2;
  }
  for (int i = 0; i < k; i++) {
    sum += p.at(i);
  }
  for (int i = 0; i < n-(k-1); i++) {
    if (i != 0) {
      sum += p.at(i+k-1);
      sum -= p.at(i-1);
    }
    if (max < sum) {
      max = sum;
    }
  }
  printf("%f", max+0.5*k);
  return 0;
}


Measured memory_bytes: 1792