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

int main(){
    string s;
    cin>>s;
    int i=0;
    while(i<s.size()){
        if(s.substr(i,7)=="dreamer"){
            if(s[i+7]=='a') i+=5;
            else if(s[i+7]=='d'||s[i+7]=='e') i+=7;
            else if(i+7==s.size()){
                cout<<"YES"<<endl;
                return 0;
            }
            else i+=7;
        }
        else if(s.substr(i,6)=="eraser"){
            if(i+6==s.size()){
                cout<<"YES"<<endl;
                return 0;
            }
            else i+=6;
        }
        else if(s.substr(i,5)=="erase"||s.substr(i,5)=="dream"){
            if(i+5==s.size()){
                cout<<"YES"<<endl;
                return 0;
            }
            else i+=5;
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include<map>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;

int main()
{
    ll n, q;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }
    cin >> q;
    sort(all(a));
    vector<pair<ll, ll>> bc(q);
    rep(i, q)
    {
        cin >> bc[i].first >> bc[i].second;
    }

    ll num;
    map<ll, ll> c;
    for (int i = 0; i < q; i++)
    {
        num = (upper_bound(all(a), bc[i].first) - lower_bound(all(a), bc[i].first));
        c.insert(make_pair(bc[i].first, num));
    }

    for (int i = 0; i < q; i++) {
        sum += (bc[i].second - bc[i].first) * c[bc[i].first];
        c[bc[i].second] += c[bc[i].first];
        c[bc[i].first] = 0;
        cout << sum << "\n";
    }

}

Measured memory_bytes: 10828
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll k, cnt = 0, cur = 0;
queue<ll> q;

int main() {
	cin >> k;
	for (int i = 1; i < 10; i++)q.push(i);
	while (cnt < k) {
		cur = q.front();
		q.pop();
		cnt++;
		if (cnt == k) {
			cout << cur << endl;
			return 0;
		}
		if (cur % 10)q.push(cur * 10 + cur % 10 - 1);
		q.push(cur * 10 + cur % 10);
		if (cur % 10 < 9)q.push(cur * 10 + cur % 10 + 1);
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
long long X;
int main() {
    cin >> X;
    long long res = 0;
    long long money = 100;
    while(money < X) {
        money = money*1.01;
        res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
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 Pt = pair<int, int>;

int main()
{
	int N;
	cin >> N;
	int ct = 0;
	for (int i = 0; i < N; ++i)
	{
		int d1, d2;
		cin >> d1 >> d2;
		if (d1 == d2)
		{
			++ct;
		}
		else
		{
			ct = 0;
		}
		if (ct == 3)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>


using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,  0, 1, -1, 1,  1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1, -1, 0,  0, 1, -1,  1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	ll N, M;
	cin >> N >> M;
	vll X(M), Y(M);
	for (int i = 0; i < M; i++) cin >> X[i] >> Y[i];


	vbool ans(N+1);
	vll size(N + 1);
	for (int i = 0; i <= N; i++)
	{
		ans[i] = false;
		size[i] = 1;
	}

	ans[1] = true;


	for (int i = 0; i < M; i++)
	{
		if (ans[X[i]])
		{
			ans[Y[i]] = true;

			if (size[X[i]] == 1)
			{
				ans[X[i]] = false;
			}
		}

		size[X[i]]--;
		size[Y[i]]++;

	}

	ll ret = 0;
	for (int i = 0; i <= N; i++)
	{
		ret += ans[i];
	}

	cout << max(ret, ll(1)) << endl;

}





Measured memory_bytes: 2688
#include<stdio.h>
int main(){
  int m,f,r,p;
  while(1){
    scanf("%d %d %d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1)break;
    p=m+f;
    if(m==-1||f==-1){
      printf("F\n");
    }else if(p>=80){
      printf("A\n");
    }else if(65<=p&&p<80){
      printf("B\n");
    }else if(50<=p&&p<65){
      printf("C\n");
    }else if(30<=p&&p<50){
      if(r>=50){
	printf("C\n");
      }else{
	printf("D\n");
      }
    }else{
      printf("F\n");
    }
  }
  return 0; 
}
  



Measured memory_bytes: 2036
N = int(input())
b = 0

while N is not 0:
    f = False
    a = 0
    M = N
    while f == False:
        if M % 2 ==0:
            M = int(M / 2)
            a += 1
        else:
            f = True
    if b < a:
        b = a
        N = N - 1
    else:
        N = N - 1
print(2**b)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll f[N];
char s[N];
ll fastpow(ll x,ll y,ll md){
	ll ret=1;
	for(;y;y>>=1,x=x*x%md)
		if(y&1) ret=ret*x%md;
	return ret;
}
int main(){
	ll n;
	scanf("%lld",&n);
	scanf("%s",s+1);
	ll one=0;
	for(ll i=1;i<=n;i++){
		if(s[i]=='1') one++;
	}
	ll num1=0,num2=0;
	for(ll i=1,j=n-1;i<=n;i++,j--){
		num1=(num1+(s[i]-'0')*fastpow(2,j,one+1))%(one+1);
	}
	if(one>1)
	for(ll i=1,j=n-1;i<=n;i++,j--){
		num2=(num2+(s[i]-'0')*fastpow(2,j,one-1))%(one-1);
	}
	for(ll i=1;i<=n;i++){
		if(s[i]=='1'){
			s[i]='0';
			ll none=one-1;
			ll cnt=0;
			if(none==0){
				puts("0");
				continue;
			}
			ll now=0;
			do{
				cnt++;
				if(cnt==1){
					now=(num2-fastpow(2,n-i,none)+none)%none;
				}
				else{
					ll nnow=now;
					none=0;
					while(nnow){
						if(nnow&1) none++;
						nnow>>=1;
					}
					now=now%none;
				}
			}while(now);
			printf("%lld\n",cnt);
			s[i]='1';
		}
		else{
			s[i]='1';
			ll none=one+1;
			ll cnt=0;
			if(none==0){
				puts("0");continue;
			}
			ll now=0;
			do{
				cnt++;
				if(cnt==1){
					now=(num1+fastpow(2,n-i,none)+none)%none;
				}
				else{
					ll nnow=now;
					none=0;
					while(nnow){
						if(nnow&1) none++;
						nnow>>=1;
					}
					now=now%none;
				}
			}while(now);
			printf("%lld\n",cnt);
			s[i]='0';
		}
		
	}
	return 0;
}

Measured memory_bytes: 4004
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  cout << (X * min(N, K) + Y * max(0, N - K)) << endl;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[505];

pi ar2[505];
int rem[505];
void ng(){
  puts("No");
  exit(0);
}

int main(){
  cin>>n;
  REP(i,n){
    cin>>ar[i];
    --ar[i];
    ar2[i]=mp(ar[i],i);
  }
  sort(ar2,ar2+n);
  REP(i,n) rem[i]=i;

  int m=n*n;
  vector<int> res,lat;;
  REP(i,m){
    bool flag=false;
    REP(j,n) if(ar[j]==i){
      if(rem[j]) ng();
      REP(k,n-j-1) lat.pb(j);
      res.pb(j);
      flag=true;
    }
    if(flag) continue;
    bool suc=false;

    REP(j,n) if(rem[ar2[j].sc]>0){
      --rem[ar2[j].sc];
      res.pb(ar2[j].sc);
      suc=true;
      break;
    }
    if(!suc){
      if(lat.empty()) ng();
      else{
        res.pb(lat.back());
        lat.pop_back();
      }
    }
  }
  puts("Yes");
  for(auto e:res) printf("%d ",e+1);
  puts("");
  return 0;
}





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

struct job {
	int A, avail;
	bool operator<(const job &other) const {
		return avail < other.avail;
	}
};

signed main() {
	int N, M;
	cin >> N >> M;
	vector<job> jobs;
	for (int n = 0; n < N; ++n) {
		int A, B;
		cin >> B >> A;
		jobs.push_back({A, M-B});
	}
	sort(jobs.rbegin(), jobs.rend());
	int idx = 0;
	priority_queue<int> pq;
	int ans = 0;
	for (int day = M; day >= 0; --day) {
		while (idx < N && jobs[idx].avail >= day) {
			pq.push(jobs[idx].A);
			++idx;
		}
		if (pq.size()) {
			ans += pq.top(); pq.pop();
			//cout << ans << endl;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    ll n;
    cin>>n;
    ll mn = LLONG_MAX;
    ll a[5];
    f(i, 5) cin>>a[i], mn = min(mn, a[i]);
    ll ans = 5;
    n = max(0ll, n - mn);
    ans += n/mn;
    if(n % mn) ans++;
    cout<<ans;
    return 0;
}

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

int main(){
    string n;
    cin >> n;
    ll sum = 0;
    rep(i, n.size()){
        int a = stoi(n.substr(i,1));
        sum += a;
        sum %= 9;
    }
    ll ans = sum%9;
    if(ans==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,m=0,mi=0;
    cin>>n>>k;
    ll h[n],g[n-1];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h,h+n);
    for(int i=1;i<n;i++){
        g[i-1]=h[i]-h[i-1];
    }
    for(int i=0;i<k-1;i++){
        mi+=g[i];
    }
    m=mi;
    for(int i=k-1;i<n-1;i++){
        m-=g[i-k+1];
        m+=g[i];
        mi=min(mi,m);
    }
    cout << mi<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#define N 100001

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

node T[N];
int dep(int);
int hei(int);

int main(){
  int i,j,n,a;

  scanf("%d",&n);

  for(i=0; i<n; i++) T[i].par = T[i].left = T[i].right =-1;

  for(i=0; i<n; i++){
    scanf("%d",&a);
    scanf("%d %d", &T[a].right, &T[a].left);
    if(T[a].left != -1) T[T[a].left].par = a;
    if(T[a].right != -1) T[T[a].right].par = a;
  }
 
 for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = ", i ,T[i].par);
    if(T[i].par == -1){
      printf("-1, ");
    }
    else{
      if(T[T[i].par].left == i){
        printf("%d, ",T[T[i].par].right);
      }
      else{
        printf("%d, ",T[T[i].par].left);
      }
    }

    printf("degree = ");
    if(T[i].left == -1 && T[i].right == -1){
      printf("0, ");
    }  
 else{
      if(T[i].left != -1 && T[i].right != -1){
        printf("2, ");
      }
      else{
        printf("1, ");
      }
    }
    printf("depth = %d, height = %d, ", dep(i), hei(i));

    if(T[i].par == -1){
      printf("root");
    }
    else{
      if(T[i].left ==-1 && T[i].right == -1){
        printf("leaf");
      }
      else{
        printf("internal node");
      }
    }
    printf("\n");
  }

  return 0;
}

int dep(int n){
  if(T[n].par == -1) return 0;
  return dep(T[n].par)+1;
}

int hei(int n){
  int right=0,left=0;

  if(T[n].right == -1 && T[n].left == -1) return 0;

  if(T[n].right != -1) right = hei(T[n].right)+1;
  if(T[n].left != -1) left = hei(T[n].left)+1;

  if(left > right) return left;
  else return right;
}

Measured memory_bytes: 604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
  int i,j;
  int a,b,c;
  int max=0,min=0,t=0;
  int d1,d2;
  int ans=0;
  scanf("%d %d %d",&a,&b,&c);
  if(a>=b && a>=c){
    max = a;
    if(b>=c){
      t=b;
      min=c;
    }else{
      t=c;
      min=b;
    }
  }else if(b>=a && b>=c){
    max=b;
    if(a>=c){
      t=a;
      min=c;
    }else{
      t=c;
      min=a;
    }
  }else if(c>=a && c>=b){
    max=c;
    if(a>=b){
      t=a;
      min=b;
    }else{
      t=b;
      min=a;
    }
  } 
  d1=max-min;d2=max-t;
  if(d1%2==1 && d2%2==1){
    ans+=(d1-d2)/2;
    ans += d2;
  }else if(d1%2==0 && d2%2==0){
    ans += (d1-d2)/2;
    ans += d2;
  }else if(d1%2==0 && d2%2==1){
    ans += (d1-d2)/2;
    ans += d2+2;
  }else{
    ans += (d1-d2)/2;
    ans += d2+2;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
x = gets.to_i

def is_prime(n)
    a = Math.sqrt(n).to_i + 1
    if n == 2
        return true
    elsif n % 2 == 0
        return false
    else
        i = 3
        while i < a
            if n % i == 0
                return false
            end
            i += 2
        end
        return true
    end
end

while true
    if is_prime(x)
        puts x
        break
    end
    x += 1
end

Measured memory_bytes: 3836
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")



#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <memory>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <ctime>
#include <sstream>  
#include <deque>
#include <unordered_set>
#include <stack>
#include <functional>
#include <memory.h>
#include <bitset>
#include <numeric>

using namespace std;

#define int long long

signed main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    for (auto it : s) {
        if (it == 'W') {
            ans += cnt;
        }
        else {
            cnt++;
        }
    }
    cout << ans << endl;
}

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

int x,y;
int deg[100];

int main() {
	scanf("%d%d",&x,&y);
	deg[x]++;
	deg[y]++;
	scanf("%d%d",&x,&y);
	deg[x]++;
	deg[y]++;
	scanf("%d%d",&x,&y);
	deg[x]++;
	deg[y]++;
	
	if (deg[1] <= 2 && deg[2] <= 2 && deg[3] <= 2 && deg[4] <= 2) printf("YES\n"); else printf("NO\n");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N, H, W;
	int *A, *B;
	int i, count = 0;
	
	scanf("%d %d %d", &N, &H, &W);
	A = (int *)malloc(sizeof(int) * N);
	B = (int *)malloc(sizeof(int) * N);
	
	for(i = 0; i < N; i++){
		scanf("%d %d", &A[i], &B[i]);
		if(A[i] >= H && B[i] >= W) count++;
	}
	
	printf("%d\n", count);
	free(A);
	free(B);
	return 0;
}

Measured memory_bytes: 128
from math import atan, pi

a, b, x = map(int, input().split(' '))

h = x / a**2
if h > b / 2:
    tan_theta = 2*(b - h) / a
else:
    tan_theta = b**2 / (2*a*h)

theta = atan(tan_theta) * 180 / pi

print(theta)


Measured memory_bytes: 2940
#include <stdio.h>

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long llong;

int main(int, char**) {
  llong n, a, b;
  cin >> n >> a >> b;

  llong p = a + b;
  llong x = n / p;
  cout << a * x + min(a, n - p * x) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, count;
  bool flag = false;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> A;
    int tmp = 0;
    while(A%2==0){
      tmp++;
      A /= 2;
    }
    if(tmp == 0){
      count = 0;
      break;
    }
    if(flag){
      if(count > tmp){
        count = tmp;
      }
    }else{
        count = tmp;
        flag = true;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n,a,b,c,d = map(int,input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()
for i in range(a,c+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
for i in range(b,d+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
if (a > b and c > d) or (a < b and c < d):
    print("Yes")
else:
    for i in range(max(a,b),min(c,d)):
        if i == b:
            if s[i-1] == "." and s[i+1] == ".":
                break
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            break
    else:
        print("No")
        exit()
    print("Yes")


Measured memory_bytes: 9512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
	string str;
	long long num,a=0;
	cin >> str;
	for(int i=0;i<str.size();i++){
		a+=(str[i]-'0');
	}
	num = stoi(str);
	if(num%a==0)	cout << "Yes\n";
	else	cout << "No\n";
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    
    int matrix[n + 1][m + 1];
    int vector[m + 1];
    int result[n + 1];
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> matrix[i][j];
        }
    }
    
    for (int i = 1; i <= m; i++) {
        cin >> vector[i];
    }
    
    
    
    for (int i = 1; i <= n; i++) {
        result[i] = 0;
        for (int j = 1; j <= m; j++) {
            result[i] += matrix[i][j] * vector[j];
        }
    }
    
    for (int i = 1; i <= n; i++) {
        cout << result[i] << endl;
    }
    
    
    return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N;
    string S;
    cin >> N >> S;
    bool ans = true;
    if(N % 2 != 0) cout << "No" << endl;
    else{
        for(int i=0; i < N/2; i++){
            if(S.at(i) != S.at(i+N/2)) ans = false;
        }
        if(ans) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  cout << char (a.at(0) - 0x20) << char (b.at(0) - 0x20) << char (c.at(0) - 0x20) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int cnt[28];
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    priority_queue<pair<int,char> >q;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char c;
			scanf(" %c",&c);
			cnt[c-'a']++;
		}
	for(int i=0;i<26;i++)
		q.push(mp(cnt[i],i));
	for(int i=1;i<=n/2;i++){
		for(int j=1;j<=m/2;j++){
			PII nd=q.top();q.pop();
			if(nd.ff>=4)
				nd.ff-=4;
			else
				return puts("No")*0;
			q.push(nd);	
		}
	}		
	if(m&1){
		for(int i=1;i<=n/2;i++){
			PII nd=q.top();q.pop();
			if(nd.ff>=2)
				nd.ff-=2;
			else
				return puts("No")*0;
			q.push(nd);	
		}
	}
	if(n&1){
		for(int j=1;j<=m/2;j++){
			PII nd=q.top();q.pop();
			if(nd.ff>=2)
				nd.ff-=2;
			else
				return puts("No")*0;
			q.push(nd);	
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

bool isMMYY(string str)
{
    int m=stoi(str.substr(0,2));
    int y=stoi(str.substr(2,2));
    if((m>0 && m<13))
    {
        return true;
    }

    return false;
}

bool isYYMM(string str)
{
    int m=stoi(str.substr(2,2));
    if((m>0 && m<13))
    {
        return true;
    }

    return false;
}

int main()
{
    string s;
    cin>>s;
    string msg;
    if(isMMYY(s) && isYYMM(s))
    {
        msg="AMBIGUOUS";
    }
    else if(isMMYY(s))
    {
        msg="MMYY";
    }
    else if(isYYMM(s))
    {
        msg="YYMM";
    }
    else msg="NA";
    cout<<msg<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[310][310];
int dp1[310][310];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> dp[i][j];
      dp1[i][j] = dp[i][j];
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
	dp1[i][j] = min(dp1[i][j], dp1[i][k] + dp1[k][j]);
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < n-1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (dp[i][j] == dp1[i][j]) {
	bool f = 0;
	for (int k = 0; k < n; k++) {
	  if (k == i || k == j) continue;
	  if (dp1[i][j] == dp1[i][k] + dp1[k][j]) {
	    f = 1;
	    break;
	  }
	}
	if (!f) {ans += dp[i][j];}
      }
      if (dp[i][j] > dp1[i][j]) {
	cout << -1 << endl;
	return 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  vector<int> kazu;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    kazu = vector<int>(n,1);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
      kazu.at(rx) += kazu.at(ry);
    }
    else{
      par.at(rx) = ry;
      kazu.at(ry) += kazu.at(rx);
    }
  }
  void newkazu(){
    int n = kazu.size();
    for(int i=0;i<n;i++){
      kazu.at(i) = kazu.at(root(i));
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n,k;
  vector<int> rsp(3);
  cin >> n >> k >> rsp.at(0) >> rsp.at(1) >> rsp.at(2);
  string T;
  cin >> T;
  vector<int> t(n);
  for(int i=0;i<n;i++){
    if(T.at(i) == 'r')t.at(i) = 2;
    else if(T.at(i) == 's')t.at(i) = 0;
    else t.at(i) = 1;
  }
  vector<int> te(n);
  int ans = 0;
  for(int i=0;i<n;i++){
    if(i < k){
      te.at(i) = t.at(i);
      ans += rsp.at(t.at(i));
    }
    else{
      if(te.at(i-k) == t.at(i)){
        if(i+k < n){
          te.at(i) = t.at(i+k)+1;
        }
      }
      else{
        te.at(i) = t.at(i);
        ans += rsp.at(t.at(i));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4292
#include <bits/stdc++.h>
#define int long long
#define uint unsigned lon1g long
#define double long double
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sett(c) (c).resize(unique(all(c))-(c).begin())
#define sz(a) (int)(a).size()
#define hell 1000000007
#define pi pair<int,int>
#define vi vector<int>
#define vb vector<bool>
#define vpi vector<pair<int,int>>
#define x first
#define y second
#define endl '\n'
#define forn(i,n) for(int i = 0 ; i < n ; i++ )
#define for1(i,n) for(int i = 1 ; i < n ; i++ )
#define fore(i,a,b) for(int i = a ; (a>b)?(i>=b):(i<=b) ; (a>b)?(i--):(i++) )

using namespace std;

bool comp(const pi& a , const pi& b ){
        return a.y < b.y;
}

double distan(int a , int b , int c , int d){

        a = abs(a-b);
        c = abs(c-d) ;
        return sqrt(a*a + c*c);

}

long long binpow(long long a, long long b) {

    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}

void task_A(){
        int n ; cin >> n ; cout << n*n << endl;
}

void task_B(){
        int n ; cin >> n ;
        string s ; cin >> s ;
        if(n&1){
                cout << "No" << endl;
                return ;
        }
        cout << ( (s.substr(0,n/2) == s.substr(n/2,n/2))?"Yes":"No" ) << endl;
}

void task_C(){
        int n ; cin >> n ;int x[n] , y[n] ;
        forn(i,n) cin >> x[i] >> y[i] ;
        double dist[n][n] ;
        for(int i = 0 ; i < n ; i++ ){
                forn(j,n){
                        dist[i][j] = distan(x[i],x[j],y[i],y[j]);
                }
        }
        double ans = 0 ;
        for(int i =0 ; i < n ; i++ ){
                for(int j = i + 1 ; j < n ; j++ ){
                        ans += dist[i][j]*2/n;
                }
        }
        cout << ans << endl;
}

void task_D(){

}

void task_E(){

}

int32_t main(){

        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        cout << fixed;
        cout.precision(10);

        int t = 1;
        //cin >> t ;
        while(t--){
                //task_A();
                task_C();
                //task_C();
                //task_D();
                //task_E();
        }

        return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x,a,b;
    cin >> x >> a >> b;

    if(b - a <= 0)
    {
        cout << "delicious" << endl;
    }
    else if(b - a <= x)
    {
        cout << "safe" << endl;
    }
    else if(b - a > x)
    {
        cout << "dangerous" << endl;
    }
}

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

int main() {
  int a[5];
  int k;

  for (int i = 0; i < 5; i++)
    cin >> a[i];
  cin >> k;

  for (int i = 0; i < 5; i++) {
    for (int j = 0; i < 5; i++) {
      if (std::abs(a[i] - a[j]) > k) {
	cout << ":(" << endl;
	return 0;
      }
    }
  }

  cout << "Yay!" << endl;
  return 0;
}


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

void check(int n, const vector<pair<int, int>> &es, int k) {
    vector<vector<int>> dist(n, vector<int>(n, 1e9));
    for (auto &e : es) {
        dist[e.first - 1][e.second - 1] = dist[e.second - 1][e.first - 1] = 1;
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (dist[i][j] == 2) cnt++;
        }
    }
    assert(cnt == k);
}

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

    int n, k;
    cin >> n >> k;

    if ((n - 1) * (n - 2) / 2 < k) {
        cout << -1 << endl;
        return 0;
    }

    if (k == 0) {
        cout << n * (n - 1) / 2 << endl;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                cout << i << ' ' << j << endl;
            }
        }
        return 0;
    }

    int N;
    for (int i = 2; i < n; i++) {
        if (i * (i - 1) / 2 >= k) {
            N = i;
            break;
        }
    }
    vector<int> right;
    for (int i = 2; i < 2 + N; i++) {
        right.push_back(i);
    }
    int del = N * (N - 1) / 2 - k;
    vector<int> unused;
    for (int i = 2 + N; i <= n; i++) {
        unused.push_back(i);
    }
    vector<pair<int, int>> ans;
    for (int a : right) {
        ans.emplace_back(1, a);
    }
    for (int i = 0; i < del; i++) {
        ans.emplace_back(2 + i, 3 + i);
    }
    for (int a : unused) {
        for (int i = 1; i < 2 + N; i++) {
            ans.emplace_back(a, i);
        }
    }
    for (int i = 0; i < unused.size(); i++) {
        for (int j = i + 1; j < unused.size(); j++) {
            ans.emplace_back(unused[i], unused[j]);
        }
    }
//    check(n, ans, k);
    cout << ans.size() << endl;
    for (auto &p : ans) {
        cout << p.first << ' ' << p.second << endl;
    }
}

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

int main()
{
    int k, x;
    cin >> k >> x;

    if (500 * k >= x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
/**
 * @author yamato
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		String S = scanner.nextLine();
		String ans = "";
		int i;
		for(i=0;i<S.length();i++) {
			ans += "x";
		}
		System.out.print(ans);
		
	}

}


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

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

  int64_t ans = 0;
  for(int64_t x=1; x*x<=N; x++){
    if(N % x == 0){
      int64_t m = N/x-1, m2 = x-1;
      if(m > x) ans += m;
      if(m2 > x) ans += m2;
      if(m == m2 && m > x) ans -= m;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	long int n;
	long int a;
	long int b;
	
	scanf("%ld%ld%ld",&n,&a,&b);
	
	if((b-a)%2 == 0)
		printf("%ld",(b-a)/2);
	else{
		if(a>= n-b+1)
			printf("%ld",(b-a-1)/2 + n-b+1);
		else
			printf("%ld",(b-a-1)/2 + a);
	}
	return 0;
}

Measured memory_bytes: 128
S = input()
 
res = [0] * 2019
res[0] = 1
 
d = 1
a = 0
 
for c in reversed(S):
    a += int(c) * d
    a %= 2019
    res[a] += 1
    d *= 10
    d %= 2019
 
ans = 0
for r in res:
    ans += r*(r-1) // 2
print(ans)

Measured memory_bytes: 9212
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main()
{
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);

  scanf("%d", &q);
  for(i = 0; i < q; i++) {
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2764
#include <iostream>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b % MOD;
    if (n % 2 == 0) {
        return mypow(b * b % MOD, n / 2);
    } else {
        return mypow(b, n - 1) * b % MOD;
    }
}

ll dp[50][1 << 18];
// dp[i][S] = i個の数値でSが作れるパターン数

int main() {
    int N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    int W = X + Y + Z;

    fill(dp[0], dp[45], 0);
    dp[0][0] = 1;

    ll ans = 0;

    for (int i = 0; i <= N; ++i) {
        for (int S = 0; S < (1 << W); ++S) {
            if (((S >> (X - 1)) & 1) && ((S >> (X + Y - 1)) & 1) && ((S >> (X + Y + Z - 1)) & 1)) {
                ans += dp[i][S] * mypow(10LL, N - i);
                ans %= MOD;
                dp[i][S] = 0;
            }
        }

        for (int S = 0; S < (1 << W); ++S) {
            for (int k = 1; k <= 10; ++k) {
                int T = ((S << k) + (1 << (k - 1))) & ((1 << W) - 1);
                dp[i + 1][T] += dp[i][S];
                dp[i + 1][T] %= MOD;
            }
        }
    }

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


Measured memory_bytes: 94464
#include<stdio.h>
int main(void){
    int i,j,m,yama[11]={0};
    for(i=0;i<10;i++){
        scanf("%d",&yama[i]);
    }
        for(i=0;i<3;i++){
            for(j=i+1;j<10;j++){
                if(yama[i]<yama[j]){
                m=yama[i];
                yama[i]=yama[j];
                yama[j]=m;
                }
            }
        }
    for(i=0;i<3;i++){
        printf("%d\n",yama[i]);
    }
    return 0;
}

Measured memory_bytes: 600
s = list(input())

a = 0
b = 0
c = 0

for i in range(len(s)):
  if i%2 == 0 and s[i] == "h":
    a += 1
  elif i%2 == 1 and s[i] == "i":
    b += 1
  else:
    c += 1
    
if a == b and c == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,string> pis;

int n;
vector<pis> a,b;

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s,t;
        cin>>s;
        t=s;
        int cnt=0,mm=0x3f3f3f3f,mx=-0x3f3f3f3f;
        for(auto c:t)
        {
            if(c=='(') cnt++; else cnt--;
            mm=min(mm,cnt);
        }
        reverse(t.begin(),t.end()),cnt=0;
        for(auto c:t)
        {
            if(c=='(') cnt++; else cnt--;
            mx=max(mx,cnt);
        }
        if(cnt>=0) a.emplace_back(-mm,s); else b.emplace_back(-mx,s);
    }
    sort(a.begin(),a.end()),sort(b.begin(),b.end());
    int cnt=0,ok=1;
    for(auto s:a) for(auto c:s.second)
    {
        if(c=='(') cnt++; else cnt--;
        if(cnt<0) ok=0;
    }
    for(auto s:b) for(auto c:s.second)
    {
        if(c=='(') cnt++; else cnt--;
        if(cnt<0) ok=0;
    }
    if(ok&&cnt==0) printf("Yes"); else printf("No");
    return 0;
}


Measured memory_bytes: 42468
#include <iostream>
using 
      namespace
                std;
                
#define int long long

signed main() {
	int n;
	int l[114];
	
	cin >> n;
	l[0] = 2;
	l[1] = 1;
	for (int i = 2; i <= n; i++) {
		l[i] = l[i - 1] + l[i - 2];
	}
	cout << l[n] << endl;
	return 0;
}

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

#define n 4


int main() {


	int l, i=0, j, a[n];
	while (std::cin >> l)
	{
		a[i] = l;
		i++;
		if (i >= n) {
			break;
		}
	}

	
	int x, y; //個数

	int count=0;

	for (x = 0; x <= 3000; x++) {
		for (y = 0; y <= 3000; y++) {
			int temp = a[3] - a[0] * x - a[1] * y;
			if (temp >= 0 && temp % a[2] == 0)
				count++;
		}

	}
	printf("%d\n",count);

	
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define rev(v) 	v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << endl;
}

int main() {
	int A, B, C, X;
	int ans = 0;
	cin >> A >> B >> C >> X;
	For(i, A + 1) {
		For(j, B + 1) {
			For(k, C + 1) {
				if (i * 500 + j * 100 + k * 50 == X)++ans;
			}
		}
	}
	say(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>

ll A, B;

int main(){
    cin >> A >> B;

    if(A % 2 !=0 && B % 2 != 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int partition(int* A,int p,int r){
  int x=A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  int k=partition(A,0,n-1);
  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    if(i==k) cout<<"[";
    cout<<A[i];
    if(i==k) cout<<"]";
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3784
h,w = map(int,input().split())
grid = ["."*(w+2)]+["."+input()+"." for _ in range(h)]+["."*(w+2)]
for y in range(1,h+1):
	for x in range(1,w+1):
		if grid[y][x]=="#":
			print("#",end="")
		else:
			print(sum(grid[i][j]=="#" for i in range(y-1,y+2) for j in range(x-1,x+2)),end="")
	print("")

Measured memory_bytes: 3444
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
from collections import deque, defaultdict, Counter
import heapq

# SegTreeの関数
def segfunc(x, y):
    return max(x, y)
#区間の最小値、最大値を求めたい、区間の和を求めたいなど。segfuncに関数を書き込んでください。


# 単位元
# min->inf, max->-inf, add->0, mul->1
ide_ele = - float('inf')


# セグメント木
class SegTree:
    """
    init(init_val, segfunc, ide_ele): 配列init_valで初期化、構築
    update(k, x): k番目の値をxに更新
    query(l, r): 区間[l, r)をsegfuncしたものを返す
    """

    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセットする
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        :param k: index(0-index)
        :param x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        :param l: 0-index
        :param r: 0-index
        :return:
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
def main():
    N, K = MI()
    A = [0] * (6 * 10 ** 5 + 1)
    seg = SegTree(A, segfunc, ide_ele)
    for i in range(N):
        a = I()
        b = seg.query(max(0, a - K), a + K + 1)
        seg.update(a, b + 1)
    print(seg.query(1, 3 * 10 ** 5 + 1))
if __name__ == "__main__":
    main()

Measured memory_bytes: 106900
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;

int mod = 1e9 + 7;

int main(){

    int n, m;
    cin >> n >> m;

    long long xSum = 0;
    long long xSum2 = 0;
    long long before = 0;
    cin >> before;
    for(int i = 1; i < n; i++){
        long long temp;
        cin >> temp;
        long long len = temp - before;
        xSum2 = (xSum2 + (i * len));
        xSum = (xSum + xSum2) % mod;
        before = temp;
    }

    long long ySum = 0;
    long long ySum2 = 0;

    cin >> before;
    for(int i = 1; i < m; i++){
        long long temp;
        cin >> temp;
        long long len = temp - before;
        ySum2 = (ySum2 + (i * len));
        ySum = (ySum + ySum2) % mod;
        before = temp;
    }

    long long ans = (xSum * ySum) % mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	var args = input.split("\n");
	var num = args[0];
	args.shift();args.pop();
	var mochi_list = args;
	var output = 0;
	var mochi_uniq={};

	for (var i in mochi_list){
		mochi_uniq[mochi_list[i]] = 1;
	}

output = Object.keys(mochi_uniq).length;
	//出力
	console.log(output);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>
#define MAX 200000
#define SENT 2000000000
void RSort(int *,int,int);
void Reverse(int *,int,int,int);
double sum=0;
int main()
{
  int i,n;
  int N[MAX];
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&N[i]);
  }
 
  RSort(N,0,n);

  printf("%.0f\n",sum);
 
  return 0;
}
 
void RSort(int A[],int left,int right)
{
  int mid,temp;
  if(left+1<right){
    mid=(left+right)/2;
    RSort(A,left,mid);
    RSort(A,mid,right);
    Reverse(A,left,mid,right);
  }
}
 
void Reverse(int A[],int left,int mid,int right)
{
  int k,n1,n2,L[MAX],R[MAX],i,j;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=SENT/2;
  R[n2]=SENT/2;;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      sum+=n1-i;
      j++;
    }
  }
}

Measured memory_bytes: 2204
#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<double> x;
    for (int i = 0; i < n;i++){
        double a;
        cin >> a;
        x.push_back(a);
    }
    sort(x.begin(), x.end());
    for (int i = 1; i < n;i++){
        x[i] = (x[i - 1] + x[i]) / 2;
    }
    cout << x[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
_ = gets
numbers = gets.chomp.split.map(&:to_i)

def get_devided(arr)
  arr.map { |n| n % 2 == 0 ? n / 2 : nil }
end

devided = get_devided(numbers)
counter = 0

while devided.all? do
  counter += 1
  devided = get_devided(devided)
end

print "#{counter}\n"

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int p[32];

int main()
{
    canhazfast();

    int n, ans = 0;

    cin >> n;
    for (int i = 0; i < n; ++i) cin >> p[i];
    for (int i = 1; i < n-1; ++i) {
        if (p[i] > min(p[i-1], p[i+1]) && p[i] < max(p[i-1], p[i+1])) ++ans;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256