akhauriyash/Code-Regression huggingface dataset:
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)


MY_NAMESPACE(testbed)
void add_levels(int i, vector<vector<int>> const& addon_of_the_books, vector<int>& levels)
{
	vector<int> const& this_addon = addon_of_the_books[i];
	for (size_t j = 0; j < this_addon.size(); j++)
	{
		levels[j] += this_addon[j];
	}
}

bool above_threshold(int threshold, vector<int> const& levels)
{
	for (size_t j = 0; j < levels.size(); j++)
	{
		if (levels[j] < threshold)
			return false;
	}
	return true;
}

// returns min cost or -1
int dfs(int i, vector<vector<int>> const& addon_of_the_books, vector<int> const& costs, int threshold, vector<int> levels, int current_cost)
{
	if (i == -1)
	{
		if (above_threshold(threshold, levels))
			return current_cost;
		else
			return -1;
	}

	int nonadd_ret = dfs(i - 1, addon_of_the_books, costs, threshold, levels, current_cost);

	add_levels(i, addon_of_the_books, levels);
	int add_ret = dfs(i - 1, addon_of_the_books, costs, threshold, levels, current_cost + costs[i]);

	if (nonadd_ret == -1 && add_ret == -1)
		return -1;
	else if (nonadd_ret == -1)
		return add_ret;
	else if (add_ret == -1)
		return nonadd_ret;
	else
		return min(nonadd_ret, add_ret);
}

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

	vector<int> cost_of_the_books(n);
	vector<vector<int>> addon_of_the_books(n, vector<int>(m));
	for (int i = 0; i < n; i++)
	{
		int c;
		cin >> c;
		cost_of_the_books[i] = c;

		for (int j = 0; j < m; j++)
		{
			int a;
			cin >> a;
			addon_of_the_books[i][j] = a;
		}
	}

	vector<int> levels(m);
	int res = dfs(n - 1, addon_of_the_books, cost_of_the_books, x, levels, 0);
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

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

int cmp(char a,char b)
{
	return a>b;
}
int main()
{
	string s,t;
	cin>>s>>t;
	sort (s.begin(),s.end());
	sort (t.begin(),t.end(),cmp);
	if (s<t)
		cout <<"Yes";
	else
		cout <<"No";
}

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

int main() {
  string s;
  cin >> s;
  int A;
  int Z;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'A') {
      A = i;
      break;
    }
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s.at(i) == 'Z') {
      Z = i;
      break;
    }
  }
  cout << Z - A + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int n, ma, mb, dp[401][401], a[40], b[40], c[40];
int main() {
    cin >> n >> ma >> mb;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (int i = 0; i <= 400; ++i) {
        for (int j = 0; j <= 400; ++j) {
            if (i != 0 || j != 0) dp[i][j] = 1e8;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 400 - a[i]; j >= 0; --j) {
            for (int k = 400 - b[i]; k >= 0; --k) {
                dp[j + a[i]][k + b[i]] = min(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
            }
        }
    }

    int ans = 1e8;
    for (int k = 1; max(k * ma, k * mb) <= 400; ++k) {
        ans = min(ans, dp[k * ma][k * mb]);
    }
    if (ans >= 1e8) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/



int main() {

	int k, x;
	cin >> k >> x;

	for (int i = x-k+1; i <= x+k-1; i++)
	{
		if (i == x - k + 1) {
			cout << i;
		}
		else
		{
			cout << " " << i;
		}
	}
	cout << endl;








	return 0;
}


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

int main() {
  
  	int N,a,b,c,d;
  	cin >> N;
  
  	a=N/1000;
  	b=(N-a*1000)/100;
	c=(N-a*1000-b*100)/10;
  	d=N-a*1000-b*100-c*10;
  
  	int count;
  	if(a==b && a==c && a==d){
    	cout << "Yes" << endl;
    }
  	else{
    	if(!(a==b) && b==c && b==d){
        	cout << "Yes" << endl;
        }
      	else if(a==b && a==c && !(a==d)){
        	cout << "Yes" << endl;
        }
      	else{
        	cout << "No" << endl;
        }
    }  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		StringBuffer sb = new StringBuffer();
		sc.close();
		for(int i = 0; i < S.length(); i++) {
			sb.append('x');
		}
		System.out.println(sb.toString());
	}

}

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

using namespace std;

int k, n;
int h[100010];

int main()
{
	scanf("%d%d", &n, &k);
	
	for (int i = 0 ; i < n ; i++)
		scanf("%d", &(h[i]));
	sort(h, h + n);
	
	int minDiff = -1;
	int curDiff;
	for (int i = 0 ; i <= n - k ; i++)
	{
		curDiff = h[i + k - 1] - h[i];
		
		if ((minDiff == -1) || (curDiff < minDiff))
			minDiff = curDiff;
	}
	
	printf("%d\n", minDiff);
	
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

#define MAX 25
#define NIL -1

typedef struct
{
  int parent;
  int left;
  int right;
}node;

node T[MAX];
int Pre[MAX],In[MAX],Post[MAX],n;

void Print(int u)
{
  static int c=1;
  
  printf(" %d",u);

  if(c < n)
    {
      c++;
    }
  else
    {
      c = 1;
      printf("\n");
    }
  
  return;
}

void Preorder(int u)
{
  if(u == NIL) return;

  Print(u);
  Preorder(T[u].left);
  Preorder(T[u].right);

  return;
}

void Inorder(int u)
{
  if(u == NIL) return;

  Inorder(T[u].left);
  Print(u);
  Inorder(T[u].right);

  
  return;
}

void Postorder(int u)
{
  if(u == NIL) return;

  Postorder(T[u].left);
  Postorder(T[u].right);
  Print(u);

  return;
}

int main()
{
  int i,left,right,root,id;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) //データの初期化
    {
      T[i].parent = NIL;
      T[i].left = NIL;
      T[i].right = NIL;
    }
  
  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&id);

      scanf("%d",&left);
      scanf("%d",&right);

      T[left].parent = T[right].parent = id;
      T[id].left = left;
      T[id].right = right;
    }

  for(i = 0 ; i < n ; i++) //root の探索
    {
      if(T[i].parent == NIL) root = i;
    }

  printf("Preorder\n");
  Preorder(root);
  
  printf("Inorder\n");
  Inorder(root);
  
  printf("Postorder\n");
  Postorder(root);

  
  return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
