akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, n, m, now = 1, ans = 0, sm = 1, a, b, t, sum = 0, max = 0;
  scanf("%lld%lld", &n, &m);
  while(sm < m) sm <<= 1;
  ll seg[sm * 2 + 1], las[sm * 2];
  for(i = 1; i < sm * 2; ++i) {
    seg[i] = 0;
    if(i == now * 2) now <<= 1;
    las[i] = (i - now + 1) * sm / now;
  }
  scanf("%lld", &b);
  for(i = 1; i < n; ++i) {
    scanf("%lld", &a);
    ans += (a - b + m) % m;
    if((a - b + m) % m > 1) {
      t = (b + 1) % m;
      if(t < a) {
        now = t + sm;
        while( 1 ) {
          while(!(now & 1)) now >>= 1;
          while(las[now] > a) now <<= 1;
          seg[now]++;
          if(las[now] == a) break;
          now++;
        }
        if(a != m) seg[sm + a] -= a - t;
      } else {
        now = t + sm;
        while( 1 ) {
          while(!(now & 1)) now >>= 1;
          seg[now]++;
          if(las[now] == sm) break;
          now++;
        }
        seg[sm] += m + 1 - t;
        now = sm + 1;
        if(a != 1) while( 1 ) {
          while(!(now & 1)) now >>= 1;
          while(las[now] > a) now <<= 1;
          seg[now]++;
          if(las[now] == a) break;
          now++;
        }
        seg[sm + a] -= a - t + m;
      }
    }
    b = a;
  }
  for(i = 0; i < m; ++i) {
    now = i + sm;
    while(now) sum += seg[now], now >>= 1;
    if(sum > max) max = sum;
  }
  printf("%lld", ans - max);
  return 0;
}

Measured memory_bytes: 4224
fun main(args: Array<String>) {
    var list = readLine()!!.split(" ")
    
    while (list[1] != "?") {
        when (list[1]) {
            "+" -> println("%d".format(list[0].toInt() + list[2].toInt()))
            "-" -> println("%d".format(list[0].toInt() - list[2].toInt()))
            "*" -> println("%d".format(list[0].toInt() * list[2].toInt()))
            else -> println("%d".format(list[0].toInt() / list[2].toInt()))
        }
        list = readLine()!!.split(" ")
    }
}




Measured memory_bytes: 32012
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

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


#define getcx _getchar_nolock

using namespace std;
 
namespace std
{
	string to_string(string const& s) { return '"' + s + '"'; }
	string to_string(char c) { return string(1, c); }
	string to_string(const char* s) { return to_string((string)s); }
	string to_string(bool b) { return (b ? "true" : "false"); }
 
