akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int a[MAXN],b[MAXN],c[MAXN];
int main()
{
	int n=read(),Ans=0;
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n;i++) b[i]=read();
	sort(b+1,b+n+1);
	for (int i=0;i<=28;i++)
	{
		int p=1<<i,ans=0;
		for (int j=1;j<=n;j++) c[j]=b[j]%(p<<1);
		sort(c+1,c+n+1);
		for (int j=1,l,r;j<=n;j++)
		{
			int t=a[j]%(p<<1);
			l=lower_bound(c+1,c+n+1,p-t)-c,r=lower_bound(c+1,c+n+1,p*2-t)-c,ans+=(r-l);
			l=lower_bound(c+1,c+n+1,p*3-t)-c,r=lower_bound(c+1,c+n+1,p*4-t)-c,ans+=(r-l);
		}
		Ans+=p*(ans&1);
	}
	printf("%d\n",Ans);
	return 0;
}


Measured memory_bytes: 6060
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
const ull MOD = 998244353;
#ifdef LOCAL
#include "../../pp.hpp"
#define debug pp::debug
#else
#define debug(args...)
#endif

vector<long> ps, a;
vector<vector<long>> dp;

long solve(int beg, int end) {
    if (beg == end) return 0;
    if (beg + 1 == end) return a[beg] + a[end];
    if (dp[beg][end] != -1) return dp[beg][end];

    long ans = std::numeric_limits<long>::max();
    for (int i = beg; i < end; ++i) {
        long curr = solve(beg, i) + solve(i+1, end);
        curr += ps[i];
        if (beg != 0) curr -= ps[beg - 1];
        curr += ps[end] - ps[i];
        ans = min(ans, curr);
    }
    dp[beg][end] = ans;
    return ans;
}

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

    int n; cin >> n;
    a = vector<long>(n); for (int i = 0; i < n; ++i) cin >> a[i];
    ps = vector<long>(n); ps[0] = a[0]; for (int i = 1; i < n; ++i) ps[i] = ps[i-1] + a[i];
    dp = vector<vector<long>>(n, vector<long>(n, -1));

    long ans = solve(0, n-1);
    cout << ans << '\n';
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    rep(a, 0, 10) {
        int a_i = -1;
        char a_ = to_string(a)[0];
        rep(i, 0, N-2) {
            if (S[i] == a_) {
                a_i = i;
                break;
            }
        }
        if (a_i == -1) continue;
        rep(b, 0, 10) {
            int b_i = -1;
            char b_ = to_string(b)[0];
            rep(i, a_i+1, N-1) {
                if (S[i] == b_) {
                    b_i = i;
                    break;
                }
            }
            if (b_i == -1) continue;
            rep(c, 0, 10) {
                char c_ = to_string(c)[0];
                rep(i, b_i+1, N) {
                    if (S[i] == c_) {
                        res++;
                        break;
                    }
                }
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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 rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  // Here, try [0, 2*(max(x,y))] of pizza c.
  ll ans = a*x+b*y;
  chmin(ans, max(0ll,y-x)*b+x*2*c);
  chmin(ans, max(0ll,x-y)*a+y*2*c);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=m;i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back




int main(){

    int h,w,k;
    cin>>h>>w>>k;

    vector<string> data(h);

    rep(i,h){
        string tmp;
        cin>>tmp;
        data.at(i)=tmp;
    }

    int answer=0;

    rep(i,(1<<(h+w))){
        bitset<12> s(i);

        int cnt=0;

        rep(x,h){
            rep(y,w){
                if (s.test(x) and s.test(h+y) and data.at(x).at(y)=='#'){
                    cnt++;


                }
            }
        }

        if (cnt==k){
            answer++;

        }



    }

    cout<<answer<<endl;



}

Measured memory_bytes: 3584
# coding: utf-8
# Here your code !

def operate_string():

    (method, i_first, i_last, str_new) = ("method", "i_first", "i_last", "replace string")

    #load data
    operations = []
    try:
        string = input().rstrip()
        _ = input()
        while(True):
            line = input().rstrip().split()
            operations.append({method : line[0], i_first : int(line[1]), i_last : int(line[2])})
            if len(line) > 3 :
                operations[-1].update({str_new : line[3]})
    except EOFError:
        pass
    except:
        return __inputError()

    #operate string
    for ope in operations:
        if ope[method] == "print" :
            print(string[ope[i_first]:ope[i_last]+1])
        elif ope[method] == "reverse" :
            string = reverse_string_by_index (string, ope[i_first], ope[i_last])
        elif ope[method] == "replace" :
            string = replace_string_by_index (string, ope[str_new], ope[i_first], ope[i_last])
        else :
            return __inputError()


def replace_string_by_index (str_raw, str_new, i_first, i_last):
    pre_post_info = __set_pre_post_string(str_raw, i_first, i_last)
    if pre_post_info["invalid index"] :
        return str_raw

    return pre_post_info["pre"] + str_new + pre_post_info["post"]

def reverse_string_by_index (str_raw, i_first, i_last):
    pre_post_info = __set_pre_post_string(str_raw, i_first, i_last)
    if pre_post_info["invalid index"] :
        return str_raw

    str_reversed = str_raw[i_last:i_first-1:-1]
    if i_first == 0 :
        str_reversed = str_raw[i_last::-1]

    return pre_post_info["pre"] + str_reversed + pre_post_info["post"]

def __set_pre_post_string (str_raw, i_first, i_last):

    info = {"pre" : "", "post" : "", "invalid index" : False}
    info["pre"]  = str_raw[:i_first]
    info["post"] = "" if (i_last == -1) else str_raw[i_last+1:]
    info["invalid index"] = ( len(info["pre"]) + len(info["post"]) >= len(str_raw) )
    
    return info

def __inputError():
    print("input Error")
    return -1

def __Test_reverse_string_by_index (lists):
    #list[index] = [str_raw, i_first, i_last]
    for item in lists:
        print(reverse_string_by_index(item[0], item[1], item[2]))

def __Test_replace_string_by_index (lists):
    #list[index] = [str_raw, str_new, i_first, i_last]
    for item in lists:
        print(replace_string_by_index(item[0], item[1], item[2], item[3]))


#test
if __name__ == "__main__" :
    
    operate_string()
    
    '''
    __Test_replace_string_by_index ([ ["abc","A",0,1], ["abc","A",-5,-1], ["abc","",1,1], ["","A",0,0],      ["abc","A",5,6] ])
    #expected results:                 "Ac",            "A",               "ac",           ""(string error),  "abc"(index error)
    
    __Test_reverse_string_by_index ([ ["abc",0,2], ["abc",-5,-1], ["abc",3,3] ])
    #expected results:                 "cba",       "cba",         "abc"(index error)
    '''
        

Measured memory_bytes: 7832
# https://onlinejudge.u-aizu.ac.jp/problems/DPL_2_A


INF = float('inf')


def rec(bit, v):
    if dp[bit][v] != -1:
        return dp[bit][v]

    if (1 << V) - 1 == bit and v == 0:
        dp[bit][0] = 0
        return 0

    res = INF
    if v in D:
        for to, dist in D[v].items():
            if not (bit & (1 << to)):
                res = min(res, rec(bit | (1 << to), to) + dist)

    dp[bit][v] = res
    return res


if __name__ == "__main__":
    D = {}
    V, E = list(map(int, input().split()))
    for _ in range(E):
        s, t, d = list(map(int, input().split()))
        if s not in D:
            D[s] = {}
        D[s][t] = d

    dp = [[-1] * (V) for _ in range(1 << V)]

    print(dp[0][0] if rec(0, 0) != INF else -1)



Measured memory_bytes: 15460
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int t=0,ma=0;
  for(char c:S){
    if(c=='T')
      t++;
    else
      t--;
    ma=max(t,ma);
  }
  cout<<ma*2<<endl;
}

Measured memory_bytes: 3700
program ABC174B
    implicit none
    integer(8)::N,D,i,X,Y,ans=0
    read*,N,D
    do i=1,N
        read*,X,Y
        if(X**2+Y**2<=D**2)ans=ans+1
    end do
    print'(i0)',ans
end program ABC174B

Measured memory_bytes: 2896
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

using Point = complex<double>;
struct Line {
    Point s, t;
    Line(Point s, Point t) : s(s), t(t){}
};
double dot(Point p, Point q) { return (conj(p) * q).real(); }
double cross(Point p, Point q) { return (conj(p) * q).imag(); }
Point project(Line l, Point p) { // project p onto line (s,t)
    return l.s + (l.t - l.s) * dot(p - l.s, l.t - l.s) / norm(l.t - l.s);
}
Point reflect(Line l, Point p) {
    return l.s + conj((p - l.s) / (l.t - l.s)) * (l.t - l.s);
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    Point p1(a, b), p2(c, d);
    Line l(p1, p2);
    cout << fixed << setprecision(10);

    int q;
    cin >> q;
    for(int i=0; i < q; ++i) {
        double x,y;
        cin >> x >> y;
        Point ret = reflect(l, Point(x, y));
        cout << ret.real() << " " << ret.imag() << '\n';
    }
    return 0;
}


Measured memory_bytes: 3320
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    cout << N * N * N << endl;
    return 0;
}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

struct Stuple {
    int first; int second; int third;
    Stuple() = default;
    Stuple(int first, int second, int third): first(first), second(second), third(third){ }
    operator tuple<int, int, int> () const { return make_tuple(first, second, third); }
    bool operator < (const Stuple& e) const { return tie(first, second, third) < tie(e.first, e.second, e.third); }
    // ostream& operator >> (ostream& out) const { prints(tie(first, second, third)); return out; }
};

struct UnionFind {
	vector<Stuple> elems;
	// vector<pair<int, int>> elems;
	UnionFind(int n):elems(n){
		for(int i = 0; i < n; i++){
			elems[i].first = i;
			elems[i].second = 1;
			elems[i].third = 0;
		}
	}
	bool same(int a, int b){
		return parent(a) == parent(b);
	}
	void unite(int a, int b){
		if(elems[parent(a)].first == parent(b)){ return; }
		int sum = getSum(a) + getSum(b);
		int sum2 = getSum2(a) + getSum2(b);
		//cout<<"sum "<<sum<<endl;
		elems[parent(a)].first = parent(b);
		elems[parent(b)].second = sum;
		elems[parent(b)].third = sum2;
	}
	int getSum(int a){
		if(a == elems[a].first){
			return elems[a].second;
		}
		return getSum(elems[a].first);
	}

	int getSum2(int a){
		if(a == elems[a].first){
            return elems[a].third;
		}
		return getSum2(elems[a].first);
	}
	void addSum2(int a){
		if(a == elems[a].first){
			elems[a].third++;
		}else{
            addSum2(elems[a].first);
        }
	}
private:
	int parent(int a){
		if(a == elems[a].first){
			return a;
		}
		return elems[a].first = parent(elems[a].first);
	}
};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    vector<int> rs(n), cs(n), as(n);
    for(int i = 0; i < n; i++){
        cin >> rs[i] >> cs[i] >> as[i];
    }
    vector<int> is(n);
    iota(is.begin(), is.end(), 0);
    sort(is.rbegin(), is.rend(), [&](int i, int j){ return as[i] < as[j]; });
    UnionFind uf(h + w + 2);
    ll ans = 0;
    for(auto& i : is){
        int r = rs[i], c = cs[i], a = as[i];
        uf.unite(r, h + 1 + c);
        printde(i, a, r, c, uf.getSum(r), uf.getSum2(r));
        if(uf.getSum(r) > uf.getSum2(r)){
            // printde(ans, i, a);
            uf.addSum2(r);
            ans += a;
            printde(ans, r, c);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4608
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace AtCoderABC111
{
    class Pa
    {
        public int v;
        public int count;
        public Pa(int a)
        {
            v = a;
            count = 0;
        }
    }
    class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Pa[] v_odd = new Pa[100001];
            Pa[] v_even = new Pa[100001];
            for (int i = 0; i < 100001; i++)
            {
                v_odd[i] = new Pa(i);
                v_even[i] = new Pa(i);
            }
            string[] s = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                if (i % 2 == 0)
                {
                    v_even[int.Parse(s[i])].count++;
                }
                else
                {
                    v_odd[int.Parse(s[i])].count++;
                }
            }
            List<Pa> sorted_odd = v_odd.OrderByDescending(x => x.count).ToList();
            List<Pa> sorted_even = v_even.OrderByDescending(x => x.count).ToList();
            int odd_num = n / 2;
            int even_num = n - odd_num;
            Pa odd_first = sorted_odd[0];
            Pa odd_second = sorted_odd[1];
            Pa even_first = sorted_even[0];
            Pa even_second = sorted_even[1];
            int res_ff = odd_num + even_num - odd_first.count - even_first.count;
            int res_fs = odd_num + even_num - odd_first.count - even_second.count;
            int res_sf = odd_num + even_num - odd_second.count - even_first.count;
            if (odd_first.v != even_first.v)
            {
                Console.WriteLine(res_ff);
            }
            else
            {
                Console.WriteLine((res_fs > res_sf)? res_sf: res_fs);
            }
        }
    }
}