ll n, m, a, b, c;

int main() {
   cin >> s;
   bool flg = true;
   for (int i = 0; i < s.size(); i++)
   {
	  if (!(i % 2)) {
		 if (s[i] != 'R'&& s[i] != 'U'&& s[i] != 'D')flg = false;
	  }
	  else {
		 if (s[i] != 'L'&& s[i] != 'U'&& s[i] != 'D')flg = false;
	  }
   }
   if (flg)cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
n,l = map(int, input().split())
tastes = [l+i for i,x in enumerate(range(n))]
eated = min([abs(i) for i in tastes]) if min([abs(i) for i in tastes]) >= 0 else -1*min([abs(i) for i in tastes])
if sum(tastes) >= 0:
    print(sum(tastes) - eated)
else:
    print(sum(tastes) + eated)

Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<int> p;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    x--;
    p.pb(x);
  }
  int res = 0;
  int curr = 0;
  for(int i = 0; i < n; i++){
    if(p[i] == i){
      curr++;
    }else{
      res += curr % 2 == 0 ? curr / 2 : curr / 2 + 1;
      curr = 0;
    }
  }
  res += curr % 2 == 0 ? curr / 2 : curr / 2 + 1;
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 892
# n = int(input())
# words = ['a', 'b', 'c', 'd', 'e', 'f','g','h', 'i', 'j']
#
# for i in range(1,n + 1):
#     for j in range():
#
a, b, c = map(int, input().split())
if a + b > c:
    print("No")
    exit()
if 0 < a ** 2 + b ** 2 + c ** 2 - 2 * b * c - 2 * a * c - 2 * a * b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
PAPER_SIZE = 10

Small = [[0, 0], [0, 1], [1, 0], [0, -1], [-1, 0]]
Medium = Small + [[1, 1], [1, -1], [-1, -1], [-1, 1]]
Large = Medium + [[0, 2], [2, 0], [0, -2], [-2, 0]]
Radiuses = [nil, Small, Medium, Large]

paper = PAPER_SIZE.times.map{[0] * PAPER_SIZE}

$<.each_line do |line|
	x, y, size = line.split(',').map(&:to_i)
	Radiuses[size].each do |dx, dy|
		i = x + dx
		j = y + dy
		next if i < 0 or PAPER_SIZE <= i or j < 0 or PAPER_SIZE <= j

		paper[j][i] += 1
	end
end

paper.flatten!
puts paper.count(0)
puts paper.max