	template <class T1, class T2>
	string to_string(pair<T1, T2> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
 
	template <class T>
	string to_string(T c)
	{
		string s = "[";
		for (auto vvv : c) { s += to_string(vvv) + ","; }
		s += "]";
		return s;
	}
 
	void debug_impl() { cerr << endl; };
 
	template <typename T1, typename... T2>
	void debug_impl(T1 a, T2 ... b)
	{
		cerr << " " << to_string(a);
		debug_impl(b...);
	}
}
 
template <typename T>
struct reversion_wrapper
{
	T& iterable;
};
 
template <typename T>
auto begin(reversion_wrapper<T> w) { return std::rbegin(w.iterable); }
 
template <typename T>
auto end(reversion_wrapper<T> w) { return std::rend(w.iterable); }
 
template <typename T>
reversion_wrapper<T> reverse(T&& iterable) { return { iterable }; }
 
template<class T>T gcd(T a, T b) { while (a && b)if (a > b)a %= b; else b %= a; return a + b; }
template<class T>T powmod(T a, T b, T mod) { if (b == 0)return 1 % mod; T res = powmod(a, b / 2, mod); res *= res; res %= mod; if (b & 1) { res *= a; res %= mod; } return res; }
template<class T>T inv(T a, T mod) { return powmod(a, mod - 2, mod); }
 
#ifdef __ASD__
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_impl(__VA_ARGS__)
#define endl "\n"
#else
#define dbg(...) ;
#define endl "\n"
#endif
 
#define lng long long

lng const MOD = 998244353;


int main()
{
#ifdef __ASD__
	auto start_t = chrono::steady_clock::now();
	freopen("input.txt", "r", stdin);
	//freopen("1nul", "w", stderr);
	//freopen("output.txt", "w", stdout);
#else
	ios_base::sync_with_stdio(false);
#endif

	int n;
	cin>>n;
	int res = n/500*1000;
	n%=500;
	res+=n/5*5;
	cout<<res<<endl;

#ifdef __ASD__
	auto finish_t = chrono::steady_clock::now();
	cerr << "Elapsed " << chrono::duration_cast<chrono::milliseconds>(finish_t - start_t).count() << " ms" << endl;
#endif
	return 0;
}

Measured memory_bytes: 256
r, g, b, n = gets.chomp.split.map(&:to_i)
gc = (r.gcd(g)).gcd(b)
r /= gc
g /= gc
b /= gc
n /= gc
r, g, b = [r, g, b].sort

res = 0
0.step(n / b) do |k|
  0.step((n - k * b) / g) do |j|
    if (n - k * b - j * g) % r == 0
      res += 1
    end
  end
end
puts res

Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
int main()
{
    long double N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    long double Min = min({A, B, C, D, E});
    cout << setprecision(20) << ceil(N / Min) + 4;
    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

FiniteField Solve() {
  int n;
  cin >> n;
  vector<int> cs(n + 1);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cs[x]++;
  }

  if (n % 2 == 1) {
    vector<int> ds(n + 1);
    ds[0] = 1;
    for (int i = 2; i <= n - 1; i += 2) {
      ds[i] += 2;
    }
    if (cs != ds) return 0;
  } else {
    vector<int> ds(n + 1);
    for (int i = 1; i <= n - 1; i += 2) {
      ds[i] += 2;
    }
    if (cs != ds) return 0;
  }

  return Power(2, n / 2);
}

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

  cout << Solve() << endl;
}

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

int main()
{   
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    vector<i64> lbc(n+1,0);
    lbc[n] = 0;
    int c_idx = 0;

    vector<int> c_cnts(n,0);
    for(int i=0;i<n;++i)
    {
        int bi = b[i];
        while(c_idx<n)
        {
            if(c[c_idx]>bi) break;
            c_idx++;
        }
        c_cnts[i] = n-c_idx;
    }

    for(int i=n-1;i>=0;--i)
        lbc[i] = lbc[i+1] + c_cnts[i];

    i64 cnt = 0;
    int b_idx = 0;
    for(int i=0;i<n;++i)
    {
        int ai = a[i];
        while(b_idx<n)
        {
            if(b[b_idx]>ai) break;
            b_idx++;
        }
        cnt += lbc[b_idx];
    }

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

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <sstream>

using namespace std;

std::vector<std::string> split(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

int main() {
    int A, B;
    string s;
    cin >> A >> B;
    cin >> s;
    vector<string> str;
    str = split(s, '-');
    if(str.size() == 2)
        if(str[0].size() == A && str[1].size() == B) {
            cout << "Yes" << endl;
            return 0;
        }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s[3] = {"Sunny", "Cloudy", "Rainy"};
    string t;
    cin >> t;
    rep(i, 0, 3) {
        if (s[i] == t) {
            cout << s[(i + 1) % 3] << endl;
            return 0;
        }
    }
    return (0^_^0);
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int ans = 0;
  string s;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] == '+')
      ans++;
    else
      ans--;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split())) # 現準備度
B = list(map(int, input().split())) # 必要準備度

if sum(A) < sum(B):
    print(-1)
else:
    minus = 0
    plus_list = []
    ans = 0
    for a, b in zip(A, B):
        if a - b < 0:
            ans += 1
            minus += b - a
        elif a - b > 0:
            plus_list.append(a - b)

    plus_list.sort(reverse=True)
    for p in plus_list:
        if minus <= 0:
            break
        ans += 1
        minus -= p

    print(ans)


