akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vl a(X), b(Y), c(Z);
    rep(i, X) cin >> a[i];
    rep(i, Y) cin >> b[i];
    rep(i, Z) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    vl ab(X*Y);
    {
        int id = 0;
        rep(i, X) rep(j, Y) {
            ab[id++] = a[i] + b[j];
        }
        sort(all(ab));
    }
    vector<ll> ans(K);
    using P = pair<ll, pii>; // sum, id_ab, id_c
    priority_queue<P> q;
    rep(i, Z) {
        q.push(make_pair(ab.back() + c[i], make_pair(ab.size()-1, i)));
    }
    rep(i, K) {
        auto p = q.top();
        q.pop();
        ans[i] = p.fi;
        int j = p.se.fi, k = p.se.se;
        if(j > 0) {
            q.push(make_pair(ab[j-1] + c[k], make_pair(j-1, k)));
        }
    }
    rep(i, K) {
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    int a[100000];
    cin >> n;
    rep(i, n){
        cin >> a[i];
    }

    bool up;
    int tmp = a[0];
    int idx = 1;
    for(int i=1; i<n; i++){
        if(a[i] > tmp){
            up = true;
            idx = i;
        } 
        else if(a[i] < tmp){
            up = false;
            idx = i;
        }

        if(tmp != a[i]){
            tmp = a[i];
            break;
        }
        tmp = a[i];
    }
    int count = 1;
    for(int i=idx+1; i<n; i++){
        if(tmp > a[i] && up){
            count++;
            tmp = a[i];
            for(int j=i+1; j<n; j++){
                if(a[j] > tmp){
                    up = true;
                    i = j;
                } 
                else if(a[j] < tmp){
                    up = false;
                    i = j;
                }
                if(tmp != a[j]){
                    break;
                }
                tmp = a[i];
            }
        }
        else if(tmp < a[i] && !up){
            count++;
            tmp = a[i];
            for(int j=i+1; j<n; j++){
                if(a[j] > tmp){
                    up = true;
                    i = j;
                } 
                else if(a[j] < tmp){
                    up = false;
                    i = j;
                }
                if(tmp != a[j]){
                    break;
                }
                tmp = a[i];
            }
        }
        tmp = a[i];
    }
    cout << count << endl;

    return 0;
}

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

int main() {
  int n,a;
  cin>>n;
  vector<int> vec(3);
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%4==0){
      vec.at(2)++;
      continue;
    }
    if(a%2==0){
      vec.at(1)++;
      continue;
    }
    else{
      vec.at(0)++;
      continue;
    }
  }
  if(vec.at(1)>0&&vec.at(0)>vec.at(2)){
    cout<<"No"<<endl;
    return 0;
  }
  if(vec.at(1)==0&&vec.at(0)>vec.at(2)+1){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll M = 1e9+7;  // 9..
const ll INF = 1e9+7;

ll n, m;
string s;
vector<ll> ans;

int main() {
  cin >> n >> m >> s;

  for (ll i = n; i > 0; ) {
    ll nxt = max(i-m, 0LL);
    while (nxt < i) {
      if (s[nxt] == '0') {
        ans.push_back(i-nxt);
        break;
      }
      nxt++;
    }
    if (nxt == i) {
      cout << -1 << endl;
      return 0;
    }
    i = nxt;
  }
  
  for (auto it = ans.rbegin(); it < ans.rend(); it++) {
    cout << *it << " ";
  }
  return 0;
}

Measured memory_bytes: 1528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int b(int a,vector<int> &v){
    int l=0,r=v.size()-1,ce;
    while(l!=r){
        ce=(l+r+1)/2;
        if(v[ce]<a) l=ce;
        else r=ce-1;
    }
    return l;
}

int main() {
    int n,cnt=0; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<int> color(n,-1);
    rep(i,n){
        int ch=b(a[i],color);
        if(color[ch]==-1) cnt++;
        color[ch]=a[i];
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

struct test{
    ll b,l,u;
    ll dis;
};
bool comptest(test a,test b){
    return a.dis>b.dis;
}

int main(){fastio
    ll n,x;cin>>n>>x;
    vector<test>v(n);
    rep(i,0,n-1){
        cin>>v[i].b>>v[i].l>>v[i].u;
        v[i].dis=x*v[i].u-v[i].b*v[i].u+v[i].b*v[i].l;
    }
    sort(v.begin(),v.end(),comptest);
    ll iniminus=0;
    rep(i,0,n-1){
        iniminus+=v[i].b*v[i].l;
    }
    ll plsum[n];
    rep(i,0,n-1){
        if(i==0)plsum[i]=0;
        else plsum[i]=plsum[i-1];
        plsum[i]+=x*v[i].u-v[i].b*v[i].u+v[i].b*v[i].l;
    }
    ll ko=-1;
    rep(i,0,n-1){
        if(plsum[i]>=iniminus){
            ko=i;break;
        }
    }
    /*
    cout<<ko<<endl;
    cout<<"plsum:";
    rep(i,0,n-1)cout<<plsum[i]<<" ";cout<<endl;*/
    ll ans=inf;
    rep(i,0,n-1){
        ll res;
        if(i<=ko){
            ll sumplus=plsum[ko]-v[i].dis;
            res=iniminus-sumplus;
        }else{
            ll sumplus=0;
            if(ko-1>=0)sumplus=plsum[ko-1];
            res=iniminus-sumplus;
        }
        if(x*v[i].u-v[i].b*v[i].u+v[i].b*v[i].l<res)continue;
        if(v[i].b*v[i].l>=res){
            Min(ans,(res+v[i].l-1)/v[i].l);
        }else{
            ll ad=(res-v[i].b*v[i].l+v[i].u-1)/v[i].u;
            Min(ans,v[i].b+ad);
        }
    }
    cout<<ans+ko*x<<endl;
    
    return 0;
}


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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(intmax_t, N);

    intmax_t res = LINF;
    for (intmax_t i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            chmin(res, i + N / i - 2);
        }
    }

    output(res);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
      	int K = sc.nextInt();
      	int S = sc.nextInt();
      	int count = 0;
      	
      	for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
           		int z = S - x - y;
              	if(z >= 0 && z <= K) count++;
            }
        }
      	System.out.println(count);
    }
}

