akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
#define ll long long int
#define REP(i,m,n) for(ll i = (ll)(m) ; i < (ll) (n);i++)
#define rep(i,n) REP(i , 0 ,n)

ll a, b, k, ab;


int main() {
	cin >> a >> b;
	ab = a + b;
	if (ab % 2 == 0) {
		cout << ab / 2 << endl;
	}
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
n,*a=`dd`.split.map(&:to_i)
a.sort!
mi,ma=a[0],a[-1]
if ma-mi>1 || n<=ma || mi<1
	puts :No
elsif ma-mi==0 && (mi==n-1||2*mi<=n)
	puts :Yes
elsif ma-mi==1 && (x=(0...n).bsearch{|e|a[e]==ma}||n;x<ma&&2*(ma-x)<=n-x)
	puts :Yes
else
	puts :No
end

Measured memory_bytes: 9732
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    ll H;
    cin >> N >> H;
    vector<ll> a(N),b(N);
    rep(i,0,N){
        cin >> a[i];
        cin >> b[i];
    }

    ll sum_d = 0LL;
    sort(all(a));
    sort(all(b));
    ll ans = 0LL;
    ll max_a = a[a.size()-1];
    for(int i = a.size() - 1;i >= 0;i--){
        if(max_a >= b[i]) break;
        if(sum_d >= H) break;
        ans++;
        sum_d += b[i];
    }

    if(sum_d < H){
        ll diff = H - sum_d;
        ans += diff/max_a;
        ans += !!(diff%max_a);
    }

    cout  << ans << endl;






    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	                        
    sort(s.begin(), s.end());   
	s.erase(unique(s.begin(), s.end()), s.end());  
	cout << s.size();
	return 0;
}

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

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll c[4]={0};
    c[a]++;
    c[b]++;
    for(ll i=1;i<=3;i++){
        if(c[i]==0){
            cout<<i<<endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		boolean non = false;
		int start = 0;
		if(s.length() < t.length()) {
			System.out.println("UNRESTORABLE");
			return;
		}
		outside : for(int i =  s.length() - t.length(); i >= 0; i--) {
			for(int j = 0; j < t.length(); j++) {
				if(!(s.charAt(i + j) == '?' || s.charAt(i + j) == t.charAt(j))) {
					break;
				}
				if(j == t.length() - 1) {
					start = i;
					break outside;
				}
			}
			if(i == 0) {
				non = true;
			}
		}
		if(non) {
			System.out.println("UNRESTORABLE");
			return;
		}
		for(int i = 0; i < start; i++) {
			if(s.charAt(i) == '?') {
				System.out.print('a');
			} else {
				System.out.print(s.charAt(i));
			}
		}
		System.out.print(t);
		for(int i = start + t.length(); i < s.length(); i++) {
			if(s.charAt(i) == '?') {
				System.out.print('a');
			} else {
				System.out.print(s.charAt(i));
			}
		}
	}
}


Measured memory_bytes: 23636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi p(n);
    rep(i,n)cin>>p[i];
    vi inv(n+1);
    rep(i,n)inv[p[i]]=i+1;
    multiset<int> st;
    st.insert(0);
    st.insert(0);
    st.insert(n+1);
    st.insert(n+1);
    int ans=0;
    for(int i=n;i>0;i--){
        int idx=inv[i];
        auto r1=st.lower_bound(idx);
        auto r2=r1;
        r2++;
        auto l1=r1;
        l1--;
        auto l2=l1;
        l2--;
        ans+=i*((*r2-*r1)*(idx-*l1)+(*l1-*l2)*(*r1-idx));
        st.insert(idx);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n, Q; cin >> n >> Q;
  vector<int> S(n), T(n), X(n);
  REP (i, n) cin >> S[i] >> T[i] >> X[i];
  set<int> rem = {(int)1e18};
  vector<int> D(Q); REP (i, Q) cin >> D[i];
  REP (i, Q) rem.insert(D[i]);

  vector<int> ord(n); REP (i, n) ord[i] = i;
  sort(ALL(ord), [&](int i, int j) {
    return X[i] < X[j];
  });
  map<int, int> ans;
  for (int i : ord) {
    int l = S[i] - X[i];
    int r = T[i] - X[i];
    while (1) {
      auto pt = rem.lower_bound(l);
      if (*pt < r) {
        ans[*pt] = X[i];
        rem.erase(pt);
      } else {
        break;
      }
    }
  }

  REP (q, Q) {
    if (ans.count(D[q])) {
      cout << ans[D[q]] << endl;
    } else {
      cout << -1 << endl;
    }
  }
}


