akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

void dfs(vector<int>& v, const vector<vector<int>>& g, int cur, vector<int>::iterator& it){
	//cout << cur << ' ' << *it << endl;
	v[cur] = *it;
	it++;

	for(auto to : g[cur]){
		if(v[to] != -1) continue;
		dfs(v, g, to, it);
	}
}

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

	vector<vector<int>> g(n);
	vector<pair<int, int>> p(n - 1);
	rep(i,n - 1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		p[i] = make_pair(a,b);
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	vector<int> c(n);
	cin >> c;

	sort(all(c), greater<int>());

	//rep(i,n) cout << in[i].first << ' ' << in[i].second << endl;

	vector<int> v(n, -1);
	auto it = c.begin();
	dfs(v, g, 0, it);
	//cout << v << endl;

	int sum = 0;
	rep(i,n - 1){
		//show( min(v[p[i].first], v[p[i].second]));
		sum += min(v[p[i].first], v[p[i].second]);
	}
	cout << sum << endl;
	rep(i,n){
		if(i) cout << ' ';
		cout << v[i];
	}
	cout << endl;
}


Measured memory_bytes: 1664
using System;
using System.Linq;
class Solution
{
    static void Main(String[] args)
    {
 
        var x =Convert.ToInt64( Console.ReadLine());
       var fivehundreds= x/500;
       x-=500*fivehundreds;
       var fives=x/5;
       Console.WriteLine(fivehundreds*1000+fives*5);
    }
 
}

Measured memory_bytes: 13268
from sys import stderr, setrecursionlimit
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, **kwargs):
    print(*args, file=stderr, **kwargs)

a1,b1 = getInts()
a2,b2 = getInts()
a3,b3 = getInts()
towns = [a1,a2,a3,b1,b2,b3]
print("YES" if all([towns.count(i) <=2 for i in range(1,5)]) else "NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI = 2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  string s,t; cin >>s >>t;
  int n = s.size(), m = t.size();
  vector<vector<int>> dp(n+1, vector<int>(m+1, 10000));
  dp[0][0] = 0;
  rep(i, n) dp[i+1][0] = i+1;
  rep(i, m) dp[0][i+1] = i+1;
  // dp[i][j]...sのi文字目までとj文字目までとの編集距離
  for (int i=0; i<n; i++){
    for (int j=0; j<m; j++){
      if (s.at(i) == t.at(j)) chmin(dp[i+1][j+1], dp[i][j]);
      chmin(dp[i+1][j+1], dp[i][j] + 1); // 置換
      chmin(dp[i+1][j+1], dp[i+1][j]+1); // 挿入/削除
      chmin(dp[i+1][j+1], dp[i][j+1]+1); // 挿入/削除
    }
  }
  int res = dp[n][m];
  cout <<res <<endl;
}



Measured memory_bytes: 6840
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int n[101]={0};
	int N,K;
	int js;//份数 
	cin>>N>>K;
	for(int i=0;i<K;i++)
	{
		cin>>js;
		for(int i1=0;i1<js;i1++)
		{
			int tg;//糖果 
			cin>>tg;
			n[tg-1]++;
		}
	}
	js=0;
	for(int i=0;i<N;i++)
	{
		if(n[i]==0)
			js++;
	}
	cout<<js;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end());
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  vector<pair<string, pair<int, int>>> ps(N);
  for (int i = 1; i <= N; ++i) {
    string s; int p; cin >> s >> p;
    ps[i-1] = {s, {-p, i}};
  }
  sort(ps.begin(), ps.end());

  for (const auto& p : ps) {
    cout << p.second.second << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009


int main(){
  ll a,b,c,aa,bb,cc;
  cin >> a >> b >> c;
  ll ans = 0;
  if(a == b && b == c && a % 2 == 0) cout << -1 << endl;
  else if(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
      ans++;
      aa = b + c;
      bb = a + c;
      cc = a + b;
      a = aa/2;
      b = bb/2;
      c = cc/2;
      //cout << a << " " << b << " " << c << endl;
    }
    cout << ans << endl;
  }
  else cout << 0 << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    bool ok = true;
    if(s.size() % 2 == 1)ok = false;
    else{
        for(int i = 0; i < s.size(); i+=2){
            if(s[i] != 'h' || s[i+1] != 'i')ok = false;
        }
    }
    if(ok)cout << "Yes";
    else cout << "No";
}   


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

using namespace std;

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 1e5 + 2;