Measured memory_bytes: 81712
n,k=map(int,input().split())
import math
i=0
p=n
Sum=0
while not p==0:
    if k>n:
        k=math.ceil(k/2)
        i=i+1
    else:
        Sum=Sum+(p-k+1)*((0.5)**i)/n
        p=k-1
        k=math.ceil(k/2)
        i=i+1
print(Sum)
        


Measured memory_bytes: 38384
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);
	string str;
	map<string, int> s;
	int maxi = 0;
	int n; cin >> n;
	rep(i, n) {
		cin >> str;
		s[str] += 1;
		maxi = max(maxi, s[str]);
	}

	for (auto& d : s) {
		if (d.second == maxi) {
			cout << d.first << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 19252
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,m; cin >> n >> m;
    vector<tuple<ll,ll,ll>> vt(n);
    rep(i,n){
        ll x,y,z; cin >> x >> y >> z;
        vt[i] = tie(x,y,z);
    }
    ll mul[3];
    ll ans = 0;
    for(ll bit=0; bit<(1<<3); bit++){
        rep(i,3){
            if(bit & (1<<i)) mul[i] = 1;
            else mul[i] = -1;
        }
        priority_queue<ll> pq;
        for(auto i : vt){
            ll sum = 0;
            sum += get<0>(i) * mul[0];
            sum += get<1>(i) * mul[1];
            sum += get<2>(i) * mul[2];
            pq.push(sum);
        }
        ll s = 0;
        rep(i,m){
            s += pq.top(); pq.pop();
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by sark2 on 14-01-2020.
//

#include "bits/stdc++.h"

using namespace std;
#define pb push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;

int main() {
    IOS

    int a, b; cin>>a>>b;

    cout<<6-a-b<<"\n";



}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
#include <bitset> // bitset
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vi vx(N), vy(N), vh(N);
    int si = -1;
    for (int i = 0; i < N; i++) {
        cin >> vx[i] >> vy[i] >> vh[i];
        if (vh[i] > 0) {
            si = i;
        }
    }
    for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
            int h = vh[si] + abs(x - vx[si]) + abs(y - vy[si]);
            bool check = true;
            for (int i = 0; i < N; i++) {
                if (vh[i] > 0 && h - vh[i] != abs(x - vx[i]) + abs(y - vy[i])) {
                    check = false;
                    break;
                }
                if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i])) {
                    check = false;
                    break;
                }
            }
            if (check) {
                cout << x << " " << y << " " << h << endl;
                return 0;
            }
        }
    }
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define printf(x) cout << fixed << setprecision(9) << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

