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

int main()
{
  int64_t n,m,ans,h;
  ans=0;
  h=0;
  cin>>n>>m;
  vector<pair<int64_t,int64_t>> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i).first>>a.at(i).second;
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++)
  {
    ans+=a.at(i).first*a.at(i).second;
    h+=a.at(i).second;
    if(h>m)
    {
      ans-=a.at(i).first*(h-m);
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,K;
  int x=0;
  cin>>N>>K;
  vector<int> a(N);
  for(int i=0;i<N;i++)
  {
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  for(int j=0;j<K;j++)
  {
    x=x+a.at(j);
  }
  cout<<x<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int m, n, h, w;
int t;
int main()
{
    cin >> m >> n;
    cin >> h >> w;
    t = m * n;
    t -= h * n;
    t -= w * (m - h);
    cout << t;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;

const int N = 2e5 + 5;

int arr[N];
int pos[N];
int l[N];

int n;



int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    pos[arr[i]] = i;
  }

  l[n] = 1;
  for (int i = n - 1 ; i >= 1 ; --i) {
    if (pos[i] < pos[i + 1]) {
      l[i] = l[i + 1] + 1;
    } else {
      l[i] = 1;
    }
  }

  int res = n;
  for (int i = 1 ; i <= n ; ++i) {
    res = min(res , n - l[i]);
  }

  cout << res;

}



Measured memory_bytes: 2560
#include <cstdio>
const int maxn=2e5+6;
#define read(a) scanf("%I64d",&a)
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ls rt<<1
#define rs rt<<1|1
#define mid ((l+r)>>1)
#define int long long
template<class T>inline T max(T a,T b) { return a>b?a:b; }
template<class T>inline T min(T a,T b) { return a<b?a:b; }
int n,a[maxn],lans[maxn],rans[maxn];
struct Segment_Tree {
	int val[maxn<<2];
	inline void pushup(int rt) { val[rt]=max(val[ls],val[rs]); }
	inline void insert(int rt,int l,int r,int k,int ch) {
		if(l==r) return(void)(val[rt]=ch);
		if(k<=mid) insert(ls,l,mid,k,ch);
		else insert(rs,mid+1,r,k,ch);
		pushup(rt);
	}
	inline int query(int rt,int l,int r,int L,int R) {
		if(L<=l&&r<=R) return val[rt];
		int ans=0;
		if(L<=mid) ans=max(ans,query(ls,l,mid,L,R));
		if(R>mid) ans=max(ans,query(rs,mid+1,r,L,R));
		return ans;
	}
	inline void build(int rt,int l,int r) {
		val[rt]=0; if(l==r) return;
		build(ls,l,mid); build(rs,mid+1,r);
	}
}t;
struct Segment_Tree_ {
	int val[maxn<<2];
	inline void pushup(int rt) { val[rt]=min(val[ls],val[rs]); }
	inline void insert(int rt,int l,int r,int k,int ch) {
		if(l==r) return(void)(val[rt]=ch);
		if(k<=mid) insert(ls,l,mid,k,ch);
		else insert(rs,mid+1,r,k,ch);
		pushup(rt);
	}
	inline int query(int rt,int l,int r,int L,int R) {
		if(L<=l&&r<=R) return val[rt];
		int ans=maxn;
		if(L<=mid) ans=min(ans,query(ls,l,mid,L,R));
		if(R>mid) ans=min(ans,query(rs,mid+1,r,L,R));
		return ans;
	}
	inline void build(int rt,int l,int r) {
		val[rt]=n+1; if(l==r) return;
		build(ls,l,mid); build(rs,mid+1,r);
	}
}T;
int ans;
signed main() {
	read(n);
	rep(i,1,n) read(a[i]);
	rep(i,1,n) {
		t.insert(1,1,n,a[i],i);
		if(a[i]!=1) lans[i]=t.query(1,1,n,1,a[i]-1);
		else lans[i]=0;
	}
	T.build(1,1,n);
	per(i,n,1) {
		T.insert(1,1,n,a[i],i);
		if(a[i]!=1) rans[i]=T.query(1,1,n,1,a[i]-1);
		else rans[i]=n+1;
	}
	rep(i,1,n) ans+=(i-lans[i])*(rans[i]-i)*a[i];
	printf("%lld",ans);
}

Measured memory_bytes: 17408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class AFiveVariables {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        vc<int> x(5);
        for(auto& xx : x) in>>xx;
        REP(i, 5) if(x[i]==0){
            out<<i+1<<'\n';
            return;
        }
    }
};


int main() {
	AFiveVariables solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#ifdef DEBUG
#include "debug.h"
#endif

using namespace std;

#define mp make_pair
#define mt make_tuple
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(a) ((int)(a).size())
#define make_unique(a) (a).resize(unique(all((x))) - (x).begin())

typedef long long ll;

template<typename T> inline bool mmin(T& a, const T &b) { return b < a ? (a = b, true) : false; }
template<typename T> inline bool mmax(T& a, const T &b) { return b > a ? (a = b, true) : false; }

struct Edge {
    int to;
    ll len;
};

vector<ll> get_d(int s, vector<vector<Edge> > &g) {
    ll inf = 1e18;
    int n = sz(g);
    vector<ll> d(n, inf);
    d[s] = 0;
    set<pair<ll, int> > q;
    q.insert({0, s});
    while (!q.empty()) {
        int v = q.begin()->second;
        q.erase(q.begin());
        for (auto &edge : g[v]) {
            int to = edge.to;
            ll len = edge.len;
            if (d[to] > d[v] + len) {
                q.erase({d[to], to});
                d[to] = d[v] + len;
                q.insert({d[to], to});
            } 
        }
    }
    return d;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    vector<vector<Edge> > g1(n), g2(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        ll len1, len2;
        cin >> a >> b >> len1 >> len2;
        a--, b--;
        g1[a].push_back({b, len1});
        g1[b].push_back({a, len1});
        g2[a].push_back({b, len2});
        g2[b].push_back({a, len2});
    }

    vector<ll> d1 = get_d(s, g1);
    vector<ll> d2 = get_d(t, g2);
    //debug(all(d1));
    //debug(all(d2));

    vector<ll> ans(n);
    for (int i = n - 1; i >= 0; i--) {
        ans[i] = d1[i] + d2[i];
        if (i != n - 1) {
            ans[i] = min(ans[i], ans[i + 1]);
        }
    }
    ll xyu = 1e15;
    for (int i = 0; i < n; i++) {
        cout << xyu - ans[i] << '\n';
    }

    return 0;
}

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

using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define all(v) v.begin(), v.end()
#define debug(x) cout << x << endl
#define vout(v) rep(i, v.size()) cout << v[i] << " "

const int MAX = 1000000;
int n;

int main() {
	cin >> n;
	vector<string> s(n);
	int ans = 0;
	rep(i, n) { cin >> s[i]; }
	sort(all(s));
	s.erase(unique(all(s)), s.end());
	cout << s.size();

	return 0;
}

Measured memory_bytes: 9600
#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>;

vector<vector<int>> g;
vector<int> id;
int sum = 0;

int f(int x, int ida, int a, int b){
	sum++;
	id.at(x) = ida;
	rep(i, g.at(x).size()){
		if(id.at(g.at(x).at(i)) != ida){
			int mia = min(x, g.at(x).at(i));
			int mab = max(x, g.at(x).at(i));
			if(!(mia == a && mab == b)){
				f(g.at(x).at(i), ida, a, b);
			}
		}
	}
	return 0;
}

int main(){
	int n, m;
	cin >> n >> m;
	g = vector<vector<int>>(n, vector<int>(0));
	id = vector<int>(n);
	vector<vector<int>> in(m, vector<int>(2));
	rep(i, n){
		id.at(i) = -1;
	}
	rep(i, m){
		int ai, bi;
		cin >> ai >> bi;
		ai--; bi--;
		g.at(ai).push_back(bi);
		g.at(bi).push_back(ai);
		in.at(i).at(0) = ai;
		in.at(i).at(1) = bi;
	}
	int ans = 0;
	rep(i, m){
		sum = 0;
		f(0, i, in.at(i).at(0), in.at(i).at(1));
		if(sum != n) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

vector<long long> yakusuu(long long N)
{
    vector<long long> ret;
    ret.push_back(1);
    for (int i = 2; i <= sqrt(N) + 1; i++)
    {
        if (N % i == 0 && i != N)
        {
            ret.push_back(i);
            if (i != N / i)
            {
                ret.push_back(N / i);
            }
        }
    }
    return ret;
}

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

    long long N;
    cin >> N;

    if (N == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    vector<long long> v = yakusuu(N);
    // for (auto a : v)
    // {
    //     cout << a << endl;
    // }

    long long ans = 0LL;
    for (int i = 0; i < v.size(); i++)
    {
        if (N / (N / v[i] - 1) == N % (N / v[i] - 1))
        {
            ans += N / v[i] - 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
int a[N], b[N];

int main() {
  int n; ni(n);
  for (int i = 1; i <= n; i++)
      ni(a[i]);
  for (int i = 1; i <= n; i++)
    ni(b[i]);
  int ans = 0;
  for (int i = 28; i >= 0; i--) {
    int c1 = 0, c2 = 0;
    for (int j = 1; j <= n; j++) {
      if (a[j] & (1 << i))
        c1++;
      if (b[j] & (1 << i))
        c2++;
      a[j] %= 1 << i;
      b[j] %= 1 << i;
    }
    sort(a+1, a+n+1); sort(b+1, b+n+1);
    int r = n;
    ll tmp = c1 * (n - c2) + c2 * (n - c1);
    for (int j = 1; j <= n; j++) {
      while (r > 0 && a[j]+b[r] >= (1 << i))
        r--;
      tmp += n-r;
    }
    if (tmp & 1)
      ans |= 1 << i;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  int two = 0, four = 0;
  for(int i=1; i<=n; i++){
    int a;  scanf("%d", &a);
    if(a%4 == 0)  four++;
    else if(a%2 == 0)  two++;    
  }

  long c = n - two;
  int ans = 0;
  if( ((c+1)/2 <= four) || (two==0 && c/2 <= four) )
    ans = 1;

  printf("%s\n", (ans ? "Yes" : "No"));

  return 0;
}
  


Measured memory_bytes: 1632
// g++ -std=c++14

#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(c) (c.begin(),c.end())
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define inf 1000000000000000001

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll
int32_t main(){ _
  int n;
  cin >> n;
  vector<vector<int> > dp(n, vector<int>(3, 0));
  vector<int> a(n), b(n), c(n);
  for(int i = 0; i < n; i++)
    cin >> a[i] >> b[i] >> c[i];
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for(int i = 1; i < n; i++){
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }
  cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = x + y;
		b[i] = x - y;
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	cout << max(a.back() - a.front(), b.back() - b.front()) << "\n";
	return 0;
}

Measured memory_bytes: 4776
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::*;

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

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

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

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

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

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

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

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


fn main() {
    input!{
        k: isize,
    }

    let mut queue = VecDeque::<isize>::new();
    for i in 1..10 {
        queue.push_back(i);
    }

    for _ in 1..k {
        let e = queue.pop_front().unwrap();
        let m = e % 10;
        if m != 0 { queue.push_back(e * 10 + (m-1)); }
        queue.push_back(e * 10 + m);
        if m != 9 { queue.push_back(e * 10 + (m+1)); }
    }

    let ans = queue.pop_front().unwrap();
    println!("{}", ans);
}


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

int main() {
  int N, C;
  long long K;
  cin >> N >> C >> K;
  vector<long long> T(N);
  for (int i = 0; i < N; i++) cin >> T.at(i);
  sort(T.begin(), T.end());
  queue<long long> q;
  int ans = 0;
  long long first = 0;
  long long next = 0;
  for (int i = 0; i < N; i++) {
    next = T.at(i);
    if (q.empty() || q.size() == C || next > first + K) {
      while (!q.empty()) q.pop();
      first = next;
      q.push(first);
      ans++;
    }
    else if (q.size() < C && next <= first + K) q.push(next);
  }
  cout << ans << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

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

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

  int n;
  cin >> n;
  vector<int64> xs(3 * n);
  for (int i = 0; i < 3 * n; i++) {
    cin >> xs[i];
  }

  vector<int64> ys(3 * n);
  vector<int64> zs(3 * n);

  priority_queue<int64, vector<int64>, greater<int64>> q1;
  int64 sum1 = 0;
  for (int i = 0; i < 3 * n; i++) {
    sum1 += xs[i];
    q1.push(xs[i]);
    if (q1.size() > n) {
      sum1 -= q1.top();
      q1.pop();
    }
    ys[i] = sum1;
  }

  priority_queue<int64> q2;
  int64 sum2 = 0;
  for (int i = 3 * n - 1; i >= 0; i--) {
    sum2 += xs[i];
    q2.push(xs[i]);
    if (q2.size() > n) {
      sum2 -= q2.top();
      q2.pop();
    }
    zs[i] = sum2;
  }

  int64 ans = INT64_MIN;
  for (int i = n - 1; i < 2 * n; i++) {
    UpdateMax(ans, ys[i] - zs[i + 1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9588
// Created by CAD on 2020/4/18.
#include <bits/stdc++.h>

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x7fffffffffffffff
#define mst(name, value) memset(name,value,sizeof(name))
#define FOPEN freopen("C:\\Users\\14016\\Desktop\\cad.txt","r",stdin)
#define tst1(a) cout<<#a<<":"<<a<<endl
#define tst2(a, b) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl
#define tst3(a, b, c) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl
#define tst4(a, b, c, d) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl
#define lson (p<<1)
#define rson (p<<1|1)
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define ll long long
#define lowbit(i) (i&-i)
using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    ll sum=0;
    for(int i=1;i<=n;++i){
        if(i%3==0||i%5==0) continue;
        sum+=i;
    }
    cout<<sum<<"\n";

    return 0;
}


Measured memory_bytes: 3596
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next() + sc.next();
    double b = Math.sqrt(Integer.parseInt(a));
    if (b == Math.floor(b)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

using namespace std;

int main(int, char**) {
        int k, a, b;
        cin >> k >> a >> b;
        for (int i=a; i<b+1; i++) {
                if (i%k==0) {
                       cout << "OK" << endl;
                     return 0;
                }
        }
        cout << "NG" << endl;
        return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(){
int m,f,r,h;
while(1){
scanf("%d %d %d",&m,&f,&r);
if(m==-1&&f==-1&&r==-1)break;
if((m+f)>=80)h='A';
if((m+f)>=65&&(m+f)<80)h='B';
if((m+f)>=50&&(m+f)<65)h='C';
if((m+f)>=30&&(m+f)<50){
if(r>=50)h='C';
else h='D';
}
if((m+f)<30)h='F';
if(m==-1||f==-1)h='F';
printf("%c\n",h);
}
return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <string>
#include <functional>

using namespace std;

long long calc(int b, vector<int> As) {
	long long sum = 0;
	for (int i = 0; i < As.size(); i++) {
		sum += abs(As[i] - b);
	}
	return sum;
}

int main() {
	int N;
	cin >> N;
	vector<int> As;
	int n;
	for (int i = 0; i < N; i++) {
		cin >> n;
		As.push_back(n - i - 1);
	}
	sort(As.begin(), As.end());
	int MID = (N % 2 == 0) ? (As[N / 2 - 1] + As[N / 2]) / 2 : As[N / 2];
	cout << calc(MID, As);
	return 0;
}

Measured memory_bytes: 1908
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <limits.h>
using namespace std;
typedef long long ll;
long long big = 200000000000;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s,t;
    cin>>s>>t;
    
    int row = s.size()+1;
    int col = t.size()+1;
    
    vector<vector<int>> count;
    
    for(int i =0; i<row;i++){
        vector<int> add(col,0);
        count.push_back(add);
    }
    
    for(int i=1;i<row;i++){
        for(int j=1;j<col;j++){
            if(s[i-1]==t[j-1]){
                count[i][j]=1+count[i-1][j-1];
            }else{
                count[i][j] = max(count[i-1][j],count[i][j-1]);
            }
        }
    }
    int a = row-1;
    int b = col-1;
    string ans="";
    while(count[a][b]!=0){
        if(s[a-1]==t[b-1]){
            ans.push_back(s[a-1]);
            a--;
            b--;
        }else{
            if(count[a-1][b]==count[a][b]){
                a--;
            }else{
                b--;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

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

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

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

  int ans = 0;
  ans = (a+b) * h /2;

  printf("%d",ans);

  return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <ostream>
#include <bitset>
#include <list>
#include <deque>
#include <complex>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <climits>

using namespace std;

#define MAX_N 100
#define MAX_W 10000
#define INF 1e9
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,n) for(int i = n ; i >= 0 ; i--)
#define FOR(i,a,b) for(int i = a ; i < b ; i++)
#define all(p) (p).begin(),(p).end() 

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

int N,W;
int v[MAX_N],w[MAX_N];

int solve(){
  int dp[MAX_N+1][MAX_W+1];
  memset(dp,0,sizeof(dp));
  rrep(i,N-1){
    rep(j,W+1){
      if(j < w[i]){
        dp[i][j] = dp[i+1][j];
      }else{
        dp[i][j] = max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
      }
    }
  }
  return dp[0][W];
}

int main(){
  scanf("%d%d",&N,&W);
  rep(i,N){
    scanf("%d%d",&v[i],&w[i]);
  }
  printf("%d\n",solve());
  return 0;
}

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

int main()
{
    int a[3];
    int sum=0;
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[0]+a[1];

    return 0;
}


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

int main(void){
  string s;
  cin >> s;
  
  string t1 = "0", t2 = "1";
  
  for(int i = 0; i < s.length(); i ++){
    if(t1.at(i) == '0') t1.push_back('1');
    else t1.push_back('0');
  }
  for(int i = 0; i < s.length(); i ++){
    if(t2.at(i) == '0') t2.push_back('1');
    else t2.push_back('0');
  }
  
  int c = 0, d = 0;
  for(int i = 0; i < s.length(); i ++){
    if(s.at(i) != t1.at(i)) c ++;
    if(s.at(i) != t2.at(i)) d ++;
  }
  
  cout << min(c, d) << endl;
  
  return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;

ll N;
ll L[100000 + 10], R[100000 + 10];

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

	sort(L, L + N, greater<ll>());
	sort(R, R + N);

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		if (L[i] >= R[i]) {
			ans += (L[i] - R[i]);
		}
	}
	cout << 2LL * ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  for(int x=1; x<=50000; x++) {
    if ((x * 108)/100 == n) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;

  return 0;
}


// EOF


Measured memory_bytes: 256
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n=int(arr_data[0][0])
k=int(arr_data[0][1])


print(0 if n % k==0 else 1)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<math.h>
using namespace std;

int main(){
    
    int N;
    cin >> N;
    N%=10;
    //cout << N << endl;
  
    if(N==2 || N==4 || N==5 || N==7 || N==9){
        cout << "hon" << endl;
    }else if(N==0 || N==1 || N==6 || N==8){
        cout << "pon" << endl;
    }else if(N==3){
        cout << "bon" << endl;
    }
    
    
    return 0;
}


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

int main(){
  int A , B , K ;
  cin >> A >> B >> K ;
  vector<int> D(110);
  for(int i=1;i<=100;i++){
    if(A%i==0&&B%i==0) {
      D[i]=i;
    }
  }
  
  sort(D.begin(),D.end());
  reverse(D.begin(),D.end());
  
  cout << D[K-1] << endl;
  
}




Measured memory_bytes: 256
using System;
using System.Linq;

namespace A___9x9
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = A_B[0], B = A_B[1];

            Console.WriteLine(A < 10 && B < 10 ? A * B : -1);
        }
    }
}


Measured memory_bytes: 13268
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')
from copy import deepcopy

#solve
def solve():
    n, k = LI()
    h = [0] + LI()
    d = defaultdict(int)
    d[(0, 0)] = 0
    for i in range(1, n + 1):
        nd = defaultdict(lambda: inf)
        for key, value in d.items():
            a, b = key
            if nd[(i, b)] > value + (h[i] - h[a] if h[i] > h[a] else 0):
                nd[(i, b)] = value + (h[i] - h[a] if h[i] > h[a] else 0)
            if b + 1 > k:
                continue
            if nd[(a, b + 1)] > value:
                nd[(a, b + 1)] = value
        d = nd
    ans = inf
    for i in range(n + 1):
        for j in range(k + 1):
            ans = min(ans, d[(i, j)])
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 148564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  string str1,str2;
  cin>>str1>>str2;
  for(ll i=0;i<str1.length();i++)
  {
    if(str1[i]!=str2[i])
    {
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n";

  return 0;
}

Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct edge{
    ll to,cost;
};
V<V<edge>> graph;
V<V<bool>> used;
V<ll> d1;
int n,m;
void dijkstra(ll s){
    d1.resize(n);
    for(int i=0;i<n;i++)d1[i]=inf;//訪れていない頂点をinfで初期化
    d1[s]=0;
    priority_queue<P,vector<P>,greater<P>> q;
    q.push(P(0,s));//始点を０で置く
    while(!q.empty()){
        P a=q.top();
        q.pop();
        if(d1[a.se]<a.fi)continue;
        for(int i=0;i<graph[a.se].size();i++){
            edge e=graph[a.se][i];
            if(d1[e.to]>d1[a.se]+e.cost){
                d1[e.to]=d1[a.se]+e.cost;//訪れていないorより低いコストの経路を発見した時、値を更新
                q.push(P(d1[e.to],e.to));//コストの低いところ優先のbfs
            }
        }
    }
     q.push(P(0,s));
    while(!q.empty()){//経路復元
        P a=q.top();
        q.pop();
        if(d1[a.se]<a.fi)continue;
        for(int i=0;i<graph[a.se].size();i++){
            edge e=graph[a.se][i];
            if(d1[e.to]==d1[a.se]+e.cost){
                used[a.se][e.to]=false;
                used[e.to][a.se]=false;
                q.push(P(d1[e.to],e.to));
            }
        }
    }
    return;
}
int main(){
cin>>n>>m;
used.assign(n,V<bool>(n,false));
graph.resize(n);
for(int i=0;i<m;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    graph[a].push_back(edge{b,c});
    graph[b].push_back(edge{a,c});
    used[a][b]=true;
    used[b][a]=true;
}
int ans=0;
for(int i=0;i<n;i++)dijkstra(i);
for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++)if(used[i][j])ans++;
}
cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {

    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    vector<int> ans(N);

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int new_v : G[v]) {
            if (dist[new_v] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 new_v について距離情報を更新してキューに追加する
            dist[new_v] = dist[v] + 1;
            que.push(new_v);
            ans[new_v] = v;
        }
    }

    cout << "Yes" << endl;
    for (int v = 1; v < N; ++v) cout << ans[v] + 1 << endl;
    return 0;
}

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

void Main()
{
    int n, m;
    cin >> n >> m;
    int a[n];
    int sum = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a+n);
    int count = 0;
    for(int i = 0; i < m; ++i){
        if(a[n-1-i] * 4 * m >= sum){
            count++;
        }
    }
    if(count == m){
       cout << "Yes" << endl;
    }else{
       cout << "No" << endl;
    }
    return;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 256
#define f(a,b)F[a+b]*I[a]%M*I[b]%M
struct T{int a,b;}A[3333];long P[3333],M=1e9+7,F[2<<17],I[2<<17];i,j,k;
c(a,b)struct T*a,*b;{*F=a->a-b->a?:a->b-b->b;}
p(a,b){return b?p(a%M*a%M,b/2)%M*(b%2?a:1)%M:1;}
main(y)
{
	for(*F=*I=1;++k<2<<17;)I[k]=p(F[k]=F[k-1]*k%M,M-2);
	for(k=A;~scanf("%d",k);k+=4)i++-1||gets(P);
	for(qsort(A,i/=2,8,c);j<i;j++)
		for(P[k=j]=f(A[j].a-1,A[j].b-1);k--;)(y=A[j].b-A[k].b)>=0?P[j]=(P[j]-f(A[j].a-A[k].a,y)*P[k]%M+M)%M:0;
	printf("%d",P[i-1]);
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[50];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    bool ans = false;
    bool f = true;
    for(int i = 0; i < n; i++) {
        if(a[i] != i + 1) {
            f = false;
            break;
        }
    }
    if(f) {
        cout << "YES" << endl;
        return 0;
    }

    for(int i = 0; i < n - 1; i++) {
        for(int j = i + 1; j < n; j++) {
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;

            bool flag = true;
            for(int i = 0; i < n; i++) {
                if(a[i] != i + 1) {
                    flag = false;
                    break;
                }
            }
            if(flag) {
                ans = true;
                break;
            }
            tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        if(ans) break;
    }

    cout << (ans? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
	int a,b,c;

	int i,num= 0;
	scanf("%d %d %d", &a, &b, &c);

	for(i=a;i <= b;i++){

		if(c % i == 0){
			num++;
		}
	}
    printf("%d\n",num);

	return 0;
}

Measured memory_bytes: 596
n = gets.split.map(&:to_i)
  ans = 0
if n[1] > 0
  for i in 2..n[0]
    ans += n[1] + i - 1
  end
elsif n[1]+n[0]-1 < 0
  for i in 1..n[0]-1
    ans += n[1] + i - 1
  end
else
  for i in 1..n[0]
    ans += n[1] + i - 1
  end
end
puts ans


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N;
    int a,b,c;
    ll dpa[N], dpb[N], dpc[N];
    rep(i,N){
        cin>>a>>b>>c;
        if(i == 0) {
            dpa[0] = a;
            dpb[0] = b;
            dpc[0] = c;
            continue;
        }
        dpa[i] = a + max(dpb[i-1],dpc[i-1]);
        dpb[i] = b + max(dpa[i-1],dpc[i-1]);
        dpc[i] = c + max(dpb[i-1],dpa[i-1]);
    }
    ll ans = max(dpa[N-1],dpb[N-1]);
    ans = max(ans,dpc[N-1]);
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
N, X, Y = map(int, input().split())
ans = [0] * N

for i in range(N):
  for j in range(i+1, N):
    tmp = min(j-i, abs(X-1-i) + 1 + abs(Y-1-j))
    ans[tmp] += 1

for k in range(1,N):
  print(ans[k])

Measured memory_bytes: 3444
#include <cassert>// c
#include <ctime>
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>

using namespace std;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define FOR(i,l,r) for(int i=(int)l;i<(int)r;++i)
#define REP(i,n) FOR(i,0,n)
#define FORr(i,l,r) for(int i=(int)r-1;i>=(int)l;--i)
#define REPr(i,n) FORr(i,0,n)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
//debug
#define DUMP(x)  cerr << #x << " = " << (x)
#define LINE()    cerr<< " (L" << __LINE__ << ")"

template<typename T,typename U> T pmod(T x,U M){return (x%M+M)%M;}

stringstream ss;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	ss   <<fixed <<setprecision(20);
	cout <<fixed <<setprecision(20);
	cerr <<fixed <<setprecision(20);

	while(true){
	    int n;cin >> n;if(n==0)break;
	    vector<int> bs(10);
	    REP(i,n){
		int v;cin >> v;
		bs[min(v/10,6)]++;
	    }
	    REP(i,7)cout << bs[i] <<endl;
	}

 	return 0;
 }

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int value = s;
		List<Integer> list = new ArrayList<>();
		list.add(s);
		int ans = 1;
		boolean flag = false;
		while(!flag) {
			ans++;
			if(value % 2 == 0) {
				value /= 2;
			} else {
				value = value * 3 + 1;
			}
			for(Integer i : list) {
				if(i == value) {
					flag = true;
				}
			}
			list.add(value);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22996
#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, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_067
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] array = ReadLongs();
            long[] sums = new long[n];
            sums[0] = array[0];
            for(int i = 1; i < n; i++)
            {
                sums[i] = sums[i - 1] + array[i];
            }

            long allSum = sums[n - 1];
            long min = long.MaxValue;
            for (int i = 0; i < n - 1; i++)
            {
                long val = Math.Abs(allSum - sums[i] * 2);
                if (val < min)
                {
                    min = val;
                }
            }
            Console.WriteLine(min);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

int main(){
  vector <vector <char>> a(3, vector<char>(3));
 
  for(int i=0; i<a.size(); i++){
    for(int j=0; j<a.size(); j++){
      cin >> a.at(i).at(j);
    }
  }
  
  
  for(int i=0; i<a.size(); i++){
    cout << a.at(i).at(i);
  }
  cout << endl;
  

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);

		int a[] = new int[5];

		for (int i = 0; i < a.length; i++) {
			a[i] = input.nextInt();

			if (a[i] == 0) {
				System.out.println(i + 1);
				break;
			}

		}

	}

}


Measured memory_bytes: 35580
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a=0;
  string b;
  cin>>a;
  while(1){
    cin>>b;
    if(b=="=") break;
    int x;
    cin>>x;
    if(b=="+") a+=x;
    else if(b=="-") a-=x;
    else if(b=="/") a/=x;
    else if(b=="*") a*=x;
  }
  cout<<a<<endl;
  return 0;
}



Measured memory_bytes: 3076
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int head = 0;
        int foot = 0;
        int yoyaku = 0;
        for (int i = 0; i < N; i++) {
            if (S.charAt(i) == '(') {
                yoyaku++;
            } else {
                if (yoyaku > 0) {
                    yoyaku--;
                } else {
                    head++;
                }
            }
        }
        yoyaku = 0;
        for (int i = N - 1; i >= 0; i--) {
            if (S.charAt(i) == '(') {
                if (yoyaku > 0) {
                    yoyaku--;
                } else {
                    foot++;
                }
            } else {
                yoyaku++;
            }
        }
        for (int i = 0; i < head; i++) {
            S = '(' + S;
        }
        for (int i = 0; i < foot; i++) {
            S = S + ')';
        }
        System.out.println(S);
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll d, t, s;
    cin >> d >> t >> s;
    
    if (d <= s*t) {
        mes("Yes");
        re0;
    }
    mes("No");
    
    
    
        
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3632
#[allow(dead_code)]
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()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<usize>();
    let n = v[0];
    let m = v[1];
    let mut xs = read_vec::<i32>();
    if n >= m {
        println!("0");
        return;
    }
    xs.sort();
    let mut diffs = vec![0i32; m-1];
    for i in 0..m-1 {
        diffs[i] = xs[i+1] - xs[i];
    }
    diffs.sort();
    for _ in 0..(n-1) {
        let _ = diffs.pop().unwrap();
    }
    let ans = diffs.iter().sum::<i32>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
from typing import List
import sys

input = lambda: sys.stdin.readline().rstrip()
n = int(input())
c = list(map(int, input().split()))
c = [x-1 for x in c]
# print(c)
adj = [[] for i in range(n)]
for i in range(n-1):
    a, b = tuple(map(int, input().split()))
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)


size: List[int] = [1 for i in range(n)]
stack: List[List[int]] = [[] for color in range(n)]
in_time: List[int] = [-1 for i in range(n)]
out_time: List[int] = [-1 for i in range(n)]
timer = 0
total = n*(n+1)//2
ans: List[int] = [total for color in range(n)]
# print(ans)


def dfs(parent: int, root: int):
    global timer
    in_time[root] = timer
    timer += 1

    for child in adj[root]:
        if parent == child:
            continue
        dfs(root, child)
        size[root] += size[child]

        cnt = size[child]
        while stack[c[root]]:
            x = stack[c[root]][-1]
            if in_time[x] > in_time[root] and out_time[x] != -1:
                cnt -= size[x]
                stack[c[root]].pop()
            else:
                break
        ans[c[root]] -= cnt*(cnt+1)//2

    out_time[root] = timer
    timer += 1

    stack[c[root]].append(root)


sys.setrecursionlimit(10**6)

dfs(0, 0)
# print(size)
for color in range(n):
    cnt = n
    while len(stack[color]) > 0:
        x = stack[color][-1]
        cnt -= size[x]
        stack[color].pop()
    # print("node:", -1, "color:", color, "cnt:", cnt)
    ans[color] -= cnt*(cnt+1)//2
    print(ans[color])


Measured memory_bytes: 400768
N = int(input())
*A, = map(int, input().split())

ave = 0
for i in range(len(A)):
    ave = ave + A[i]
ave = ave / N

min = float("inf")
for i in range(len(A)):
    temp = abs(A[i]-ave)

    if min> temp:
        min = temp
        ans = i
print(ans)

Measured memory_bytes: 3064
n = int(input())
a = [int(input()) for _ in range(n)]

cur = 1
c = 0
while True:
    c += 1
    cur = a[cur - 1]
    if cur == 2:
        print(c)
        break
    elif c >= 10 ** 5 + 2:
        print(-1)
        break


Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll K;
string S;
int main(void){
	cin >> S >> K;
	for(int i=0; i<S.size(); i++){
		if(S[i] != '1'){
			cout << S[i] << endl;
			return 0;
		}else if(S[i] == '1' && i == K-1){
			cout << '1' << endl;
			return 0;
		}else if(i == S.size()-1){
			cout << '1' << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 384