akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

void dfs(int u, vector <int> gr[], vector<int>& intime, vector<int>& out, vector <pii>& oriented, int& timer) {
    intime[u] = timer++;
    for (int v : gr[u]) {
        if (intime[v] && intime[v] < intime[u]) continue;
        if (!intime[v])
            dfs(v, gr, intime, out, oriented, timer);
        int source = (out[v] & 1) ? v : u;
        out[source]++;
        oriented.pb({source, source ^ u ^ v});    
    }
}

int main() {
    nfs
    int i, j, n, m;
    cin >> n >> m;
    if (m & 1) {
        cout << "-1\n";
        return 0;
    }

    vector <int> gr[n + 1];
    vector <int> out(n + 1, 0), intime(n + 1, 0);
    vector <pii> oriented;
    
    while (m--) {
        int u, v;
        cin >> u >> v;
        gr[u].pb(v);
        gr[v].pb(u);
    }

    int timer = 1;
    dfs(1, gr, intime, out, oriented, timer);
    for (pii ed : oriented)
        cout << ed.ff << " " << ed.ss << "\n";
    return 0;
}

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

const int N = 100010;

int a[N];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
	}
	if (n == 1){
		puts(a[0] & 1 ? "Second" : "First");
		return 0;
	}
	std::sort(a, a + n, std::greater <int>());
	int sit;
	for (sit = 0; sit < n - 1; ++ sit){
		if (a[sit] <= sit) break;
	}
	-- sit;
	if (sit == n - 2){
		if (a[n - 1] <= sit){
			puts(a[n - 2] - sit & 1 ? "Second" : "First");
			return 0;
		}
		puts(a[n - 1] - sit & 1 ? "First" : "Second");
		return 0;
	}
	int cnt = 0;
	for (int i = sit + 1; i < n; ++ i){
		cnt += a[i] == sit + 1;
	}
	puts((cnt & 1) || (a[sit] - sit - 1 & 1) ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define po pop_back
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd
#define maximum INT_MAX
#define minimum INT_MIN

int main() {

int r;
cin>>r;
cout<<r*r;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
string S;
int solve(){
    int count=0;
    rep(i,(int)S.length()/2){
        if(S[i]!=S[S.length()-i-1])count++;
    }
    return count;
}
int main(){
cin>>S;
cout<<solve()<<endl;
}

Measured memory_bytes: 384
A, B, C, K = map(int, input().split())
ans = 0
if A < K:
    K -= A
    ans += A
else:
    ans += K
    print(ans)
    exit()

if B < K:
    K -= B
else:
    print(ans)
    exit()

if C < K:
    K -= C
    ans -= C
else:
    ans -= K
print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#include <utility>
using namespace std;
typedef long long ll;
int r,c;
int sr, sc;
int gr,gc;
vector<vector<char> > maper(50,vector<char>(50));
vector<vector<int> > maper_check(50,vector<int>(50, 0));
int inter1 = 1;
int inter2 = 0;
int kkk = 0;
queue<int> where_r;
queue<int> where_c;
int goal_counter = 1;

int search_count(){
	where_r.push(sr);
	where_c.push(sc);
	maper_check.at(sr).at(sc) = 1;
	while(!where_r.empty()){
		int now_r =where_r.front();
		int now_c =where_c.front();
		where_r.pop();
		where_c.pop();
		int x[4] ={0,1,0,-1};
		int y[4] ={1,0,-1,0};

		for (int j = 0;j <4;j++){
			if (now_r+x[j] < 0 || now_c+y[j] < 0) continue;
			if (now_r+x[j] >= r || now_c+y[j] >= c) continue;
			if (maper.at(now_r+x[j]).at(now_c+y[j]) == '.' && maper_check.at(now_r+x[j]).at(now_c+y[j]) == 0) {
				maper_check.at(now_r+x[j]).at(now_c+y[j]) = maper_check.at(now_r).at(now_c) + 1;
				if (now_r+x[j] == gr && now_c+y[j] == gc){
					return maper_check.at(now_r+x[j]).at(now_c+y[j]);
				}
				where_r.push(now_r+x[j]);
				where_c.push(now_c+y[j]);
			}

		}
	}
	return -1;
}

int main(){
	cin >> r >> c;
	sr = 0;
	sc = 0;
	gr = r-1;
	gc = c-1;
	for (int i = 0;i < r;i++){
		for (int j =0;j<c;j++){
			cin >> maper.at(i).at(j);
		}
	}
	int kkk=0;
	for (int i = 0;i < r;i++){
		for (int j =0;j<c;j++){
			if (maper.at(i).at(j) == '.') kkk++;
		}
	}
	goal_counter = search_count();
	if (goal_counter == -1) {
        cout << -1 << endl;
    } else {
        cout << kkk-goal_counter << endl;
    }

}

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

int main(){
  vector<int> a(4);
  for(int i = 0;i < 4;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  //cout << a.at(0) << a.at(1) << a.at(2) << a.at(3) << endl;
  if(a.at(0) == 1 && a.at(1) == 4 && a.at(2) == 7 && a.at(3) == 9){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
tile = input()
ans = 0
for i in range(len(tile) - 1):
  if tile[i+1] != tile[i]:
    continue
  else:
    ans += 1
    if tile[i+1] == "0":
      tile = tile[:i+1] + "1" + tile[i+2:]
    else: 
      tile = tile[:i+1] + "0" + tile[i+2:]
print(ans)

Measured memory_bytes: 3436
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
n = min(A[0], B[0])
ans = n
for i in range(N-1):
    n = min(A[i+1], B[i] - n)
    ans += n
    n = min(A[i+1] - n, B[i+1])
    ans += n
ans += min(A[-1], B[-1] - n)
print(ans)


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 200010

ll N;
vector<ll> X, Y;

signed main()
{
    cin >> N;
    REP(i, N) {
        ll tmp;
        cin >> tmp;
        X.push_back(tmp);
        Y.push_back(tmp);
    }
    SORT(X);
    REP(i, N) {
        ll ans;
        if(Y[i] < X[N/2]) { ans = X[N/2]; }
        else { ans = X[N/2 - 1]; }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 5476
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int N;
  cin >> N;
  vector<bitset<10>> f(N);
  rep(i, 0, N) {
    rrep(j, 0, 10) {
      int a;
      cin >> a;
      f[i][j] = a;
    }
  }
  vector<vector<int>> p(N, vector<int>(11));
  rep(i, 0, N) rep(j, 0, 11) { cin >> p[i][j]; }

  int ans = -INF;
  rep(bits, 1, (1 << 10)) {
    bitset<10> b(bits);
    int score = 0;
    rep(i, 0, N) { score += p[i][(b & f[i]).count()]; }
    chmax(ans, score);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <iterator>
using namespace std;
typedef long long lint;

map<int,char> a;

lint gcd(lint x,lint y){
	return y?gcd(y,x%y):x;
}

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

	lint N,M;
	string S,T;
	cin >> N >> M;
	cin >> S >> T;

	lint L = N*M/gcd(N,M);

	for(int i=0;i<N;i++){
		a[1+i*L/N] = S[i];
	}
	for(int i=0;i<M;i++){
		if(a.find(1+i*L/M)!=a.end()){
			if(a[1+i*L/M] != T[i]){
				cout << "-1" << endl;
				return 0;
			} 
		}else{
			a[1+i*L/M] = T[i];
		}
	}

	cout << L << endl;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
typedef pair<int,int> Pp;


signed main(){
    int h,w;
    char c[100][100];
    cin >> h >> w;
    REP(i,h){
        REP(j,w){
            cin >> c[i][j];
        }
    }
    REP(i,w+2){
        cout << "#";
    }cout << endl;
    REP(i,h){
        cout << "#";
        REP(j,w){
            cout << c[i][j];
        }
        cout << "#" << endl;
    }
    REP(i,w+2){
        cout << "#";
    }cout << endl;
    
    return 0;
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    int dp[n];
    fill(dp, dp + n, 1e9);
    rep(i, n) cin >> A[i];

    rep(i, n) {
        *lower_bound(dp, dp + n, A[i]) = A[i];
    }

    cout << lower_bound(dp, dp + n, 1e9) - dp << endl;
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

ll dp[101][N];
void solve() {
    int n,w,x,y;
    cin>>n>>w;
    REP(i,1,n) {
        cin>>x>>y;
        REP(j,0,w) {
            dp[i][j] = dp[i-1][j];
            if(j>0) dp[i][j] = max(dp[i][j],dp[i][j-1]);
            if(j>=x) dp[i][j] = max(dp[i][j],y+dp[i-1][j-x]);
        }
    }
    cout<<dp[n][w];
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 78336
MOD = 1000000007
INF = float("inf")

n, k = map(int, input().split())
A = list(map(int, input().split()))

for i in range(len(A)):
    A[i] = (A[i]+1)/2

start = 0
end = k-1
cur_sum = sum(A[start:end+1])
ans = cur_sum

for i in range(len(A)-k):
    cur_sum = cur_sum - A[start] + A[end+1]
    ans = max(ans, cur_sum)
    end += 1
    start += 1

print(ans)


Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int K,A,B;
    cin>>K>>A>>B;
    if(A%K==0){
        cout<<"OK";
    }
    else if(B%K==0){
        cout<<"OK";
    }
    else if((B-A)>=K)
    {cout<<"OK";}
    else if((B/K)>(A/K))
    {cout<<"OK";}
    else
    {
        cout<<"NG";
    }
    return 0;

}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
 int main(void){
   char A,B;
   cin >> A >> B;
   if(A < B){
     cout << "<" << endl;
   } else if(B < A){
     cout << ">" << endl;
   } else {
     cout << "=" << endl;
   }
   return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
int main(){
  ll N;
  cin>>N;
  string str;
  cin>>str;
  if(N>=(ll)str.size()){cout<<str<<endl;}
  else{
    for(ll i=0;i<N;i++){
      cout<<str.at(i);
    }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[110],b[110];
	for (int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	int i;
	for (i=1;i<=n;i++)
	{
		int ans=0;
		if (a[i]==b[i]){
			int j=i;
			while(a[j]==b[j]&&j<=n){
				ans++;
				j++;
			}
		}
		if (ans>=3) break;
	}
	if (i<=n) printf ("Yes\n");
	else printf ("No\n");
	return 0;
}

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

using namespace std;
int main(int argc, const char * argv[]) {
    int H,W;
    int i,j;
    while (true) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        else{
            for (j=0; j<H; j++) {
                for (i=0; i<W; i++){
                    cout << '#';
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

const int MOD = 1e9+7;
int memo[20010];

ll calc(ll s, ll sum){
    if (sum > s) return 0;
    if (sum == s) return 1;
    if (~memo[sum]) return memo[sum];
    ll ans = 0;
    for (int i = 3; i <= s; ++i) {
        ans += calc(s, sum+i);
        ans %= MOD;
    }
    return memo[sum] = ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1, n;
    mem1(memo);
    while (T--){
        cin >> n;
        cout << calc(n,0) << "\n";
    }
}

Measured memory_bytes: 3744
from collections import defaultdict

N = int(input())
s_counter = defaultdict(int)
for _ in range(N):
    S = input()
    s_counter[S] += 1
S_list = sorted(s_counter.items(), key=lambda x: x[1], reverse=True)
answer = []
for i in range(len(S_list)):
    if S_list[0][1] != S_list[i][1]:
        break
    answer.append(S_list[i][0])
answer.sort()
[print(a) for a in answer]


Measured memory_bytes: 49380
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 101
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int n,X,D,sz[N],p[N],top[N]; ll m[N],f[2][N*N*N],g[N*N*N];
struct node{int v,c,id;}a[N]; int q[N*N*N];
bool operator<(node x,node y){return 1ll*x.c*y.v<1ll*x.v*y.c;}
int main()
{
	n=read(),X=read(),D=read(),m[1]=read(); sz[1]=1; top[1]=X;
	for(int i=2;i<=n;i++)	m[i]=read(),p[i]=read(),sz[i]=1;
	for(int i=n;i>1;i--)	sz[p[i]]+=sz[i],m[p[i]]+=m[i],m[i]=min(m[i],1000000001ll),top[i]=D;
	m[1]=min(1000000001ll,m[1]); for(int i=1;i<=n;i++)	a[i]=(node){sz[i],m[i],i};
	int cur=1,lst=0,s=0; memset(f[cur],63,sizeof(f[cur])); f[cur][0]=0;
	for(int i=1;i<=n;i++)
	{
		cur^=1,lst^=1; memset(f[cur],63,sizeof(f[cur]));
		int ctop=min(top[i],n); top[i]-=ctop;
		s+=ctop*sz[i];
		for(int j=0;j<sz[i];j++)
		{
			int hd=1,tl=0;
			for(int k=0;k*sz[i]+j<=s;k++)
			{
				int p=k*sz[i]+j;
				while(hd<=tl&&k-q[hd]>ctop)	hd++;
				while(hd<=tl&&g[tl]+1ll*(k-q[tl])*m[i]>=f[lst][p])	tl--;
				q[++tl]=k; g[tl]=f[lst][p];
				f[cur][p]=min(f[cur][p],g[hd]+1ll*(k-q[hd])*m[i]);
			}
		}
	}
	sort(a+1,a+n+1); ll ans=0;
	for(int i=0;i<=s;i++)	if(f[cur][i]<=X)
	{
		ll s1=0,s2=0;
		for(int j=1;j<=n;j++)
		{
			int x=a[j].id;
			ll nw=min(1ll*top[x],(X-f[cur][i]-s2)/a[j].c)*a[j].v;
			ans=max(ans,s1+i+nw);
			s1+=nw; s2+=1ll*top[x]*a[j].c;
			if(s2+f[cur][i]>X)	break;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 22400
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int N, K;
    cin >> N >> K;

    double ans = 0;
    for (int i = 1; i <= N; i++) {
        int cnt = 0;
        for (int k = i; k < K; k *= 2, cnt++);

        double t = (1.0 / N) * pow(0.5, cnt);
        ans += t;
    }
    cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10 ** 9 + 7

cnt = [0] * (k + 1)

for i in range(k, 0, -1):
    c = pow(k // i, n, mod)
    c -= sum(cnt[i * 2::i])
    c %= mod
    cnt[i] = c

ans = 0
for i in range(1, k + 1):
    ans += i * cnt[i]
    ans %= mod

print(ans)


Measured memory_bytes: 12012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (long long)(1e9+7)
int main(){
	ll a,b;
	cin>>a>>b;
	if(b%a==0){
		cout<<a+b<<endl;

	}
	else cout<<b-a<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int 
#define endl '\n'
ll mod=1e9+7;

class Graph { 
    // No. of vertices 
    int V; 
  
    // Pointer to an array containing adjacency lists 
    list<int>* adj; 
  
    // A function used by DFS 
    void DFSUtil(int v, bool visited[]); 
  
public: 
    // Constructor 
    Graph(int V); 
  
    void addEdge(int v, int w); 
    int NumberOfconnectedComponents(); 
}; 
  
// Function to return the number of 
// connected components in an undirected graph 
int Graph::NumberOfconnectedComponents() 
{ 
  
    // Mark all the vertices as not visited 
    bool* visited = new bool[V]; 
  
    // To store the number of connected components 
    int count = 0; 
    for (int v = 1; v <= V; v++) 
        visited[v] = false; 
  
    for (int v = 1; v <= V; v++) { 
        if (visited[v] == false) { 
            DFSUtil(v, visited); 
            count += 1; 
        } 
    } 
  
    return count; 
} 
  
void Graph::DFSUtil(int v, bool visited[]) 
{ 
  
    // Mark the current node as visited 
    visited[v] = true; 
  
    // Recur for all the vertices 
    // adjacent to this vertex 
    list<int>::iterator i; 
  
    for (i = adj[v].begin(); i != adj[v].end(); ++i) 
        if (!visited[*i]) 
            DFSUtil(*i, visited); 
} 
  
Graph::Graph(int V) 
{ 
    this->V = V; 
    adj = new list<int>[V+1]; 
} 
  
// Add an undirected edge 
void Graph::addEdge(int v, int w) 
{ 
    adj[v].push_back(w); 
    adj[w].push_back(v); 
} 

int main()
{
   FASTio;
    #ifndef ONLINE_JUDGE                    //file start
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
    #endif                                  //file end
    int n,m,x,y,i;
    cin>>n>>m;
    Graph g(n); 
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        g.addEdge(x,y);
    }
    cout<<g.NumberOfconnectedComponents() - 1<<"\n";    
    return 0;
}

Measured memory_bytes: 13588
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
int i;
cin>>s;
for(i=0;i<s.length();i++)
if(s[i]=='Y' && s[i+1]=='A' && s[i+2]=='K' && s[i+3]=='I'){
cout<<"Yes";
break;}
else{
cout<<"No";
break;} 
}



Measured memory_bytes: 256
import java.io.*;

/**
 * Created by Ayushi on 21 Jun 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String a = br.readLine();
        br.close();
        if (a.equals(a.toUpperCase())) System.out.println("A");
        else System.out.println("a");
    }
}


Measured memory_bytes: 32532
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll X,Y,Z;
  cin >> X >> Y >> Z;
  X-=Z;

  cout << X/(Y+Z) << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let i: i32 = read();
    let c: Vec<i32> = i.to_string().chars().map(|x| x.to_digit(10).unwrap() as i32).collect();
    let d:i32 = c.iter().sum();
    if i % d == 0{
        println!("Yes");
    } else {
        println!("No");
    }

}

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

int main(){
  int N,sum=0;
  cin >> N;
  vector<int> B(N-1);
  for(int i=0;i<N-1;i++){
    cin >> B.at(i);
  }
  sum+=B.at(0)+B.at(N-2);
  for(int i=1;i<N-1;i++){
    sum+=min(B.at(i-1),B.at(i));
  }
  cout << sum << endl;
}

Measured memory_bytes: 3596
# encoding: utf-8
S = input()
target = 'keyence'

for i in range(1, len(S)):
    tarl = target[:i]
    tarr = target[i:]
    if S.startswith(tarl) and S.endswith(tarr):
        print('YES')
        break
    else: continue
else:
    print('NO')

Measured memory_bytes: 3060
using System;
using System.Text;
using System.Linq;

class aizu_judge
{
    static void Main()
    {
        while(true)
        {
            int aPoint = 0, bPoint = 0;
            int n = Convert.ToInt32(Console.ReadLine());
            
            if (n == 0)
                break;

            for(int i = 0; i < n; i++)
            {
                int[] card = Console.ReadLine().Split().Select(int.Parse).ToArray();

                if (card[0] > card[1])
                    aPoint += card[0] + card[1];
                else if (card[0] < card[1])
                    bPoint += card[0] + card[1];
                else
                {
                    aPoint += card[0];
                    bPoint += card[1];
                }
            }
            Console.WriteLine("{0} {1}",aPoint,bPoint);

        }
    }
}

Measured memory_bytes: 9652
a,b = [int(i) for i in input().split()]

flg  = False
for i in range(1,1009):
    a_s = int(i * 0.08)
    b_s = int(i * 0.1)
    
    if (a_s == a) and (b_s == b):
        ans = i
        flg = True
        break
        
print(ans if flg else '-1')


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int k=sc.nextInt();
		
		if(a>=k){
			int n=a-k;
			System.out.println(a-n);
		}
		else if(a+b>=k){
			System.out.println(a);
		}
		else {
			k-=a;
			k-=b;
			System.out.println(a+(k*(-1)));
		}
		
	}
}


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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string

#define sz(x) x.size()
#define INF LONG_MAX
#define IINF LLONG_MAX
#define PI (2.0*acos(0.0))

#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);
#define sfd2(x,y) scanf("%lf %lf",&x,&y);

#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))

#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Rof(i, j, k) for(int i = j; i >= k; i--)
#define all(x) x.begin(),x.end()
#define asort(x) sort(all(x));
#define dsort(x) sort(all(x), greater<int>())
#define unq(x) x.erase(unique(x.begin(),x.end()),x.end())

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;

LL gcd(LL a,LL b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
    return a/gcd(a,b)*b;
}

LL bigmod(LL base, LL power, LL mod)
{
    if(power==0) return 1;
    else if(power%2==1)
    {
        LL value1 = base % mod; LL value2 = (bigmod(base,power-1,mod))%mod;
        return (value1*value2)%mod;
    }
    else
    {
        LL value1 = (bigmod(base,power/2,mod))%mod;
        return (value1*value1)%mod;
    }
}


int main()
{
    int a,b,c,k;
    sfi3(a,b,c); sfi(k);


    int sum = 0;
    while(k--)
    {
        if(a!=0) sum++, a--;
        else if(b!=0)
        {
            b--;
            continue;
        }
        else if(c!=0) sum--, c--;
    }
    cout<<sum;
}


Measured memory_bytes: 3664
# coding: utf-8

n = int(input())
R = [ int(input()) for i in range(n)]

MIN = R[0]
MAXdiff = R[1]-R[0]

for i in range(1,n):
    MAXdiff = max(MAXdiff,R[i]-MIN)
    MIN = min(MIN,R[i])

print(MAXdiff)


Measured memory_bytes: 13600
#include<stdio.h>
#include<stdlib.h>
typedef struct 
{
  char mark;
  int number;
}card;

void bubblesort(card*,int);
void selectionsort(card*,card*,int);

int main(){
  int n,i,j,t;
   card detail[36],detail2[36],cr,vr;
  char a;
  

  scanf("%d",&n);
  
  for(i=0; i<n; i++)
    {
    scanf(" %c%c",&detail[i].mark,&a);
    detail[i].number = atoi(&a);
  }

  for(i=0; i<n; i++)
  detail2[i]=detail[i];
  bubblesort(detail,n);
  selectionsort(detail,detail2,n);
  return 0;
}
  

void bubblesort(card a[],int n){
  int i,j;
  card tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j].number<a[j-1].number){
	tmp=a[j];  //swap
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }

  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a[i].mark,a[i].number);
  }

  printf("\n");
  printf("Stable\n");    
}


void  selectionsort(card a[],card a2[],int n){
  int i,j,minj,count=0;
  card tmp;
  for(i=0; i<=n; i++){
    minj=i;
    for(j=i; j<n; j++){
      if(a2[j].number<a2[minj].number){
	minj=j;
      }
    }
    tmp=a2[i];
    a2[i]=a2[minj];
    a2[minj]=tmp;
}
  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a2[i].mark,a2[i].number);
  }
  printf("\n");

  for(i=0;i<n;i++){
    if(a[i].mark != a2[i].mark || a[i].number != a2[i].number){
      printf("Not stable\n");
      count=1;
      break;
    }
  }
  if(count == 0) printf("Stable\n");
  
}

 



Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.Linq;

public static class Test
{

    public static IEnumerable<S> Scan<T, S>(this IEnumerable<T> ie, S init, Func<S, T, S> predicate)
    {
        var sum = init;
        foreach(var x in ie)
        {
            yield return sum = predicate(sum, x);
        }
    }
    
    public static IEnumerable<T> StartWith<T>(this IEnumerable<T> ie, T init)
    {
        yield return init;
        foreach(var x in ie)
            yield return x;
    }
    
    public static void Main()
    {
        int.Parse(Console.ReadLine());
        IEnumerable<char> directions = Console.ReadLine();
        
        var cost0 = new {
                cost = directions.Skip(1).Count(x => x == 'E'),
                prev = directions.First()
            };
        
        var costs = directions
            .Skip(1)
            .Scan(
                cost0,
                (s, x) => new {
                    cost = (s.cost + (s.prev == 'W' ? 1 : 0) - (x == 'E' ? 1 : 0)),
                    prev = x
                })
            .StartWith(cost0)
            .Select(x => x.cost);
        
        Console.WriteLine(costs.Min());
    }
}


Measured memory_bytes: 18524
/**
   * @Author:Monk78
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define vpshVar() int main()
Vll graph[MAX];
bool visited[MAX];
ll dist[MAX];
void dfs(ll node){
    visited[node]=true;
    for(auto it:graph[node]){
        ll dd=it.S;
        ll xx=it.F;
        if(!visited[xx])
        {
            dist[xx]=dd+dist[node];
            dfs(xx);
        }
    }
}
vpshVar(){
    ll N,u,v,wt;
    sl(N);
    for(ll i=0;i<N-1;i++){
        sl(u);sl(v);sl(wt);
        //u--,v--;
        graph[u].pb(mp(v,wt));
        graph[v].pb(mp(u,wt));
    }
    ms(visited,false);
    dist[1]=0;
    dfs(1);
    for(ll i=1;i<=N;i++){
        pl(dist[i]%2);
        cout<<endl;
    }
return 0;
}
/*
#include <stdio.h>
#include <vector>
#include <utility>
#include <string.h>

#define lli long long int
#define ll pair<lli, lli>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

bool visited[100010];
lli dist[100010];
vector<ll> adj[100010];

void dfs(lli pos) {
	ll x;
	lli nxt;
	visited[pos] = true;
	for (lli j = 0; j < (lli) adj[pos].size(); j++) {
		x = adj[pos][j];
		nxt = x.fi;
		if (!visited[nxt]) {
			dist[nxt] = dist[pos] + x.se;
			dfs(nxt);
		}
	}
}

int main() {
	lli n, u, v, w;
	scanf("%lld", &n);
	for (lli i = 1; i < n; i++) {
		scanf("%lld %lld %lld", &u, &v, &w);
		adj[u].pb(mp(v, w));
		adj[v].pb(mp(u, w));
	}
	dist[1] = 0;
	memset(visited, false, sizeof visited);
	dfs(1);
	for (lli i = 1; i <= n; i++)
		printf("%lld\n", dist[i] % 2);
	return 0;
}


*/


Measured memory_bytes: 9472
#include <cstdio>
#include <algorithm>

using namespace std;

int a[5000];
int dp1[5001][5001];
int dp2[5001][5001];

int main() {
    int n, k, ans, i, j;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    dp1[0][0] = 1;
    
    for (i = 0; i < n; i++) {
        for (j = 0; j <= k; j++) {
            if (dp1[i][j] == 0) continue;
            
            dp1[i + 1][j] = 1;
            dp1[i + 1][min(j + a[i], k)] = 1;
        }
    }
    
    for (i = 0; i <= n; i++) {
        for (j = 1; j <= k; j++) dp1[i][j] += dp1[i][j - 1];
    }
    
    dp2[n][0] = 1;
    
    for (i = n; i > 0; i--) {
        for (j = 0; j <= k; j++) {
            if (dp2[i][j] == 0) continue;
            
            dp2[i - 1][j] = 1;
            dp2[i - 1][min(j + a[i - 1], k)] = 1;
        }
    }
    
    for (i = 0; i <= n; i++) {
        for (j = 1; j <= k; j++) dp2[i][j] += dp2[i][j - 1];
    }
    
    ans = n;
    
    for (i = 0; i < n; i++) {
        if (a[i] >= k) {
            ans--;
            
            continue;
        }
        
        for (j = 0; j < k; j++) {
            if (j > 0 && dp1[i][j] == dp1[i][j - 1]) continue;
            
            if (j >= k - a[i]) {
                ans--;
                
                break;
            }
            
            if (dp2[i + 1][k - j - 1] - dp2[i + 1][k - j - a[i] - 1] > 0) {
                ans--;
                
                break;
            }
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 195584
import numpy as np

U = 10**5
n, W = map(int, input().split())
dp = np.full(U+1, float("inf"))
dp[0] = 0
for _ in range(n):
  w, v = map(int, input().split())
  np.minimum(dp[v:], dp[:-v]+w, out=dp[v:])
ans = np.where(dp <= W)[0][-1]
print(ans)

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

const int N = 1010 , mod = 1e9 + 7;
int n, m;
ll mem[N][N];
char g[N][N];

ll dp(int i , int j){
	if(i == n-1 && j == m-1) return 1;
	if(i >= n || j >= m) return 0;
	if(g[i][j] == '#') return 0;
	ll &ret = mem[i][j];
	if( ret != -1 ) return ret;
	ret = 0;
	return ret = (dp(i+1 , j) + dp(i , j+1))%mod;
}

int main(){
	memset(mem , -1 , sizeof mem);
	scanf("%d%d" , &n , &m);
	for(int i=0 ; i<n ; i++)
		scanf("%s" , &g[i]);
	printf("%lld" , dp(0 , 0));
}


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

int main (void) {
    long long X;
    cin >> X;

    long long ans=0;
    long long money=100;
    while ( money < X ) {
        ans++;
        money *= 1.01;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N;
  scanf("%d",&N);
  std::vector<int > d(N);
  for (int i=0; i<N; i++){
    scanf("%d",&d[i]);
  }
  std::sort(d.begin(), d.end());
  int ans = d[N/2]-d[N/2-1];
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------

int main(){
  int H,W;
  cin >> H >> W;
  char s[H][W];
  rep(i,H){
    rep(j,W) cin >> s[i][j];
  }
  

  rep(i,H){
    rep(j,W){
      if(s[i][j] == '#'){
  	bool f = false;
  	rep(k,4){
  	  int x=j+dx[k],y=i+dy[k];
  	  if(x>=0&&y>=0&&x<W&&y<H){
  	    if(s[y][x]=='#') f=true;
  	  }
  	}
  	if(!f){
  	  cout << "No" << endl;
  	  return 0;
  	}
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

template<typename T,typename U>
bool chmax(T& a,const U& b){if(a<b) return a=b,true; else return false;}

double f(double a,double b,double h)
{
	return (a+b)/2*h;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi ts(n),vs(n);
		rep(i,n) cin>>ts[i];
		rep(i,n) cin>>vs[i];
		vvd dp(n+1,vd(201,-1));
		dp[0][0]=0;
		rep(i,n){
			// 0.5秒ずつ進める(奇数秒区間の中間で減速することがあるため．入力例4)
			for(double t=0;t<ts[i];t+=0.5){
				vd tmp(201,-1);
				for(double v=0;v<=vs[i];v+=0.5){
					if(dp[i][2*v]==-1) continue;
					if(0<v) chmax(tmp[2*v-1],dp[i][2*v]+f(v,v+0.5,0.5));
					chmax(tmp[2*v],dp[i][2*v]+f(v,v,0.5));
					if(v<vs[i]) chmax(tmp[2*v+1],dp[i][2*v]+f(v,v-0.5,0.5));
				}
				dp[i]=tmp;
			}
			dp[i+1]=dp[i];
		}
		printf("%f\n",dp[n][0]);
	}
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner scanner = new Scanner(System.in);
        String X = scanner.next();
        String Y = scanner.next();
        int x = X.codePointAt(0);
        int y = Y.codePointAt(0);
        if(y-x > 0){
            System.out.println("<");
        }
        if(x-y > 0){
            System.out.println(">");
        }
        if(x == y){
            System.out.println("=");
        }
    }

}


Measured memory_bytes: 22996
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	int Year[] = { 1868, 1912, 1926, 1989 };
	int Month[] = { 9, 7, 12, 1 };
	int Day[] = { 8, 30, 25, 8 };
	char* era[] = { "meiji", "taisho", "showa", "heisei" };
	const int wy = 10000;
	const int wm = 100;
	int y, m, d;
	while (scanf("%d %d %d", &y, &m, &d) != EOF)
	{
		int t = y*wy + m*wm + d;
		int i;
		for (i = 0; i < 4 && t >= Year[i]*wy + Month[i]*wm + Day[i]; ++i)
			;
		if (i == 0)
			printf("pre-meiji\n");
		else
		{
			--i;
			printf("%s %d %d %d\n", era[i], y-Year[i]+1, m, d);
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using ll = unsigned long long;
using namespace std;

string s;
vector<string> cands = {"dream", "dreamer", "erase", "eraser"};

bool traverse(int n) {
    
    if(n == s.size()) 
    {
        return true;
    }

    for(const auto& ri : cands) {
        if(n + ri.size() <= s.size() && s.substr(n, ri.size()) == ri) {
            if(traverse(n+ri.size())){
                return true;
            }
        }
    }
    
    return false;

}

int main(void) {
    cin >> s;

    // sol
    // bool can = false;

    reverse(s.begin(), s.end());
    for(vector<string>::iterator itr = cands.begin(); itr != cands.end(); itr++) {
        reverse(itr->begin(), itr->end());
    }

    bool can = traverse(0);

    if(can) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;

int main(void) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll s=c-a;
    ll t=d-b;
    cout << c-t << " " << d+s << " " << a-t << " " << b+s << endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define sort(x) sort(x.begin(), x.end())
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;


int main(){
   ll n, k;
   cin >> n >> k;
   string s;
   cin >> s;
   ll hap = 0;
   rep(i,n){
       hap += (s[i] == s[i+1]);
   }
   cout << min(hap + 2*k, n-1) << endl;
}

Measured memory_bytes: 512
import sys
 
def main():
    input = sys.stdin.readline
    N = int(input())
    S = input().rstrip()
    tree = SegmentTree(initial_values=S, f=lambda x,y:x|y, converter=lambda c: 1 << (ord(c)-ord('a')))
    Q = int(input())
    update = tree.update
    query = tree.query
    for _ in range(Q):
        t, a, b = input().rstrip().split()
        if t == '1': update(int(a)-1, b)
        else: print(bin(query(int(a)-1, int(b))).count('1'))    

class SegmentTree:
    def __init__(self, n=None, f=max, zero_factory=int, converter=lambda x:x, initial_values=None):
        assert(n or initial_values)
        self.__f, self.__z, self.__c = f, zero_factory, converter
        size = n if n else len(initial_values)
        self.__n = 1 << ((size - 1).bit_length())
        d = [zero_factory() for _ in range(2 * self.__n + 1)]
        self.__dat = d
        if initial_values:
            for i, v in enumerate(initial_values): d[self.__n + i] = converter(v)
            for i in range(self.__n - 1, 0, -1): d[i] = f(d[i<<1], d[i<<1|1])

    def update(self, index, value):
        i, v, d = index + self.__n, self.__c(value), self.__dat
        if d[i] == v: return
        d[i] = v
        while i:
            i = i >> 1
            d[i] = self.__f(d[i<<1], d[i<<1|1])

    def query(self, from_inclusive, to_exclusive):
        ans = self.__z()
        if to_exclusive <= from_inclusive: return ans
        l, r = from_inclusive + self.__n, to_exclusive + self.__n
        while l < r:
            if l & 1: ans, l = self.__f(ans, self.__dat[l]), l+1
            if r & 1: ans, r = self.__f(ans, self.__dat[r-1]), r-1
            l, r = l >> 1, r >> 1
        return ans

if __name__ == '__main__':
    main()


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

int n,m;
cin>>n>>m;
vector<int>h(n);
Graph g(n);

rep(i,n)
{cin>>h[i];}
rep(i,m)
{int s,e;
 cin>>s>>e;
 s--;e--;
 g[s].push_back(e);
 g[e].push_back(s);
}
int ans=0;

rep(i,n)
{ int hi=h[i];
  bool isgood=true;
  //cout<<i<<" : ";
  rep(j,g[i].size())
  {
    if(hi<=h[g[i][j]])isgood=false;
    //cout<<hg[i][j]<<" ";
  }
  if(isgood){ans++;}

}
cout<<ans<<endl;
return 0;
}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 8740
#include <iostream>
#include <stdio.h>

int A[11];

int main() {
    for (int i = 0; i < 10; i++) {
        scanf("%d", &A[i]);
    }
    for (int i = 0; i < 3; i++) {
        int max_val = A[i];
        for (int j = i+1; j < 10; j++) {
            if (max_val < A[j]) std::swap(max_val, A[j]);
        }
        A[i] = max_val;
    }
    for (int i = 0; i < 3; i++) {
        printf("%d\n", A[i]);
    }
    return 0;
}



Measured memory_bytes: 3196
#!/usr/bin/env python
# -*- coding: utf-8 -*-


class Node(object):

  def __init__(self, pos):
    self.pos = pos
    self.highest = True


def main():
  _, M = map(int, input().split())
  nodes = [Node(v) for v in map(int, input().split())]

  for _ in range(M):
    a, b = map(int, input().split())
    a = nodes[a - 1]
    b = nodes[b - 1]

    if a.pos <= b.pos:
      a.highest = False

    if b.pos <= a.pos:
      b.highest = False

  print(len([n for n in nodes if n.highest]))


if __name__ == '__main__':
  main()


Measured memory_bytes: 90228