akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
template <typename T>
class SegmentTreeUpdMax {
    int n;
    const T inf_min = std::numeric_limits<T>::min();
    std::vector<T> node;
public:
    SegmentTreeUpdMax(std::vector<T> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n, inf_min);
        for(int i=0;i<sz;++i) node[i+n-1] = v[i];
        for(int i=n-2;i>=0;--i) node[i] = std::max(node[2*i+1], node[2*i+2]);
    }
    void update(int idx, T val) {
        assert(0 <= idx && idx < n);
        node[idx + n - 1] = val;
        idx = idx + n - 1;
        while(idx > 0) {
            idx = (idx - 1) / 2;
            node[idx] = std::max(node[2*idx + 1], node[2 * idx + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return inf_min;
        if(a <= l && r <= b) return node[k];
        T vl = query(a, b, k*2+1, l, ((l+r)/2));
        T vr = query(a, b, k*2+2, (l+r)/2, r);
        return std::max(vl, vr);
    }
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<P> v(n);
  vll a(n);
  for(int i=0;i<n;++i) {
    cin >> v[i].first;
    v[i].second = i;
  }
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  sort(v.begin(), v.end());
  vll init(n, 0);
  SegmentTreeUpdMax<ll> st(init);
  for(int i=0;i<n;++i) {
    int now = v[i].second;
    ll val = st.query(0, now+1);
    st.update(now, val + a[now]);
  }
  cout << st.query(0, n) << endl;
}


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

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

  long long X;
  cin >> X;
  vector<long long> vec;
  int x = -750;
  for(int i = 0; i < 1501; i++){
    long long tmp = pow(x, 5);
    vec.push_back(tmp);
    x++;
  }
  for(int i = 0; i < 1501; i++){
    for(int j = 0; j < 1501; j++){
      if(vec[i] - vec[j] == X){
        cout << i - 750 << " " << j - 750 <<endl;
        return 0;
      }
    }
  }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, K; cin >> N >> K;
    vector<i64> A(N);
    vector<i64> F(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> F[i];

    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());

    i64 ub = 1e12;
    i64 lb = -1;
    while (ub - lb > 1) {
        i64 mid = (lb + ub) / 2;

        i64 s = 0;
        REP(i, N) {
            if (A[i] * F[i] <= mid) continue;
            s += A[i] - mid / F[i];
        }
        if (s <= K) {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    cout << ub << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <cstring>
#include <algorithm>

template <typename Tp>Tp Max(const Tp &a, const Tp &b) {return a > b ? a : b;}
template <typename Tp>Tp Min(const Tp &a, const Tp &b) {return a < b ? a : b;}

template <typename Tp>void Read(Tp &x) {
    Tp in = 0, f = 1; char ch = getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f = -1; ch = getchar();}
    while(ch>='0' && ch<='9') {in = in * 10 + ch - '0'; ch = getchar();}
    x = in * f;
}

typedef long long LL;

const int SN = 524288;

const int MOD = 924844033;

const int phi = MOD - 1;

const int g = 5;

LL A[SN], B[SN], jie[SN], inv_jie[SN], Ans[SN];

int size[SN], head[SN], rev[SN], LG, m, num, n;

struct Edge {
    int v, next;
}E[SN];

void Add_E(int u, int v) {
    E[++num].v = v, E[num].next = head[u], head[u] = num;
    E[++num].v = u, E[num].next = head[v], head[v] = num;
}

void Dfs(int u, int fa) {

    size[u] = 1;

    for(int i = head[u]; i; i = E[i].next) {
	int to = E[i].v;
	if(to == fa) continue ;
	Dfs(to, u);
	size[u] += size[to];
    }	
        
}

LL ksm(LL a, LL b) {
    LL ans = 1, B = a;
    while(b) {
	if(b & 1) ans = (ans * B) % MOD;
	B = (B * B) % MOD;
	b >>= 1;
    }
    return ans;
}

void NTT(LL *f, int n, int d) {

    for(int i = 1; i < n; i++)
	if(rev[i] > i) std :: swap(f[rev[i]], f[i]);

    for(int i = 1; i < n; i <<= 1) {
	LL w = ksm(g, phi / (i << 1));
	if(d == -1) w = ksm(w, MOD - 2);
	for(int j = 0; j < n; j += (i << 1)) {
	    LL wn = 1;
	    for(int k = 0; k < i; k++, wn = (wn * w) % MOD) {
		LL u = f[j + k], v = (f[j + k + i] * wn) % MOD;
		f[j + k] = (u + v) % MOD, f[j + k + i] = (u - v + MOD) % MOD;
	    }
	}
    }
    
    if(d == -1) {
	LL inv = ksm(n, MOD - 2);
	for(int i = 0; i < n; i++)
	    f[i] = (f[i] * inv) % MOD;
    }
}

LL C(LL n, LL m) {
    if(n < m) return 0;
    return jie[n] * inv_jie[m] % MOD * inv_jie[n - m] % MOD;
}

int main() {

    int x, y;
    
    Read(n);

    for(int i = 1; i < n; i++) Read(x), Read(y), Add_E(x, y);

    Dfs(1, 0);

    for(int i = 1; i <= n; i++) B[size[i]]++, B[n - size[i]]++;

    B[0] = 0, jie[0] = 1;

    for(int i = 1; i <= n; i++) jie[i] = (jie[i - 1] * i) % MOD;

    inv_jie[n] = ksm(jie[n], MOD - 2);

    for(int i = n - 1; i >= 0; i--)
	inv_jie[i] = (inv_jie[i + 1] * (i + 1)) % MOD;

    for(int i = 0; i <= n; i++)
	A[i] = inv_jie[n - i], B[i] = B[i] * jie[i] % MOD;

    for(m = 1; m <= (n + n); m <<= 1) LG++;

    for(int i = 1; i < m; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (LG - 1));
    
    NTT(A, m, 1), NTT(B, m, 1);

    for(int i = 0; i < m; i++) A[i] = (A[i] * B[i]) % MOD;

    NTT(A, m, -1);

    for(int i = 1; i <= n; i++) Ans[i] = A[i + n];
    
    for(int i = 1; i <= n; i++) Ans[i] = (Ans[i] * inv_jie[i]) % MOD;

    for(int i = 1; i <= n; i++) Ans[i] = (n * C(n, i) % MOD - Ans[i] + MOD) % MOD;
    
    for(int i = 1; i <= n; i++) printf("%lld\n", (Ans[i] + C(n, i)) % MOD); 

    return 0;
}

Measured memory_bytes: 34560
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.function.IntToDoubleFunction;
 
/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int num = scanner.nextInt();
        List<Double> values = new ArrayList<Double>();
        for (int i = 0 ; i < num ; i++) {
            values.add(scanner.nextDouble());
        }
        Collections.sort(values);
        Double ans = values.stream().reduce(values.get(0), (val, elm) -> (val + elm)/2);
        System.out.println(ans);
    
        
    }
}

Measured memory_bytes: 30036
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    System.out.println(Math.max(a*b,c*d));
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<cassert>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define all(n) (n).begin(),(n).end()
#define inf (1<<29)

using namespace std;
typedef pair<int,int> ii;

struct P
{
  ii time;
  bool dir;//0->上, 1->下
  P(ii time=ii(inf,inf),bool dir=false):time(time),dir(dir){}
};

int ans;
int n;

void compute(vector<vector<P> > &record,ii person)
{
  //cout << "\nperson : " << person.first << "," << person.second << endl;
  int cur = 0;
  record.push_back(vector<P>());


  rep(i,person.second*2)
    {
      bool dir = i % 2;//0->上,1->下
      int next = cur + person.first;

      //cout << "chech---------- : " << i << " | " << record.size() << endl;
      rep(j,record.size()-1)
	{
	  rep(k,record[j].size())
	    {
	      P p = record[j][k];
	      //cout << "ch(" << p.time.first << "," << p.time.second <<") dir : " <<  (dir?"↓":"↑") << "\n";
	      //if(p.time.second < cur)break;
	      if(p.dir != dir)continue;
	      if(p.time.first > cur)break;

	      if(p.time.second == next || p.time.first == cur)
		{
		  break;		  
		}
	      else if(p.time.first < next && next < p.time.second)
		{
		  next = max(p.time.second,next);
		  break;
			     //goto Skip;
		}
	    }
	}
	  //Skip:;
      //cout << "result (" << cur << "," << next << ") : " << (dir?"↓":"↑") << endl;
      record[record.size()-1].push_back(P(ii(cur,next),dir));
      cur = next;
      ans = max(ans,next);
    } 
}

int main()
{
  while(scanf("%d",&n),n)
    {
      ans = 0;
      vector<ii> info(n);
      rep(i,n)scanf("%d %d",&info[i].first,&info[i].second);
      sort(all(info),greater<ii>());

      vector<vector<P> > record;

      rep(i,n)compute(record,info[i]);

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

    }
  return 0;
}

Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n, m, b[100], a[100][100], c[100] = {};
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      c[i] += a[i][j] * b[j];
    }
  }
  for(int i = 0; i < n; i++){
    cout << c[i] << endl;
  }
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=200010;
const int mod=1000000007;
vector<int> g[maxn];
int p[maxn],inv2,son[maxn],f[maxn][3],ff[maxn][3],lv[maxn],dep[maxn];
deque<int> dp[maxn][2];
inline int qpow(int x,int y){
	int ret=1;
	while(y){
		if(y&1) ret=(ll)ret*x%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return ret;
}
inline int get_inv(int x){
	return qpow(x,mod-2);
}
void dfs(int u){
	son[u]=-1;
	lv[dep[u]]++;
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		dep[v]=dep[u]+1;
		dfs(v);
		if(son[u]==-1 || dp[v][0].size()>dp[son[u]][0].size())
			son[u]=v;
	}
	if(son[u]!=-1) dp[u][0].swap(dp[son[u]][0]),dp[u][1].swap(dp[son[u]][1]);
	dp[u][1].push_front(inv2);
	dp[u][0].push_front(inv2);
	int maxd=-1;
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		if(v==son[u]) continue;
		maxd=max(maxd,(int)dp[v][0].size());
	}
	if(maxd==-1) return;
	for(int d=1;d<=maxd;d++){
		f[d][0]=dp[u][0][d];
		f[d][1]=dp[u][1][d];
		f[d][2]=0;
	}
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		if(v==son[u]) continue;
		for(int d=1;d<=min(maxd,(int)dp[v][0].size());d++){
			ff[d][0]=ff[d][1]=ff[d][2]=0;
			for(int s=0;s<3;s++){
				for(int ss=0;ss<2;ss++)
					ff[d][min(s+ss,2)]=(ff[d][min(s+ss,2)]+(ll)f[d][s]*dp[v][ss][d-1])%mod;
			}
			f[d][0]=ff[d][0],f[d][1]=ff[d][1],f[d][2]=ff[d][2];
		}
	}
	for(int d=1;d<=maxd;d++)
		dp[u][0][d]=(f[d][0]+f[d][2])%mod,dp[u][1][d]=f[d][1];
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",p+i);
		g[p[i]].push_back(i);
	}
	inv2=get_inv(2);
	dfs(0);
	int ans=0,m=qpow(2,n+1);
	for(int i=0;i<(int)dp[0][1].size();i++){
		ans=(ans+(ll)dp[0][1][i]*m)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int n; cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
    return 0;
  } else {
    int a, b; cin >> a >> b;
    cout << a + b << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    string words[] = {"dream", "dreamer", "erase", "eraser"};
    for (int i = 0; i < 4; i++) {
        reverse(words[i].begin(), words[i].end());
    }

    bool flag = true;
    while (flag) {
        flag = false;
        for (int i = 0; i < 4; ++i) {
            if (s.substr(0, words[i].length()) == words[i]) {
                flag = true;
                s = s.substr(words[i].length());
                if (s.empty()) {
                    cout << "YES" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}


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

public class Hello
{
    public static void Main()
    {
        int[] num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        if(num[0] > num[1])
        {
            Console.WriteLine("a > b");
        }
        else if(num[0] < num[1])
        {
            Console.WriteLine("a < b");
        }
        else
        {
            Console.WriteLine("a == b");
        }
    }
}

Measured memory_bytes: 9440
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N;
  in(N);
  vector<long>H(N);
  ins(H);
  long base=H[0];
  up(i,1,N-1){
    if(H[i]>base)base=H[i];
    if(base-H[i]>1){
      out("No");
      return;
    }
  }
  out("Yes");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1024
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <random>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))

#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;
using ull = __uint128_t;

using sc = signed char;
using si = signed int;
using sl = signed long long int;
using sll = __int128_t;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

namespace std {
  template <>
  struct is_integral<__int128_t> {
    constexpr static bool value = true;
  };
};

static sl K, N;
static vector<sl> Ai;

void solve(void) {
  vector<sl> Bi(N);
  sl min_dist = K + 1;
  FOR0(i, N) {
    Bi[i] = K - (Ai[i + 1] - Ai[i]);
  }
  FOR0(i, N) {
    min_dist = min(Bi[i], min_dist);
  }
  cout << min_dist << endl;
}

int main(void) {
  cin >> K >> N;
  Ai.resize(N + 1);
  FOR0(i, N) {
    cin >> Ai[i];
  }
  Ai[N] = Ai[0] + K; // sentinel
  solve();
  return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    private static long solve(long K, long A, long B) {
        if (B <= (A + 2)) {
            return 1 + K;
        }

        long rest = K - (A + 1);
        if (rest < 0) {
            return 1 + K;
        }

        long ex = rest / 2;
        long m = rest % 2;

        return ex * (B - A) + B + m;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long K = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        System.out.println(solve(K, A, B));
    }
}


Measured memory_bytes: 23252
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

using lint = long long;

int main(){
    lint a,b;
    scanf("%lld%lld",&a,&b);
    if(a==0 || b==0){
        puts("Zero");
    }
    else{
        if(0<a){
            puts("Positive");
        }
        else if(b<0){
            lint d = b - a + 1;
            if(d&1LL){
                puts("Negative");
            }
            else{
                puts("Positive");    
            }
        }
        else{
            puts("Zero");
        }
    }
    return 0;
}

Measured memory_bytes: 128
//コード整形版
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

int n, l[2020];

int main(){
  cin >> n;
  rep(i, n) cin >> l[i];
  sort(l, l + n);
  int sum = 0;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      auto sentou = l + j + 1;
      auto ub = upper_bound(sentou, l + n, l[i] + l[j] - 1);
      int num = ub - sentou;
      sum += num;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int q = scan.nextInt();
		
		double x0, y0, x1, y1, x2, y2, x3, y3, s1, s2;
		
		for(int i = 0; i < q; i++) {
			x0 = scan.nextDouble();
			y0 = scan.nextDouble();
			x1 = scan.nextDouble();
			y1 = scan.nextDouble();
			x2 = scan.nextDouble();
			y2 = scan.nextDouble();
			x3 = scan.nextDouble();
			y3 = scan.nextDouble();
			
			s1 = ((x3 - x2) * (y0 - y2) - (y3 - y2) * (x0 - x2)) / 2;
			s2 = ((x3 - x2) * (y2 - y1) - (y3 - y2) * (x2 - x1)) / 2;
			
			System.out.print(x0 + (x1 - x0) * s1 / (s1 + s2));
			System.out.print(" ");
			System.out.println(y0 + (y1 - y0) * s1 / (s1 + s2));
		}
		
		scan.close();
	}
}

Measured memory_bytes: 57452
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void){
	long long X,N;
	int i;
	char str[10000000],buf[10000000];
 
	fgets(str, sizeof(str), stdin);
	X=strtoll(strtok(str," "),buf,10);

	N=100;i=0;
	while(1){
		if(N>=X) break;
		i++;
		N=N*1.01;
	}

	printf("%ld\n",i);

	return 0;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

string s, t;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s >> t;
	int mindif = 1e9;
	for (int i = 0; i < s.size() - t.size() + 1; i++)
	{
		string ssub(s.begin() + i, s.begin() + i + t.size());
		cerr << ssub << '\n';
		int dif = 0;
		for (int k = 0; k < ssub.size(); k++)
		{
			if (ssub[k] != t[k])
				dif++;
		}
		mindif = min(mindif, dif);
	}
	cout << mindif << '\n';
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int a;
	cin >> a;
	ll ans = 1;
	rep(i, a) {
		ans *= (i+1);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <iostream>
#include<stack>
using namespace std;
const int MAXn=100;

int n,M[MAXn][MAXn]={0},nt[MAXn],col[MAXn];//color:0=white,1=gray,2=brack
int d[MAXn],f[MAXn],t;

int next(int u)
{
	for(int v=nt[u];v<n;v++)
	{
		nt[u]=v+1;
		if(M[u][v])return v;
	}
	return -1;
}

void dfs_visit(int u)
{
	stack<int> S;
	S.push(u);
	col[u]=1;
	d[u]=++t;
	while(!S.empty())
	{
		int v=S.top();
		int r=next(v);
		if(r!=-1)
		{
			if(col[r]==0)
			{
				col[r]=1;
				d[r]=++t;
				S.push(r);
			}
		}
		else
		{
			S.pop();
			col[v]=2;
			f[v]=++t;
		}
	}
	return;
}

void dfs()
{
	int u;
	for(u=0;u<n;u++)
	{
		col[u]=0;
		nt[u]=0;
	}
	t=0;
	
	for(u=0;u<n;u++)if(col[u]==0)dfs_visit(u);
	
	for(u=0;u<n;u++)cout<<u+1<<" "<<d[u]<<" "<<f[u]<<endl;
	
	return;
}

int main() {
	cin>>n;
	int id,k,v;
	for(int i=0;i<n;i++)
	{
		cin>>id>>k;
		id--;
		for(int j=0;j<k;j++)
		{
			cin>>v;
			M[id][--v]=1;
		}
	}
	dfs();
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mk make_pair
#define N 5010
#define M 210
int n, m, b[N][M], L[N], R[N];
ll a[N], f[N][N], ans = 0;
pii stk[N]; int top;
inline void init() {
	for (int j = 1; j <= m; ++ j) {
		top = 0;
		for (int i = 1; i <= n; ++ i) {
			while (top > 0 && b[i][j] > stk[top].fi) {
				-- top;
			}
			if (top > 0) L[i] = stk[top].se + 1;
			else L[i] = 1;
			stk[++ top] = mk(b[i][j], i);
		}
		top = 0;
		for (int i = n; i >= 1; -- i) {
			while (top > 0 && b[i][j] > stk[top].fi) {
				-- top;
			}
			if (top > 0) R[i] = stk[top].se - 1;
			else R[i] = n;
			stk[++ top] = mk(b[i][j], i);
		}
		for (int i = 1; i <= n; ++ i) {
			// x : [L, i] , y : [i, R]
//			printf("i = %d, L %d, R %d\n", i, L[i], R[i]);
//			for (int x = L[i]; x <= i; ++ x)
//				for (int y = i; y <= R[i]; ++ y) f[x][y] += b[i][j];
			f[L[i]][i] += b[i][j];
			f[i + 1][R[i] + 1] += b[i][j];
			f[L[i]][R[i] + 1] -= b[i][j];
			f[i + 1][i] -= b[i][j];
		}
	}
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= n; ++ j) f[i][j] += f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
}
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i < n; ++ i) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= m; ++ j) {
			cin >> b[i][j];
		}
	init();
	for (int l = 1; l <= n; ++ l)
		for (int r = l; r <= n; ++ r) {
			ans = max(ans, f[l][r] - (a[r] - a[l]));
//			printf("f[%d][%d] = %lld, dist = %lld\n", l, r, f[l][r], a[r] - a[l]);
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 200576
N, M = list(map(int, input().split()))

A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(key = lambda x: x[1], reverse = True)
cnt = 0
for b, c in BC:
  for i in range(b):
    if A[cnt] < c:
      A[cnt] = c
      cnt += 1
      if cnt >= N:
        break
    else:
      break
  if cnt >= N:
    break

print(sum(A))

Measured memory_bytes: 32964
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll flag = 0;
    while(a > 0 or c > 0){
        if(flag%2==0){
            c -= b;
        }else{
            a -= d;
        }
        flag++;
    }
    if(flag%2==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3628
# パナソニック2020E

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))