int rng(int i, int n) {
      int lo = (i - 1) * i / 2;
      int hi = n*(n+1)/2 - (n - i)*(n-i+1)/2;
      return hi-lo+1;
}

void solve() {
      int i = 0, j = 0, k = 0, n = 0, m = 0; 
      cin >> n >> k;
      int ans = 0;
      for(i = k; i <= n+1; i++) {
            //range with i
            ans += rng(i, n);
            ans %= mod;
      }

      cout << ans << el;
}

int32_t main() {
      ios::sync_with_stdio(false); cin.tie(0); 
      int T = 1; 
      // cin >> T;
      for(int tc = 1; tc <= T; tc++) {
            solve();
       }

      return 0;
}

Measured memory_bytes: 3640
// In The Namw Of Allah
#include <bits/stdc++.h>
using namespace std;

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

const int N = 2e6 + 10, mod = 1e9 + 7;

ll fact[N], rev[N];

ll pw(ll a, ll b) {
	if(!b)	return 1;
	ll ans = pw(a, b / 2);
	ans *= ans;
	ans %= mod;
	if(b & 1)	ans *= a;
	return ans % mod;
}

void prep() {
	fact[0] = 1;
	for (int i = 1; i < N; i++)	fact[i] = (fact[i - 1] * i) % mod;
	rev[N - 1] = pw(fact[N - 1], mod - 2);
	for (int i = N - 2; ~i; i--)
		rev[i] = (rev[i + 1] * (i + 1)) % mod;
}

ll c(int n , int k) {
	if(k > n || k < 0)	return 0;
	ll ans = fact[n] * rev[k];
	ans %= mod;
	ans *= rev[n - k];
	return  ans % mod;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll x, y;
	cin >> x >> y;
	prep();
	ll ans = 0;
	for (int i = 0; i <= x; i++) {
		ll nx = i * 2, ny = i;
		int t = (y - ny);
		if(t < 0 || t % 2)	continue;
		t /= 2;
		nx += t;
		if(nx != x)	continue;
		ans += c(i + t, t);
		ans %= mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, arr[200005], tot;

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) {
		cin >> arr[i];
		tot ^= arr[i];
	}
	FOR(i, 1, n) cout << (arr[i] ^ tot) << " ";
}


Measured memory_bytes: 5076
// C - Sequence

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int a[100000];
ll cum1[100000];
ll cum2[100000];

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

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

	// 偶数項を正にする場合
	ll ans1 = 0;
	if (a[0] > 0) {
		cum1[0] = a[0];
	} else {
		ans1 += abs(a[0]) + 1;
		cum1[0] = 1;
	}

	for (int i=1; i<n; i++) {
		if (i % 2 == 0) {
			if (cum1[i-1] + a[i] > 0) {
				cum1[i] = cum1[i-1] + a[i];
			} else {
				ans1 += abs(cum1[i-1] + a[i]) + 1;
				cum1[i] = 1;
			}
		} else {
			if (cum1[i-1] + a[i] < 0) {
				cum1[i] = cum1[i-1] + a[i];
			} else {
				ans1 += abs(cum1[i-1] + a[i]) + 1;
				cum1[i] = -1;
			}
		}
	}

	// 偶数項を負にする場合
	ll ans2 = 0;
	if (a[0] < 0) {
		cum2[0] = a[0];
	} else {
		ans2 += abs(a[0]) + 1;
		cum2[0] = -1;
	}

	for (int i=1; i<n; i++) {
		if (i % 2 == 0) {
			if (cum2[i-1] + a[i] < 0) {
				cum2[i] = cum2[i-1] + a[i];
			} else {
				ans2 += abs(cum2[i-1] + a[i]) + 1;
				cum2[i] = -1;
			}
		} else {
			if (cum2[i-1] + a[i] > 0) {
				cum2[i] = cum2[i-1] + a[i];
			} else {
				ans2 += abs(cum2[i-1] + a[i]) + 1;
				cum2[i] = 1;
			}
		}
	}

	ll ans = min(ans1, ans2);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
Def inf = sizeof(Def) == sizeof(long long) ?  2e18:1e9+10;
const double EPS=1e-7;
#include<complex>
typedef complex<double> P;
typedef vector<P> G;
typedef vector<double> vd;

struct L : public vector<P>{
	L(const P &a, const P &b){
		push_back(a);
		push_back(b);
	}
	
};

struct C{
	P c;double r;
	C(const P &c,double r):c(c),r(r){}
};