//最小公倍数
int lcm(int number1,int number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main(){

string S;
cin >> S;

for(int i = 1; i < 4; i++){ 
   if(S[i] == S[i - 1]) {
     cout << "Bad" << endl;
     return 0;
   } 
}

cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

lli n,a,b;
int main(){
	cin >> n >> b >> a;

	cout << max(0ll,(a*(n-1)+b) - (a + (n-1)*b)+1) << endl;
	return 0;
}

Measured memory_bytes: 256
def bb(A,n):
    cnt=0
    for k in range(n):
        for i in range(n-1,k,-1):
            if A[i] < A[i-1]:
                tmp=A[i]
                A[i]=A[i-1]
                A[i-1]=tmp
                cnt=cnt+1
    return A,cnt

n=int(input())
A=list(map(int,input().split()))
A,cnt=bb(A,n)
As=[str(i)for i in A]
As = ' '.join(As)
print(As)
print(cnt)



Measured memory_bytes: 5604
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;


int main() {
	FASTIO
	ll n, k;
	cin >> n >> k;
	int a[n];
	rep(i, 1, n + 1)
		cin >> a[i];
	int c = 0;
	vector<bool> vis(n+1, false);
	int curr = 1, cnt = 0;
	while(!vis[curr]){
		vis[curr] = true;
		curr = a[curr];
		cnt++;
	}
	int start = curr;
	vector<bool> vis2(n+1, false);
	while(!vis2[curr]){
		vis2[curr] = true;
		curr = a[curr];
		c++;
	}
	cnt -= c;
	if(k <= cnt){
		curr = 1;
		while(k > 0){
		curr = a[curr];
		k--;
		}
		cout << curr;
		return 0;
	}
	k -= cnt;
	k %= c;
//	cout << k << endl;
	curr = start;
	if(k == 0)
		k = c;
	while(k > 0){
		curr = a[curr];
		k--;
	}
	cout << curr;
	return 0;
}




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

int main()
{
	int g[7] = { 1,3,5,7,8,10,12 },x,y;

	cin >> x >> y;

	int xx = 0, yy = 0;
	for (int i = 0; i < 7; i++) {
		if (x == g[i])xx++;
		if (y == g[i])yy++;
	}

	if (xx != yy || x == 2 || y == 2)
		cout << "No";
	else
		cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    ll k;
    cin >> n >> k;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
        a[i]--;
    }
    bool reached[n] = {};
    reached[0] = true;
    ll cnt = 0;
    int now = 0;
    int d = 0;
    bool flag = false;
    while (1) {
        if (reached[a[now]]) {
            flag = true;
            d = a[now];
        } else {
            reached[a[now]] = true;
        }
        cnt++;
        if (cnt == k) {
            cout << a[now] + 1 << endl;
            return 0;
        }
        now = a[now];
        if (flag) break;
    }
    vector<int> visited;
    bool f[n] = {};
    while (1) {
        if (!f[d]) {
            visited.push_back(d);
            f[d] = true;
            d = a[d];
        } else {
            break;
        }
    }
    //for (auto i : visited) cout << i + 1 << endl;
    //cout << "k-cnt" << k - cnt << endl;
    ll s = visited.size();
    //cout << "s" << s << endl;
    ll x = (k - cnt) % s;
    //cout << "x" << x << endl;
    cout << visited[x] + 1 << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  
  sort(a.begin(),a.end());
  
  double x=a.at(0);
  
  for(int i=1;i<n;i++){
    x=(x+a.at(i))/2;
  }
  
  cout << x << endl;
  
}

Measured memory_bytes: 256
def check(p):
    s = w[0]
    track = 1
    for i in range(1, n):
        if s + w[i] <= p:
            s += w[i]
        else:
            track += 1
            if track > k: return False
            s = w[i]
    return True

n, k = map(int, input().strip().split())
w = []
for i in range(n):
    w.append(int(input()))

L = max(w)
if check(L):
    print(L)
else:
    R = sum(w)
    assert check(R)

    while L + 1 < R:
        M = (L + R) // 2
        if check(M):
            R = M
        else:
            L = M

    print(R)

Measured memory_bytes: 11140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi A(N);
  int max_=0;
  rep(i,0,N){
    cin>>A[i];
    max_=max(max_,A[i]);
  }
  int ans=0;
  REP(i,1,max_){
    rep(j,1,N){
      if(A[j-1]>=i&&A[j]<i)
        ans++;
    }
    if(A[N-1]>=i)
      ans++;
  }
  cout<<ans<<endl;
  }



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

int main(){
  set<string> st;
  int n;
  cin >> n;
  while(n--){
    string com,s;
    cin >> com >> s;
    if(com == "insert") st.insert(s);
    else cout << (st.find(s)!=st.end()?"yes":"no") << endl;
  }
  return 0;
}


Measured memory_bytes: 32156
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int h = sc.nextInt();
    int n = sc.nextInt();
    int x[] = new int[n];
    int y[] = new int[n];
    int a[] = new int[n];
    int x1 = 0;
    int x2 = w;
    int y3 = 0;
    int y4 = h;
    for(int i=0 ; i<n ; i++){//入力の受け取り
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
      a[i] = sc.nextInt();
    }

    for(int i=0 ; i<n ; i++){
      if(a[i]==1){
        x1 = Math.max(x1,x[i]);
      }else if(a[i]==2){
        x2 = Math.min(x2,x[i]);
      }else if(a[i]==3){
        y3 = Math.max(y3,y[i]);
      }else if(a[i]==4){
        y4 = Math.min(y4,y[i]);
      }
    }
    // System.out.print(x1+" "+ x2+" "+ y3+" "+y4);
    int d = x2-x1;
    int e = y4-y3;
    int s = d*e;
    if(d<0 || e<0){
      s = 0;
      System.out.println(s);
    }else{
      System.out.println(s);
    }

  }
}