a,b,c = [input() for _ in range(3)]
la, lb, lc = len(a), len(b), len(c)

def ok(c1,c2):
    return True if c1==c2 or c1=="?" or c2=="?" else False
def sub(s,t,gap=0):
    # tを固定したとき、
    # sの開始位置座標としてありえるもののset
    S = set(list(range(-len(s)-gap, -len(s)+1)) + list(range(len(t), len(t)+gap+1)))
    i1 = min(len(s), len(t))
    i2 = max(len(s), len(t))
    i3 = len(s)+len(t)
    for i in range(1,i1+1):
        if all((ok(s[-i+ii], t[ii])) for ii in range(i)):
            S.add(i-len(s))
    for i in range(i1, i2):
        if len(s)<len(t) and all((ok(s[ii], t[ii+i-i1]) for ii in range(i1))):
            S.add(i-len(s))
        elif len(t)<len(s) and all(ok(s[i2-i+ii], t[ii]) for ii in range(i1)):
            S.add(i-len(s))
    for i in range(i2, i3):
        if all((ok(s[ii], t[i-i3+ii]) for ii in range(i3-i))):
            S.add(i-len(s))
    return S

ab = sub(a,b, lc)
bc = sub(c,b, la)
ac = sub(a,c, lb)
ans = 10**9
import itertools
for ii, jj in itertools.product(ab, bc):
    if ii - jj in ac:
        val = max(lb, ii+la, jj+lc) - min(0, ii, jj)
        ans = min(ans, val)