Measured memory_bytes: 23808
#include <stdio.h>

int main(void)
{
	int flag=0;
	char a[5];
	scanf("%s",&a);
	if(a[0]==a[1]&&a[2]==a[3])flag=1;
	if(a[0]==a[2]&&a[1]==a[3])flag=1;
	if(a[0]==a[3]&&a[1]==a[2])flag=1;
	if(a[0]==a[3]&&a[1]==a[2]&&a[0]==a[1])flag=0;
	
	if(flag==1)printf("Yes\n");
	else printf("No\n");
	
	return 0;
}


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

int main(void) {
	i64 n, m = 0, c = 0;
	cin >> n;
	for (i64 i = 0; i < n; i++) {
		i64 h;
		cin >> h;
		if (h >= m) c++;
		m = max(m, h);
	}
	cout << c << endl;
}

Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 14.07.2020 16:09:33
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}

int r,s,p;
int calc(char pl, char n)
{
  if(pl=='r' && n=='s')return r;
  else if(pl=='s' && n=='p')return s;
  else if(pl=='p' && n=='r')return p;
  else return 0;
}

char calc2(char pre, char n, char next)
{
  if(pre=='r')
  {
    if(n=='r')return 'p';
    else if(n=='p')return 's';
    else if(next=='r') return 's';
    else return 'p';
  }
  else if(pre=='s')
  {
    if(n=='s')return 'r';
    else if(n=='r')return 'p';
    else if(next=='s') return 'p';
    else return 'r';
  }
  else if(pre=='p')
  {
    if(n=='p')return 's';
    else if(n=='s')return 'r';
    else if(next=='p') return 'r';
    else return 's';
  }
}


int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  int n,k;
  cin>>n>>k>>r>>s>>p;

  string t;
  cin>>t;

  char mae[n];
  ll ans=0;
  REP(i,k)
  {
    if(t[i]=='r')
    {
      ans+=p;
      mae[i]='p';
    }
    else if(t[i]=='s')
    {
      ans+=r;
      mae[i]='r';
    }
    else{
      ans+=s;
      mae[i]='s';
    }
  }

  FOR(i,k,n-1-k)
  {
    char pl=calc2(mae[i-k],t[i],t[i+k]);
    if(pl=='r')
    {
      ans+=calc('r',t[i]);
      mae[i]='r';
    }
    else if(pl=='s')
    {
      ans+=calc('s',t[i]);
      mae[i]='s';
    }
    else
    {
      ans+=calc('p',t[i]);
      mae[i]='p';
    }
  }

  FOR(i,n-k,n-1)
  {
    if(mae[i-k]=='r')
    {
      if(calc('p',t[i])>calc('s',t[i]))ans+=calc('p',t[i]);
      else ans+=calc('s',t[i]);
    }
    else if(mae[i-k]=='s')
    {
      if(calc('p',t[i])>calc('r',t[i]))ans+=calc('p',t[i]);
      else ans+=calc('r',t[i]);
    }
     else if(mae[i-k]=='p')
    {
      if(calc('r',t[i])>calc('s',t[i]))ans+=calc('r',t[i]);
      else ans+=calc('s',t[i]);
    }
  }

cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3888
/* ex4_3
   offNaria */
#include <stdio.h>

int numberOfEastMonument(int a, int b);
int heightOfMonument(int a);
int getDepthOfSnow(int a, int b);

int main(void){
  int visibleWestMonument, visibleEastMonument;
  scanf("%d %d", &visibleWestMonument, &visibleEastMonument);
  printf("%d\n", getDepthOfSnow(heightOfMonument(numberOfEastMonument(visibleWestMonument, visibleEastMonument)), visibleEastMonument));
  return 0;
}

int numberOfEastMonument(int visibleWestMonument, int visibleEastMonument){
  return visibleEastMonument - visibleWestMonument; //東の塔が全体の何番目か取得
}

int heightOfMonument(int number){
  return number * (number + 1) / 2; //number番目の塔の高さを取得
}