Measured memory_bytes: 23892
n, m = list(map(int, input().split()))
pl = list(map(int, input().split()))


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


uf = UnionFind(n)
for i in range(m):
    a, b = list(map(int, input().split()))
    uf.union(a-1, b-1)

ans = 0
for i, p in enumerate(pl):
    if uf.same(i, p-1):
        ans += 1
print(ans)


Measured memory_bytes: 89324
for loop in range(int(raw_input())):
    manu = raw_input()
    msg = raw_input()
    size = len(msg)
    
    for s in manu[::-1]:
        if   s == "J":
            msg = msg[-1]+msg[:-1] if size > 1 else msg
        elif s == "C":
            msg = msg[1:]+msg[0] if size > 1 else msg
        elif s == "E":
            if size == 1: continue
            if size%2 == 0:
                msg = msg[size/2:]+msg[:size/2]
            else:
                msg = msg[size/2+1:]+msg[size/2]+msg[:size/2]
        elif s == "A":
            msg = msg[::-1]
        elif s == "P":
            for i in range(len(msg)):
                if msg[i].isdigit():
                    msg = msg[:i]+str((int(msg[i])-1+10)%10)+msg[i+1:]
        elif s == "M":
            for i in range(len(msg)):
                if msg[i].isdigit():
                    msg = msg[:i]+str((int(msg[i])+1)%10)+msg[i+1:]
    
    print msg

Measured memory_bytes: 4272
N, P = map(int, input().split())
K = 96
m = int(("1" * 32 + "0" * 64) * 8192, 2)
pa = (1 << 64) - ((1 << 64) % P)
modP = lambda x: x - ((x & m) >> 64) * pa

def getsum(x):
    for i in range(13):
        x += x >> (K << i)
    return x & ((1 << K) - 1)

a, b, c = 1 << K * N, 0, 0
fa = 1
for i in range(1, 3 * N + 1):
    a, b, c = modP(((a << K) + (b >> K) + c) * pow(i, P-2, P)), a, b
    fa = fa * i % P

print(getsum(a >> K * N) * fa % P)

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

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 100;
int a[N];
ll c[N][N];

ll ans = 0;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n, p;
    for ( int i = 1; i < N; i++ ){
        c[i][0] = 1;
        c[0][i] = 0;
    }
    c[0][0] = 1;
    for ( int i = 1; i < N; i++ ){
        for ( int j = 1; j < N; j++ ){
            c[i][j] = c[i-1][j] + c[i-1][j-1];
        }
    }
    scanf("%d %d",&n,&p);
    int cntOdd = 0, cntEven = 0;
    for ( int i = 1; i <= n; i++ ){
        scanf("%d",&a[i]);
        if ( a[i] % 2 == 1 ){
            cntOdd++;
        }
        else{
            cntEven++;
        }
    }
    for ( int i = 0; i <= cntOdd; i++ ){
        if ( i % 2 == p ){
            ans += c[cntOdd][i];
        }
    }
    ans *= ( 1LL << cntEven );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define MAX 500000