Measured memory_bytes: 36956
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll dp[101][100001];
ll mod=1e9+7;
int main(){
    int n,k,A[200001];
    cin>>n>>k;
    rep(i,n) cin>>A[i];
    fill(dp[0],dp[0]+k+1,0);
    dp[0][0]=1;
    rep(i,n){
        rep(j,k) (dp[i][j+1]+=dp[i][j])%=mod;
        rep(j,k+1){
            dp[i+1][j]=dp[i][j];
            if(j-A[i]-1>=0) (dp[i+1][j]+=mod-dp[i][j-A[i]-1])%=mod;
        }
    }
    cout<<dp[n][k]<<"\n";
}

Measured memory_bytes: 79104
let n, a, b = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let cs = Array.make 3 0
let f i = cs.(i) <- cs.(i) + 1
let _ = Array.(iter (fun p -> if p <= a then f 0 else if p <= b then f 1 else f 2) ps; fold_left min cs.(0) cs) |> Printf.printf "%d\n"

Measured memory_bytes: 384
I=lambda:list(map(int,input().split()))
n,k=I()
z=[I()for _ in[0]*n]
z.sort()
a=10**20
for i in range(n):
 for j in range(i+k-1,n):l=sorted(t[1]for t in z[i:j+1]);a=min(a,*[(z[j][0]-z[i][0])*(v-u)for u,v in zip(l,l[k-1:])])