namespace std{
	bool operator < (const P &a,const P &b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
	bool operator == (const P &a, const P &b){
		return a.real()==b.real()&&a.imag()==b.imag();
	}

}

P pin(){
	double x,y;
	char d;
	cin>>x>>y;
	P p(x,y);
	return p;
}

L crosspointCC(C a,C b){
	P tmp=b.c-a.c;
	double d=abs(tmp);
	double q=acos((a.r*a.r+d*d-b.r*b.r)/(2*a.r*d));
	double t=arg(tmp);
	P p1=a.c+polar(a.r,t+q);
	P p2=a.c+polar(a.r,t-q);
	if(p2<p1)swap(p1,p2);
	return L(p1,p2);
}




int main(){
	int n;
	while(cin>>n,n){
		vector<C>in;
		rep(i,n){
			double a,b,c;cin>>a>>b>>c;
			in.pb(C(P(a,b),c));	
		}
		if(n==1){
			printf("%.9f\n",in[0].r);
			continue;
		}
		double l=0,r=311;
		while(r-l>EPS*1e-3){
			double h=(l+r)/2;
			bool H=false;
			vector<C>t;
			rep(i,n){
				double w=in[i].r*in[i].r-h*h;
				if(w<0)goto end;
				t.pb(C(in[i].c,sqrt(w)));
			}
			rep(i,n){
				bool e=true;
				rep(j,n)if(abs(t[i].c-t[j].c)>t[j].r+EPS)e=false;
				if(e)H=true;
			}
			rep(i,n)loop(j,i+1,n)if(abs(t[i].c-t[j].c)<t[i].r+t[j].r){
				if(t[i].r>EPS+abs(t[i].c-t[j].c)+t[j].r)continue;
				if(t[j].r>EPS+abs(t[i].c-t[j].c)+t[i].r)continue;
				L l=crosspointCC(t[i],t[j]);
				rep(k,2){
					bool e=true;
					rep(x,n)
						if(abs(t[x].c-l[k])-EPS>t[x].r)e=false;
					if(e)H=true;
				}
			}
			end:;
//			printf("         %.9f %.9f %.9f\n",l,h,r);
			if(H)l=h;
			else r=h;
		}
		printf("%.9f\n",r);
	}
	
}












Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  vector<char> str;
  while(n)
  {
      long long p = n%26;
      if(p==0){
      str.push_back('z');
      n = (n / 26) - 1;} 
      else{
      n = n/26;
     str.push_back('a'+p-1);}
  }
for(long long i=str.size()-1;i>=0;i--)
printf("%c",str[i]);
}

Measured memory_bytes: 3624
// 解き直し.
// https://img.atcoder.jp/hitachi2020/editorial.pdf
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define a first
#define b second
#define all(x) x.begin(), x.end()
const LL UPPER = 202020202020202020;
const int LIMIT = 29;
LL dp[202020][LIMIT], zCum[202020];
int cnt[LIMIT];

struct store{
    LL a, b;
    bool operator < (const store& rhs) const{
        return a * (rhs.b + 1) > rhs.a * (b + 1);
    }
};