#define SEN 2000000000
int L[MAX/2+2],R[MAX/2+2];
long long merge(int a[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	long long cnt=0;
	for(int i=0;i<n1;i++) L[i]=a[left+i];
	for(int i=0;i<n2;i++) R[i]=a[mid+i];
	L[n1]=R[n2]=SEN;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			a[k]=L[i++];
		}else{
			a[k]=R[j++];
			cnt+=n1-i;
		}
	}
	return cnt;
}
long long mergesort(int a[],int n,int left,int right){
	int mid;
	long long v1,v2,v3;
	if(left+1<right){
		mid=(left+right)/2;
		v1=mergesort(a,n,left,mid);
		v2=mergesort(a,n,mid,right);
		v3=merge(a,n,left,mid,right);								
		return v1+v2+v3;
	}else return 0;
}
int main(){
	int a[MAX],n,i;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	long long ans=mergesort(a,n,0,n);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4660
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var H = myconv(input[0],4)[0];
  var W = myconv(input[0],4)[1];
  input.shift();
  for(var i = 0; i < H; i++){
    if(input[i].indexOf("#") == -1){
       input.splice(i,1);
      H--;
      i--;
    }
  }
  var checkWidth = new Array(W).fill(0);
  for(var i = 0; i < H; i++){
    var tmp = myconv(input[i],6);
    for(var j = 0; j < W; j++){
      if(tmp[j] == "."){
         checkWidth[j]++;
      }
    }
  }
  for(var i = 0; i < H; i++){
    var tmp = myconv(input[i],6);
    for(var j = 0; j < W; j++){
      if(checkWidth[j] == H){
         tmp[j] = "";
      }
    }
    input[i] = tmp.join("");
  }
  myout(input.join("\n"));
}
Main(myin());

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

int main(){
    string s;
    getline(cin,s);
    string ans = "A";
    for(int i=3;i<s.size();i++){
        if('A'<=s.at(i)&&s.at(i)<='Z'){
            ans += s.at(i);
        }
    }
    cout << ans << endl;
}

int min(int a,int b){
    if(a-b>0) return b;
    return a;
}

int max(int a,int b){
    if(a-b>0) return a;
    return b;
}

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

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    s,p = map(str, input().split())
    p = int(p)
    a.append((s,p,i+1))
#scoreが高い順にソート
a.sort(key=lambda x:x[1], reverse=True)

a.sort(key=lambda x:x[0])

for i in range(n):
    print(a[i][2])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<62;
constexpr double eps = (1e-9);