Measured memory_bytes: 21716
N, K = map(int,input().split())
P = list(map(float,input().split()))
for i in range(N):
    P[i] = (P[i]+1.0)/2.0

anss=0        
for i in range(N-K+1):
    #print(i)
    #ans_kari = sum(P[i:i+K])
    if i==0:
        ans_kari = sum(P[i:i+K])
    else:
        ans_kari = ans_kari - P[i-1] + P[i+K-1]
    #print(ans_kari)
    #print(i)
    if ans_kari > anss:
        anss = ans_kari

print(anss)

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

using namespace std;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  vector<int> ans(n);
  for(int ri=0;ri<2;ri++){
    int cnt=0;
    for(int i=0;i<n;i++){
      if(s[i]=='L'){
        ans[i]+=cnt/2;
        ans[i-1]+=(cnt+1)/2;
        cnt=0;
      }
      else{
        cnt++;
      }
      if(s[i]=='L') s[i]='R';
      else s[i]='L';
    }
    reverse(s.begin(),s.end());
    reverse(ans.begin(),ans.end());
    
  }
  for(int i=0;i<n;i++){
    cout << ans[i] << endl;
  }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    string S, T;
    cin >> S >> T;
    bool ok = true;
    rep(i, S.size()) {
        if (S[i] != T[i]) ok = false;
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll A,B;
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int main(){
    cin >> A >> B;
    ll u = gcd(A,B);
    ll count = 0;
    for(ll i = 2;i*i<u;i++){
        if(u%i==0){
            count++;
            while(u%i==0){
                u /= i;
            }
        }

    }
    if(u!=1)count++;
    cout << count+1 << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s1, s2;
    cin >> s1;
    cin >> s2;

    bool flag = true;

    for (int i = 0; i < 3; i++) {
        if (s1[i] != s2[2 - i]) {
            flag = false;
            break;
        }
    }

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

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,a,b;
  cin >> x >> a >> b;
  x -= a;
  int ans = x / b * b;
  cout << x - ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod = 1000 * 1000 * 1000 + 7;

ll power(ll x, ll n) {
	ll res = 1;
	for (; n; n >>= 1, x = (x*x) % mod)
		if (n & 1)res = (res*x) % mod;
	return res;
}

int main() {
	int n; cin >> n;
	if (n == 1) { cout << 0 << '\n'; return 0; }
	ll one = power(9, n), two = power(8, n);
	ll sub = ((one << 1) - two + mod) % mod;
	cout << (power(10, n) - sub + mod) % mod << '\n';
	cin.ignore(2); return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

ll dp[25000200];
ll N;
ll ga[3];
ll gb[3];

void f() {
    dp[0] = 0;
    for(int val = 1; val <= N; val++) {
        dp[val] = dp[val-1] + 1;
        for(int j = 0; j <= 2; j++) {
            if(val >= ga[j]) chmax(dp[val], dp[val - ga[j]] + gb[j]);
        }
        //cerr << val << " " << dp[val] << endl;
    }
    N = dp[N];
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i <= 2; i++) cin >> ga[i];
    for(int i = 0; i <= 2; i++) cin >> gb[i];
    f();
    //return 0;
    swap(ga, gb);
    f();
    cout << N << endl;
    return 0;
    return 0;
}


Measured memory_bytes: 195584
#include <stdio.h>

int main(int argc, char *argv[])
{
        int x, y;

        while (1) {
                scanf("%d %d", &x, &y);

                if (x == 0 && y == 0) break;

                if (x < y) printf("%d %d\n", x, y);
                else printf("%d %d\n", y, x);
        }

        return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

vector<int> num(100);

typedef struct{
    int from;
    int to;
}Edge;

vector<Edge> G;

int dan(int n){
    for(int i=1;i<=9;i++){
        if(n<=i*(i+1)/2)return i;
    }
    return -1;
}

int point(vector<int> a, int turn){
    int res=0;
    set<int> setten;
    REP(i,G.size()){
        if(a[G[i].from]==0){
            setten.insert(G[i].to);
        }
    }
    
    for(auto itr=setten.begin();itr!=setten.end();itr++){
        if(a[*itr]!=0){
            int num_area=a[*itr];
            queue<int> q;
            q.push(*itr);
            while(q.size()!=0){
                int v=q.front();
                q.pop();
                REP(i,G.size()){
                    if(G[i].from==v){
                        if(a[G[i].to]==num_area){
                            q.push(G[i].to);
                        }
                    }
                }
                a[v]=0;
            }
        }
    }
    
    int minus=0;
    REP(i,a.size()){
        if(a[i]!=0){
            if(a[i]==turn)minus++;
            else res++;
        }
    }
    return res-minus;
}


int main(){
    
    while(true){
    int n,turn;
    cin>>n>>turn;
    if(n==0&&turn==0)break;
    G.clear();
    num.clear();
    REP(i,100)num.push_back(0);
    REP(i,n*(n+1)/2)cin>>num[i+1];
    
    
    for(int i=1;i<=n*(n-1)/2;i++){
        Edge e1,e1r,e2,e2r,e3,e3r;
        e1.from=e1r.to=e2.from=e2r.to=i;
        e1.to=e1r.from=e3.from=e3r.to=i+dan(i);
        e2.to=e2r.from=e3.to=e3r.from=i+dan(i)+1;
        G.push_back(e1);
        G.push_back(e2);
        G.push_back(e3);
        G.push_back(e1r);
        G.push_back(e2r);
        G.push_back(e3r);
    }
    
    int ans=-10000000;
    
    for(int i=1;i<=n*(n+1)/2;i++){
        if(num[i]==0){
            vector<int> numt=num;
            numt[i]=turn;
            ans=max(ans,point(numt,turn));
        }
    }
    
    cout<<ans<<endl;
    
        
    }
    
    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    string s; cin >> s;
    int w = 0, l = 0;
    rep(i, s.size()) {
        if(i % 2 == 0) {
            if(s[i] == 'p') l++;
        } else {
            if(s[i] == 'g') w++;
        }
    }
    cout << w - l << endl;
    return 0;
}


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

using namespace std;

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

int n;
ll a, b, c, d;

int main() {
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	int i, flag = 0;
	b-=a;
	for (i=0;i<n;i++) {
		if (c*i-d*(n-1-i)<=b&&b<=d*i-c*(n-1-i)) {
			flag = 1;
		}
	}
	if (flag) printf("YES\n");
	else printf("NO\n");

    return 0;
}


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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define rep0(i,n) for (int i=0; i<(n); i++)
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; }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%ld "; return r + "\n"; }
#define debug(...) do { printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__); } while(0)
#define fast_ios() do {} while(0);
#else //_DEBUG
#define debug(...) do {} while(0)
#define fast_ios() do { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } while(0)
#endif //_DEBUG

int main() {
    fast_ios();

    int x;
    cin >> x;
 
    ll ans = (x / 500) * 1000 + ((x % 500) / 5) * 5;
    cout << ans << endl;
}


Measured memory_bytes: 3580
h,w = map(int,input().split())
s = [['.']*(w) for i in range(h+2)]

for i in range(h):
    s[i+1] = [x for x in input()]

for i in range(h+2):
    s[i].insert(w,".")
    s[i].insert(0,".")

flg ="Yes"
for i in range(h+2):
    for j in range(w+2):
        if s[i][j] == "#":
            if s[i-1][j]=="#" or s[i+1][j]=="#" or s[i][j-1]=="#" or s[i][j+1]=="#":
                pass
            else:
                flg = "No"
print(flg)


Measured memory_bytes: 40816
import sys
import numpy as np
import math as mt

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
cnt = 1
while n != 1:
  n = n//2
  cnt += 1

print(sum(2**i for i in range(cnt)))
    


Measured memory_bytes: 27000
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,a;
Vi x;

ll dp[51][2510][51];


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>a;
    x.resize(n);
    rep(i,n){
        cin>>x[i];
    }
    rep(i,50){
        rep(j,2510){
            rep(k,50)dp[i][j][k] = 0;
        }
    }
    dp[0][0][0]=1;
    rep(i,n){
        rep(j,2501){
            rep(k,n){
                if(dp[i][j][k]==0)continue;
                ll tp = j + x[i];
                if(tp<=2500){
                    dp[i+1][tp][k+1] += dp[i][j][k];
                }
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    rep(i,n){//i+1個
        ll tp = (i+1)*a;
        ans += dp[n][tp][i+1];
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 50816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i=0;i<M;i++){
    cin >> B[i];
  }
  vector<vector<int>> A(N,vector<int>(M));
  for (int i=0;i<N;i++){
    for (int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  int ans=0;
  for (int i=0;i<N;i++){
    int sum=0;
    for (int j=0;j<M;j++){
      sum+=B[j]*A[i][j];
    }
    if (sum+C>0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<list>
#include<string>
#include<unordered_map>
#include<set>
#include<limits.h>
#include<string.h>
#include<functional>
#include<map>
#include<unordered_set>
#define int long long
using namespace std;

signed main() {
	int a, b; cin >> a >> b;
	if (a == 1) {
		if (b == 1) {
			cout << 1 << endl;
		}
		else {
			cout << b - 2 << endl;
		}
	}
	else {
		if (b == 1) {
			cout << a - 2 << endl;
		}
		else {
			cout << a * b - (a+b-2)*2 << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#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, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, v[1000];
    cin >> N;
    REP(i, N) cin >> v[i];
    sort(v, v + N);

    double before = v[0];
    FOR(i, 1, N) before = (v[i] + before) / 2;
    cout << setprecision(12) << before << endl;
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> c(n);
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    
    int ans = 0;
    for(int i=0; i<n; i++){
        if(v[i] - c[i] > 0){
            ans += v[i] - c[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/agc016/tasks/agc016_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    string s; cin>>s;
    auto check = [](string& ins){
        assert(ins.size()>0);
        char c=ins[0];
        bool ret=true;
        for(ll i=1;i<ins.size();++i){
            if(c!=ins[i]) {
                ret=false;
                break;
            }
        }
        return ret;
    };
    ll ans=INT64_MAX;
    for(char c='a';c<='z';++c){
        string cur=s;
        ll cnt=0;
        while(!check(cur)){
            //消すの決める
            ll i=cur.size()-1;
            for(;i>=0;--i){
                if(cur[i]!=c) {
                    break;
                }
            }
            for(ll j=0;j<i;++j){
                if(cur[j+1]==c) cur[j]=c;
            }
            cur.erase(cur.begin()+i);
            ++cnt;
        }
        ans=min(cnt,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	int K;
	cin >> K;
	if (K % 2 == 0 || K % 5 == 0) {
		cout << -1 << endl;
		return 0;
	}
	ll V = 0;
	for (int i = 1;i <= K;i++) {
		V = (V * 10 + 7) % K;
		if (V == 0) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
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; }

string s;

int main(){
  cin >> s;
  int n = s.size();
  int res = 0, left = -1;
  for(int i = 0; i < n; i++){
    char c = s.at(i);
    if(c != 'A' && c != 'G' && c != 'C' && c != 'T'){
      left = i;
    }
    chmax(res, i - left);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n1,n2,n;
    cin>>n1>>n2;
    n=n1+n2;
    if(n<10){
        cout<<n1+n2<<endl;
    }
    else{
        cout<<"error"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n;
string s;
vector <int> v[266];
int main() {
	ios_base::sync_with_stdio(false);

	cin >> s;
	int ans = s.size() - 1;
	for(char c = 'a'; c <= 'z'; c++) v[c].push_back(0);
	for(int i = 0; i < s.size(); i++)
		v[s[i]].push_back(i + 1);
	for(char c = 'a'; c <= 'z'; c++) v[c].push_back(s.size() + 1);

	for(char c = 'a'; c <= 'z'; c++) {
		int tmp = 0;
		for(int j = 1; j < v[c].size(); j++)
			tmp = max(tmp, v[c][j] - v[c][j - 1] - 1);
		ans = min(ans, tmp);
	}
	cout << ans << '\n';

}	

	

Measured memory_bytes: 256
class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

N, K = map(int, input().split())
K = min(K, N)
MOD = 10**9 + 7
comb = Combination(N + 100)

ans = 0
for k in range(K + 1):
    ans += comb.ncr(N, k) * comb.nhr(N - k, k)
    ans %= MOD

print(ans)


Measured memory_bytes: 30388
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i =a; i < (b);++i)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
main(){
    ll n, k;
    cin >> n >> k;
    ll a[n+1], dp[n+1][k+1], dp_pre[n+1][k+2], pre[n+1];
    memset(dp, 0, sizeof dp);
    memset(dp_pre, 0, sizeof dp_pre);
    pre[0] = 0;
    rep(i, 0, n) cin >> a[i + 1];
    sort(a + 1, a + n + 1);
    rep(i ,0 ,n)  pre[i+1] = pre[i] + a[i+1];
    rep(i, 0 ,n+1) dp[i][0] = 1, dp_pre[i][1] = 1;
    rep(i, 0, min(pre[1], k) + 1) dp[1][i] = 1;
    rep(i, 1, k + 1) dp_pre[1][i+1] = (dp_pre[1][i] + dp[1][i]) % mod;
    rep(i, 2, n+1){
        rep(j, 1, min(pre[i], k) + 1){
            //cout << i << ' ' << j << '\n';
            ll dj =  min((ll)j, pre[i-1]);
            //cout << dj << '\n';
            dp[i][j] = ((dp_pre[i-1][dj+1] - dp_pre[i-1][max(0LL, j - a[i])])%mod + mod ) % mod;
            dp_pre[i][j+1] = (dp_pre[i][j] + dp[i][j])%mod;
        }
    }
    /*rep(i, 0, n + 1){
        rep(j , 0, k+2){
            cout << dp_pre[i][j] << ' ';
        }
        cout << '\n';
    }
    
    rep(i, 0, n+1){
        rep(j, 0, k + 1){
            cout << dp[i][j] << ' ';
        }
        cout<< '\n';
    }*/
    cout << dp[n][k] << '\n';
}

Measured memory_bytes: 158080
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#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 <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

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

    int a, b;
    cin >> a >> b;
    if( ( a + b ) % 2 ) cout << "IMPOSSIBLE";
    else cout << ( a + b ) / 2;
    cout << endl;
    return 0;
}



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

int main() {
  int X,N;
  double a,b,x,m,n,A;
  cin >> a >> b;
  
  x =(a+b)/2;
  X =(a+b)/2;
  
  m =x-X;
  N = m+0.9;
  A = X+N;
  cout  << A << endl;
  
  /*
  x =(a+b)/2;
  X =(a+b)/2;
  
  m =x-X;	//小数部分だけ
  n = m/m;	//0の時/にすると-namになってしまう
  A = X+n;	//
  cout  << A << endl;
  */
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
xlist = [0, w]
ylist = [0, h]
for count in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and xlist[0] < x: xlist[0] = x
    elif a == 2 and xlist[1] > x: xlist[1] = x
    elif a == 3 and ylist[0] < y: ylist[0] = y
    elif a == 4 and ylist[1] > y: ylist[1] = y
print(max(0, xlist[1] - xlist[0]) * max(0, ylist[1] - ylist[0]))


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

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

  bool ans=true;
  for(int i=0; i<s.size(); ++i){
    if(i%2==0 && s[i]=='L'){ans=false; break;}
    if(i%2==1 && s[i]=='R'){ans=false; break;}
  }

  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]

def dfs(question_num, rquired_point):
    if question_num < 0:
        return 10 ** 9

    point = (question_num+1) * 100
    ans_num = min(rquired_point // point, pc[question_num][0])
    score = ans_num * point

    if ans_num == pc[question_num][0]:
        score += pc[question_num][1]

    if rquired_point > score:
        ans_num += dfs(question_num-1, rquired_point-score)
    
    return min(ans_num, dfs(question_num-1, rquired_point))

print(dfs(D-1, G))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

void success(int x, int y, int z) {
  cout << x << " " << y << " " << z << endl;
  exit(0);
}

void err() {
  cout << -1 << " " << -1 << " " << -1 << endl;
  exit(0);
}

int main() {
  int N, Y;
  cin >> N >> Y;

  int A = Y / 10000 + 1;
  int B = Y / 5000 + 1;
  rep(i,A) {
    rep(j, B) {
      int C = N - i - j;
      if (C < 0) continue;
      if (i * 10000 + j * 5000 + C * 1000 == Y) success(i, j, C);
    }
  }
  err();
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e3+6;


int s(int n)
{
	int ans=0;
	while(n)
	{
		ans+=n%10;
		n/=10;
	}
	return ans;
}

int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		if(n%s(n))	printf("No\n");
		else		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 256
main () {
  int a, b, i, j;
  while(~scanf("%d %d", &a, &b)) {
    if (!a && !b) return 0;
    for (i = 0; i < a; i++) {
      for (j = 0; j < b; j++) putchar(i == 0 || i == a - 1 || j == 0 || j == b - 1 ? '#' : '.');
      putchar('\n');
    }
    putchar('\n');
  }
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



signed main() {
	int n, ans = 0;cin>>n;
	int b[100];rep(i,n-1)cin>>b[i];
	ans += b[0] + b[n-2];
	repd(i,0,n-2){
		ans += min(b[i], b[i+1]);
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	string S;
	cin >> N;
	cin >> S;
	if (N < 3200) {
		cout << "red" << endl;
	}
	else {
		cout << S << endl;
	}
}

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

int main(){
  ll n;
  cin>>n;
  ll x=n%10;
  if(x==2 or x==4 or x==5 or x==5 or x==7 or x==9){
    cout<<"hon\n";
  }
  else if(x==0 or x==1 or x==6 or x==8){
    cout<<"pon\n";
  }
  else{
    cout<<"bon\n";
  }
}

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

using namespace std;

#define M 600001

int main(){
  int N,Q,q,in,c[M]={0};
  cin >> N >> Q;
  for(int i = 0 ; i < N ; i++){
    scanf("%d",&in);
    c[in] = in;
  }
  for(int i = 1 ; i < M ; i++){
    c[i] = max(c[i],c[i-1]);
  }
  while(Q--){
    cin >> q;
    int r = 0;
    for(int i = q-1 ; i < M ; i += q){
      r = max(r,c[i]%q);
    }
    printf("%d\n",r);
  }
  return 0;
}

Measured memory_bytes: 3576
import numpy as np
    
N = int(input())
MOD=7+10**9

def pattern_calc(num,i,j,k,l):
    #print(num,":",i,",",j,",",k,",",l,end="")
    
    #最終4文字がNGならパターン数0
    if calc_result[0,i,j,k,l]==0:
        #print("last 4 char is NG pattern.")
        sub_ans = 0
        
    else:
        if calc_flag[num,i,j,k,l] == True:
            sub_ans = calc_result[num,i,j,k,l]
            #print("…Calculated:",calc_result[num,i,j,k,l])
        else:
            #print("…Need  Calc :")

            for atot in range(4): 
                calc_result[num,i,j,k,l] = calc_result[num,i,j,k,l] + pattern_calc(num-1,atot,i,j,k)%MOD #uint64にしてもエラー出たのでここにもMODを入れた。
                #print(pattern_calc(num-1,atot,i,j,k))
                #print(calc_result[num,i,j,k,l])
                
            calc_flag[num,i,j,k,l] = True
            sub_ans = calc_result[num,i,j,k,l]
            #print(num,":",i,",",j,",",k,",",l,"→",sub_ans)
    return sub_ans            

if N==3:
    print("61")
else:   
    calc_result = np.zeros((N-3,4,4,4,4),dtype=np.uint64) #計算結果。[]の条件を満たせるのは何通りあるか? #ここがfloatだとダメだった!!!
    #ex
    #result_list[0,0,1,2,3]…最後4文字がA,G,C,TでAより前の文字数が0のパターンは満たせるか? → 0
    #result_list[1,0,1,2,3]…最後4文字がA,G,C,TでAより前の文字数が0のパターンは満たせるか? → 0


    #result_list[0,0,1,2,3]…0
    #result_list[0,1,1,2,3]…1
    #result_list[0,2,1,2,3]…1
    #result_list[0,3,1,2,3]…1

    #result_list[1,1,2,3,0]…最後4文字がG,C,T,AでGより前の文字数が1のパターンは満たせるか? → 3
    #result_list[2,2,3,0,1]…最後4文字がC,T,A,GでCより前の文字数が1のパターンは満たせるか? 
    #   →result_list[1,0,2,3,0],result_list[1,1,2,3,0],result_list[1,2,2,3,0],result_list[1,3,2,3,0]のSUM

    calc_flag = np.zeros((N-3,4,4,4,4), dtype=np.bool) #計算済みか
    #A→0,G→1,C→2,T→3として扱う。

    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    calc_result[0,i,j,k,l] = 1
                    calc_flag[0,i,j,k,l] = True

    calc_result[0,0,0,1,2]=0
    calc_result[0,0,0,2,1]=0
    calc_result[0,0,1,1,2]=0
    calc_result[0,0,1,3,2]=0
    calc_result[0,0,1,2,0]=0
    calc_result[0,0,1,2,1]=0
    calc_result[0,0,1,2,2]=0
    calc_result[0,0,1,2,3]=0
    calc_result[0,0,1,0,2]=0
    calc_result[0,0,2,1,0]=0
    calc_result[0,0,2,1,1]=0
    calc_result[0,0,2,1,2]=0
    calc_result[0,0,2,1,3]=0
    calc_result[0,0,3,1,2]=0
    calc_result[0,1,0,1,2]=0
    calc_result[0,1,0,2,0]=0
    calc_result[0,1,0,2,1]=0
    calc_result[0,1,0,2,2]=0
    calc_result[0,1,0,2,3]=0
    calc_result[0,1,1,0,2]=0
    calc_result[0,2,0,2,1]=0
    calc_result[0,2,1,0,2]=0
    calc_result[0,2,0,1,2]=0
    calc_result[0,3,0,2,1]=0
    calc_result[0,3,1,0,2]=0
    calc_result[0,3,0,1,2]=0

    N = N - 4
    ans = 0
    
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    #print(N,",",i,",",j,",",k,",",l,":",int(pattern_calc(N,i,j,k,l)))
                    ans = (ans + pattern_calc(N,i,j,k,l))

    print(int(ans%MOD))
    
    #29まではOKっぽい?
    #30 正答　531294469　自分の　531293960…5093足りない →floatからintに直したらいけた!

Measured memory_bytes: 14556
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  int x,y;
  cin >> x >> y;

rep(i,x+1){
  int a = x - i; 
if(y == i * 2 + a * 4){
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592
S = input()
N = len(S)
ans1 = 0
ans2 = 0
for i in range(N):
  if i % 2 == 0 and S[i] == "0":
    ans1 += 1
  if i % 2 == 1 and S[i] == "1":
    ans1 += 1
for i in range(N):
  if i % 2 == 0 and S[i] == "1":
    ans2 += 1
  if i % 2 == 1 and S[i] == "0":
    ans2 += 1
print(min(ans1, ans2))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(){
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> g(n+1);
    vector<p> vp;
    for(ll i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        vp.push_back(p(a, b));
    }
    ll ans = 0;
    for(ll i = 0; i < m; i++){
        ll a = vp[i].first, b = vp[i].second;
        vector<ll> dist(n+1, -1);
        queue<ll> que;
        dist[1] = 0;
        que.push(1);
        while(!que.empty()){
            ll v = que.front();
            que.pop();
            for(ll nv : g[v]){
                if(dist[nv]!=-1) continue;
                if(a==v&&b==nv || a==nv&&b==v) continue;
                dist[nv] = dist[v]+1;
                que.push(nv);
            }
        }
        bool ok = false;
        for(ll j = 1; j <= n; j++){
            //cout << j << " " << dist[j] << endl;
            if(dist[j]==-1) ok = true;
        }
        if(ok==true) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
"""
References
----------
[0]. 解説(公式), https://img.atcoder.jp/abc144/editorial.pdf, AtCoder
    - O(NM)
[1]. kmjp. AtCoder ABC #144 : F - Fork in the Road, <http://kmjp.hatenablog.jp/entry/2019/10/28/0930>, kmjp's blog
    - O(NM)
[2]. physics0523. Fork in the Road(ABC144-F), <https://physics0523.hatenablog.com/entry/2019/10/27/235334>, physics0523's 精進ログ
    - O(M)
[3]. Genki Ogaki. BC144 F - Fork in the Road考察＋参戦記, <https://www.onakasuitacity.com/abc144-f>, おじさん、今日プロ始
めるってよ
    - O(M)
"""
def solve(n, m, s, t):
    edges = [[] for i in range(n)]
    for i in range(m):
        u, v = s[i], t[i]
        edges[u-1].append(v-1)
    p = [0] * n
    p[0] = 1
    for i in range(n):
        for j in edges[i]:
            p[j] += p[i] / len(edges[i])
    E = [0] * n
    for i in range(n-2, -1, -1):
        v = [E[j] for j in edges[i]]
        E[i] = 1 + sum(v) / len(v)
    res = E[0]
    for i in range(n):
        deg = len(edges[i])
        if deg <= 1:
            continue
        k = max((E[j], j) for j in edges[i])[1]
        v = [E[j] for j in edges[i] if j != k]
        res = min(res, E[0] + p[i] * (sum(v) / (deg-1) - E[k]) / deg)
    return res

n, m = map(int, input().split())
s = [0] * m
t = [0] * m
for i in range(m):
    s[i], t[i] = map(int, input().split())
print(solve(n, m, s, t))

Measured memory_bytes: 18756
# Distance

points = [float(i) for i in input().rstrip().split()]
a = [points[0], points[1]]
b = [points[2], points[3]]

distanceSquare = (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2
distance = distanceSquare ** 0.5

print(distance)



Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define N 100009
#define mod 998244353
using namespace std;

int n,m,dp[N][2]; map<pii,int> mp;
int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
void gg(){ puts("0"); exit(0); }
int pw(ll y){
	int x=2,ans=1; y=max(0ll,y);
	for (; y; y>>=1,x=(ll)x*x%mod) if (y&1) ans=(ll)ans*x%mod;
	return ans;
}
int calc(int x,int y){ return mp[mpr(x,y)]-1; }
int main(){
	scanf("%d%d",&n,&m);
	int i,j,k,x,y,z,ans=1; ll cnt=0;
	for (i=1; i<=m; i++){
		scanf("%d%d%d",&x,&y,&z);
		mp[mpr(x,y)]=z+1;
		if (abs(x-y)>2){
			if (calc(y,x)==-1) cnt++; else
			if (calc(y,x)!=calc(x,y)) gg();
			//cerr<<calc(x,y)<<' '<<calc(y,x)<<'\n';
			//cnt+=(calc(y,x)==-1);
		}
	}
	cerr<<cnt<<'\n';
	for (i=2; i<n; i++){
		int x=calc(i-1,i+1),y=calc(i,i),z=calc(i+1,i-1);
		//cerr<<x<<' '<<y<<' '<<z<<'\n';
		if (x!=-1 && y!=-1 && z!=-1)
			if (x^y^z) gg();
		ans=(ll)ans*pw(1-(x!=-1)-(z!=-1))%mod;
		if (y==-1 && x!=-1 && z!=-1){
			mp[mpr(i,i)]=(x^z)+1;
			cerr<<i<<' '<<i<<' '<<(x^z)<<'\n';
		}
	}
	cnt=((ll)n*n-n-(n-1)*2-(n-2)*2)/2-cnt;
	cerr<<'?'<<cnt<<'\n';
	ans=(ll)ans*pw(cnt)%mod;
	cerr<<ans<<'\n';
	dp[1][0]=(calc(1,1)!=1); dp[1][1]=(calc(1,1)!=0);
	for (i=2; i<=n; i++)
		for (j=0; j<2; j++)
			for (k=0; k<2; k++){
				if (calc(i,i)!=-1 && calc(i,i)!=k) continue;
				x=calc(i-1,i); y=calc(i,i-1);
				if (x!=-1 && y!=-1)
					if (x^y^j^k) continue;
				ad(dp[i][k],(ll)dp[i-1][j]*pw(1-(x!=-1)-(y!=-1)));
			}
	cerr<<pw((ll)n*(n+1)/2)<<'\n';
	printf("%lld\n",(ll)ans*(dp[n][0]+dp[n][1])%mod);
	return 0;
}


Measured memory_bytes: 38528
N, K = map(int, input().split())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7
f = [1]
for i in range(1,N+1):
    f.append((f[-1] * i) % mod)
def comb(n,r):
    return f[n] * (pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod) % mod

A.sort()
ans = 0
for i in range(N-K+1):
    c = comb(N-1-i,K-1)
    ans -= (A[i] * c) % mod 
    ans += (A[-(i+1)] * c) % mod 
    ans %= mod
print(ans)

Measured memory_bytes: 14416
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n-2):
  if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2]):
    cnt+=1
print(cnt)

Measured memory_bytes: 3064