int main(){
    
    // 1. 入力情報.
    int N;
    LL T, a, b;
    scanf("%d %lld", &N, &T);
    vector<store> v1;
    vector<LL> v2;
    rep(i, N){
        scanf("%lld %lld", &a, &b);
        if(a == 0){
            v2.pb(b);
        }else{
            store s;
            s.a = a;
            s.b = b;
            v1.pb(s);
        }
    }
    
    // 2. sort.
    sort(all(v1));
    sort(all(v2));
    // for(auto &p : v1) printf("a=%lld b=%lld\n", p.a, p.b);
    
    // 3. 累積和.
    int l2 = v2.size();
    rep(i, l2) zCum[i + 1] = zCum[i] + v2[i] + 1;
    // rep(i, l2 + 1) printf("%lld ", zCum[i]);
    // puts("");
    
    // 4. 初期化.
    rep(i, 202020) repx(j, 1, LIMIT) dp[i][j] = UPPER;
    
    // 5. dp更新.
    int l1 = v1.size();
    repx(i, 1, l1 + 1){
        rep(j, min(LIMIT, i + 1)){
            if(j){
                LL t = min(T + 1, v1[i - 1].a * (dp[i - 1][j - 1] + 1) + v1[i - 1].b + dp[i - 1][j - 1] + 1);
                if(i > j) dp[i][j] = min(dp[i - 1][j], t);
                else      dp[i][j] = t;
            }
        }
    }
    // rep(i, l1 + 1){
    //     rep(j, min(LIMIT, i + 1)) printf("%lld ", dp[i][j]);
    //     puts("");
    // }
    
    // 6. いくつのお店を回ることができるか？
    rep(i, min(LIMIT, l1 + 1)){
        // a >= 1 となるお店を, i個回る場合について, それぞれ計算.
        LL res = T - dp[l1][i];
        if(res >= 0){
            int at = upper_bound(zCum, zCum + l2 + 1, res) - zCum;
            cnt[i] = i + (at - 1);
            // printf("at=%d cnt[%d]=%d\n", at, i, cnt[i]);
        }
    }
    
    // 7. 出力.
    int ans = 0;
    rep(i, LIMIT) ans = max(ans, cnt[i]);
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 52296
# include <bits/stdc++.h>
///# include <ext/pb_ds/assoc_container.hpp>
///# include <ext/pb_ds/tree_policy.hpp>

///using namespace __gnu_pbds;
using namespace std;

# define ll long long
# define ld long double
# define pb push_back
# define ppb pop_back

const ll N = 1e5 + 10;
const ll M = 1e7 + 1000;
const ll mod = 998244353;
const ll INF = 1e18;
const ll inf = -1e18;

///typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> void_set;

bool isprime(ll x) {
    if(x == 1) return false;
    ll y = sqrt(x);
    for(int i = 2;i <= y;i++) {
        if(x % i == 0) {
            return false;
        }
    }
    return true;
}

ll bin_pow(ll a, ll b) {
    if(b == 0) return 1;
    if(b == 1) return a;
    if(a == 0) return 0;
    if(a == 1) return a;
    if(b % 2 == 0) {
        ll pw = bin_pow(a, b / 2);
        return pw * pw;
    } else {
        return bin_pow(a, b - 1) * a;
    }
}

const ld pi = acos(-1);

ll n, m, x, ans;
ll a[N], b[N], d[N], arr[1010][24];

int main() {
    ///ios_base::sync_with_stdio(false);
    ///cin.tie(NULL), cout.tie(NULL);
    ///setlocale(0,"RUS");
    ///ifstream cin("input.txt");
    ///ofstream cout("output.txt");
    cin >> n >> m;
    for(int i = 1;i <= (1 << n) - 1;i++) d[i] = INF;
    for(int i = 1;i <= m;i++) {
        cin >> a[i] >> b[i];
        for(int j = 1;j <= b[i];j++) {
            cin >> arr[i][j];
        }
    }
    d[0] = 0;
    for(int i = 1;i <= (1 << n) - 1;i++) {
        ll t = i;
        for(int j = 1;j <= m;j++) {
            ll f = t;
            for(int k = 1;k <= b[j];k++) {
                f = f & (~(1 << (arr[j][k] - 1)));
            }
            d[t] = min(d[t], d[f] + a[j]);
        }
    }
    if(d[(1 << n) - 1] >= INF) {
        cout << -1;
    }
    else cout << d[(1 << n) - 1];
}
/**
**/



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

typedef long long ll;
typedef int64_t in;
using namespace std;
#define INF 1000000007
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)