print(a)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << (a!=c ? 1:0) << endl;




}


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

#define ll long long
const int MOD = 1e9+7;

void solve()
{
    int n;
    cin >> n;
    int stones[n],dp[n+1];
    for(int i=0;i<n;i++)
        cin >> stones[i];
    dp[0] = 0;
    dp[1] = abs(stones[1]-stones[0]);
    for(int i=2;i<n;i++)
        dp[i] = min(abs(stones[i]-stones[i-1])+dp[i-1],abs(stones[i]-stones[i-2])+dp[i-2]);
    cout << dp[n-1];
}




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define INF (1LL << 60)
#define ALL(x) (x).begin(),(x).end()
typedef long long LL;
using namespace std;

int main() {
	int n, m;	cin >> n >> m;
	if (n >= m) {
		cout << 0;
		return 0;
	}
	vector<LL> x(m);
	for (auto& i : x) {
		cin >> i;
	}
	sort(ALL(x));
	vector<LL> dist(m - 1);
	for (int i = 0; i < m - 1; i++) {
		dist[i] = x[i + 1] - x[i];
	}
	sort(ALL(dist), greater<LL>());
	LL count = x[m - 1] - x[0];
	for (int i = 0; i < n - 1; i++) {
		count -= dist[i
		];
	}
	cout << count;
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define inf ((1LL << 62) - 1 + (1LL << 62))

// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int N;
    cin >> N;
    vi L(N);
    rep(i, N) cin >> L[i];
    sort(L);
    int tori = 0;

    rep(i, N - 2) {
        for (int j = i + 1; j < N - 1; j++) {
            int wa = L[i] + L[j];
            int min = j + 1;
            for (int k = j + 1; k < N; k++) {
                if (wa <= L[k]) break;
                tori++;
            }
        }
    }
    cou(tori);
	// TLEにならなかったらキレる
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;

  auto graph = ReadUndirectedGraph(n, n - 1, true);

  vector<int> v_dists(n, -1);
  function<void(int, int)> dfs_1_fn = [&](int v, int p) {
    if (p < 0) v_dists[v] = 0;
    else v_dists[v] = v_dists[p] + 1;
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      dfs_1_fn(e.to, v);
    }
  };
  dfs_1_fn(v, -1);

  vector<int> u_dists(n, -1);
  int ans = 0;
  function<void(int, int)> dfs_2_fn = [&](int v, int p) {
    if (p < 0) u_dists[v] = 0;
    else u_dists[v] = u_dists[p] + 1;

    if (u_dists[v] >= v_dists[v]) return;
    UpdateMax(ans, v_dists[v] - 1);
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      dfs_2_fn(e.to, v);
    }
  };
  dfs_2_fn(u, -1);

  cout << ans << endl;
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