ll mod = 1000000007;

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

  int n;
  cin >> n;
  string u, l;
  cin >> u >> l;

  ll ans = 1;
  int prev = 0;
  for (int i = 0; i < n; i++) {
    if (u[i] == l[i]) {
      if (prev == 0) {
        ans *= 3;
      } else if (prev == 1) {
        ans *= 2;
      } else if (prev == 2) {
        ans *= 1;
      }
      prev = 1;
      ans %= mod;
    } else if (i + 1 < n && u[i] == u[i+1] && l[i] == l[i+1]) {
      if (prev == 0) {
        ans *= 6;
      } else if (prev == 1) {
        ans *= 2;
      } else if (prev == 2) {
        ans *= 3;
      }
      prev = 2;
      ans %= mod;
      i++;
    }
  }

  cout << ans % mod << endl;

  return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt32();
            var N = line[0];
            var T = line[1];
            var routes = consoleReader.RepeatSplitInt32(N).Select(l => new Route { cost = l[0], time = l[1] });

            var ok = routes.Where(r => r.time <= T).OrderBy(r => r.cost).ToArray();
            return ok.Length > 0 ? ok[0].cost.ToString() : "TLE";
        }
        struct Route
        {
            public int cost;
            public int time;
        }

        public const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int32() => int.Parse(String()); public long Int64() => long.Parse(String()); public ulong UInt64() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray(); public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt32(int count) { for (int i = 0; i < count; i++) yield return Int32(); } public IEnumerable<long> RepeatInt64(int count) { for (int i = 0; i < count; i++) yield return Int64(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt32(int count) { for (int i = 0; i < count; i++) yield return SplitInt32(); } }
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N;
  double ans;
  vl v;
  cin >> N;
  REP(i,N){
		int x;
		cin >> x;
		v.push_back(x);
	}
  ans = 0;
  sort(v.begin(), v.end());
  REP(i,N){
    if(i != N-1){
      ans = ans + (double)v[N-1-i]/pow(2,i+1);
    }else{
      ans = ans + (double)v[N-1-i]/pow(2,i);
    }
  }
  cout << ans<< endl;
  return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll h,w;cin>>h>>w;
  auto p=vec(h,w,MP(0,0));
  rep(i,0,h)rep(j,0,w)cin>>p[i][j].fi;
  rep(i,0,h)rep(j,0,w)cin>>p[i][j].se;
  ll lim=6401;
  auto dp=make_v(h,w,6401,false);
  dp[0][0][abs(p[0][0].fi-p[0][0].se)]=true;
  rep(i,0,h)rep(j,0,w){
    rep(o,0,lim){
      if(!dp[i][j][o])continue;
      if(i<h-1){
        ll d=abs(p[i+1][j].fi-p[i+1][j].se);
        if(o+d<lim)dp[i+1][j][o+d]=true;
        dp[i+1][j][abs(o-d)]=true;
      }
      if(j<w-1){
        ll d=abs(p[i][j+1].fi-p[i][j+1].se);
        if(o+d<lim)dp[i][j+1][o+d]=true;
        dp[i][j+1][abs(o-d)]=true;
      }
    }
  }
  rep(i,0,lim){
    if(dp[h-1][w-1][i]){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

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

using namespace std;

typedef long long int Int;

bool f(string s,string cm,int position)
{
    int p = 0;
    for(int i = position;i < position+cm.size()-1;i++)
    {
	if(s[i] != cm[p++])
	    return false;
    }

    return true;
}

int main(void)
{
    string s;

    cin>>s;
    for(int i = s.size()-1;i >= 0;)
    {
	if(i - 4 >= 0 && f(s,"dream",i-4))
	    i = i - 5;
	else if(i-4 >=0 && f(s,"erase",i-4))
	    i = i - 5;
	else if(i-6>= 0 && f(s,"dreamer",i-6))
	    i = i - 7;
	else if(i-5 >= 0 && f(s,"eraser",i-5))
	    i = i - 6;
	else
	{
	    cout<<"NO"<<endl;

	    return 0;
	}
    }

    cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> vec(m);
  rep(i,m){
    cin >> vec[i];
  }
  sort(all(vec));
  vector<ll> cou(n+1,INFLONG);
  cou[0] = 0;
  rep(i,n){
    rep(j,m){
      if(vec[j] <= i+1){
        chmin(cou[i+1],cou[i+1-vec[j]] + 1);
      }
    }
  }
  cout << cou[n] << endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[200200];
int main() {
    li n;
    cin >> n;
    li s = 0;
    rin{
        cin >> a[i];
        s ^= a[i];
    }
    rin{
        cout << (s^a[i]) << " ";
    }
    cout << endl;


    return 0;
}

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

typedef long long ll;

int main(){
  int n, a; cin >> n >> a;
  int x[n];

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

  ll dp[n+1][sum+1][n+1];
  memset(dp, 0, sizeof(dp));
  for(int i=0; i<=n; i++){
    dp[i][0][0] = 1;
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<=sum; j++){
      for(int k=1; k<=n; k++){
        if(j < x[i]) dp[i+1][j][k] = dp[i][j][k];
        else {
          dp[i+1][j][k] = dp[i][j][k] + dp[i][j-x[i]][k-1];
        }
      }
    }
  }

  ll ans=0;
  for(int i=1; a*i<=sum && i<=n; i++){
    ans += dp[n][a*i][i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 51072
using System;

namespace B___Echo
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            Console.WriteLine(S.Substring(0, N / 2) == S.Substring(N / 2) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
//By Bibi
///                 .-~~~~~~~~~-._       _.-~~~~~~~~~-.
///             __.'              ~.   .~              `.__
///           .'//                  \./                  \\`.
///        .'//                     |                     \\`.
///       .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
///     .'//.-"                 `-.  |  .-'                 "-.\\`.
///   .'//______.============-..   \ | /   ..-============.______\\`.
/// .'______________________________\|/______________________________`.
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define dep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
const int MAXN=1000;
int read(){
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int n;
int D,X;
int a[MAXN];
void init(){
	n=read();
	D=read();X=read();
	rep(i,1,n) a[i]=read();
}
void work(){
	rep(i,1,n){
		X+=(D-1)/a[i]+1;
	}
}
int main(){
	init();
	work();
	printf("%d",X);
	return 0;
}

Measured memory_bytes: 256