int main() {
    int x,a; cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int inf = 1e9 + 5;
static const int max_val = 1e5 + 5;

class Item{
private:
public:
  int weight, value;
};

int main() {
  int n, max_weight;

  cin >> n >> max_weight;

  Item item[n];
  int dp[max_val];

  for (int i = 0; i < n; i++) {
    cin >> item[i].weight >> item[i].value;
  }

  for (int v = 0; v < max_val; v++) {
    dp[v] = inf;
  }
  dp[0] = 0;
  
  for (int i = 0; i < n; i++) {
    for (int v = max_val - item[i].value; v >= 0; v--) {
      dp[v + item[i].value] = min(dp[v + item[i].value], dp[v] + item[i].weight);
    }
  }

  int ans = max_val - 1;
  while(ans >= 0 && dp[ans] > max_weight) {
    ans--;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ll long long
#define endl "\n"
#define lu unsigned long long
#define mod 1000000007
#define ld long double
#define f(i, n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define v vector<ll>
#define vv vector<vector<ll> >
#define vs vector<string>
#define vpr vector<pair<ll,ll>>
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define bg(x)  x.begin()
#define sz(x)  x.size()
#define in(x,n) f(i,n) cin>>x[i]
#define out(x,n) f(i,n) cout<<x[i]<<" "
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define mem(x,val) memset(x,val,sizeof(x))
#define tc    ll t;cin>>t;while(t--)
#define pi pair<int,int>
#define prfloat(val,precise) cout<<fixed<<setprecision(precise)<<val<<endl;
const ld PI = 2 * acos(0.0);
void yes(){ cout<<"YES\n";}
void no(){cout<<"NO\n";}
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){ ;if((x1%y1)==0)return x1/y1;return x1/y1+1;}
ll power(ll a,ll b){ if(b==0)return 1;ll d=power(a,b/2);d=m(d*d);
if(b&1)d=m(d*a);return d;}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int dp[10004],a[10005],b[10005];
int n;
int fun(int h)
{
	if(h<=0)
		return 0;
	if(dp[h]!=-1)
		return dp[h];
	int ans=fun(h-a[0])+b[0];
	for(int i=1;i<n;i++)
	{
		ans=min(ans,fun(h-a[i])+b[i]);
	}
	return dp[h]=ans;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h;cin>>h>>n;
	for(int i=0;i<10004;i++)
		dp[i]=-1;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	cout<<fun(h)<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans=0, n=0;
  for (int i = 0; i < N; i++){
    if (S[i]=='I'){
      n++;
    }else{
      n--;
    }
    if (n > ans){
      ans = n;
    }
    
  }
  
  printf("%d\n", ans);
}


Measured memory_bytes: 3700
w = ["dream", "dreamer", "erase", "eraser"]
s = input()

flag = True
while flag and s != "":
    flag = False
    for i in range(len(w)):       
        if s[-1*len(w[i]):] == w[i]:
            s = s[:-1*len(w[i])]
            flag = True

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
n = int(input())
a = []
b = []
for i in range(n):
  c, d= map(int, input().split())
  a.append(c)
  b.append(d)
a.reverse()
b.reverse()
tot = 0
for i in range(n):
  if (a[i]+tot)%b[i] == 0: continue
  x = b[i] - (a[i]+tot)%b[i]
  tot += x
print (tot)

Measured memory_bytes: 16904
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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;

int main()
{
    int num[3];
    int a = 0, b = 0;

    for (int i = 0; i < 3; ++i)
    {
        cin >> num[i];
        if (num[i] == 5)
            a++;
        else if (num[i] == 7)
            b++;
    }
    if (a == 2 && b == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 3592
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<cmath>//
#include<limits>//
#include <stdio.h>//
#include <math.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n,d,cnt = 0,m;
  cin >> n >> d;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
    m = pow(x[i],2) + pow(y[i],2);
    if (sqrt(m) <= d){
      cnt++;
    }
    
  }
  
  cout << cnt << '\n';
  return 0;
}

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

int main() {
    long long N,M;
    cin >> N >> M;
    long long a[N],asum=0,b = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        asum += a[i];
    }
    for (int i = 0; i < N; i++)
    {
        if(a[i] * 4 * M >= asum ){
            b++;
        }
    }
    if(M > b){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	for n > 0 {
		if n%10 == 7 {
			fmt.Fprintln(writer, "Yes")
			return
		}
		n /= 10
	}
	fmt.Fprintln(writer, "No")
}


Measured memory_bytes: 1800
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n;
    i64 h;
    cin >> n >> h;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n) cin >> a[i] >> b[i];
    int max_a = *max_element(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<int>());

    i64 d = 0;
    int cnt = 0;
    int idx = 0;

    while(d<h)
    {
        if(idx>=n || b[idx]<=max_a)
            d += max_a;
        else
        {
            d += b[idx];
            ++idx;
        }
        ++cnt;   
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


def segfunc(x, y):
    return max(x, y)


def main():
    N, K = map(int, readline().split())
    A = list(int(readline()) for _ in range(N))
    Amax = max(A)
    dp = [0] * (Amax + 1)

    ide_ele = -float('inf')
    segtree = SegTree(dp, segfunc, ide_ele)

    for a in A:
        l = max(0, a - K)
        r = min(Amax, a + K)
        L = segtree.query(l, r + 1)
        segtree.update(a, L + 1)

    ans = segtree.query(0, Amax + 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 97964
#include <iostream>
#include <cstdio>
using namespace std;
int main () {
  int i;
  int h[999999],w[999999],x,y;

  for (i=0;i<999999;i++) {
    h[i] = 0;
    w[i] = 0;
  }
  i=0;
  while (1) {
    cin >> h[i] >> w[i];
    if (h[i]==0 || w[i]==0) { break;
    }
    i++;
  }
  for (i=0;i<999999;i++) {
    if (h[i] == 0 || w[i] == 0) break;
    for (y=0;y<h[i];y++) {
      for (x=0;x<w[i];x++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 10908
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int sum = 0;
	vector<pair<int, int>> v(5);
	for (int i = 0; i < 5; i++) {
		cin >> v.at(i).second;
		if (v.at(i).second % 10 != 0) {
			v.at(i).first = 10 - v.at(i).second % 10;
		} else {
			v.at(i).first = v.at(i).second % 10;
		}
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < 5; i++) {
		sum += v.at(i).first + v.at(i).second;
	}
	cout << sum - v.at(4).first << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
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; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int n,m;
vector<P> v;

int main(){
	cin >> n >> m;	
	rep(i,m){
		int a,b;
		cin >> a >> b;
		v.push_back(P(b,a));
	}

	sort(all(v));

	int cnt = 0,cur = -1;
	for(int i = 0;  i < m; i++){
		if(v[i].second > cur){
			cur = v[i].first-1;
			cnt++;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

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

int main(void){
  vector<int> time(3);

  for(int i = 0; i < 3; i++) cin >> time[i];

  sort(time.begin(), time.end());
  cout << time[0] + time[1] << endl;
  return 0;
}

Measured memory_bytes: 256
# Problem B - Trick or Treat

# input
N, K = map(int, input().split())

# initialization
snuke = [0]*N
ans = 0

# count
for k in range(K):
    d = int(input())
    a_nums = list(map(int, input().split()))
    for a in a_nums:
        snuke[a-1] += 1

# check
for s in snuke:
    if s==0:
        ans += 1

# output
print(ans)


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

int main() {
	int a[4];
	for (int i = 0;i < 4;i++)cin >> a[i];
	sort(a, a + 4);
	if (a[0] == a[1] && a[2] == a[3])cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;

int main() {
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++) {
    string a;
    cin>>a;
    if(a=="Y") {
      ans++;
    }
  }
  if(ans>0) {
    cout<<"Four"<<endl;
  }
  else {
    cout<<"Three"<<endl;
  }
}

Measured memory_bytes: 256
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

n = iinput()
ans = (n + 1)//2
print(ans)


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long x;
    long long result=0;
    long long local_max;
     vector<int> arr;
    for(int i=0;i<n;i++){
        cin>>x;
        arr.push_back(x);
    }
    local_max=arr[0];
    for(int i=1;i<n;i++){
        if(arr[i]<local_max){
            result+=local_max-arr[i];
        }
        else{
            local_max=arr[i];
        }
    }
  cout<<result;
    return 0;
}

Measured memory_bytes: 4152
#include <cstdio>
#include <vector>
using namespace std;

int main ()
{
  int n;
  int count = 0;
  vector<int> A(200);

  scanf("%d", &n);

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

  while (1) {
    for (int i = 0; i < n; i++) {
      if (A[i] % 2 != 0) {
        printf("%d\n", count);
        return 0;
      }
    }
    count++;
    for (int i = 0; i < n; i++) {
      A[i] /= 2 ;
    }
  }
}

Measured memory_bytes: 256
//============================================================================
// Name        : RootedTree.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

class Node{
public:
	int id;
	Node* p_parent;
	vector<Node*> p_children;

	Node(int n):id(n), p_parent(), p_children(){}
	Node(int n, Node& supernode):id(n), p_parent(&supernode), p_children(){}
};

void initializeNodes(vector<Node>& nodes, int n, Node& supernode){
	for(int i=0; i<n; i++){
		nodes.push_back(Node(i, supernode));
	}
}

string checkNodeType(vector<Node>& nodes, int i){
	if(i>=nodes.size()){
		cout << "ERROR!\n";
	}

	if(nodes.at(i).p_parent->id == -1){
		return "root";
	}

	if(nodes.at(i).p_children.size()==0){
		return "leaf";
	}

	return "internal node";
}

int checkDepth(vector<Node>& nodes, int i){
	if(i>=nodes.size()){
		cout << "ERROR!\n";
	}

	int depth = 0;
	Node* p_parent = nodes.at(i).p_parent;
	int id = p_parent->id;
	while(id != -1){
		depth ++;
		p_parent = p_parent->p_parent;
		id = p_parent->id;
	}

	return depth;
}

void writeTree(vector<Node>& nodes){
	//for(int i=0; i<nodes.size(); i++){
	//	cout << "node " << nodes.at(i).id << "\n";
	//}

	for(int i=0; i<nodes.size(); i++){
		cout << "node " << nodes.at(i).id << ": parent = " << nodes.at(i).p_parent->id;

		int depth = checkDepth(nodes, i);
		cout << ", depth = " << depth;


		string nodeType = checkNodeType(nodes, i);
		cout << ", " << nodeType;

		cout << ", [";
		int n_children = nodes.at(i).p_children.size();
		if(n_children>0){
		    for(int j=0; j<n_children-1; j++){
			    cout << nodes.at(i).p_children.at(j)->id << ", ";
		    }
		cout << nodes.at(i).p_children.at(n_children-1)->id;
		}
		cout << "]\n";
	}
}

int main() {
	int n;
	cin >> n;
	vector<Node> nodes;
	Node SuperNode(-1);

	initializeNodes(nodes, n, SuperNode);

	//writeTree(nodes);

	for(int i=0; i<n; i++){
		//cout << "here: " << i << "\n";
		int id, m;
		cin >> id >> m;

		if(m==0){
			//cout << "continue: " << i << "\n";
			continue;
		}

		for(int j=0; j<m; j++){
			int child;
			cin >> child;
			nodes.at(id).p_children.push_back(&(nodes.at(child)));
			nodes.at(child).p_parent = &(nodes.at(id));
		}

	}

	//cout << "here3";
	writeTree(nodes);

	return 0;
}



Measured memory_bytes: 8432
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
c = gets.chomp.split.map(&:to_i)
sum = 0
n.times do |i|
  sum += b[a[i] - 1]
  if i >= 1 && a[i-1] + 1 == a[i]
    sum += c[a[i-1]-1]
  end
end

puts sum

Measured memory_bytes: 14300
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() {
    IOS;
	ll n;
	cin>>n;
	ll f[110]={};
	rep(i,n) {
		rep(j,10) {
			ll a;
			cin >> a;
			f[i] += a << (9 - j);
		}
	}
	ll p[n][11];
	rep(i,n) {
		rep (j,11) {
			cin >> p[i][j];
		}
	}
	int ans = -1e9;
	for (int i = 1;i < 1024;i++) {
		int cost = 0;
		for (int j = 0;j < n;j++) {
			cost += p[j][__builtin_popcount(f[j] & i)];
		}
		ans = max(ans, cost);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

    bool oc[26];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    for (char c: s) oc[c-'a'] = 1;
    F0R(i,26) if (!oc[i]) {
        cout << s << char('a'+i);
        return 0;
    }
    
    F0Rd(i,sz(s)-1) if (s[i] < s[i+1]) {
        cout << s.substr(0,i);
        char mn = 'z';
        FOR(j,i+1,sz(s)) if (s[j] > s[i]) mn = min(mn,s[j]);
        cout << mn;
        return 0;
    }
    cout << -1;
}

// read the question correctly (is y a vowel?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007

int main(){
  int N,i,M=0,ans=0;
  scanf("%d",&N);
  int H[N];
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
    if(M<=H[i]){
      ans++;
      M=H[i];
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cassert>
using namespace std;


int main(){
  int n,m,a,b,c,d,s,g,money,pay,matrix[40][40];
  for(int i=0;i<40;i++)for(int j=0;j<40;j++)matrix[i][j]=1<<22;
  cin >> n;
  cin >> m;
  for(int i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    matrix[a][b] = c;
    matrix[b][a] = d;
  } 
  for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)matrix[i][j] = min(matrix[i][j],matrix[i][k]+matrix[k][j]);
  scanf("%d,%d,%d,%d",&s,&g,&money,&pay);
  int sum=0;
  sum += matrix[s][g];
  sum += matrix[g][s];
  sum += pay;
  assert(money-sum>=0);
  cout << money-sum << endl;


  return 0;
}

Measured memory_bytes: 1244
import java.util.*;
import java.io.*;

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();
        
        if((A==5&&B==5&&C==7)||(A==5&&B==7&&C==5)||(A==7&&B==5&&C==5))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

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

int comp(pair<string,int>a,pair<string,int>b){
	return a.second < b.second;
}
int main() {
	map<string,int> strtable;
	map<string,int>::iterator mnum;
	string word;
	string maxlw;

	while(cin>>word){
		if(strtable.find(word) == strtable.end())strtable[word]=1;
		else strtable[word]++;
		if(word.length() > maxlw.length())maxlw = word;
	}
	
	mnum = max_element(strtable.begin(),strtable.end(), comp);
	
	cout<<mnum->first<<" "<<maxlw<<endl;
	
	return 0;
}

Measured memory_bytes: 1196
s = str(input())
t = str(input())
total = 0
for i in range(len(s)-len(t)+1):
  u = s[i:i+len(t)]
  sum = 0
  for j in range(len(t)):
    if u[j] == t[j]:
      sum += 1
  total = max(sum,total)

print(len(t)-total)

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

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

  sort(l, l+n);

  int ans = 0;
  for ( int i = 0; i < n-1; i++){
    for ( int j = i+1; j < n; j++){
      int c = lower_bound(l,l+n, l[i]+l[j]) - l;
      ans += (c-j-1);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX_N 200000

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

    int a[N+1];
    for(int i =0;i<=N;i++)a[i]=0;

    for(int i =0;i<N; i++)a[A[i]]++;
    sort(a,a+N+1);

    int x;
    for(int i =0;i<N;i++){
      if(a[i]>0){
        x=i;
        break;}
    }

    int y=0;
    if(N-x+2> K){
      for(int i=x;i <N-K+1;i++)y += a[i];
      printf("%d",y);
    }
    else printf("0");

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
int t[100002];
int a[100002];
int b[100002];
int f;
int main()
{
	f=1;
	cin>>n;
	rep(i,n)cin>>t[i+1]>>a[i+1]>>b[i+1];
	rep(i,n)
	{
		if((t[i+1]-t[i])%2!=(a[i+1]+a[i]+b[i+1]+b[i])%2)
		{
			f=0;
			//cout<<i<<"a";
		}
		if(t[i+1]-t[i]<abs(a[i+1]-a[i])+abs(b[i+1]-b[i]))
		{
			f=0;
			//cout<<i<<2;
		}
	}
	if(f==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
using namespace std; 
 
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()
 
typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	
 
 
int main(){
	
	int a,b;
	
	
	int dp[1000];
	
	dp[0] = 0;
	
	f(i,1,1000){
		dp[i] = dp[i-1] + i;
	}
	
	cin >> a >> b; 
	
	int idx = 1;
	
	while(1){
		if(dp[idx]-a==dp[idx+1]-b){
			cout << dp[idx]-a << endl;
			break;
		}
		idx++;
	}
 
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, prime = 1;
  scanf("%d", &n);

  for (int i = 1; i <= 9; i++)
  {
    for (int j = 1; j <= 9; j++)
    {
      if (i * j == n)
      {
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}


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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        int r=0,r1=0;
        loop(i,0,n-1)
        {
            if(s[i]=='R') r++;
        }
        loop(i,0,r-1)
        {
            if(s[i]=='R') r1++;
        }
        cout<<r-r1;


    }
    return 0;
}


Measured memory_bytes: 3772
import math


def judge(n, k):
    m = n % k
    while m == 0:
        n //= k
        m = n % k
    return m


def div_list(n):
    l = set()
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            l.add(i)
            j = n // i
            if i != j:
                l.add(j)
    return l


def main():
    N = int(input())

    cnt = len(div_list(N-1)) - 1
    cnt += sum(1 for d in div_list(N) if d != 1 and judge(N, d) == 1)

    print(cnt)


main()


Measured memory_bytes: 3828
input = STDIN.read.split("\n").map{|l| l.split(" ").map{|i| i.to_i}}

N = input[0][0]
H = input[1]

BAG = {}

def jump(i = 0)
  if BAG.key?(i)
    return BAG[i]
  end
  if i == N - 1
    c = 0
    BAG[i] = c
    return c
  end
  cost = jump(i + 1)
  to_next = (H[i] - H[i + 1]).abs

  if i == N - 2
    return cost + to_next
  end

  cost_two = jump(i + 2)
  to_next_two = (H[i] - H[i + 2]).abs
  c = [(cost + to_next), (cost_two + to_next_two)].min
  BAG[i] = c
  return c
end

c = 0
(0..(N - 1)).reverse_each { |i|
  c = jump(i)
}
puts c


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    

    ll test=1;
    //cin>>test;
    while(test--)
    {
        ll r;
        cin>>r;

        cout<<setprecision(10);

        ld ans=(2*22*r)/7.0;

        cout<<ans;
    }
}

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

#define MAX 100

int N;
int s[MAX];

int main()
{
	cin >> N;
	for( int i = 0; i < N; i++ ) {
		cin >> s[i];
	}
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		ans += s[i];
	}
	if( ans % 10 == 0 ) {
		sort( s, s + N );
		for( int i = 0; i < N; i++ ) {
			if( ( ans - s[i] ) % 10 ) {
				ans -= s[i];
				break;
			}
		}
	}
	if( ans % 10 == 0 ) {
		ans = 0;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256