int getDepthOfSnow(int heightOfEastMonument, int visibleEastMonument){
  return heightOfEastMonument - visibleEastMonument; //東の塔の真の高さから見えている部分の高さが雪の深さ
}


Measured memory_bytes: 128
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
 
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3188
#include <iostream>
#include<string>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <cstdlib>
//#include <vector.h>
//#include <malloc.h>

#include <math.h>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
double maxvolume(int s)
{
    int maxvalue = 0;
    //if(s<3){
        double ss=s/3.0;
        double sss=s/3.0;
        double ssss = s-ss-sss;
        return ss*sss*ssss;
    //}
  
    // for length
    for (int i = 1; i <= s - 1; i++) {
  
        // for breadth
        for (int j = 1; j <= s-1; j++) {
  
            // for height
            int k = s - i - j;
  
            // calculating maximum volume.
            maxvalue = max(maxvalue, i * j * k);
        }
    }
  
    return maxvalue;
}
  
int main(){
    int n;
    cin>>n;
    double sum =maxvolume(n);
    printf("%lf\n",sum);
    return 0;
}


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

int main(){
  while(true){
    int n, x;
    cin >> n >> x;
    if(n == 0 && x == 0){
      break;
    }
    int count = 0;
    vector<int> data(x);
    for(int i = 1; i <= n ; i++){
      for(int j = 1; j <= n; j++){
        if(j == i || j < i){
          continue;
        }
          for(int k = 1; k <= n; k++){
            if(k == i || k == j || k < j){
              continue;
            }
            if(i + j + k == x){
              count++;
            }
          }
      } 
    }
    cout << count << endl;
  }
}



Measured memory_bytes: 3116
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    int n;
    cin >> n;
    auto p = vector<int>(n);
    auto Pos = map<int, int, greater<int>>();
    for (auto i = 0; i < n; ++i) {
        cin >> p[i];
        Pos.emplace(p[i], i);
    }

    auto sum = 0LL;
    auto indices = set<int>();
    for (auto [p_i, i] : Pos) {
        indices.insert(i);
        const auto this_itr = indices.find(i);

        auto L0 = -1;
        auto L1 = -1;

        {
            auto itr = this_itr;
            while (itr != indices.begin()) {
                --itr;
                if (p[*itr] > p[i]) {
                    L1 = *itr;
                    break;
                }
            }
            while (itr != indices.begin()) {
                --itr;
                if (p[*itr] > p[i]) {
                    L0 = *itr;
                    break;
                }
            }
        }

        auto R0 = n;
        auto R1 = n;
        {
            auto itr = this_itr;
            for (++itr; itr != indices.end(); ++itr) {
                if (p[*itr] > p[i]) {
                    R0 = *itr;
                    ++itr;
                    break;
                }
            }
            for (; itr != indices.end(); ++itr) {
                if (p[*itr] > p[i]) {
                    R1 = *itr;
                    break;
                }
            }
        }

        auto cases = 0LL;
        {
            auto Ls = L1 - L0;
            auto Rs = R0 - i;
            cases += large{Ls} * large{Rs};
        }
        {
            auto Ls = i - L1;
            auto Rs = R1 - R0;
            cases += large{Ls} * large{Rs};
        }
        sum += cases * p_i;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 13036
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=2e5+200;

int main(){
	ll n;
	cin>>n;
	vector<ll>a,b;
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			a.pb(i);
			if(n/i!=i)a.pb(n/i);
		}
	}
	a.pb(n);
	for(int i=2;i<=sqrt(n-1);i++){
		if((n-1)%i==0){
			b.pb(i);
			if((n-1)/i!=i)b.pb((n-1)/i);
		}
	}
	b.pb(n-1);
	ll cnt=0;
	for(auto p:b){
		if(n%p){
			cnt++;
		}
	}
	for(auto p:a){
		ll tmp=n;
		while(tmp%p==0)tmp/=p;
		if(tmp%p==1)cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int n;
	double x[100], y[100];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = 0; i < n; i++){
		cin >> y[i];
	}
	double d1 = 0, d2 = 0, d3 = 0, d4 = 0;
	for(int i = 0; i < n; i++){
		d1 += abs(x[i] - y[i]);
		d2 += (x[i] - y[i]) * (x[i] - y[i]);
		d3 += abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
		d4 = max(d4, abs(x[i] - y[i]));
	}
	d2 = sqrt(d2);
	d3 = pow(d3, 1.0 / 3.0);
	printf("%f\n%f\n%f\n%f\n", d1, d2, d3, d4);
	return 0;
}