const int maxn = 100003;

int n, ans;
struct Node
{
	int x, l, y;
} a[maxn];

inline bool cmp(Node x, Node y)
{
	return x.y < y.y;
}

int main()
{
	//File("");
	n = gi();
	for (int i = 1; i <= n; i+=1)
	{
		a[i].x = gi(), a[i].l = gi(), a[i].y = a[i].x + a[i].l;
	}
	sort(a + 1, a + 1 + n, cmp);
	int tmpp = -1000000007;
	for (int i = 1; i <= n; i+=1)
	{
		if (a[i].x - a[i].l >= tmpp)
		{
			++ans;
			tmpp = a[i].y;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        String[] strs;
        int x;
        int y;
        int w;
        while(true){
            str = br.readLine();
            strs = str.split(" ");
            x = Integer.parseInt(strs[0]);
            y = Integer.parseInt(strs[1]);
            if(x == 0 && y == 0){
                break;
            }else if(x > y){
                w = y;
                y = x;
                x = w;
            }//if
            System.out.println(x + " " + y);
        }//while
    }
}

Measured memory_bytes: 24416
#include<iostream>
#include<cmath>
#include<map>
#include<string>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
int N;
map<int,int>m;
int checker=0;
int main(){
    cin>>N;
    rep(i,0,N){
        int x=0;
        cin>>x;
        m[x]++;
    }
    fore(i,m){
        if(i.second>=2){
            checker=1;
        }
    }
    if(checker==0){
        puts("YES")
    }else{
        puts("NO");
    }
}

Measured memory_bytes: 9600
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()

ans = 0
for i in range(1,N+1):
  if i%2 != 0:
    ans += 1

print(ans/N)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll s;
    cin >> s;
    ll x, y;
    ll v = 1000000000;
    y = (s+v-1) / v;
    x = v * y - s;
    cout << "0 0 1000000000 1 " << x << " " << y << endl;
}