print(ans)

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

int main(){

    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    int ans = 2*N;
    rep (i, N){
        if (s.substr(i, N-i) == t.substr(0, N-i)){
            ans -= N-i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;
const int M=110;
char a[M];
int n;
bool check()
{
    n/=2;
    for(int i=0;i<n;i++)
        if(a[i]!=a[i+n])
            return 0;
    return 1;
}
int main()
{
    scanf("%d%s",&n,a);
    if((n&1) || !check())
        puts("No");
    else
        puts("Yes");
    return 0;
}


Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  for i in range(20):
    x=i*1000
    if x>=n:
      return x-n

# main()
print(main())


Measured memory_bytes: 10776
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
typedef long long ll;
using namespace std;
ll INF = 1e16;
int main(){
  ll i,j,k,n,W,V=0ll;
  cin >> n >> W;
  vector<ll>w(n+1),v(n+1);
  for(i=1;i<=n;i++){
    cin >> w[i] >> v[i];
    V+=v[i];
  }
  ll dp[n+1][V+1];
  for(i=0;i<=V;i++)dp[0][i]=INF;
  dp[0][0]=0;
  for(i=1;i<=n;i++){
    for(j=0;j<=V;j++){
      if(j-v[i]<0)dp[i][j]=dp[i-1][j];
      else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
    }
  }
  ll ret = 0;
  for(i=0;i<=V;i++){
    if(dp[n][i]<=W)ret = i;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 79104
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
int main(){
    int N,M;
    scanf("%d %d",&N,&M);
    int ans = N;
    for(int i=0;i<M;i++){
        int num;
        scanf("%d",&num);
        ans -= num;
    }
    if(ans < 0) ans = -1;
    printf("%d",ans);
}


Measured memory_bytes: 1732
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"2 2"# => r#"6"#,
r#"5 15"# => r#"1"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        k: usize, s: usize,
    }
    let mut ans = 0;

    for x in 0..s + 1 {
        if k < x {
            break;
        }
        for y in 0..s - x + 1 {
            if k < y {
                break;
            }

            let z = s - x - y;
            if k < z {
                continue;
            }

            if x + y + z == s {
                ans += 1;
            }
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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

    int i, count, num, flag, ans=0, tmp=1;
    for(i=1; i<N+1; i++) {
        count = 0;
        num = i;
        flag = 1;

        while(flag) {
            if(num%2==0) {
            num /= 2;
            count += 1;
            } else {
                flag = 0;
            }
        }
        if(ans<count) {
            ans = count;
            tmp = i;
            // cout << ans << endl;
        }
    }

    cout << tmp << endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val x, y = sc.nextInt()

  val S = Set(4, 6, 9, 11)

  if (S.contains(x) && S.contains(y)) {
    println("Yes")
  }
  else if (x == 2 || y == 2) {
    println("No")
  }
  else if (!S.contains(x) && !S.contains(y)) {
    println("Yes")
  }
  else {
    println("No")
  }
}


Measured memory_bytes: 27424
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define pb push_back
#define all(c) c.begin(), c.end()

const int MAX_N=5000;

// winner -> loser
vector<int> win[MAX_N+1];
vector<int> lose[MAX_N+1];

vector<int> ord;
int used[MAX_N+1]={0};

// vがordに追加される時点で，
// vから到達可能な全ての頂点は必ずordに追加されている
void tsort(int v){
    used[v]=true;
    for(int i=0; i<win[v].size(); i++){
        if(!used[win[v][i]]) tsort(win[v][i]);
    }
    ord.pb(v);
}

int main(){
    int n;cin>>n;
    int m;cin>>m;
    while(m--){
        int w,l;
        cin>>w>>l;
        win[w].pb(l);
        lose[l].pb(w);
    }
    for(int i=1; i<=n; i++)
        if(!lose[i].size()) tsort(i);

    bool exi=0;
    for(int i=1; i<n; i++){
        bool ok=1;
        ok=find(all(win[ord[i]]), ord[i-1])==win[ord[i]].end();
        // for(int j=0; j<win[ord[i]].size(); j++)
        //     if(win[ord[i]][j]==ord[i-1])ok=false;
        exi|=ok;
    }
    for(int i=0; i<ord.size(); i++){
        cout<<ord[n-i-1]<<endl;
    }
    cout<<exi<<endl;
}

Measured memory_bytes: 2952
#include <bits/stdc++.h>
#define MAX 26
using namespace std;

struct BiNode { int l, r; } bt[MAX];

void visit(int node) {
    cout << " " << node ;
}

void PreOrder(int root)
{
    int p = root;
    if (p != -1) {
        stack<int> s;
        s.push(p);
        while (!s.empty()) {
            p = s.top();
            s.pop();
            visit(p);
            if (bt[p].r != -1)
                s.push(bt[p].r);
            if (bt[p].l != -1)
                s.push(bt[p].l);
        }
    }
}

void InOrder(int root)
{
    int p = root;
    stack<int> s;
    while (p != -1 || !s.empty()) {
        if (p != -1) {
            s.push(p);
            p = bt[p].l;
        }
        else {
            p = s.top();
            s.pop();
            visit(p);
            p = bt[p].r;
        }
    }
}

void PostOrder(int root)
{
    int p = root;
    if (p != -1) {
        stack<int> s1, s2;
        s2.push(p);
        while (!s2.empty()) {
            p = s2.top();
            s2.pop();
            s1.push(p);
            if (bt[p].l != -1)
                s2.push(bt[p].l);
            if (bt[p].r != -1)
                s2.push(bt[p].r);
        }
        while (!s1.empty()) {
            visit(s1.top());
            s1.pop();
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int n, rt, l, r;
    bool notRoot[MAX];
    memset(notRoot, false, sizeof(notRoot));
    cin >> n;
    for (int i = 0; i < n; i++)
        bt[i].l = bt[i].r = -1;
    for (int i = 0; i < n; i++) {
        cin >> rt >> l >> r;
        bt[rt].l = l;
        bt[rt].r = r;
        notRoot[l] = notRoot[r] = true;
    }
    for (int i = 0; i < n; i++) {
        if (!notRoot[i]) {
            rt = i;
            break;
        }
    }
    cout << "Preorder" << endl;
    PreOrder(rt); cout << endl;
    cout << "Inorder" << endl;
    InOrder(rt); cout << endl;
    cout << "Postorder" << endl;
    PostOrder(rt); cout << endl;
    return 0;
}



Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){
    int n = 0;
    int k[101];
    k[0] = -1000;
    cin >> n;
    int max = 0;
    for(int i = 1; i <= n; i++){
        cin >> k[i];
        if(max < k[i]) max = k[i];
    }
    int min = 0;
    for(int i = 1; i <= max; i++){
        int sum = 0;
        for(int j = 1; j <= n; j++){
            sum += (k[j] - i)*(k[j] - i);
        }
        if(i == 1) min = sum;
        if(min > sum) min = sum;
    }
    cout << min << endl;
}

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

int main() {
    string S;
   
    cin >> S;

    int index = 0;
    int answer = 0;
    while(index < S.size() - index -1 ){
        int tailIndex = S.size() - index -1 ;

        if (S[index] != S[tailIndex]){
            answer++;
        }

        index++;
    }


    cout << answer << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace lean {
    class Program {
        static void Main() {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i <5; i++)
            {
                if (a[i] == 0)
                {
                    Console.WriteLine(i+1);
                }
            }
        }
    }
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    vector<ll>v(n+1,0);
    rep(i,0,n){
        cin>>a.at(i);
        v.at(a.at(i))++;
    }
    vector<ll>sum(n+2,0);
    vector<ll>vv(n+1,0);
    rep(i,1,n+1){
        sum.at(i+1)=sum.at(i)+v.at(i)*(v.at(i)-1)/2;
        if(v.at(i)!=0)vv.at(i)=v.at(i)*(v.at(i)-1)/2-(v.at(i)-1)*(v.at(i)-2)/2;
    }
    rep(i,0,n){
        cout<<sum.at(n+1)-vv.at(a.at(i))<<endl;
    }
return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

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

int main(void)
{
        int h,w;
        int dist[10][10];
        int a[210][210];
        cin >> h >> w;
        REP(i,10) REP(j,10) cin >> dist[i][j];
        REP(i,h) REP(j,w) cin >> a[i][j];

        REP(k,10) REP(i,10) REP(j,10)
                dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);

        int sum = 0;
        REP(i,h) REP(j,w){
                if(a[i][j] == -1) continue;
                sum += dist[a[i][j]][1];
        }

        cout << sum << endl;

        return 0;
}

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int i = 0;
    while (i < s.size()) {
        if (s.substr(i, 2) != "hi") {
            cout << "No\n";
            return 0;
        }
        i += 2;
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

vector<ll>relation[20], money(20, 1);

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = (a - b) % c;
	cout << ans << endl;
	return 0;
}

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

int main() {
	int	N;
	cin >> N;
	vector<int> vec(N);
	vector<int> temp(N);
	rep(i, N)
		cin >> vec.at(i);
	temp = vec;
	if (prev_permutation(vec.begin(), vec.end()))
	{
		rep(i, N)		
		{
			if (i)
				cout << ' ';
			cout << vec.at(i);
		}
		cout << endl;
	}
	rep(i, N)
	{
		if (i)
			cout << ' ';
		cout << temp.at(i);
	}
	cout << endl;
	if (next_permutation(temp.begin(), temp.end()))
	{
		rep(i, N)		
		{
			if (i)
				cout << ' ';
			cout << temp.at(i);
		}
		cout << endl;
	}
}



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y;
    cin >> X >> Y;
    ll ans = 1;
    ll d = abs(X - Y);
    ll x = std::min(X, Y) - d;
    ll y = std::max(X, Y) - 2 * d;
    if (x != y)
        ans = 0;
    if (x % 3 != 0)
        ans = 0;

    Combination cmb(3000005);

    ans *= cmb.get(x / 3 + d + x / 3, d + x / 3);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 47232
#include <iostream>
#include <string>
#include <cstdio>

void print_array(int A[], int N) {
  
  for (int i=0; i < N; i++) {
    if (i > 0) printf(" ");

    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N) {

  for (int i=1; i < N; i++) {
    int v = A[i];
    int j = i - 1;
  
    while (j>= 0 and A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
  A[j+1] = v;
  print_array(A, N);
  }
}

int main() {

  int N;
  int A[100];
  scanf("%d", &N);

  for (int i = 0; i < N; i++)
    scanf("%d", &A[i]);

  print_array(A, N);
  insertionSort(A, N);

  return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

int n, k;
int a[100];
ll ans;

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

	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);

	for(int i = 1; i <= min(n, k); i++) {
		ans += a[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
struct Node{
	int x;
	int y;
}b[100000];
ll a[500][500];
vector<int>G[100000];

int main(){
	int h,w,d;
	scanf("%d%d%d",&h,&w,&d);
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			scanf("%d",&a[i][j]);
			b[a[i][j]].x=i;
			b[a[i][j]].y=j;
		}
	}
	
	for (int i=1;i<=d;i++){
		int u=i,dist=0,v;
		G[i].push_back(dist);
		while (u+d<=h*w){
			v=u+d;
			dist+=abs(b[u].x-b[v].x)+abs(b[u].y-b[v].y);
			G[i].push_back(dist);
		//	cout<<dist<<" ";
			u=v;
		}
		//cout<<endl;
	}
	
	
	int q;
	scanf("%d",&q);
	for (int i=1;i<=q;i++){
		int ans=0,l,r;
		scanf("%d%d",&l,&r);
		int s=l%d;
		if (s==0) s=d;
		
		if (s==d) ans=G[s][r/d-1]-G[s][l/d-1];
		else ans=G[s][r/d]-G[s][l/d];
		
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#ifdef IS_MY_ENV
#include <tourist>
#endif
using namespace std;

int x[64];

signed main() {

    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> x[i];
    }
    int cnt = 0;
    for ( int i = 1; i < n-1; i++ ) {
        if ( x[i-1] < x[i] && x[i] < x[i+1] ) cnt++;
        else if ( x[i-1] > x[i] && x[i] > x[i+1] ) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

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

int main(void) {
  string s[3];
  rep(i, 3) {
    cin >> s[i];
  }

  cout << s[0][0] << s[1][1] << s[2][2] << endl;
  
  return 0;
}

Measured memory_bytes: 3612