Measured memory_bytes: 6120
#include <bits/stdc++.h>
typedef long long ll;
const long long INF = 1LL << 60;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int H, N; cin >> H >> N;
    vector<int> A(N), B(N);
    rep (i, 0, N) cin >> A[i] >> B[i];

    vector<vector<long long>> DP(N+1, vector<long long>(H+1, INF));
    DP[0][0] = 0;
    rep (i, 0, N) {
        rrep (j, 0, H) {  //
            DP[i+1][j] = min(DP[i+1][j], DP[i][j]);
            DP[i+1][min(j+A[i], H)] = min(DP[i+1][min(j+A[i], H)], DP[i+1][j]+B[i]);
        }
    }

    cout << DP[N][H] << endl;
}

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

int n,a[3][3],b[10];
bool appear[3][3];

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

    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		appear[i][j]=false;
    		for(int k=0;k<n;k++){
    			if(a[i][j]==b[k]) appear[i][j]=true;
    		}
    	}
    }

    string ans="No";
    for(int i=0;i<3;i++){
    	if(appear[i][0] and appear[i][1] and appear[i][2]) ans="Yes";
    }
    for(int i=0;i<3;i++){
    	if(appear[0][i] and appear[1][i] and appear[2][i]) ans="Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2]) ans="Yes";
    if(appear[0][2] and appear[1][1] and appear[2][0]) ans="Yes";
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
  string s;
  int i, n, p;

  cin >> s;
  n = s.size();
  p = 0;

  for(i=0;i<n;i++){
    if(s[i]=='p')p++;
  }

  cout << (i/2) - p << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
typedef long long ll;

int main(){
  int n,x;
  cin>>n>>x;
  vector<int>l(n);
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  int sum=0,ans=0;
  for(int i=0;i<n;i++){
    sum+=l[i];
    if(sum<=x){
      ans++;
    }
  }
  cout<<ans+1<<endl;
  return 0;
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
int a[200001];
int b[200001];
int m[200001];

void solve()
{
    int s = 0;
    FORR(i, N, 1){
        int j = i * 2;
        while(j <= N){
            b[i] = (b[i] + b[j]) % 2;
            j += i;
        }
        b[i] = (b[i] + a[i]) % 2;
        if(b[i] == 1) s++;
    }

    cout << s << endl;
    if(s > 0){
        int i = 0;
        while(s > 1){
            if(b[i] == 1){
                s--;
                cout << i << " ";
            }
            i++;
        }
        while(true){
            if(b[i] == 1){
                cout << i << endl;
                break;
            }
            i++;
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 1, N+1) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    return(b%a,a);
}

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}

int main()
{
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    go(i,0,n)
    {
        cin>>a[i];
    }
    ll d=a[0],s=1;
    go(i,1,n)
    {
        if(a[i]>=d)
        {
            s++;
            d=a[i];
        }
    }
    show(s);
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;
cin >> x >> y;
int a = x-y;
int b = x+y;
int c = x*y;
int maxx = INT_MIN;
maxx = max(maxx,a);
maxx = max(maxx,b);
maxx = max(maxx,c);
cout << maxx << endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
map<int, int> cnt;
int main() {
  string s;
  cin >> s;
  if (s == "Sunny")
    cout << "Cloudy";
  else if (s == "Cloudy")
    cout << "Rainy";
  else
    cout << "Sunny";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[16][16],ans,n;
int main(){
  cin >> n;
  for (int i = 0; i < n; i++){
  	int a; cin >> a;
  	for (int j = 0; j < a; j++){
	  	int x,y;
	  	cin >> x >> y;
	  	x--;
		A[i][x] = y+1;
	}
  }
  for (int i = 0; i < (1 << n); i++){
  	int x = __builtin_popcount(i);
  	vector<bool> in(n);
  	for (int j = 0; j < n; j++){
  		if (i & (1 << j))
		  in[j] = 1;				
	}
	bool flag = 1;
	for (int i = 0; i < n; i++){
		if (in[i]){
			for (int j = 0; j < n; j++){
				if ((in[j] & A[i][j] == 1) | (!in[j] & A[i][j] == 2))
				flag = 0;
			}
		}
	}
	if (flag)	ans = max(ans,x); 	
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
x, n = list(map(int, input().split()))
if n == 0:
  inputs = []
else:
  inputs = list(map(int, input().split()))
nums = [0] * 201
diff = 1000
n = 100
for i in inputs:
  nums[i] = 1
for i in range(0, 201):
  d = abs(i - x)
  if nums[i] == 1:
    continue
  if d < diff:
    diff = d
    n = i
print(n)


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

int main(){

long long a,i,x,y,z;

int n;

cin>>n;

x=1000000;
y=-1000000;
z=0;

for(i=0;i<n;i++){

cin>>a;

if(a<x)x=a;
if(a>y)y=a;
z+=a;

}

cout<<x<<" "<<y<<" "<<z<<"\n";

return 0;

}

Measured memory_bytes: 1168
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair

double rou(double d){
  if( abs(d) < 0.0001)
    return 0.0;
  return d;
}

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(3);

  int INF = 1000000;

  int a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f){
    cout << rou((double)(c*e-b*f)/(a*e-b*d)) << " "
	 << rou((double)(c*d-a*f)/(b*d-a*e)) << endl;
  }


  return 0;
}

Measured memory_bytes: 1236
n, a, b, c, d = map(int, input().split())

ans = False
for m in range(n):
    if a + m * c - (n - 1 - m) * d <= b <= a + m * d - (n - 1 - m) * c:
        ans = True
        break

print('YES' if ans else 'NO')


Measured memory_bytes: 39408
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
As, Al = A[:N//2], A[N//2:]
Sum = 0
if N%2 == 0:
    for i in range(N//2 - 1):
        Sum += (Al[i+1] - As[i])*2
    Sum += Al[0] - As[-1]
else:
    S, L = 0, 0
    for i in range(N//2):
        S += (Al[i+1]-As[i])*2
        L += (Al[i+1]-As[i])*2
    L += Al[0]-Al[1]
    S += As[-1] - Al[0]
    Sum = max(L, S)
print(Sum)

Measured memory_bytes: 7764
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;


int main() {
    string s;
    cin >> s;
    std::string buf = s[0] + std::to_string(s.length()-2) + s[s.length() - 1];
    std::cout << buf.c_str() << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                push_back
#define mp              make_pair
#define sz(a)           a.size()
#define mods(a, m)          ((a % m + m) % m)
#define md(a)               mods(a, MOD)
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)     for (int i = b; i < e; i++)
#define forr(i, b, e)     for (int  i = b; i < e; i++)
#define endl '\n'
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;
typedef long double       ld;

typedef pair<int, int>  ii;
typedef pair<int,ii> iii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const int MOD = 1e9+7;
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 1000003 
int main()
{    
    std::ios::sync_with_stdio(false); cin.tie(0);
    string s,t,menos;
    cin>>s>>t;
    map<string,int> m1;
    cin>>m1[s]>>m1[t];
    cin>>menos;
    m1[menos]--;
    cout<<m1[s]<<" "<<m1[t]<<endl;
}   
// PLUS ULTRA!


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

// x番の組織が親組織に提出する枚数を返す
// childrenは組織の関係を表す2次元配列(参照渡し)
int main() {
  int N;
  cin >> N;
  cout << pow(N, 3) << endl;
}




Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
const LL mo1=998244353;
const LL mo2=1e9+7;
const LL Base=20011119;
const int N=1e6;
int len,cnt=0,num[N+10];
char s[N+10];
LL ans;
LL mul(LL x,LL y,LL mo) {
    x%=mo;
    LL z=1;
    while (y) {
        if (y&1) z=z*x%mo;
        y>>=1;
        x=x*x%mo;
    }
    return z;
}
struct data {
    LL h1,h2;
    data operator + (const data &p) {
        data now;
        now.h1=(h1+p.h1)%mo1;
        now.h2=(h2+p.h2)%mo2;
        return now;
    }
    data operator - (const data &p) {
        data now;
        now.h1=((h1-p.h1)%mo1+mo1)%mo1;
        now.h2=((h2-p.h2)%mo2+mo2)%mo2;
        return now;
    }
    data operator * (const data &p) {
        data now;
        now.h1=(h1*p.h1)%mo1;
        now.h2=(h2*p.h2)%mo2;
        return now;
    }
    data operator * (LL x) {
        data now;
        now.h1=(h1*x%mo1+mo1)%mo1;
        now.h2=(h2*x%mo2+mo2)%mo2;
        return now;
    }
    bool operator < (const data &p) const {
        if (h1!=p.h1) return h1<p.h1;
        return h2<p.h2;
    }
}f[N+10],fac[N*2+10],invn;
vector <int> v[N+10];
map <data,int> mp;
data make(LL x,LL y) {
    data now;
    now.h1=x;
    now.h2=y;
    return now;
}
void Pre_Hash() {
    data now=make(0,0);
    int vx=N;
    f[0]=make(0,0);
    fac[0]=make(1,1);
    for (int i=1;i<=N*2;i++) fac[i]=fac[i-1]*Base;
    num[0]=vx;
    for (int i=1;i<=len;i++) {
        if (s[i]=='<') vx--;
        else if (s[i]=='>') vx++;
        else if (s[i]=='+') now=now+fac[vx];
        else now=now-fac[vx];
        num[i]=vx;
        f[i]=now;
        if (mp.find(f[i])==mp.end()) {
            mp[f[i]]=++cnt;
            v[cnt].push_back(i);
        }
        else v[mp[f[i]]].push_back(i);
    }
    invn=make(1,1);
    data invx=make(mul(Base,mo1-2,mo1),mul(Base,mo2-2,mo2));
    for (int i=1;i<=N;i++) invn=invn*invx;
}
void Calc(int x,int loc) {
    int l=0,r=v[loc].size();
    while (l<r) {
        int mid=(l+r)/2;
        if (v[loc][mid]>=x) r=mid;
        else l=mid+1;
    }
    ans+=v[loc].size()-l;
}
void work() {
    for (int i=1;i<=len;i++) {
        data now=f[len];
        now=now*fac[num[i-1]]*invn;
        now=now+f[i-1];
        if (mp.find(now)==mp.end()) continue;
        Calc(i,mp[now]);
    }
}
int main() {
    scanf("%d",&len);
    scanf("%s",s+1);
    Pre_Hash();
    work();
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 87168
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
int i,j,k,l;
static const int MAX_N=10e5;
int A[MAX_N],B[MAX_N+1];
long ans=0;
int main(void){
	int N;
		cin >> N;
	rep(i,0,N+1){
		cin >> B[i];
	}
	rep(i,0,N){
		cin >> A[i];
		if(B[i]>0){
			ans+=min(B[i],A[i]);
			A[i]-=B[i];
		}
		if(A[i]>0){
			if(A[i]>=B[i+1]){
				ans+=B[i+1];B[i+1]=0;
			}else if(A[i]<B[i+1]){
				ans+=A[i];B[i+1]-=A[i];
			}
		}
	}puts(ans);
	
	return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstring>

using namespace std;
typedef long long ll;

int main() {
  int n;

  cin >> n;

  ll sum = 0;
  for(int i = 1; i <= n; i++) {
    if(i % 3 == 0 && i % 5 == 0) {
      continue;
    }
    else if(i % 3 == 0) {
      continue;
    }
    else if(i  % 5 == 0) {
      continue;
    }
    else sum += i;
  }
  cout << sum << endl;
}

  


Measured memory_bytes: 3636
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  if(s=="zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
    return 0;
  }
  bool flag[30];
  int N = s.size();
  fill(flag,flag+30,false);
  rep(i,N){
    flag[int(s[i]-'a')] = true;
  }
  rep(i,26){
    if(!flag[i]){
      cout << s << char('a'+i) << endl;
      return 0;
    }
  }
  vi a;
  rrep(i,N-1){
    int ind = int(s[i]-'a');
    bool ok = false;
    for(auto j:a){
      if(j>ind){
        ok = true; break;
      }
    }
    if(ok){
      // ind より 大きい min of a
      int mi = INF;
      for(auto j:a){
        if(j>ind) mi = min(mi,j);
      }
      cout << s.substr(0,i) << char('a'+mi) << endl;
      return 0;
    }
    a.pb(ind);
  }
  return 0;
}


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

int main(int argc, char const *argv[]) {

  ll n, k;
  ll h[1000000];

  cin >> n;
  cin >> k;
  rep(i, n) { cin >> h[i]; }

  sort(h, h + n, greater<ll>());

  ll dmg = 0;
  for (int i = k; i < n; i++) {
    dmg += h[i];
  }
  cout << dmg;

  return 0;
}


Measured memory_bytes: 3840
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
for i in range(N-2):
    if D[i][0] == D[i][1] and  D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
        print('Yes')
        exit()
print('No')




Measured memory_bytes: 9084
import java.util.*;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int n = sc.nextInt();
    int a[] = new int[n];
    int x = 0;
 
    for(int i=0;i<n;i++){
      a[i] = sc.nextInt();
    }
    int answer1[] = new int[h*w];
    for(int i=0;i<n;i++){
      for(int j=0;j<a[i];j++){
        answer1[x] = i+1;
        x = x + 1;
      }
    }
    x = 0;
    int answer2[][] = new int[h][w];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(i%2==0){
          answer2[i][j] = answer1[x];
          x = x + 1;
        }else{
          answer2[i][w-1-j] = answer1[x];
          x = x + 1;
        }
      }
    }
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          System.out.print(answer2[i][j] + " ");
        }
        System.out.println("");
      }
 
  }
}

Measured memory_bytes: 34016
import fractions
from functools import reduce
N,M= [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
#print(n)
n=sorted(set(n),reverse = True)
bs = n[0]
#print(n)
#c=len(n)
 
 
def lcm_b(a, b):
        #print("base",a,b)
        return (a * b) // fractions.gcd(a, b)
 
def lcm_o():
        global n
        return reduce(lcm_b, n)
 
def chk(v):
        global n
        for i in range(1,30):
                if v%2 == 1:break
                v = v//2
        t=2**(i-1)
        for j in range(len(n)):
                if n[j] % t == 0 and (n[j] / t) % 2 == 1:
                        n[j] = int(n[j]/t)
                else: return 0
        return i-1
 
if len(n) > 1:
        
        c = chk(n[-1])
        
        if  c != 0:
                v = lcm_o()*(2**(c-1))
                
                if v > M:
                        print(0) 
                else:
                        v = M//v
                        if v%2==1: v+=1
                        print(int(v//2))
        
        else: print(0)
elif len(n)==1:
        v = int(bs*0.5)
        v = M//v
        if v%2==1: v+=1
        print(int(v//2))

Measured memory_bytes: 16284
#include <stdio.h>

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printf("%d %d\n", min(a, min(b, c)), max(a, max(b, c)));
	return 0;
}



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

#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define sieve(j,mp) for(ll j=i*i ; j<=mp ; j+=i)
#define pb(x) push_back(x)
#define mp(x,y) push_back(make_pair(x,y))
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t=1;  while(t--)
#define F first
#define S second
int n;
double dp[301][301][301];
double rec(ll a, ll b, ll c)
{
    double sum=a+b+c;
    if(sum==0) return 0;
    if(dp[a][b][c]) return dp[a][b][c];
    double ans=(double)n/sum;
    if(a>0)
        ans+=rec(a-1,b,c)*(a/sum);
    if(b>0)
        ans+=rec(a+1,b-1,c)*(b/sum);
    if(c>0)
        ans+=rec(a,b+1,c-1)*(c/sum);
    return dp[a][b][c]=ans;
}
main()
{
    flash
    clock_t launch=clock();
    test
    {
        ll sc[4]={0},v; cin>>n;
        f(i,n) cin>>v,sc[v]++;
        double pr=rec(sc[1],sc[2],sc[3]);
        cout<<fixed<<setprecision(11)<<pr<<endl;
    }
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    return 0;
}


Measured memory_bytes: 213248
import org.w3c.dom.ls.LSOutput;

import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        int n = sc.nextInt();
        Map<Integer, Integer> a = new HashMap<>();
        for (int i = 0; i < n; i++) {
            a.put(i, sc.nextInt());
        }
        a.entrySet().stream().sorted(
            Map.Entry.comparingByValue()).forEach(
            entry ->  {
                System.out.print(entry.getKey()+1+" ");
            }
        );
    }
}



Measured memory_bytes: 72716
#include <stdio.h>
int main(void){
    /* 変数宣言，ちゃんと初期化しよう */
    int A1 = 0;
    int A2 = 0;
    int A3 = 0;
    int ans = 0;
    /* 変数宣言終わり */
    
    /* 入力を受け付ける部分*/
    
    // %dはdecimalの略．つまり，入力を10進数として扱うよという意味．
    scanf("%d %d %d", &A1, &A2, &A3);
    
    /* 入力を受け付ける部分終わり*/
    
    
    /* 何か処理*/
    ans = A1 + A2 + A3;
    
    if(ans >= 22){
      /* 真の場合の処理 */
      printf("bust");
    }else{
      /* 偽の場合の処理 */
       printf("win");
    }
    
    for(int i = 0; i < 10; i++){ 
      // i = 0,1,2,3,4,5,6,7,8,9のとき処理される
      
    }
    
    /* 何か処理終わり*/
    
    
    /* 出力する部分*/
    
   ; // %dの部分にansの値が表示される
    
    /* 出力する部分*/
    
    
    
    return 0;
}






Measured memory_bytes: 128
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=500005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
template<class T> inline void read(T &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
template<class T> inline void print(T x){
	if(!x){puts("0");return;}
	if(x<0){putchar('-');x=-x;}
	int a[20],m=0;
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');puts("");
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,sum,a[N];
char str[N];

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%s",str+1);n=strlen(str+1);
	for(int i=1;i<=n;i++)
		a[i]=str[i]-'0';
	reverse(a+1,a+n+1);
	for(int i=1,g=0;i<=n||g;i++){
		gmax(n,i);
		a[i]=a[i]*9+g;
		g=a[i]/10;a[i]%=10;
		sum+=a[i];
	}
	for(int ans=1;;ans++){
		a[1]+=9;sum+=9;
		int r=1;
		while(a[r]>=10)
			sum-=10,a[r]-=10,sum++,a[r+1]++,r++;
		if(sum<=ans*9){printf("%d\n",ans);return 0;}
	}
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define inf INT_MAX
using namespace std;

int h, n, dp[40001], a[1001], b[1001], dif, rez = inf;

int main()
{
    cin >> h >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i] >> b[i];
    }
    memset(dp, 63, sizeof(dp));
    dp[h] = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = h; j >= 0; --j)
        {
            dp[max(0, j - a[i])] = min(dp[max(0, j - a[i])], dp[j] + b[i]);
        }
        rez = min(rez, dp[0]);
    }
    cout << rez;
    return 0;
}


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

using namespace std;
#define ll long long int
#define pp pair<ll, pair<ll, ll>>

int main()
{
    ll t;
    t = 1;
    //cin t;
    while (t--)
    {
        ll n, m, s;
        cin >> n >> m >> s;
        s = min(s , (ll)2500);
        vector<pair<ll, pair<ll, ll>>> adj[n + 1];
        for (ll i = 0; i < m; i++)
        {
            ll x, y, a, b;
            cin >> x >> y >> a >> b;
            adj[x].push_back({y, {a, b}});
            adj[y].push_back({x, {a, b}});
        }
        ll coins[n + 1], time[n + 1];
        for (ll i = 1; i <= n; i++)
            cin >> coins[i] >> time[i];
        ll dp[n + 1][2502];
        for (ll i = 1; i <= n; i++)
        {
            for (ll j = 0; j <= 2500; j++)
            {
                dp[i][j] = (ll)10e18;
            }
        }
        priority_queue<pp, vector<pp>, greater<pp>> pq;
        pq.push({0, {s, 1}});
        dp[1][s] = 0;
        while (!pq.empty())
        {
            pp temp = pq.top();
            pq.pop();
            ll cost1 = temp.first;
            ll silver = temp.second.first;
            ll node = temp.second.second;
            if (dp[node][silver] < cost1)
                continue;

            if (silver + coins[node] <= 2500)
            {
                if (dp[node][silver + coins[node]] > dp[node][silver] + time[node])
                {
                    dp[node][silver + coins[node]] = dp[node][silver] + time[node];
                    pq.push({dp[node][silver + coins[node]], {silver + coins[node], node}});
                }
            }
            for (auto x : adj[node])
            {
                ll child = x.first;
                ll expense = x.second.first;
                ll time1 = x.second.second;

                if (silver - expense >= 0)
                {
                    if (dp[child][silver - expense] > dp[node][silver] + time1)
                    {
                        dp[child][silver - expense] = dp[node][silver] + time1;
                        pq.push({dp[child][silver - expense], {silver - expense, child}});
                    }
                }
            }
        }
        for (ll i = 2; i <= n; i++)
        {
            ll res = (ll)10e18;
            for (ll j = 0; j <= 2500; j++)
                res = min(res, dp[i][j]);

            cout << res << endl;
        }
    }
}


Measured memory_bytes: 7276
#include "iostream"
#include "stack"
#include "vector"
#include "algorithm"

using namespace std;

struct Mizu {
	int pos, val;
};

int main() {

	stack<int> s;
	stack<Mizu> each;

	char input[20001];
	int ans = 0;

	cin >> input;

	for (int i = 0; ; i++) {
		if (input[i] == '\\') {
			s.push(i);
		}
		else if (input[i] == '/') {
			if (!s.empty()) {
				ans += i - s.top();

				Mizu biger;
				biger.pos = s.top();
				biger.val = 0;

				while (!each.empty()) {
					if (each.top().pos < s.top()) {
						break;
					}
					Mizu m;
					m = each.top();
					each.pop();

					biger.pos = m.pos;
					biger.val += m.val;
					
				}
				biger.val += i - s.top();
				each.push(biger);
				s.pop();
			}
		}
		else if (input[i] == '_');
		else break;
	}

	cout << ans << endl;

	vector<int> v;

	while (!each.empty()) {
		v.push_back(each.top().val);
		each.pop();
	}

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

	cout << v.size();
	if (v.size() > 0) {
		for (int i = 0; i < v.size(); i++) {
			cout << " " << v[i] ;
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 1304
x,y,s,t;main(v,w){for(scanf("%*d");~scanf("%d%d",&v,&w);v|w||(s=t=!printf("%d %d\n",s,t)))x+=v,y+=w,(x*x+y*y-s*s-t*t)*1e4>s-x?s=x,t=y:0;}

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

int N, Q, A[100005];

int main() {
    scanf("%d %d", &N, &Q);
    for(int i=0, x, y; i<Q; i++) {
        scanf("%d %d", &x, &y);
        A[x]++, A[y]++;
    }
    bool ans = 0;
    for(int i=1; i<=N; i++) ans |= A[i] % 2;
    puts(ans ? "NO" : "YES");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,c,i,ans=-1;
  cin>>n>>c;
  vector<int64_t> x(n+2),v(n+1),rsum(n+1),lsum(n+1),rmax(n+1),lmax(n+1);
  for(i=1;i<=n;i++) cin>>x.at(i)>>v.at(i);
  x.at(n+1)=c;
  for(i=1;i<=n;i++){
    rsum.at(i)=rsum.at(i-1)+v.at(i);
    rmax.at(i)=max(rmax.at(i-1),rsum.at(i)-x.at(i));
    lsum.at(i)=lsum.at(i-1)+v.at(n+1-i);
    lmax.at(i)=max(lmax.at(i-1),lsum.at(i)-(c-x.at(n+1-i)));
  }
  for(i=0;i<n;i++){
    ans=max(ans,rsum.at(i)-2*x.at(i)+lmax.at(n-i));
    ans=max(ans,lsum.at(i)-2*(c-x.at(n+1-i))+rmax.at(n-i));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7940
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll H, N;
        cin >> H >> N;
        vll A(N);
        rep(i, 0, N) cin >> A[i];
        ll sm = accumulate(all(A), 0LL);
        if (sm >= H) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
}


Measured memory_bytes: 3932
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int i,m=-5,N,H[100005],x=0;
    cin>>N;
    for(i=1; i<=N; i++)
        scanf("%d",&H[i]);
    for(i=1; i<N; i++)
    {
        H[i]--;
        if(H[i+1]<m)
        {
            x=1;
            break;
        }
        if(H[i]>H[i+1])
        {
            x=1;
            break;
        }
        else if(H[i]==H[i+1])
            m=H[i];
    }
    if(x==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define __  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

int main()
{
    __

    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,((a+b)-n));
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};

int calc(int a, int b) {
	int a2b2 = a*a + b*b;
	int t1 = a - b;
	int t2 = (a2b2 * a2b2) - (a*a*b*b)+ a*b*a2b2;
	return t1 * t2;
}

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	// xはb-aの倍数
	int x;
	cin >> x;
	for(int i = -5000; i <= 5000; i++) {
		for(int j = i; j <= 5000; j++) {
			if((calc(i, j) == x)) {
				cout << i << " " << j << endl;
				return 0;
			}
			if(calc(j, i) == x) {
				cout << j << " " << i << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
const int maxn = 200005;
int a[maxn];
int sum[maxn];
bool cmp(int a, int b)
{
    return a > b;
}
int main()
{
    int n, k;
    cin >> n >> k;
    FOR(i,1,n)
    cin >> a[i];
    memset(sum, 0, sizeof(sum));
    FOR(i,1,n)
    {
        sum[a[i]]++;
    }
    sort(sum+1, sum+1+n, cmp);
    int ji = 1;
    int ans = 0;
    FOR(i,1,n)
    {
        if(ji > k)
        {
            ans += sum[i];
        }
        ji++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
string s;
int a[101000],p[101000],n;
int main(){
	cin>>n>>s;
	for(int i=0;s[i];i++)
	{
		if(s[i]=='o')
		{
			p[i+1]=0;
		}
		else
		{
			p[i+1]=1;
		}
	}
	p[n+1]=p[1];
	for(int i=0;i<8;i++)
	{
		a[0]=i&1,a[1]=(i>>1)&1,a[2]=(i>>2)&1;
		for(int j=2;j<=n+1;j++)
		{
			a[j+1]=p[j]^a[j-2]; 
		}
		if(a[0]^a[n]^a[1]^a[n+1]||a[1]^a[n+1]^a[2]^a[n+2])
		{
			continue;
		}
		for(int j=1;j<=n;j++)
		{
			cout<<((a[j]^a[j-1])?'W':'S');
		}return 0;
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 1408