Measured memory_bytes: 256
program abc165a
      implicit none
      integer::k,a,b
      integer::i

         read *, k
         read *, a,b

         do i=a,b
            if (mod(i,k)==0) then
               print *, 'OK'
               stop
            end if
         end do

         print *, 'NG'

   end program abc165a

Measured memory_bytes: 2796
#include<stdio.h>
int fib(int);
int a[45]={0};
int main(){
  int n;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}
int fib(int n){
  if(n<=1)return 1;
  else{
    if(a[n]!=0)return a[n];
    else return a[n]=fib(n-1)+fib(n-2);
  }
}



Measured memory_bytes: 2104
L,R=map(int,input().split())
ans=[]
for i in range(L,R):
    for j in range(i+1,R+1):
        ans.append(i*j%2019)
        if (i*j)%2019==0:
            print((i*j)%2019)
            exit()
print(min(ans))

Measured memory_bytes: 6892
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();

int n, m;
int x[100100];
int y[100100];

int main() {
  cin >> n >> m;
  rep(i, m) cin >> x[i];

  solve();

  return 0;
}

void solve() {
  int cnt = 0;

  sort(x, x+m);

  for(int i=0; i<m-1; ++i) {
    y[i] = x[i+1]-x[i];
  }

  sort(y, y+(m-1), greater<int>());

  for(int i=n-1; i<m-1; ++i) {
    cnt += y[i];
  }

  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,a; cin >> n >> a;

    if(n % 500 <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    } 

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int s[205];
LL dp[205][100005];
LL fact[205];
LL inv[205];

LL mod_pow(LL a, LL p) {
	LL tmp = a;
	LL ret = 1;
	while (p) {
		if (p & 1)ret = (ret*tmp)%MOD;
		tmp = (tmp*tmp) % MOD;
		p >>= 1;
	}
	return ret;
}

LL  mod_inv(LL a) {
	return mod_pow(a, MOD - 2);
}

int main() {
	int n, x;
	scanf("%d%d", &n, &x);
	REP(i, n)scanf("%d", &s[i]);
	sort(s, s + n, greater<int>());
	dp[0][x] = 1;
	REP(i, n) {
		LL p = mod_inv(n - i);
		LL q = (mod_inv(n - i)*(n - i - 1)) % MOD;
		REP(j, x + 1) {
			dp[i + 1][j%s[i]] = (dp[i + 1][j%s[i]] + dp[i][j] * p %MOD) % MOD;
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * q) % MOD;
		}
	}
	LL ret = 0;
	REP(i, x + 1) ret = (ret + (i * dp[n][i]) % MOD) % MOD;
	REP(i, n)ret = (ret*(i + 1)) % MOD;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 157184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] h = new int[N];
        int ans = 0;
        for(int i = 0; i < N; i++) {
            h[i] = scanner.nextInt();
            if(K <= h[i]) ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 51936
# 実行時の引数の入力：https://qiita.com/orange_u/items/3f0fb6044fd5ee2c3a37

# ***.py a b c形式の引数使用時
# import sys
#
# args = sys.argv
#
# num_len = int(args[1])
# a = []
# b = []
# N = 100
# # b = [1,2,1]
# for i in range(2, 2+num_len):
#     b.append(int(args[i]))
# print(b)

a = []
# print('input:')
num_len = int(input())
b = list(map(int, input().split()))
# print('--'*len(b))
# print('output:')
# print(b)
N = 100



# for i in range(len(b)):
for i in range(num_len):
    # try:
    #     # print(i)
    #     a.insert(b[i], b[i])
    #     print(a)
    # except:
    #     print(-1)

    if b[i]-1 <= len(a):
        # print(i)
        a.insert(b[i]-1, b[i])
        # print(a)
        flag = True
    else:
        flag = False
        break


if flag:
    for i in a:
        print(i)
else:
    print(-1)




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

using namespace std;

int main(){
  int c,sum=0;
  int change[]={1,5,10,50,100,500};
  for(int i=0;i<6;++i) {
    cin >> c;
    sum+=c*change[i];
  }
  cout << (sum<1000?0:1) << endl;
  
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n;i++)

int main(){

    int64_t H,i=1,cnt=1;
    cin >> H;

    if(H==1)
        cout << cnt << endl;
    else{
        while(1){
            i = i * 2;
            cnt = i;
            if (H < i)
            {
                break;
            }
        }
        cout << cnt-1 << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

typedef pair<int, int> P;
int main() {
	while (true) {
		int h, w;
		cin >> h >> w;
		int mr = h*h+w*w;
		if (!h) break;
		P p = P(1000, 1001);
		for (int i = 1; i < 200; i++) {
			for (int j = i+1; j < 200; j++) {
				if (mr < i*i+j*j || (mr == i*i+j*j && h < i)) {
					int u = p.first*p.first+p.second*p.second;
					if (i*i+j*j < u || (i*i+j*j == u && i < p.first)) {
						p = P(i, j);
					}
				}
			}
		}
		cout << p.first << ' ' << p.second << endl;
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private int M;

    public Main() {
	M = Integer.parseInt(scan.next());
	
	scan.close();
    }

    public final void answer() {
	System.out.println(48 - M);	
    }
}


Measured memory_bytes: 23764
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
         string[] str=Console.ReadLine().Split(' ');
      int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      int count=B-A;
      int ans; 
      if(B==1){
        ans=0;
      }else{
        ans=1;
      while(count>0){
        count++;
        ans++;
        count=count-A;
     
      }
      }  
    Console.WriteLine(ans);
      
      
    }
    
  }

}


Measured memory_bytes: 27432
N, x = map(int, input().split())
a = list(map(int, input().split()))

cnt = 0
for i in range(N-1):
    if(a[i] + a[i+1] > x):
        if(a[i] > x):
            cnt += (a[i]-x)+a[i+1]
            a[i+1] = 0
        else:
            cnt += a[i]+a[i+1]-x
            a[i+1] -= a[i]+a[i+1]-x
print(cnt)

Measured memory_bytes: 14068
import heapq
N = int(input())
v_ls = [int(i) for i in input().split()]
heapq.heapify(v_ls)
while len(v_ls) > 1:
    smallest = heapq.heappop(v_ls)
    second = heapq.heappop(v_ls)
    heapq.heappush(v_ls, (smallest + second) / 2)
print(heapq.heappop(v_ls))

Measured memory_bytes: 3060
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  writeln(readln.chomp.to!(char[]).map!(to!long).array.sort!"a<b".uniq.count > 1 ? "Yes" : "No");
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cassert>
#include <deque>
#include <iostream>
#include <iomanip>
#include <istream>
#include <iterator>
#include <map>
#include <math.h>
#include <memory>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 4000000000000000000LL
#define INF 1000000000
#define EPS 1e-12
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))
#define bits(a) __builtin_popcountll(a)