Measured memory_bytes: 1280
import math

def solve():
    N = int(input())
    ans = 0
    for i in range(2, int(math.sqrt(N)) + 2):
        n = 1
        cnt = 0
        while N % i == 0:
            N //= i
            cnt += 1
            if cnt == n:
                cnt = 0
                n += 1
                ans += 1
    if N != 1:
        ans += 1
    return ans

print(solve())


Measured memory_bytes: 9188
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define ok cout<<"OK"<<endl
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int a,b;
    scanf("%d%d",&a,&b);
    b=b+a*3;
    printf("%d\n",b/2);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


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

int main() {

  int N,K;
  cin >> N >> K;

  vector<int> V(N);
  for(int i = 0;i < N;i++) {
    cin >> V.at(i);
  }

  int m = min(N,K),ans = 0;
  for(int i = 0;i <= m;i++) {
    for(int j = 0;j <= m-i;j++) {
      int sum = 0;
      vector<int> c(0);
      for(int k = 0;k < i;k++) {
        sum += V.at(k);
        c.push_back(V.at(k));
      }

      for(int k = 0;k < j;k++) {
        sum += V.at(N-1-k);
        c.push_back(V.at(N-1-k));
      }

      int rest = K-i-j;
      sort(c.begin(),c.end());
      for(int k = 0;k < min((int)c.size(),rest);k++) {
        if(c.at(k) < 0) sum -= c.at(k);
      } 

      ans = max(ans,sum);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    char s[110];
    cin >> n;
    cin >> s;
    int val = 0;
    int maxval = 0;
    imfor(i, strlen(s)) {
        if (s[i] == 'I') {
            val++;
        }
        else {
            val--;
        }
        maxval = max(maxval, val);
    }
    cout << maxval << endl;
}

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

using namespace std;
#define ll long long 

int main() {
  int k, x;

  cin >> k >> x;

  for(int i = x - (k - 1); i <= x + (k - 1); i++){
    if(1000000 >= i && i >= -1000000){
      cout << i << " ";
    }
  }

  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        while (true)
        {

            String[] str = Console.ReadLine().Split(' ');

            char[,] ary = new char[int.Parse(str[0]), int.Parse(str[1])];

            if (int.Parse(str[0]) == 0 && int.Parse(str[1]) == 0)
            {
                break;
            }

            for (int i = 0; i < ary.GetLength(0); i++)
            {
                for (int j = 0; j < ary.GetLength(1); j++)
                {
                    if ( ( i+j ) % 2== 0)
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.WriteLine();
            }

            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9052
A, B, C, D = map(int, input().split())
#A,C:体力, B,D:攻撃力
cnt = 0
while ((A > 0) and (C > 0)):
    if cnt % 2 == 0:
        C -= B
    else:
        A -= D
    cnt += 1

if A <= 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;

int main(){
    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    int c[H][W];
    int h=0;
    int w=0;
    
    int i=1;
    while(h<H){
        while(a[i-1]==0){
            i++;
        }
        c[h][w]=i;
        a[i-1]--;
        
        if((h%2==0 && w==W-1) || (h%2==1 && w==0)){
            h++;
        }else{
            if(h%2==0){
                w++;
            }else{
                w--;
            }
        }
    }
    
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout<<c[i][j];
            if(j==W-1){
                cout<<endl;
            }else{
                cout<<" ";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fi first
#define se second
#define pb push_back
#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);

using namespace std;

template<typename T> void macro_scan(T& t){cin>>t;};
template<typename F, typename ...R>void macro_scan(F& f , R& ...r){
  cin>>f;macro_scan(r...);
}

void deb(){
    cerr<<endl;
}
template<typename T , typename... t>
void deb(T a , t...b){
    cerr<<a<<" ";
    deb(b...);
}
template<typename T>
void dev(vector<T>v){
    int c = 0;
    for(auto i : v){
        cerr<<i<<" ";
        c++;
    }
    cerr<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int t; cin>>t;for(;t--;)done();
    read(long long , a , b);
    if((a + b)&1){
        cout<<"IMPOSSIBLE\n";
    }else{
        cout<<(a + b) / 2 << "\n";
    }
}




Measured memory_bytes: 256
from itertools import permutations
from math import ceil
D, G = map(int, input().split())
prob = [tuple(map(int, input().split())) for _ in range(D)]
perms = [i for i in range(D)]
ans = 10 ** 100
for p in permutations(perms):
    point = 0
    manip = 0
    for i in range(D):
        if point + (p[i] + 1) * 100 * (prob[p[i]][0] - 1) >= G:
            manip += ceil((G - point) / ((p[i] + 1) * 100))
            ans = min(ans, manip)
            break
        else:
            point += (p[i] + 1) * 100 * prob[p[i]][0] + prob[p[i]][1]
            manip += prob[p[i]][0]
            if point >= G:
                ans = min(ans, manip)
                break
print(ans)

Measured memory_bytes: 42088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  string buf(N*3, 0);
  rep(i, N) {
    buf[N + i] = S[i];
  }
  
  //まず後ろに挿入
  int rparen = 0;
  rep(i, N) {
    if(S[i] == '(') {
      rparen ++;
    } else if(S[i] == ')' && rparen > 0) {
      rparen --;
    }
  }
  
  rep(i, rparen) {
    buf[N + N + i] = ')';
  }
  
  int lparen = 0;
  drep(i, N) {
    if(S[i] == ')') {
      lparen ++;
    } else if(S[i] == '(' && lparen > 0) {
      lparen --;
    }
  }
  
  rep(i, lparen) {
    buf[N - i - 1] = '(';
  }
  
  string res(N + lparen + rparen, 0);
  rep(i, N + lparen + rparen) {
    res[i] = buf[N - lparen + i];
  }
  
  fin(res);
}

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

using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vll;

main(){
  int n; cin >> n;
  vll asc(n);
  for(int i=0;i<n;++i) cin >> asc[i];
  sort(asc.begin(),asc.end());
  vll ans(n,-1);
  ans[(n-1)/2] = asc[0];
  int l = (n-1)/2 - 1; int r = l+2;
  bool turn = 1;
  int posA =1, posD = n-1;
  for(int i=1;i<n-1;i+=2){
    if(turn){
      ans[r] = asc[posD]; ans[l] = asc[posD-1];
      posD-=2;
    }else{
      ans[r] = asc[posA]; ans[l] = asc[posA+1];
      posA+=2;
    }
    r++;l--;
    turn = !turn;
  }
  if(n%2==0){
    if(turn) ans[n-1] = asc[posD];
    else ans[n-1] = asc[posA];
  }
  ll val1 = 0;
  for(int i=0;i<n-1;++i){
    val1 += abs(ans[i] - ans[i+1]);
  }
  sort(asc.begin(),asc.end(),greater<ll>());
  ans[(n-1)/2] = asc[0];
  l = (n-1)/2 - 1; r = l+2;
  turn = 1;
  posA =1, posD = n-1;
  for(int i=1;i<n-1;i+=2){
    if(turn){
      ans[r] = asc[posD]; ans[l] = asc[posD-1];
      posD-=2;
    }else{
      ans[r] = asc[posA]; ans[l] = asc[posA+1];
      posA+=2;
    }
    r++;l--;
    turn = !turn;
  }
  if(n%2==0){
    if(turn) ans[n-1] = asc[posD];
    else ans[n-1] = asc[posA];
  }
  ll val2 = 0;
  for(int i=0;i<n-1;++i){
    val2 += abs(ans[i] - ans[i+1]);
  }
  cout << max(val1,val2) << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>>ka(n,pair<int,int>(0,0));
  for(int i=0;i<n;i++){
    cin >> ka.at(i).first;
    ka.at(i).second=i+1;
  }
  sort(ka.begin(),ka.end());
  for(int i=0;i<n;i++){
    cout << ka.at(i).second;
    if(i<n-1)
      cout << " ";
  }
  cout << endl;
  return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int n;
    cin >> n;

    string S;
    cin >> S;

    int open = 0;
    int close = 0;
    for (int i = 0; i < n; i++) {
        char cur = S[i];
        if (cur == '(') {
            close++;
        } else if (cur == ')') {
            if (close > 0) {
                close--;
            } else if (close == 0) {
                open++;
            }
        }
    }

    if (open == 0 && close == 0) {
        cout << S << endl;  // もともと閉じている
    } else {
        if (close > 0) {
            S += string(close, ')');
        }
        if (open > 0) {
            S = string(open, '(') + S;
        }
        cout << S << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define re register int
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline int
template<class D>I read(D &res){
	res=0;register D g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
int n,m,k,ans;
int main(){
	read(n);read(m);read(k);
	n=max(n,m);
	ans=k/n;
	if(k%n)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)
//g++ -std=c++11 

using namespace std;

long long N;
long long P[200005];
int main(){
	cin >> N;
	rep(i, N) cin >> P[i];

	long long mini = LONG_MAX;
	long long ans = 0;

	rep(i, N) {
		if(mini >= P[i]) {
			ans++;
		}
		mini = min(mini, P[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5088
#include <stdio.h>

int main(void) {
	int n,l,temp,l2,kari,temp2,ans,ans2;
	scanf("%d %d",&n,&l);
	temp = temp2 = kari = ans = 0;
	l2 =l; 
	ans = 9999;
	for(int i = 0;i < n;i++){
	    temp += l;
	    l++;
	}
	
	for(int i = 0;i < n;i++){
	    temp2 = temp - l2;
	    
	    l2++;
	   kari = abs(temp - temp2);
	   //abs(kari);
	   if(kari < ans){
	       ans = kari;
	       ans2 = temp2;
	   }
	}
	printf("%d",ans2);
	return 0;
}



Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    ans = 0

    for k in range(60):
        # 各要素のk桁目をXOR演算
        x0 = 0
        x1 = 0
        for i in range(N):
            x = A[i] >> k & 1  # k桁目
            if x == 0:
                x0 += 1
            else:
                x1 += 1
        ans += (x0 * x1) * (2 ** k)
    print(ans % mod)


resolve()

Measured memory_bytes: 124696
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = []
for i in range(N):
    A.append(list(map(int,input().split())))
    
count = 0
for j in range(N):
    sum = 0
    for k in range(M):
        sum += A[j][k] * B[k]
    if sum > -C:
        count += 1

print(count)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=100005;

int N,L,T,X[MAXN];

int main()
{
	scanf("%d%d%d",&N,&L,&T);
	int pos=0;
	for(int i=1;i<=N;i++)
	{
		int flag;
		scanf("%d%d",&X[i],&flag);
		if(flag==2)
			flag=-1;
		pos+=(X[i]+flag*T)/L;
		X[i]=(X[i]+flag*T)%L;
		if(X[i]<0)
			X[i]+=L,pos--;
	}
	pos=(pos%N+N)%N;
	sort(X+1,X+N+1);
	for(int i=pos+1;i<=N;i++)
		printf("%d\n",X[i]);
	for(int i=1;i<=pos;i++)
		printf("%d\n",X[i]);
	
	return 0;
}


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

int main() {
    string s; cin >> s;
    int n = 0;

    if(s.size() % 2 != 0) cout << "No" << endl;
    else {
        int n = 0;
        while((s[n] == 'h') && (s[n+1] == 'i')) {
            if(n+1 == s.size()-1) {
                cout << "Yes" << endl;
                return 0;
            }else{
                n += 2;
            }
        }
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int>kdm(n);
  for(int i=0;i<n;i++)
    cin >> kdm.at(i);
  sort(kdm.begin(),kdm.end());
  int ans=0,c=0;
  while(x>0&&c<n){
    if(x>=kdm.at(c)){
      ans++;
    }
    x-=kdm.at(c);
    c++;
  }
  if(x>0&&c==n)
    ans=max(0,ans-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    Iterator.continually {(
      scanner.nextInt(),
      scanner.nextInt(),
      scanner.nextInt()
    )}.takeWhile {
      case (-1, -1, -1) => false
      case _ => true
    }.map {
      case (-1, _, _) => 'F'
      case (_, -1, _) => 'F'
      case (m, f, r) =>
        val sum = m + f
        if (80 <= sum) 'A'
        else if (65 <= sum) 'B'
        else if (50 <= sum) 'C'
        else if (30 <= sum) {
          if (50 <= r) 'C'
          else 'D'
        } else 'F'
    }.foreach(println)
  }
}

Measured memory_bytes: 45132
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  vll a(5);
  re(i, 5) std::cin >> a[i];
  re(i, 5){
    if(a[i]==0){
      std::cout << i+1 << '\n';
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long INF = 1LL<<60;
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; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

ll dp[105][100005];
ll weight[105], value[105];
ll n,w;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> w;
    rep(i,n) cin >> weight[i] >> value[i];
    rep(i,105) rep(j,100005) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n) {
        rep(j,100001) {
            if(j>=value[i]) chmin(dp[i+1][j],dp[i][j-value[i]]+weight[i]);
            chmin(dp[i+1][j],dp[i][j]);
        }
    }
    ll ans = 0;
    rep(i,100005) {
        if(dp[n][i] <= w) ans = i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 82304
n=int(input())
data=[]
for _ in range(n):
    data.append(list(map(int,input().split())))

data_sum=[]
for i in range(n):
    data_sum.append(data[i][0]+data[i][1])


data_sum_1=[]
for i in range(n):
    data_sum_1.append(data[i][1]-data[i][0])

d_1=max(data_sum)-min(data_sum)
d_2=max(data_sum_1)-min(data_sum_1)

print(max(d_1,d_2))

Measured memory_bytes: 61412
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  string s;
  bool flaga=false, flagb=false, flagc=false;
  cin >> s;
  int n=3;
  r(i,n){
    if(s[i]=='a')flaga=true;
    else if(s[i]=='b')flagb=true;
    else if(s[i]=='c')flagc=true;
  }

  if(flaga && flagb && flagc){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // 入力を受け取る
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut mass: Vec<usize> = Vec::with_capacity(n);
    for i in 0..n {
        let mut tmp: usize = iter.next().unwrap().parse().unwrap();
        mass.push(tmp);
    }

    let mut max_move: usize = 0;
    let mut can_move: usize = 0;
    let mut cur_pos: usize = mass[0];
    for i in 1..n {
        if cur_pos >= mass[i] {
            cur_pos = mass[i];
            can_move += 1;
            max_move = cmp::max(can_move, max_move);
        } else {
            cur_pos = mass[i];
            max_move = cmp::max(can_move, max_move);
            can_move = 0;
        }
    }

    println!("{}", max_move);
}

Measured memory_bytes: 6396
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f
inline int read() {
    int x = 0, neg = 1; char op = getchar();
    while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
    while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
    return neg * x;
}
inline void print(int x) {
    if (x < 0) { putchar('-'); x = -x; }
    if (x >= 10) print(x / 10);
    putchar(x % 10 + '0');
}
const int maxn = 2e3 + 10;
int n,dis[maxn];
int x,y;
int old_dis(int a,int b) {
    return abs(dis[a] - dis[b]);
}
int new_dis(int a,int b) {
    int k1 = old_dis(a, b);
    int k2 = old_dis(a, x) + old_dis(b, y) + 1;
    int k3 = old_dis(a, y) + old_dis(b, x) + 1;
    return min(k1, min(k2, k3));
}
int ans[maxn];
signed main() {
    IO;
    cin >> n >> x >> y;
    rep(i,1,n){
        dis[i] = i - 1;
    }
    for(int i = 1 ; i<= n ; i++){
        for(int j = 1 ; j < i ; j++){
            ans[new_dis(i,j)]++;
        }
    }
    rep(i,1,n-1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int D;
    cin >> D;
    
    if (D == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    } else if (D == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else if (D == 24) {
        cout << "Christmas Eve" << endl;
    } else if (D == 25) {
        cout << "Christmas" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import           Control.Exception (assert)

main :: IO ()
main = do
  n <- readLn
  [a, b] <- words <$> getLine
  assert (length a == n && length b == n) $
    putStrLn $ solve a b

solve :: String -> String -> String
solve a b = concat $ zipWith (\c1 c2 -> [c1, c2]) a b


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (1000000007)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


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

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}






int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	lli n,k; cin >> n>>k;
	vector<lli>arr(n + 1);
	for (int i = 1; i <= n; i++)cin >> arr[i];
	vector<vector<lli>> dp(k + 1, vector<lli>(n + 1,0));
	for (int i = 0; i <= k; i++) {
		dp[i][1] = (i<=arr[1])?1:0;
	}
	for (int j = 2; j <= n; j++) {
		for (int i = 0; i <= k; i++) {
			if (i == 0)dp[i][j] = dp[i][j - 1]%MOD;
			else {
				if (i <= arr[j])dp[i][j] = (dp[i - 1][j] + dp[i][j-1])%MOD;
				else dp[i][j] = (MOD+dp[i][j-1] + dp[i-1][j] - dp[i-arr[j]-1][j-1])%MOD;
			}
		}
	}
	cout << dp[k][n];
	//system("PAUSE");
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
bitset<4000005>S;
int n,a[2005],sum;
int main()
{
	scanf("%d",&n);
	S[0]=1;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
		S|=S<<a[i];
	}
	for (int i=(sum+1)/2;i<=sum;i++)
		if (S[i])
		{
			printf("%d\n",i);
			return 0;
		}
}


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

vector<int> A(3, 0);

int main(void){
    
    cin >> A[0] >> A[1] >> A[2];
    
    int ans = INT_MAX;
    for(int i = 0; i < 3; ++i){
        int sum = 0;
        for(int j = 0; j < 3; ++j){
            if(i != j){
                sum += abs(A[j] - A[i]);
            }
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    
    return 0;
}

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

int main(){
    int N,M; cin>>N>>M;
    int maximum=0;
    int minimum=999999;
    int L,R;
    for(int i=0;i<M;i++){
        cin>>L>>R;
        maximum=max(maximum,L);
        minimum=min(minimum,R);
    }
    int ans=minimum-maximum+1;
    if(ans<0){
        cout<<0;
    }
    else{
        cout<<ans;
    }
    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



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

    vector<int> v(2*n);
    v[0] = 0;   //0=L, 1=R

    REP(i, 2*n-1){
        if(s[i] == s[i+1]){
            v[i+1] = (v[i] + 1) % 2;
        }else{
            v[i+1] = v[i];
        }
    }

    int cnt = 0;
    ll ans = 1;

    if(s.front() == 'W' || s.back() == 'W'){
        ans = 0;
    }

    if(SUM(v) != n){
        ans = 0;
    }

    REP(i, 2*n){
        if(v[i] == 0){
            cnt++;
        }else{
            ans *= cnt;
            ans %= MOD;
            cnt = max(0, cnt - 1);
        }
    }

    REP(i, n){
        ans *= i + 1;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1412
import sys
sys.setrecursionlimit(int(1e6))

s = input()
t = input()

len_s = len(s)
set_s = set(s)
set_t = set(t)

if len(set_t - set_s) != 0:
    print(-1)
    sys.exit()

ss = s + s
indexes_c = {}
for c in set_t:
    indexes = list()
    index = 0
    index_sum = 0
    word = ss
    while index_sum < len_s:
        index = word.index(c)+1
        index_sum += index
        indexes.append(index_sum)
        word = word[index:]
    indexes_c[c] = indexes

from bisect import bisect_right
ans = 0
for c in t:
    i = ans % len_s
    indexes = indexes_c[c]
    ans += indexes[bisect_right(indexes, i)] - i

print(ans)


Measured memory_bytes: 8020
#include <iostream>
#include <algorithm>
int A[210000];
using namespace std;

int main(){
   int N;
   scanf("%d",&N);
   for(int i=0;i<N;i++)scanf("%d",A+i);
   sort(A,A+N);
   for(int i=0;i<N-1;i++){
     if(A[i]==A[i+1]){
       printf("NO\n");return 0;
     }
   }

   printf("YES\n");
   
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a>b?b:a
#define pii pair<int, int>
#define mp make_pair
#define mem(x) memset(x,0,sizeof(x))
using namespace std;
class Solution
{
public:
    void solve()
    {
        int q;
        cin >> q;
        vector<ll> v;
        while(q--)
        {
            int t;
            cin >> t;
            if(!t)
            {
                ll k;
                cin >> k;
                v.push_back(k);
            }
            else if(t & 1)
            {
                int k;
                cin >> k;
                cout << v[k] << endl;
            }
            else v.pop_back();
        }
    }
};
int main()
{
    Solution s;
    s.solve();
    return 0;
}




Measured memory_bytes: 4832
import scala.io.StdIn

object Main extends App {
  val Array(_,m) = StdIn.readLine().split(" ").map(_.toInt)
  val a = StdIn.readLine().split(" ").map(_.toInt)
  val c = a.count(_ >= (1/(4.0*m)) * a.sum)
  println(if (c >= m) "Yes" else "No")
}

Measured memory_bytes: 25416