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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
int32_t main()
{
	int a,b;
	cin >> a >> b;
	if(a < b)
		swap(a,b);
	for(int i = 0;i<a;i++)
		cout << b;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  for (int i = 0; i < 1000; i++){
    c -= b;
    if (c <= 0){
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}



signed main()
{
	//IOS();
	vector<int>ans;
	while(1){
		int N;
		cin>>N;
		if(N==0)break;
		vector<double>a(N);
		int sum = 0;
		rep(i,0,N){
			cin>>a[i];
			sum += a[i];
		}
		double ave =(double) sum / N;
		int cnt = 0;
		rep(i,0,N){
			if(a[i]<=ave)cnt++;
		}
		ans.push_back(cnt);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}



Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
//priority_queue<int, vector<int>, std::greater<int> >
int main()
{
    lli ac=0,tle=0,re=0,wa=0;
    lli n;
    cin>>n;
    string s;
    for(lli i=0;i<n;i++)
    {
        cin>>s;
        if(s=="RE")
        {
            re++;
        }
        else if(s=="WA")
        {
            wa++;
        }
        else if(s=="TLE")
        {
            tle++;
        }
        else if(s=="AC")
        {
            ac++;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n){
		int s[n];
		double sum=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			sum+=s[i];
		}
		double ave=sum/n;
		sum=0.0;
		for(int i=0;i<n;i++) sum+=(s[i]-ave)*(s[i]-ave);
		cout<<sqrt(sum/n)<<endl;
		cin>>n;
	}
	return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
using namespace std;

int main() {
    fio;
    ll n;
    cin >> n;
    ll a[n];
    For(i, 0, n)
        cin >> a[i];
    ll mx = 0;
    ll ans = 0;
    For(i, 0, n) {
        mx = max(a[i], mx);
        if(mx >= a[i]) {
            ans += mx - a[i];
        }
    }
    cout << ans;
}

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

int N, K, Q, A[100009], minx = (1 << 30); bool P[100009];

int solve(int B) {
	for (int i = 1; i <= N; i++) {
		if (A[i] < B) P[i] = true; else P[i] = false;
	}
	vector<int>S, T;
	for (int i = 1; i <= N + 1; i++) {
		if (P[i] == true || i == N + 1) {
			sort(T.begin(), T.end());
			if (T.size() >= K) { for (int j = 0; j < T.size() - K + 1; j++) S.push_back(T[j]); }
			T.clear();
		}
		else {
			T.push_back(A[i]);
		}
	}
	sort(S.begin(), S.end());
	if (S.size() < Q) return (1 << 30);
	return S[Q - 1] - S[0];
}

int main() {
	cin >> N >> K >> Q;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) {
		minx = min(minx, solve(A[i]));
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst ll T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    string s;
    cin >> s;
    cout << s.substr(0, 3);
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int max(int a, int b)
{
	return a>b ? a: b;
}

int min(int a, int b)
{
	return a<b ? a: b;
}
int main()
{
	int a[200000];
	int n, maxv, minv;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	maxv = -2000000000;
	minv = a[0];
	for(int i =1; i < n; i++)
	{
		
		maxv = max(maxv, a[i] - minv);
		minv = min(minv, a[i]);
	}
	printf("%d\n", maxv);
	return 0;
}


Measured memory_bytes: 3516
/* Never Say Die. */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <ctime>
#include <cstdlib>
#include <cassert>
using namespace std;
int _c = 0;
template <class _T> inline void read(_T &_a) {
	_a = 0; bool _f = 0;
	while (_c < '0' || _c > '9') _f |= _c == '-', _c = getchar();
	while (_c >= '0' && _c <= '9') _a = _a * 10 + _c - '0', _c = getchar();
	if (_f) _a = -_a;
}
typedef long long LL;
typedef long double LD;
#define MAXN 200005
 
struct edge {
	int next, to;
} e[MAXN * 2];
 
int n, ecnt = 0;
int root, d[MAXN], head[MAXN];
void add(int u, int v) {
	d[u]++, d[v]++;
	e[++ecnt].to = v; e[ecnt].next = head[u]; head[u] = ecnt;
	e[++ecnt].to = u; e[ecnt].next = head[v]; head[v] = ecnt;
}
LL a[MAXN], tot[MAXN];
 
 
bool dfs(int x, int fa) {
	bool lf = 1;
	for (int now = head[x]; now; now = e[now].next) {
		if (e[now].to != fa) {
			lf = 0;
			if (dfs(e[now].to, x)) return 1;
			tot[x] += a[e[now].to];
		}
	}
	if (!lf) {
		LL ta = 2 * a[x] - tot[x], su = 0;
		if (ta < 0) return 1;
		for (int now = head[x]; now; now = e[now].next) {
			if (e[now].to != fa) {
				su = min(2 * (a[x] - ta), su + min(a[x] - ta, a[e[now].to]));
			}
		}
		if (su < 2 * (a[x] - ta)) return 1; 
		a[x] = ta;
	}
	return 0;
}
 
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	if (n == 2) return puts(a[1] == a[2] ? "YES" : "NO"), 0;
	for (int i = 1, u, v; i < n; i++) cin >> u >> v, add(u, v);
	for (int i = 1; i <= n; i++) if (d[i] != 1) {root = i; break;}
	if (!root) return puts("NO"), 0;
	if (dfs(root, 0) || a[root]) return puts("NO"), 0;
	puts("YES");
	return 0;
}




Measured memory_bytes: 8192
N = int(input())
ans = -1
NG = 0
A = list(map(int, input().split()))
while (NG == 0):
    for i in range(N):
        if (A[i] % 2 != 0):
            NG = 1
        A[i] = A[i] // 2
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007

int main(){
    char s[4];
    scanf("%s",s);
    if(s[0]!=s[1]||(s[1]!=s[2]||s[0]!=s[2]))printf("Yes");
    else printf("No");
}

Measured memory_bytes: 256
D,G=map(int,input().split())
G/=100
P=[]
C=[]
for _ in range(D):
    x,y=map(int,input().split())
    P.append(x)
    C.append(y//100)

ans=10**9
for x in range(2**D):
    cost=0
    value=0
    for i in range(D):
        if (x>>i)%2==1:
            value += P[i]*(i+1) + C[i]
            cost += P[i]
    for i in range(D-1,-1,-1):
        if value >= G:
            break
        elif (x>>i)%2==0:
            for _ in range(P[i]-1):
                value += i+1
                cost += 1
                if value>=G:
                    break
    if value>=G:
        ans=min(ans,cost)
print(ans)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;


int main(){
    int n;  cin >> n;
    int a;
    vector<pair <int , int >> stu(n);
    for(int i=0;i<n;i++){
        cin >> a;
        stu[i] = make_pair(a,i+1);
    }
    sort(stu.begin(),stu.end());
    for(int i=0;i<n;i++){
        cout << stu[i].second << " ";
    }
    cout << endl;
}




Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,a,b;cin>>n>>a>>b;
    if((b-a)%2==0)cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define int long long
const int N=1e5+10,L=32;
int n,x,w[N],mc[N],f[N][L];
main(){
	scanf("%lld",&n);
	//Ã¿¸öµãÒª¾­¹ýw[i]´Î´©Ô½²Ù×÷ºÍmc´Î¶Ëµã²Ù×÷. 
	for (int i=1;i<=n;++i){
		scanf("%lld",&x);
		for (int v=x>>1;v;v>>=1) ++w[i];
		if ((1<<w[i])!=x) mc[i]=1;
	}
	//f[i][j]±íÊ¾ÔÚiºÅµã,µ±Ç°»¹ÓÐj´Î¶Ëµã²Ù×÷µÄ×îÐ¡´ú¼Û
	memset(f,0x3f,sizeof f); 
	for (int j=0;j<L;++j) f[0][j]=j;
	for (int i=1;i<=n;++i){
		for (int j=0;j<L;++j)
			if (mc[i]){
				if (j<L-1&&w[i]>=j) f[i][j]=min(f[i][j],f[i-1][j+1]+w[i]-j);//ºÍÇ°ÃæµÄ×ó¶ËµãºÏ²¢. 
				if (j&&w[i]>=j-1) f[i][j]=min(f[i][j],f[i-1][j-1]+w[i]-j+2);//ÐÂ¿ª×ó¶Ëµã. 
			}else{
				if (w[i]>=j) f[i][j]=min(f[i][j],f[i-1][j]+w[i]-j);
			}
		for (int j=L-2;~j;--j) f[i][j]=min(f[i][j],f[i][j+1]);
		for (int j=1;j<L;++j) f[i][j]=min(f[i][j],f[i][j-1]+1);
	}
	printf("%lld",f[n][0]);
	return 0;
}

Measured memory_bytes: 26880
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007



int main() {
  int N, K;
  cin >> N >> K ;
  vector<int> l(N);
  rep(i, N) cin >> l.at(i);

  sort(all(l), greater<int>());
  
  int ans = 0;
  rep(i, K) ans += l.at(i);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
using namespace std;
typedef  long long ll;
int d[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>d[i];
    }
    sort(d,d+n);
    cout<<d[(n-1)/2+1]-d[(n-1)/2]<<endl;
    return 0;
}



Measured memory_bytes: 640
// 2020-07-05 21:02:09
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << '\n';
  cout << "WA x " << mp["WA"] << '\n';
  cout << "TLE x " << mp["TLE"] << '\n';
  cout << "RE x " << mp["RE"] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3664
/*
 * Matheus Oliveira
 * 09:58:37 02/06/2019
 * b2.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN 200100
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, ini, fim) printf("%s: ", #x); for(int i = ini; i <= fim; i++) printf("%d%c", x[i], (i == fim) ? '\n' : ' ');

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

char inp[MAXN];

int main() {
	scanf("%s", inp);
	ll ans = 0;
	int n = strlen(inp), auxa = 0;
	
	for(int i = 0; i < n; i++) {
		if(inp[i] == 'A') auxa++;
		else auxa = 0;

		if(i+2 < n) {
			if(inp[i] == 'A' and inp[i+1] == 'B' and inp[i+2] == 'C') {
				ans += ((ll) auxa);
				
				if(auxa == 1) inp[i] = 'B', inp[i+1] = 'C', inp[i+2] = 'A', auxa = 0;
				if(auxa == 2) inp[i] = 'C', inp[i+1] = 'A', inp[i+2] = 'A', auxa = 0;
				if(auxa >= 3) inp[i] = 'A', inp[i+1] = 'A', inp[i+2] = 'A', auxa -= 2;
			}
		}
	}

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>


int main(void){
    int al,b,c,d,e,k;
    int a[10];
    scanf("%d",&al);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&k);
    a[0]=k+al-b;
    a[1]=(k+al-c);
    a[2]=(k+al-d);
    a[3]=(k+al-e);
    a[4]=(k+b-c);
    a[5]=(k+b-d);
    a[6]=(k+b-e);
    a[7]=(k+c-d);
    a[8]=(k+c-e);
    a[9]=(k+d-e);
    for(int i=0;i<10;i++){
        if(a[i]<0){
            printf(":(");
            return 0;
        }
    }
    printf("Yay!");
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
	int i,flg,ren;
	char a[11],b[11];
	flg=0;
	scanf("%s %s",a,b);
	ren=strlen(a);
	for(i=0;i<ren;i++){
		if(a[i]!=b[i]){
			flg=1;
			break;
		}
	}
	if(flg==1){
		printf("No\n");
	}
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1632
/*************************************************************************
        > File Name: b.cpp
        > Author: BlockChanZJ
        > Mail: 386636627@qq.com 
        > Created Time: 2018年05月27日 星期日 10时28分27秒
     ************************************************************************/
     
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <string>
    #include <map>
    #include <set>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <ctime>
    #include <queue>
    #include <cassert>
    #include <iomanip>
    using namespace std;
     
    #define rep(i,a,b) for(int i = (a); i <= (b); ++i)
    #define per(i,a,b) for(int i = (a); i >= (b); --i)
    #define pb push_back
    #define mp make_pair
    #define all(x) (x).begin(), (x).end()
    #define fi first 
    #define se second
    #define SZ(x) ((int)(x).size())
    #define sqr(x) (x) * (x)
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> PII;
    typedef vector<int> VI;
    typedef pair<PII,int> PIII;
    const int N = 100005;
    const int P = 1000000007;
    const ll mod = P;
    const int INF = 0x3f3f3f3f;
    const ll LLINF = 0x3f3f3f3f3f3f3f3f;
    const ld eps = 1e-8;
    ll qmod(ll a,ll n,ll mod){ll ans=1;while(n){assert(ans>0);if(n&1ll)ans=ans*a%mod;n>>=1;a=a*a%mod;}return ans%mod;}
     
    //head
     
    //your code goes there
     
    int pre[105][27], suf[105][27];
    char s[105];
    int n;
    int main()
    {
    	cin >> n >> (s+1);
    	rep(i,1,n)
    	{
    		rep(j,0,25) pre[i][j]=pre[i-1][j];
    		pre[i][s[i]-'a']++;
    	}
    	per(i,n,1)
    	{
    		rep(j,0,25) suf[i][j]=suf[i+1][j];
    		suf[i][s[i]-'a']++;
    	}
    	int Max = 0;
    	rep(i,1,n)
    	{
    		int cnt = 0;
    		rep(j,0,25) cnt = cnt+(pre[i][j]&&suf[i+1][j]);
    		Max = max(Max, cnt);
    	}
    	cout << Max << endl;
    	return 0;
    }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  while(1){
    int x,y,s,ans=0,a,b,m;
    cin>>x>>y>>s;
    if(x==0)break;
    for(a=1;a<s;a++)
      for(b=a;a+b<=s;b++){
	m=a*(100+y)/100+b*(100+y)/100;
	if(a*(100+x)/100+b*(100+x)/100==s&&ans<m)ans=m;
      }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int res = 0, current = 10;
      while(sc.hasNext()){
        int a = sc.nextInt();
        if(a%10 == 0){res-=10;}
        else if(a%10 < current){current = a%10;}
        
        res += (a/10+1)*10;
      }
      System.out.println(res - 10 + current);
    }
}

Measured memory_bytes: 25300
N, W = map(int, input().split())
item = [list(map(int, input().split())) for i in range(N)]

dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(1, W+1):
        if w - item[i][0] >= 0:
            dp[i+1][w] = max(
                dp[i][w],
                dp[i][w-item[i][0]] + item[i][1]
            )
        else:
            dp[i+1][w] = dp[i][w]
print((dp[N][W]))




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


int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N, -1);
    vector<int> ans(N, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    
    while(!que.empty()){
        int v = que.front();
        que.pop();
        
        for(int nv : G[v]){
            if (dist[nv] != -1) continue;

            dist[nv] = dist[v] + 1;
            ans[nv] = v;
            que.push(nv);
        }
    }

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

Measured memory_bytes: 10496
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[])
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int sum = 0;
    for (int i = 0; i <= a; i++)
        for (int j = 0; j <= b; j++)
            for (int k = 0; k <= c; k++)
                if (i*500+j*100+k*50 == x) sum++;
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 256
import sys

S= list(input())
#ループカウンタ
count =-1
#フラグ
flug =0
#奇数の数列[0,2,4,6...]の時にR,U,Dのいずれか
for i in range(len(S)):
    count +=1
    #奇数の時
    if(count %2 == 0):
        #踏みやすい場合
        if(S[count]== 'R' or S[count] == 'U' or S[count] == 'D'):
            continue
        #踏みにくい場合
        else:
            print('No')
            sys.exit()
    #偶数の場合
    if(count %2 == 1):
        if(S[count]== 'L' or S[count] == 'U' or S[count] == 'D'):
            continue
        #踏みにくい場合
        else:
            print('No')
            sys.exit()
    
print('Yes')
        
        

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	int res=0;
	for(int i=1;i<=m;i++){
		int a;
		cin>>a;
		res+=a;
	}
	if(res>n) cout<<-1<<endl;
	else cout<<n-res<<endl;
    return 0;
}


Measured memory_bytes: 3652
<?php
  list($a,$b)=explode(" ",trim(fgets(STDIN)));
$array=[];
for($i=0;$i<$b;$i++){
  $c=trim(fgets(STDIN));
  $num=explode(" ",trim(fgets(STDIN)));
  foreach($num as $d){
    $array[$d]=1;
  }
}
echo $a-count($array);

Measured memory_bytes: 16320
import Data.Maybe

type Grade = String

grade :: Int -> Int -> Int -> Maybe Grade
grade (-1) (-1) (-1) = Nothing
grade m f r
    | m == -1 || f == -1 = Just "F"
    | s >= 80 = Just "A"
    | s >= 65 = Just "B"
    | s >= 50 = Just "C"
    | s >= 30 = Just (if r >= 50 then "C" else "D")
    | otherwise = Just "F"
    where s = m+f

main = getContents >>=
        mapM_ (putStrLn . fromJust) . takeWhile isJust .
            map ((\[m,f,r] -> grade m f r) . map read . words) . lines

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define RSORT(o) sort((o).rbegin(), (o).rend())


int  x , y , a , b , c;


main( ) {
	cin >> x >> y >> a >> b >> c;
	vector<int> r( a ) , g( b ) , rg( c );
	rep( i , a )cin >> r[ i ];
	rep( i , b )cin >> g[ i ];
	rep( i , c )cin >> rg[ i ];
	RSORT( r );
	RSORT( g );
	rep( i , x ) rg.push_back( r[ i ] );
	rep( i , y ) rg.push_back( g[ i ] );
	RSORT( rg );
	long long ans=0;
	rep( i , x + y )ans += rg[ i ];
	cout << ans;

}


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

int main(){
    vector<int> a(3);
    for(int i = 0; i < 3; i++){
        cin >> a.at(i);
    }
    
    sort(a.begin(), a.end());
    
    int tmp = 0;
    int ans = 3;
    for(int i = 0; i < 3;i++){
        if(a.at(i) == tmp){
            ans--;
        }
        tmp = a.at(i);
    }
    
    cout << ans << endl;       
}




Measured memory_bytes: 256
S = str(input())
Q = int(input())

head = ""
tail = ""
main = ""

main = S

status = 0

while Q:
  Q -= 1
  l = list(map(str,input().split()))
  if l[0] == "1":
    status = 1-status
  else:
    letter = l[2]
    if l[1] == "1":
      if status == 0:
        head += letter
      else:
        tail += letter
    else:
      if status == 0:
        tail += letter
      else:
        head += letter

if status == 0:
  print(head[::-1]+main+tail)
else:
  print(tail[::-1]+main[::-1]+head)
  


Measured memory_bytes: 4468
N,M=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in range (N):
  s+=a[i]
a.sort(reverse=True)
if s%(4*M)==0:
  if a[M-1]>=s//(4*M):
    print("Yes")
  else:
    print("No")
else:
  if a[M-1]>=(s//(4*M)+1):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; ll x; cin >> n >> x;
    vector<ll> vec;
    for(int i = 0; i < n; i++){
        ll t; cin >> t; vec.pb(t);
    }
    vec.pb(x); sort(vec.begin(),vec.end());
    vector<ll> vec2;
    for(int i = 0; i < vec.size()-1; i++){
        vec2.pb(vec[i+1]-vec[i]);
    }
    ll res = vec2[0];
    for(int i = 1; i < vec2.size(); i++){
        res = __gcd(res, vec2[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5496
import sys
input=lambda: sys.stdin.readline().rstrip()
from collections import defaultdict
n=int(input())
D=defaultdict(int)
i=1
while i*(i+1)//2<=10**5:
  D[i*(i+1)//2]=i
  i+=1
if D[n]==0:
  print("No")
else:
  print("Yes")
  k=D[n]+1
  print(k)
  A=[[0]*(k) for _ in range(k)]
  for i in range(k):
    A[i][0]=k-1
  D=dict()
  D[1]=1*k+1
  for i in range(2,n+1):
    d1,d2=D[i-1]//k,D[i-1]%k
    if d2==k-d1:
      D[i]=(d1+1)*k+1
    else:
      D[i]=d1*k+d2+1
  for i in range(1,n+1):
    d1,d2=D[i]//k,D[i]%k
    A[d1-1][d1+d2-1]=i
    A[d1+d2-1][d1]=i
  for a in A:
    print(*a)


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


int main(){
    int num[3];
    int ans = 0;
    cin >> num[0] >> num[1] >> num[2];
    sort(num,num+3);

    ans += num[2]-num[1];
    num[0]+=num[2]-num[1];
    num[1]=num[2];

    ans += (num[2]-num[0])/2;
    num[0] += ((num[2]-num[0])/2)*2;

    if(num[0]!=num[2])ans += 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int n;
ll z,w;
vector<ll>a;
ll solve(){
   ll ans=0;
   if(n==1){
       ans=abs(a[n-1]-w);
   }else{
       ans=max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]));
   }

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

    cin>>n>>z>>w;
    rep(i,n){
        ll ai;
        cin>>ai;
        a.push_back(ai);
        }
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long double a, b, c;

	std::cin >> a >> b >> c;

	if (std::sqrt(a) + std::sqrt(b) + 1.0E-14 < std::sqrt(c)) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll h, w;
    cin >> h >> w;

    vvl board(h, vl(w));  // board[i][j] : 黒なら1
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '#') {
                board[i][j] = 1;
            }
        }
    }

    vvl dp(h, vl(w));  // dp[i][j] : (i,j)に到達するための操作回数の最小値
    if(board[0][0]) {
        dp[0][0] = 1;
    }
    rep(i, h-1) {
        if(board[i][0] == 0 && board[i+1][0] == 1) {
            dp[i+1][0] = dp[i][0] + 1;
        }
        else {
            dp[i+1][0] = dp[i][0];
        }
    }
    rep(j, w-1) {
        if(board[0][j] == 0 && board[0][j+1] == 1) {
            dp[0][j+1] = dp[0][j] + 1;
        }
        else {
            dp[0][j+1] = dp[0][j];
        }
    }

    exrep(i, 1, h-1) {
        exrep(j, 1, w-1) {
            ll x = dp[i][j-1];
            ll y = dp[i-1][j];
            if(board[i][j] == 1) {
                if(board[i][j-1] == 0) {
                    x++;
                }
                if(board[i-1][j] == 0) {
                    y++;
                }
            }
            dp[i][j] = min(x, y);
        }
    }
    
    out(dp[h-1][w-1]);
    re0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    int n;
    cin>>n;
    int max=0;
    long long ans=0;
    rep(i,n){
        int a;
        cin>>a;
        if(a<max) ans+=max-a;
        else max=a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

const ll INF = 1e15;
int n, z, w;
ll dp[2000][2];
vi a;

ll solve(int p, int t)
{
	if (dp[p][t] >= 0) return dp[p][t];
	ll res;
	if (t == 0)
	{
		res = 0;
		int x;
		if (p == 0) x = w;
		else x = a[p - 1];
		chmax(res, abs(x - a.back()));
		FOR(i, p, n - 1) chmax(res, solve(i + 1, 1));
	}
	else
	{
		res = INF;
		int x = a[p - 1];
		chmin(res, abs(x - a.back()));
		FOR(i, p, n - 1) chmin(res, solve(i + 1, 0));
	}
	return dp[p][t] = res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> n >> z >> w;
	MS(dp, -1);
	a.resize(n); cin >> a;
	cout << solve(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

#define BLACK   ('.')
#define RED     ('#')
#define MAN     ('@')
#define VISITED ('X')

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

int dfs(std::vector<std::vector<char> >& tiles, const int width, const int height, const int x, const int y) {
  if (tiles[y][x] == VISITED)
    return 0;
  tiles[y][x] = VISITED;
  int retval = 1;
  for (int i = 0; i < 4; ++i) {
    int cx = x + dx[i], cy = y + dy[i];
    if (cx < 0 || cy < 0 || width <= cx || height <= cy || tiles[cy][cx] == VISITED || tiles[cy][cx] == RED)
      continue;
    retval += dfs(tiles, width, height, cx, cy);
  }
  return retval;
}

int main(int argc, char const* argv[])
{
  while (true) {
    int W, H;
    std::cin >> W >> H;
    if (W == 0 && H == 0)
      break;
    int ix, iy;
    std::vector<std::vector<char> > tiles(H, std::vector<char>(W, '\0'));
    for (int y = 0; y < H; ++y) {
      for (int x = 0; x < W; ++x) {
        std::cin >> tiles[y][x];
        if (tiles[y][x] == MAN) {
          ix = x;
          iy = y;
        }
      }
    }
    std::cout << dfs(tiles, W, H, ix, iy) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{

	string s,t;
	cin >> s >> t;

	long long Acount = 0;
	long long Bcount = t.length();

	//int A[5]
	//sort(A, A + 5);

	for (long long i = 0; i <1 + s.length() - t.length(); i++)
	{
		for (long long j = 0; j < t.length(); j++)
		{
			if (s[i + j] != t[j])
			{
				Acount++;
			}
		}
		if (Bcount > Acount)
		{
			Bcount = Acount;
		}
		Acount = 0;
	}

	if (true)
	{
		cout << Bcount << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int x, y, z, n, m, s, t;
    cin >> x >> y >> z >> n >> m >> s >> t;
    s--, t--;
    s += x+y+z;
    t += x+y+z+n;
    int all = x+y+z+n+m;
    vector<int> v[all];
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        b += x;
        v[x+y+z+i].push_back(a);
        v[x+y+z+i].push_back(b);
        v[a].push_back(x+y+z+i);
        v[b].push_back(x+y+z+i);
    }
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        a += x;
        b += x+y;
        v[x+y+z+n+i].push_back(a);
        v[x+y+z+n+i].push_back(b);
        v[a].push_back(x+y+z+n+i);
        v[b].push_back(x+y+z+n+i);
    }
    vector<int> d(all, 1<<30);
    queue<int> q;
    q.push(s);
    d[s] = 0;
    while(!q.empty()){
        int x = q.front();  q.pop();
        if(x == t){
            cout << d[x]/2 << endl;
            return 0;
        }
        for(int next : v[x]){
            if(d[next] == 1<<30){
                d[next] = d[x]+1;
                q.push(next);
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

const int N=1005,P=1E9+7;

struct mat{
	ll a,b,c,d;mat(ll _a=0,ll _b=0,ll _c=0,ll _d=0){a=_a%P,b=_b%P,c=_c%P,d=_d%P;}
	mat operator*(const mat&x)const{return mat(a*x.a+b*x.c,a*x.b+b*x.d,c*x.a+d*x.c,c*x.b+d*x.d);}
};
int n,m;ll K;
char s[N][N];
bool f1,f2;
inline int power(int a,ll t){static int r;for(r=1;t;a=(ll)a*a%P,t>>=1)if(t&1)r=(ll)r*a%P;return r;}
inline mat power(mat a,ll t){static mat r;for(r=mat(1,0,0,1);t;a=a*a,t>>=1)if(t&1)r=r*a;return r;}

int main(){
	scanf("%d%d%lld",&n,&m,&K);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=m;i++)f1|=s[1][i]=='#'&&s[n][i]=='#';
	for(int i=1;i<=n;i++)f2|=s[i][1]=='#'&&s[i][m]=='#';
	if(f1&&f2)puts("1"),exit(0);
	int c=0;
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)c+=s[i][j]=='#';
	K--;
	if(!f1&&!f2)printf("%d\n",power(c,K)),exit(0);
	int a=0,b=0;
	if(f1){
		for(int j=1;j<=m;j++){
			a+=s[1][j]=='#'&&s[n][j]=='#';
			for(int i=1;i<n;i++)b+=s[i][j]=='#'&&s[i+1][j]=='#';
		}
	}else{
		for(int i=1;i<=n;i++){
			a+=s[i][1]=='#'&&s[i][m]=='#';
			for(int j=1;j<m;j++)b+=s[i][j]=='#'&&s[i][j+1]=='#';
		}
	}
	mat now=power(mat(a,0,b,c),K);
	int ans=(power(c,K)-now.c+P)%P;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int add(int a, int b){return  a + b > mod ? a + b - mod : a + b;}
int mul(int a, int b){return a * b > mod ? a * b % mod : a * b;}
ll a[N], b[N];
ll acca[N], accb[N];
int main(){
    //FL;
    FIN;
    int n, m;
    ll k;
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++)cin >> a[i];
    for(int i = 1; i <= m; i++)cin >> b[i];
    acca[1] = a[1];
    accb[1] = b[1];
    for(int i = 2; i <= n; i++)acca[i] = acca[i - 1] + a[i];
    for(int i = 2; i <= m; i++)accb[i] = accb[i - 1] + b[i];   
    int ans = 0;
    for(int i = 0; i <= n; i++){
        int l = 0, h = m + 1, mid;
        if(acca[i] <= k){
            while(h - l > 1){
                mid = (h + l) >> 1;
                if(accb[mid] <= k - acca[i])
                    l = mid;
                else
                    h = mid;

            }   
            if(accb[l] + acca[i] > k)
                l = 0;

            ans = max(ans, l + i);

        }
    }
    cout << ans << '\n';
    EjecuteTime;
    return 0;
}       


Measured memory_bytes: 10040
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int width = sc.nextInt();
        int height = sc.nextInt();
        
        int area = width * height;
        int allLines = (width + height) * 2;
        
        System.out.println(area + " " + allLines);
    }
}

Measured memory_bytes: 17304
def main():
    n = input()
    keta = int(n[-1])
    ans = ""
    if keta == 3:
        ans = "bon"
    elif keta == 0 or keta == 1 or keta == 6 or keta == 8:
        ans = "pon"
    else:
        ans = "hon"
    print(ans) 

if __name__ == '__main__':
  main()

Measured memory_bytes: 9104
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define ll long long
#define REP(i, n) for(ll i = 0; i < n; i++)
 
int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i,N){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  ll ans=0;
  REP(i,N){
    ll num=1;
    while(A[i] == A[i+1]){
      num++;
      i++;
    }
    if(num%2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int A,B,C,X;
    cin >> A >> B >> C >> X ;

    int count=0;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                if(500*i + 100*j + 50*k ==X){
                    count++;
                }
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int x=scan.nextInt();
		int y=scan.nextInt();
		if(y>=(2*x) && y<=(4*x) && y%2==0) System.out.println("Yes");
		else System.out.println("No");
		

	}

}


Measured memory_bytes: 35632
import sys
sys.setrecursionlimit(10 ** 6)

N, *A = map(int, open(0))

E = [[] for _ in [0] + A]
for i, v in enumerate(A, 1):
    E[v - 1] += i,

def dfs(v):
    D = sorted(map(dfs, E[v]))
    l = len(D)
    return max([0] + [l - i + d for i, d in enumerate(D)])

print(dfs(0))


Measured memory_bytes: 204496
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
  int L, R;
  cin >> L >> R;
  //cout << L / 2019 << endl;
  //cout << R / 2019 << endl;
  if (L / 2019 != R / 2019) {
    cout << 0 << endl;
    return 0;
  }
  int m = 2019;
  for (int i = L; i < R; i++) {
    for (int j = i + 1; j <= R; j++) {
      int tmp = ((i % 2019) * (j % 2019)) % 2019;
      if (tmp < m) {
        //cout << i << "," << j << endl;
        m = tmp;
      }
      if (m == 0) {
        cout << m << endl;
        return 0;
      }
    }
  }
  cout << m << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    multiset<ll> s;
    rep(i,n){
        ll a; cin>>a;
        if (s.empty()){
            s.ins(a);
            continue;
        }
        auto itr = s.lower_bound(a);
        if (itr==s.begin()){
            s.ins(a);
        }else{
            s.erase(--itr);
            s.ins(a);
        }
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string SN = to_string(N);
  bool ans = false;
  for (int i = 0; i < SN.size(); i++){
    if(SN.at(i) == '7'){
      ans = true;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

long long modpow(long long a, long long n, long long MOD) {//a^n(MOD)を求める
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;//次の準備
        n >>= 1;
    }
    return res;
}

const ll MAX = 200010;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


ll f(ll n){
  if(n==0)return 1;
  ll ans=(n+2)*modpow(2ll,(n-1),mod);
  ans%=mod;
  //cerr<<ans<<ENDL;

  return ans;
}

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

  ll n,ans=0;cin>>n;
  V<ll> v(n);
  rep(i,0,n)cin>>v[i];
  sort(all(v));

  rep(i,0,n){
    ll res=f(n-1-i);
    //cerr<<res<<ENDL;
    res%=mod;
    res*=v[i];
    res%=mod;
    res*=modpow(2ll,n,mod);
    res%=mod;
    res*=modpow(2ll,i,mod);

    ans+=res;
    ans%=mod;

    //cerr<<ans<<ENDL;
  }

  cout<<ans<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	std::vector<int> vec;
	std::vector<int> p;
	int n;
	int ans = 0;
	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		vec.push_back(a);
	}
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		p.push_back(a);
	}

	for (int i = 0; i < n; ++i) {
		if (vec[i] > p[i]) {
			ans += vec[i] - p[i];
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskC   {
StringBuilder ans = new StringBuilder();

public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        if(N == 0) out.println(0);
        else {
            rec(N);
            out.println(ans.reverse());
        }
    }

void rec(int N) {
        if(N==0)return;
        ans.append(yo(N, -2));
        rec(syo(N, -2));
    }

int syo(int n1, int n2) {
        if(n1>=0) return n1/n2;
        else return (n1-Math.abs(n2)+1)/n2;
    }

int yo(int n1, int n2) {
        if(n1>=0) return n1%n2;
        else return ((Math.abs(n2) + n1%n2)%n2);
    }

}
}



Measured memory_bytes: 21844
fun main(args:Array<String>){
    var (a,b,k) = readLine()!!.split(" ").map{it.toLong()}
    val t : Long = Math.min(a,k)
    a -= t
    k -= t
    if(k > 0) b = Math.max(0L, b - k)
    println(a.toString() + " " + b)
}

Measured memory_bytes: 37872
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B;cin>>A>>B;
  string S;cin>>S;
  bool isok = true;
  repeat(i,S.length()){
    isok &= i==A? S[i]=='-':('0'<=S[i]&&S[i]<='9');
  }
  cout << (isok? "Yes":"No")<<endl;
  return 0;
}


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

using namespace std;

#define lli long long int

lli mx=1000000007;

lli dp[2000][2000];

int main()
{
    lli h,w;
    ///cout<<dp[1005][1005]<<endl;
    cin>>h>>w;
    string s[h+5];
    for(int i=0;i<h;i++)
    {
        cin>>s[i];
    }
    for(int i=1;i<w;i++)
    {
        if(s[0][i]=='#')
            break;
        else
            dp[0][i]=1;
    }
    for(int i=1;i<h;i++)
    {
        if(s[i][0]=='#')
            break;
        else
            dp[i][0]=1;
    }
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(s[i][j]!='#')
            dp[i][j]=((dp[i-1][j]%mx)+(dp[i][j-1]%mx))%mx;
        }
    }
    cout<<dp[h-1][w-1];
    return 0;
}


Measured memory_bytes: 17152
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
 
 
int main(){
 int r;
 cin >> r;
 double ans ;
 ans = 2*r*M_PI;
 printf("%.10f\n",ans);
   }

Measured memory_bytes: 3748