using namespace std;

/**
 * x..x
 */

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

/*素因数分解*/
map<llong,int> prime_factor(llong n){
	map<llong,int> res;//自然数nの約数firstがsecond個ある.
	for(llong i=2;i*i<=n;++i){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1) res[n]=1;
	return res;
}

int main(){
	llong n;
	cin>>n;
	
	map<llong,int> mp=prime_factor(n);
	
	int ans=0;
	for(auto elem:mp){
		int tmp=elem.second;
		for(int i=1;tmp>=i;++i){
			tmp-=i;
			ans++;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
const int twx=3e3+100;
const int MOD=1000000007;
const int inf=0x3f3f3f3f;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int n,m;
char s[twx];
int l[twx],r[twx];
int ans=0;
int one[twx];
int asd[twx][twx];
int To[twx];
ll add(ll x,ll y)
{
    return x+y>=MOD?x+y-MOD:x+y;
}
ll sub(ll x,ll y)
{
    return x-y<0?x-y+MOD:x-y;
}
ll mul(ll x,ll y)
{
    return 1LL*x*y%MOD;
}
void init()
{
	n=read();
    m=read();
    scanf("%s",s+1);
    f1(1,n,i)
    {
        if(s[i]=='1')
        {
            one[i]=one[i-1]+1;
        }
        else
        {
            one[i]=one[i-1];
        }
        To[i]=i;
    }
    one[n+1]=one[n];
    f1(1,m,i)
    {
        l[i]=read();
        r[i]=read();
        To[l[i]]=max(To[l[i]],r[i]);
    }
    f1(2,n+1,i)
    {
        To[i]=max(To[i],To[i-1]);
    }
}
void work()
{
    asd[1][one[To[1]]]=1;
    f1(1,n,i)
    {
        f1(0,n,j)
        {
            if(asd[i][j])
            {
                int Left=To[i]+1;
                int Right=To[i+1];
                int tmp=one[Right]-one[Left-1];
                int a=j;
                int b=To[i]-i+1-a;
                if(a)
                {
                    asd[i+1][j+tmp-1]=add(asd[i+1][j+tmp-1],asd[i][j]);
                }
                if(b)
                {
                    asd[i+1][j+tmp]=add(asd[i+1][j+tmp],asd[i][j]);
                }
            }
        }
    }
}
void print()
{
	printf("%d\n",asd[n+1][0]);
}
int main()
{
    init();
    work();
    print();
	return 0;
}

Measured memory_bytes: 35840
import sys

def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n,k=get_ints()
Arr=get_array()
count=0
for i in Arr:
  if i>=k:
    count+=1
print(count)

Measured memory_bytes: 11896
#include<stdio.h>
int main()
{
    int a,b,c,d,e,f;
    double x,y;
    while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)!=EOF)
    {
       y=(double)(a*f-c*d)/(a*e-b*d);
       x=(double)(c-b*y)/a;
       printf("%.3lf %.3lf\n",x,y);
    }
    return 0;

}

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

int main(){
  int N,A;
  cin>>N>>A;
  vector<int> x(N);
  for(int i=0;i<N;++i) cin>>x[i];


  //x[0],..,x[i-1]までからj個選んで和をsにする総通りdp[i][j][s];
  //i=0は空
  int64_t dp[N+1][N+1][3000];
  
  dp[0][0][0]=1;
  for(int j=0;j<=N;++j){
  for(int s=1;s<3000;++s){
    dp[0][j][s]=0;
  }
  }

  for(int i=1;i<=N;++i){
    for(int j=0;j<=N;++j){
      for(int s=0;s<3000;++s){
        //j=0つまり選ばない時
        if(j==0){
          if(s==0) dp[i][j][s]=1;
          else dp[i][j][s]=0;
        }
        //選ぶとき
        else{
          if(x[i-1]>s) dp[i][j][s]=dp[i-1][j][s];
          else dp[i][j][s]=dp[i-1][j][s]+dp[i-1][j-1][s-x[i-1]];
        }
      }
    }
  }

  int64_t sum=0;
  for(int i=1;i<=N;++i){
    sum += dp[N][i][i*A];
  }

  cout<<sum<<endl;

}

Measured memory_bytes: 61184
#include<map>
#include<string>
#include<vector>
#include<cstdlib>
#include<iostream>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int size[128];
map<int,int> val[128];

int number(const string &s,int &idx){
	int res=0;
	while(idx<s.length() && isdigit(s[idx])){
		res=10*res+(s[idx++]-'0');
	}
	return res;
}

bool ok;
int expr(const string &s,int &idx){
	if(isdigit(s[idx])){
		return number(s,idx);
	}
	else{
		char a=s[idx++];
		idx++;
		int i=expr(s,idx);
		if(val[a].count(i)==0 || size[a]<=i) ok=false;
		idx++;
		return val[a][i];
	}
}

bool parse(string s){
	char a=s[0];
	int eq=s.find('='),idx=0;
	ok=true;
	int i=expr(s.substr(2,eq-3),idx);
	if(!ok || size[a]<=i) return false;

	idx=0;
	ok=true;
	int res=expr(s.substr(eq+1),idx);
	val[a][i]=res;
	return ok;
}

int main(){
	while(1){
		rep(c,128) val[c].clear();

		vector<string> s;
		while(1){
			string t; getline(cin,t);
			if(t==".") break;
			s.push_back(t);
		}
		if(s.empty()) break;

		int n=s.size();
		int ans=0;
		rep(i,n){
			if(s[i].find('=')==-1){ // 宣言文
				size[s[i][0]]=atoi(s[i].c_str()+2);
			}
			else{ // 代入文
				if(!parse(s[i])){ ans=i+1; break; }
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1340
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int n;
        cin>>n;
        if(n==0)break;
        int T[n];
        for(int i=0;i<n;i++){
            cin>>T[i];
        }
        int count=0,sum=0;
        for(int i=0;i<n;i++){
            if(T[i]<=1)count++;
            if(T[i]>=1)sum++;
        }
        if(count==n)cout<<"NA"<<endl;
        else if(n==1&&sum>=2)cout<<2<<endl;
        else cout<<sum+1<<endl;
    }
}



Measured memory_bytes: 3172
#include<stdio.h>

int main(){
	int n, a[100], i;
	
	scanf("%d", &n);
	
	for(i=0; i<n; i++)	scanf("%d", &a[i]);
	
	for(i=0;i<n;i++){
		if(a[i]%2==0){
			if ( !(a[i]%3==0 || a[i]%5==0)){
				printf("DENIED");
				return 0;
			}
		}
	}
	printf("APPROVED");
	return 0;
	}

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

A=[0]+A     #最初
A.append(0) #最後 要素数 N+2 になった
full=0
for i in range(N+1):
    full+=abs(A[i+1]-A[i])

for i in range(1,N+1):
    if (A[i+1]-A[i])*(A[i]-A[i-1])<0:
        ans=full-2*min(abs(A[i+1]-A[i]),abs(A[i]-A[i-1]))
    else:
        ans=full
    print(ans)


Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);


int main(){
	ll d;
	while(cin>>d){
		ll ans = 0;
		for(ll x=0;x<600;x+=d){
			ans += x*x*d;
		}
		cout << ans << endl;
	}
}




Measured memory_bytes: 3004