akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, m;
  cin >> n >> m;
  if (n == m) yn;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,k;
    vector<int> h;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        int th;
        cin >>th;
        h.push_back(th);
    }
    int ct=0;
    for(int i=0;i<n;i++){
        if(h[i]>=k) ct++;
    }
    cout << ct <<endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = s.size();
	bool b = true;
	rep(i,n-1) if (s[i] != s[i+1]) b = false;
	if (b) {
		cout << (ll) n * k / 2 << endl;
	} else {
		ll cir = 0;
		int t = 1;
		rep(i,n-1) {
			if (s[i] == s[i+1]) t++;
			else {
				cir += t / 2;
				t = 1;
			}
		}
		cir += t / 2;
		if (s[0] != s[n-1]) cout << cir * k << endl;
		else {
			ll l = 1;
			ll r = 1;
			rep(i,n-1) {
				if (s[i] == s[i+1]) l++;
				else break;
			}
			rep(i,n-1) {
				if (s[n-1-i] == s[n-1-i-1]) r++;
				else break;
			}
			cout << cir * k - (l/2 + r/2 - (l+r)/2) * (k - 1) << endl;
		}
	}
}

Measured memory_bytes: 3624
#include <vector>
#include <functional>
#include <deque>
#include <stdexcept>

template<typename T, typename Container = ::std::vector<T>, typename Compare = ::std::greater<typename Container::value_type>>
class sliding_window {
    using iterator_type = typename Container::const_iterator;
    using value_compare = Compare;
    using value_type = T;
    using const_reference = const value_type &;

    iterator_type right_bound, left_bound, end;
    value_compare comp;
    size_t length;
    ::std::deque<value_type> val;

public:
    void push() {
        if (left_bound == end) {
            throw ::std::runtime_error("already reached to the end");
        }
        const auto &tmp = *left_bound;
        while (!val.empty() && comp(val.back(), tmp))val.pop_back();
        val.push_back(tmp);
        ++left_bound;
        ++length;
    }

    void pop() {
        if (right_bound == left_bound) {
            throw ::std::runtime_error("interval is empty");
        }
        const auto &tmp = *right_bound;
        if (tmp == val.front())val.pop_front();
        ++right_bound;
        --length;
    }

    sliding_window(iterator_type _begin, iterator_type _end, const Compare &_comp = Compare()) : length(0),
                                                                                                 right_bound(_begin),
                                                                                                 left_bound(_begin),
                                                                                                 end(_end), comp(_comp),
                                                                                                 val({}) {}

    const size_t size() const {
        return length;
    }

    const_reference top() const {
        return val.front();
    }

    void resize(size_t n) {
        if (n < length) {
            while (n < length) {
                pop();
            }
        } else {
            while (n > length) {
                push();
            }
        }
    }

    void forward() {
        if (left_bound != end)push();
        pop();
    }

};

#include <iostream>
#include <algorithm>

int main() {
    unsigned long long N, M, K;
    scanf("%llu%llu%llu", &N, &M, &K);

    std::vector<unsigned long long> A(N), dp1(N), dp2(N);
    for (auto &i : A)scanf("%llu", &i);

    std::copy(A.begin(), A.end(), dp1.begin());

    for (unsigned long long i = 1; i < K; ++i) {
        sliding_window<unsigned long long, std::vector<unsigned long long>, std::less<>> slidingWindow(
                dp1.begin(), dp1.end());
        std::transform(A.begin(), A.end(), dp2.begin(), [&i](auto a) { return a * (i + 1); });

        for (unsigned long long j = 0; j < N; ++j) {
            if (j >= i)dp2[j] += slidingWindow.top();
            slidingWindow.push();
            if (slidingWindow.size() > M)slidingWindow.pop();
        }

        std::swap(dp1, dp2);
    }

    std::cout << *std::max_element(dp1.begin(), dp1.end()) << std::endl;

    return 0;
}

Measured memory_bytes: 2560
N=int(input())
a=[int(i) for i in input().split()]
b,c,d,e,f,g,h,j,k=0,0,0,0,0,0,0,0,0
for i in range(N):
 if (a[i]<400):
  b=1
 elif (400<=a[i]<800):
  c=1
 elif (800<=a[i]<1200):
  d=1
 elif (1200<=a[i]<1600):
  e=1
 elif (1600<=a[i]<2000):
  f=1
 elif (2000<=a[i]<2400):
  g=1
 elif (2400<=a[i]<2800):
  h=1
 elif (2800<=a[i]<3200):
  j=1
 else:
  k += 1
min=b+c+d+e+f+g+h+j
max=min+k
if min==0:
 min=1
print (min,max)

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

int main(){
  string S, T;
  cin >> S >> T;
  int Ans=0;
  for(int i=0; i<3; i++){
    if(S.at(i)==T.at(i)){
      Ans++;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ




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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m ;
  priority_queue<ll, vector<ll>, less<ll>> que;
  
  REP(i,n){
    ll a ;
    cin >> a ;
    que.push(a) ;
  }
  
  ll ans = 0 ;
  
  REP(i,m){
    ll b ;
    b = que.top() ;
    que.pop();
    que.push(b/2) ;
  }
  
  REP(i,n){
    ans += que.top() ;
    que.pop() ;
  }
  
  cout << ans <<endl ;
    
    
  
  
  
  
  return 0 ;
}



Measured memory_bytes: 1400
# DPL_1_D - Longest Increasing Subsequence
from typing import Sequence


def longest_subsequence(A: Sequence[int], is_equal: bool, is_increasing: bool) -> int:
    """
    Compute the length of LIS or LDS.

    Args:
        A (Sequence[int]): a list or tuple to compute.
        is_equal (bool): permit adjacent numbers in subsequence to equal.
        is_increasing (bool): compute an increasing subsequence or decreasing one.
    Returns: (int) the length of a subsequence.
    """
    from bisect import bisect_left, bisect_right

    bs = bisect_right if is_equal else bisect_left
    compare = (lambda x, y: x >= y) if is_equal else (lambda x, y: x > y)
    if not is_increasing:
        A = A[::-1]

    dp = [A[0]]  # dp := length of LIS (dp table itself is not LIS)
    for i in A[1:]:
        if compare(i, dp[-1]):
            dp.append(i)
        else:
            dp[bs(dp, i)] = i
    return len(dp)


def main():
    N, *A = map(int, open(0))
    ans = longest_subsequence(A, is_equal=False, is_increasing=True)
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 12804
#include <iostream>

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

const int INF = 10000000;
using namespace std;
typedef long long  ll;
const int MAX = 10000;

/** Problem2012 : Space Coconut Grab **/
int main()
{
	int e;
	int m=INF;
	
	while (cin>>e, e!=0) {
		m=INF;
		REP(i, 0, 1000) {
			REP(j, 0, 1000) {
				if (e-i*i-j*j*j >= 0) {
					int t = e-i*i-j*j*j + i + j;
					if (t<m)
						m = t;
				}
			}
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        a: i64,
        b: i64,
    }
    // a, bは相違なるという仮定から、 k = 0.5(a + b)が整数になるかという問題になる。
    let r: i64 = (a + b) % 2;
    match r {
        0 => println!("{}", (a + b) / 2 as i64),
        1 => println!("IMPOSSIBLE"),
        _ => println!("error")
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    double ar = a;
    double br = b;
    double r;
    r = a%b;
    
    
    cout << a/b << " " << r << " " << fixed << setprecision(9) << ar/br << endl;
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){cout << "Yes" << endl;}
inline void No(){cout << "No" << endl;}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){cout << "YES" << endl;}
inline void NO(){cout << "NO" << endl;}
inline void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

ll n, k;
vector<ll> a, f, af;

bool check(ll mid){
    ll m = 0;
    rep(i, n){
        if(a[i]*f[i] > mid) {
            m += a[i]-mid/f[i];
        }
    }
    return m <= k;
}


int main(){
   
    scanf("%lld%lld", &n, &k); 
    a.resize(n);
    f.resize(n);
   
    rep(i, n) scanf("%lld", &a[i]);
    rep(i, n) scanf("%lld", &f[i]);
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    ll ok = LINF, ng = -1;
    ll mid;
    while(abs(ok-ng) > 1){
        mid = (ok+ng) >> 1;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    ppp(ok);
    return 0;
}


Measured memory_bytes: 3456
def partition(p, r):
    global A

    x = A[r]
    i = p - 1

    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]

    A[i+1], A[r] = A[r], A[i+1]
    return i + 1


N = int(input())
A = list(map(int, input().split()))

q = partition(0, N-1)

A_str = list(map(str, A))
A_str[q] = '[' + A_str[q] + ']'

print(' '.join(A_str))



Measured memory_bytes: 16588
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000001
#define PI 3.14159265358979323846
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x;
	cin >> x;
	if(x >= 30)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n){
    cin >> p.at(i);
    p.at(i)--;
  }
  vector<int> c(n);
  rep(i, n) cin >> c.at(i);

  vector<ll> loopscore(n, 0);
  vector<int> loopsize(n, 0);
  rep(i, n){
    int sz = 1, pos = p.at(i);
    ll add = c.at(pos);
    while(pos != i){
      pos = p.at(pos);
      add += c.at(pos);
      sz++;
    }
    loopscore.at(i) = add;
    loopsize.at(i) = sz;
  }

  ll ans = -1e18;
  rep(i, n){
    int now = p.at(i);
    ll add = c.at(now);
    ans = max(ans, add);
    if(loopscore.at(i) <= 0 || loopsize.at(i) >= k){
      int co = 1;
      while(now != i && co < k){
        now = p.at(now);
        add += c.at(now);
        ans = max(ans, add);
        co++;
      }
    }else{
      int lc = k/loopsize.at(i)-1;
      add = loopscore.at(i)*lc;
      ans = max(ans, add);
      now = i;
      rep(j, k-lc*loopsize.at(i)){
        now = p.at(now);
        add += c.at(now);
        ans = max(ans, add);
      }
    }
  }

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

Measured memory_bytes: 3716
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0])
#include <stdlib.h>

int main() {
	int ans=0;

	//int n;
	//cin >> n;

	string n;
	cin >> n;
	char tmp[1];

	int nmax;
	nmax=n.length();

	//for(int i=nmax-1;i>-1;i--){
	for(int i=0;i<nmax;i++){
	//for(int i=0;i<10;i++){
		tmp[0]=n[i];
		ans+= atoi(tmp);
		//cout << ans << endl;
	}

	if(ans%9==0) cout << "Yes" << endl;
	else cout << "No" << endl;



}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

// 素因数分解
map< ll, ll > primeFactors(ll n) {
  map< ll, ll > ret;

  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }

  if (n != 1)
    ret[n] = 1;

  return ret;
}

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

  ll A, B;
  CIN(A >> B);

  map< ll, ll > mA = primeFactors(A);
  map< ll, ll > mB = primeFactors(B);

  set< ll > s;
  s.insert(1);
  ll c = 1;

  for (auto i : mA) {
    s.insert(i.first);
  }
  for (auto i : mB) {
    if (s.find(i.first) != s.end()) {
      c++;
    }
  }

  COUT(c);

  return 0;
}


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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    char s[128]={0},*ptr=s+read();
    scanf("%s",s);
    if(ptr-s>=strlen(s)) print(s);
    else{
        *ptr=*(ptr+1)=*(ptr+2)='.';
        *(ptr+=3)=0;
        print(s);
    }
    output();
    return 0;
}

Measured memory_bytes: 3760
#include<cstdio>
#include<vector>
#include<math.h>
 
using namespace std;
 
const int MAX_N = 100001;
 
struct edge {int to,cost;};
vector<edge> tree[MAX_N];
bool flag[MAX_N] = {false};
int depth[MAX_N];
int s,t,c;
double sum = 0.0;
double ans = 0.0;
double p;
int N;
 
void dfs(int v,int d){
    flag[v] = true;
    depth[v] = d;
    for(int i = 0;i < tree[v].size();i++){
        if(!flag[tree[v][i].to]){
            sum += tree[v][i].cost * pow(p,(d+1.0));
            dfs(tree[v][i].to,d+1);
        }
    }
}
 
int main(){
    scanf("%lf %d",&p,&N);
     
    for(int i =0; i<N-1; i++){
        scanf("%d %d %d",&s,&t,&c);
        s--;
        t--;
        edge e;
        e.to = t;
        e.cost = c;
        tree[s].push_back(e);
        e.to = s;
        tree[t].push_back(e);
    }
     
    dfs(0,0);
     
    ans = 2*sum;
    for(int i = 1; i < N;i++){
        ans += sum * pow(p,depth[i]);
    }
    printf("%.10lf\n",ans);
     
    return 0;
}

Measured memory_bytes: 15136
#include <cstdio>
#include <cstring>
#include <algorithm>
#define next next2
#define inf (ll)(1e18)

using namespace std;

typedef long long ll;

char s[200005];

ll sum[100][26],len[100],ans[26];
int ns;

void pre(int n,int m) {
  ns=1;
  len[0]=m;len[1]=n;
  for(int i=0;i<m;i++) sum[0][s[i]-'a']++;
  for(int i=0;i<n;i++) sum[1][s[i]-'a']++;
  for(;len[ns]<inf;ns++) {
  	len[ns+1]=len[ns]+len[ns-1];
  	for(int j=0;j<26;j++) sum[ns+1][j]=sum[ns][j]+sum[ns-1][j];
  } 
}

ll calc(ll n,int num) {
  for(int i=ns;i>0;i--) 
    if (n>=len[i]) {
    	for(int j=0;j<26;j++) ans[j]+=sum[i][j]*num;
    	n-=len[i];
	}
  for(int i=0;i<n;i++) ans[s[i]-'a']+=num;
}

int next[200005];

int kmp(int n) {
  s[n]='\0';
  next[0]=next[1]=0;
  for(int i=1,j=0;i<n;i++) {
  	while (j&&s[j]!=s[i]) j=next[j];
  	if (s[j]==s[i]) j++;
  	next[i+1]=j;
  }
  return next[n];
}

int main() {
  scanf("%s",s);
  int n=strlen(s);
  n>>=1;
  int m=n-kmp(n);
  pre(n,m);
  ll l=0,r=0;
  scanf("%lld%lld",&l,&r);
  calc(r,1);
  calc(l-1,-1);
  for(int i=0;i<26;i++) printf("%lld ",ans[i]);
  printf("\n");
  return 0;
}

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

#define DEBUG_MSG_off

string S;
map<char, int> res_map;

int main() {
  cin >> S;

  for (int i=0;i<S.size();i++){
    auto itr  = res_map.find(S[i]);
    if ( itr != res_map.end() ) {
      res_map[S[i]]++;
    } else {
      res_map[S[i]] = 1;
    }
  }
  if (res_map.size()==2) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
#ifdef DEBUG_MSG
  for (auto t_p: res_map) {
    cerr << t_p.first << "," << t_p.second << "\n";
  }
#endif

#ifdef DEBUG_MSG
  cerr << S << "\n";
#endif
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
d = list(map(int,input().split()))
c = Counter(d)
mod=998244353
if d[0]==1:
    print(0)
else:
    D = 1
    for i in d[1:]:
        D = (D*c[i-1])%mod
    print(D)

Measured memory_bytes: 19936
package main

import (
	"fmt"
)

func main() {
	var h, w, k int
	fmt.Scan(&h, &w, &k)
	cs := make([][]byte, h)
	for i := range cs {
		fmt.Scan(&cs[i])
	}
	var ans int
	for i := 0; i < 1<<uint(h+w); i++ {
		var cnt int
		for s := 0; s < h; s++ {
			for t := 0; t < w; t++ {
				if i&(1<<uint(s)) > 0 {
					continue
				}
				if i&(1<<uint(h+t)) > 0 {
					continue
				}
				if cs[s][t] == '#' {
					cnt++
				}
			}
		}
		if cnt == k {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

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

  i64 N, S, i;
  cin >> N >> S;
  vi A(N);
  REP(0, N, i) {
    cin >> A[i];
  }

  i64 s;
  vi CL(S, 0); // sum value, starting point

  i64 NUM = 998244353LL;
  i64 ans = 0;
  REP(0, N, i) {
    if(A[i] == S) {
      ans += (i + 1) * (N - i);
      ans %= NUM;
    }
    else if(A[i] < S) {
      vi CL_new = CL;
      CL_new[A[i]] += i + 1;
      CL_new[A[i]] %= NUM;

      REP(0, S, s) {
	i64 s_new = s + A[i];
	if(s_new < S) {
	  CL_new[s_new] += CL[s];
	  CL_new[s_new] %= NUM;
	}
	else if(s_new == S) {
	  ans += CL[s] * (N - i);
	  ans %= NUM;
	}
      }
      CL.swap(CL_new);    
    }

    /*
    REP(0, S, s) {
      cout << CL[s] << " ";
    }
    cout << endl;
    */
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//
// Created by 绔ユ闃?on 2018/9/14.
// https://abc044.contest.atcoder.jp/tasks/arc060_a
// 鍔ㄦ€佽鍒掞細dp[i][j]琛ㄧず閫塱涓暟鍜屼负j鐨勬柟娉曟暟
// 閭ｄ箞鏈夛細dp[i][j]=\sum{dp[i-1][j-a[k]], 1<=k<=N}
// 鏈€缁堢粨鏋滀负锛歕sum{dp[i][i*A]}
//
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
int N, A, x[51], sum[51];
ll dp[51][2501];
int main() {
    cin >> N >> A;
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= N; i++) {
        cin >> x[i];
        sum[i] = sum[i-1] + x[i];
    }
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int k = 1; k <= N; k++) {
        for (int i = k; i >= 1; i--) {
            for (int j = sum[k]; j >= x[k]; j--) {
                dp[i][j] += dp[i-1][j-x[k]];
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += dp[i][i*A];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
// Created by: WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	if(k >= 60)
	{
		for(int i = 0; i < n; i++)
			cout << n << " ";
		cout << endl;
		return;
	}
	while(k--)
	{
		int b[n] = {0};
		for(int i = 0; i < n; i++)
		{
			int l = max(0, i - a[i]);
			int r = min(n - 1, i + a[i]);
			b[l]++;
			if(r + 1 < n)
				b[r + 1]--;
		}	
		for(int i = 1; i < n; i++)
			b[i] += b[i - 1];
		for(int i = 0; i < n; i++)
			a[i] = b[i];
	}
	for(int i = 0; i < n; i++)
		cout << a[i] << " ";
	cout << endl;
	
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 5104
def ser(X, Y):
    dp = [[0] * (len(Y)+1) for x in range(len(X)+1)]
    for i, x in enumerate(X, 1):
        tmp = dp[i]
        pre = dp[i-1]
        for j, y in enumerate(Y, 1):
            if x == y:
                tmp[j] = pre[j-1] + 1
            elif pre[j] < tmp[j-1]:
                tmp[j] = tmp[j-1]
            else:
                tmp[j] = pre[j]
    return(dp[-1][-1])

for _ in range(int(input())):
    X, Y = input(), input()
    print(ser(X, Y))


Measured memory_bytes: 30940
//*Author : Franklin*
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const int N = 2e5;
#define deb(x) cout << #x << "=" << x << "\n"
#define debug(a) for(auto &x:a) cout << x << " "
#define debugg(p) for(auto &x:p) cout << "(" << x.first << "," << x.second << ")" << "\n"

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j : {i+1,i+2}) {
            if(j < n) {
                dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    cout << dp[n-1] << "\n";

    return 0;

}


Measured memory_bytes: 3916
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<utility>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX_N 200010
using ll = long long;
using P = std::pair<int, int>;
template <class T> inline void chmax(T& a, T b) { if(a < b) a = b;}

struct UnionFind{
	ll par[MAX_N];
	ll cost[MAX_N];
	ll rank[MAX_N];

	UnionFind(int n){
		rep(i, n){
			par[i] = i;
			rank[i] = 0;
			cost[i] = 1;
		}
	}

	ll find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	ll unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return cost[x];

		if(rank[x] > rank[y]){
			par[y] = x;
			cost[x] += cost[y];
			return cost[x];
		}else{
			par[x] = y;
			cost[y] += cost[x];
			if(rank[x] == rank[y]) rank[y]++;
			return cost[y];
		}
	}
};

int main(){
	int N, M;
	std::cin >> N >> M;
	UnionFind uf(N);
	ll res = 1;
	rep(i, M){
		int a, b;
		std::cin >> a >> b;
		--a; --b;
		chmax(res, uf.unite(a, b));
	}
	std::cout << res << std::endl;

	return 0;
}



Measured memory_bytes: 8216
#include <iostream>
#include <algorithm>

using namespace std;
using ll=long long;
using R=double;

// Combination Table
ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N){
for(int i=0;i<=N;++i){
for(int j=0;j<=i;++j){
if(j==0 or j==i){
C[i][j]=1LL;
}else{
C[i][j]=(C[i-1][j-1]+C[i-1][j]);
}
}
}
}

int main(void){
int N,A,B;
cin >> N >> A >> B;
const int NMAX=50;
ll v[NMAX];

for(int i=0;i<N;++i){
cin >> v[i];
}

comb_table(N);
sort(v,v+N);
reverse(v,v+N);

R max_average=0.0;
for(int i=0;i<A;++i){
max_average+=v[i];
}
max_average/=A;

int a_th_val_num=0,a_th_val_pos=0;
for(int i=0;i<N;++i){
if(v[i]==v[A-1]){
a_th_val_num++;
if(i<A){
a_th_val_pos++;
}
}
}

ll cnt=0LL;
if(a_th_val_pos==A){
for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
cnt+=C[a_th_val_num][a_th_val_pos];
}
}else{
cnt+=C[a_th_val_num][a_th_val_pos];
}

cout.precision(20);
cout << fixed << max_average << endl;
cout << cnt << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
int main(){
  long long s; cin >> s;
  cout << "0 0 1000000000 1 ";
  long long x, y;
  y = (s + 999999999)/1000000000;
  x = 1000000000*y - s;
  cout << x << ' ' << y << endl;
  return 0;
}


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

int main(){
  int n, l;
  cin >> n >> l;
  vector<int> a(n+1);
  for(int i=1;i<=n;i++) cin >> a[i];
  int lst = -1;
  for(int i=1;i<=n-1 && lst < 0;i++) lst = (l <= a[i] + a[i+1]?i:-1);
  if(lst < 0){
    cout << "Impossible" << endl;
  }else{
    cout << "Possible" << endl;
    for(int i=1;i<lst;i++) cout << i << endl;
    for(int i=n-1;i>lst;i--) cout << i << endl;
    cout << lst << endl;
  }
}


Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main(void){
  string str = "";
  string tmp;
  bool digit = false;
  long long ret=0;
  long long itmp;
  while(getline(cin,tmp)){
    int n = tmp.size();

    for(int i=0;i<tmp.size();i++){
      if('0' <= tmp[i] && tmp[i] <= '9'){
	str += tmp[i];
      }else if(!str.empty()){
	//cout << str << endl;
	istringstream iss(str);
	iss >> itmp;
	ret += itmp;
	str.clear();
      }
    }
    if(!str.empty()){
      istringstream iss(str);
      iss >> itmp;
      ret += itmp;
      str.clear();
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
string S; cin >> S;
bool flag = false;
for(int i = 0; i < 3 ; i++){
  if(S[i] == S[i+1]){
    flag = true;
  }
}
if(flag){
  cout << "Bad" << endl;
} else {
  cout << "Good" << endl;
}
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextLine()
	ss := strings.Split(n, "")
	hh := make([]int, 0, len(ss))
	for _, item := range ss {
		v, _ := strconv.Atoi(item)
		hh = append(hh, v)
	}

	var b float64 = 753
	var re float64 = 100000000

	r := 2
	for index := 0; r < len(hh); index++ {
		v := float64(100*hh[index] + 10*hh[index+1] + hh[r])
		tmp := math.Abs(b - v)
		if re > tmp {
			re = tmp
		}
		r++
	}

	fmt.Println(re)
}


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

using namespace std;

int main()
{
        string a,b;
        int i,c=0,x=0;
        cin>>a>>b;
        a=a+b;
       // cout<<a<<endl;
       stringstream g(a);
       g>>c;
      // cout<<c<<endl;
       x=sqrt(c);
       if(x*x==c)
        cout<<"Yes"<<endl;
       else
        cout<<"No"<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    int N, K;
    input(N, K);

    vector<int> p(N);
    input(p);

    sort(p.begin(), p.end());

    int sum = 0;
    rep(i, 0, K)
    {
        sum += p[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b[3];
    set<int> d;

    for(int i = 0;i < 3;++i){
        cin >> a;
        d.insert(a);
    }

    if(d.size() == 2)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M,K;
    cin >>N>>M>>K;
    vector<ll> A(N);
    vector<ll> B(M);
    vector<ll> sumA(N+1);
    vector<ll> sumB(M+1);
    
    rep(i,N){
        cin>>A[i];
        sumA[i+1]=sumA[i]+A[i];
    }
    rep(i,M){
        cin>>B[i];
        sumB[i+1]=sumB[i]+B[i];
    }
    ll l=0;
    ll r=N+M;
    ll now;
    map<ll,ll>seen;
    while(1){
        now = (l+r)/2;
        ll m = INF;
        rep(i,now+1){
            if(i<=N && now-i<=M)
                chmin(m,sumA[i]+sumB[now-i]);
        }
        //cout<<m<<endl;
        if(m<=K){
            if(seen[now]){
                cout<<now<<endl;
                return 0;
            }
            l = now+1;
        }else{
            r = now-1;
        }
        seen[now]=1;
        //cout<<now<<endl;

    }

    return 0;
    

}

Measured memory_bytes: 9504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		
		int[] nums = new int[num];
		for(int i = 0; i < num; i++) {
			nums[i] = in.nextInt();
		}
		int max_profit = Integer.MIN_VALUE;
		int min_current = Integer.MAX_VALUE;
		for(int i = 0; i < num; i++) {
			if(i > 0) max_profit = Math.max(max_profit, nums[i] - min_current);
			if(nums[i] < min_current) min_current = nums[i];
		}
		System.out.println(max_profit);
	}

}


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

int main() {
    long int n,d;
    cin >> n >> d;

    long int x,y;
    int counter = 0;
    for (int i=1; i<=n ; i++) {
        cin >> x >> y;
        if ((x*x + y*y) <= (d*d)){
            counter++;
        }
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI

using namespace std;

inline double nCr(const int n, int r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return(result);
}

int main() {

	int N, M;
	cin >> N >> M;

	int ans = 0;
	if (N >= 2) {
		ans += static_cast<int>(nCr(N, 2));
	}
	if (M >= 2) {
		ans += static_cast<int>(nCr(M, 2));
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3600
import java.util.Scanner;

class Main {

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

  private Scanner sc = new Scanner(System.in);

  private void run() {
    int A = sc.nextInt();
    int B = sc.nextInt();
    int M = sc.nextInt();

    int[] as = new int[A];
    int minA = 99999999;
    for (int i = 0; i < A; i++) {
      as[i] = sc.nextInt();
      minA = Math.min(minA, as[i]);
    }

    int[] bs = new int[B];
    int minB = 99999999;
    for (int i = 0; i < B; i++) {
      bs[i] = sc.nextInt();
      minB = Math.min(minB, bs[i]);
    }

    int minAplusB = minA + minB;
    int minPrice = minA + minB;

    for (int i = 0; i < M; i++) {
      int fridgeIdx = sc.nextInt() - 1;
      int microwaveIdx = sc.nextInt() - 1;
      int discountPrice = sc.nextInt();
      minPrice = Math.min(minPrice, as[fridgeIdx] + bs[microwaveIdx] - discountPrice);
    }

    System.out.println(minPrice);
  }
}


Measured memory_bytes: 130576
// https://atcoder.jp/contests/dp/tasks/dp_i
#include<bits/stdc++.h>
#define forz(i,n) for(int i=0;i<n;i++)
#define foro(i,n) for(int i=1;i<=n;i++)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define lli long long int
using namespace std;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
     faster
     int n;
     cin>>n;
     cout<<fixed;
     cout<<setprecision(10);
     double a[n];
     forz(i,n)cin>>a[i];
     double dp[n+1][n+1]={0};
     for(int i=0;i<=n;i++)
     {
          for(int j=0;j<=n;j++)
          {
               dp[i][j]=0;
          }
     }
    dp[0][0]=1;
     for(int i=1;i<=n;i++)
     {
          for(int j=0;j<=n;j++)
          {
               if(j==0)
               {
                    dp[i][j]=(1-a[i-1])*dp[i-1][j];
               }
               else{
                    dp[i][j]=(a[i-1]*dp[i-1][j-1])+((1-a[i-1])*(dp[i-1][j]));
               }
          }
     }
     double sum=0;
     int itrstart=(n+1)/2;
     for(int i=itrstart;i<=n;i++)
     {
          sum+=dp[n][i];
     }

     cout<<sum<<'\n';

return 0;
}

Measured memory_bytes: 70656
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> chomp
	b = readline() |> chomp
	c = readline() |> chomp
	k = 0
	for i in 1:n
		if a[i]!=b[i]
			if b[i]==c[i]||a[i]==c[i]
				k += 1
			else
				k += 2
			end
		elseif b[i]!=c[i]
			if c[i]==a[i]||a[i]==b[i]
				k += 1
			else
				k += 2
			end
		elseif c[i]!=a[i]
			if a[i]==b[i]||b[i]==c[i]
				k += 1
			else
				k += 2
			end
		end
	end
	println(k)
end

main()

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

int main(void){
    int n,a,b;
    cin >> n>>a>>b;
    vector<int> ans;
    for (size_t i = 1; i <= n; i++)
    {
        string s=to_string(i);
        int tmp=0;
        for (size_t j = 0; j < s.size(); j++)
        {
            tmp+=s[j]-'0';
        }
        if (a<=tmp&&tmp<=b)
        {
            ans.push_back(i);
        }
    }
    int sum=0;
    for (size_t i = 0; i < ans.size(); i++)
    {
        sum+=ans[i];
    }
    cout <<sum <<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    long alp[5]; fill(alp, alp + 5, 0);
    for(int i=0; i<N; i++){
        string name;
        cin >> name;
        if(name[0] == 'M') alp[0]++;
        if(name[0] == 'A') alp[1]++;
        if(name[0] == 'R') alp[2]++;
        if(name[0] == 'C') alp[3]++;
        if(name[0] == 'H') alp[4]++;
    }
    cout << alp[0] * alp[1] * (alp[2] + alp[3] + alp[4]) + alp[0] * alp[2] * (alp[3] + alp[4]) + alp[0] * alp[3] * alp[4]
    + alp[1] * alp[2] * (alp[3] + alp[4]) + alp[1] * alp[3] * alp[4] + alp[2] * alp[3] * alp[4] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
    ll a,b,x;
    ll res,max_p=1;
    cin>>a>>b>>x;
    if(b>x)
    {
        res = floor((a*x)/b);
        cout<<res<<"\n";
    }
    else
    {
       ll temp = x/b;
       ll temp1 = temp*b - 1;
      // here our new x is temp1.....
       
       res = floor((a*temp1)/b) - a*floor(temp1/b); 
      
       cout<<res<<"\n";
    }
   
    
	return 0;
}

Measured memory_bytes: 3588
A, B, C, D, E, F = [int(i) for i in input().split()]

w, s = 1, -1
for a in range(0, F + 1, 100 * A):
    for b in range(0, F - a + 1, 100 * B):
        m = min(F - a - b, (a + b) * E // 100)
        if (a, b) == (0, 0):
            continue
        for c in range(0, m + 1, C):
            for d in range(0, m - c + 1, D):
                if s / w < (c + d) / (a + b):
                    w, s = a + b, c + d

print(w + s, s)


Measured memory_bytes: 3064
class Dice(object):
    def __init__(self, s1, s2, s3, s4, s5, s6):
        self.s1 = s1 #このクラスが持つ「s1」変数に引数を格納 以下も同様
        self.s2 = s2
        self.s3 = s3
        self.s4 = s4
        self.s5 = s5
        self.s6 = s6
    def east(self):
        prev_s6 = self.s6
        self.s6 = self.s3
        self.s3 = self.s1
        self.s1 = self.s4
        self.s4 = prev_s6
    def west(self):
        prev_s6 = self.s6
        self.s6 = self.s4
        self.s4 = self.s1
        self.s1 = self.s3
        self.s3 = prev_s6
    def north(self):
        prev_s6 = self.s6
        self.s6 = self.s5
        self.s5 = self.s1
        self.s1 = self.s2
        self.s2 = prev_s6
    def south(self):
        prev_s6 = self.s6
        self.s6 = self.s2
        self.s2 = self.s1
        self.s1 = self.s5
        self.s5 = prev_s6
    def rotate(self):
        prev_s2 = self.s2
        self.s2 = self.s4
        self.s4 = self.s5
        self.s5 = self.s3
        self.s3 = prev_s2
    def top(self):
        return self.s1
    def front(self):
        return self.s2
    def right(self):
        return self.s3

s1, s2, s3, s4, s5, s6 = map(int, input().split())
dice = Dice(s1, s2, s3, s4, s5, s6)
q = int(input())
for i in range(q):
    t, f = map(int, input().split())
    flag = False
    for j in range(6):
        if j % 2 == 0:
            dice.north()
        else:
            dice.west()
        
        for k in range(4):
            dice.rotate()
            if dice.top() == t and dice.front() == f:
                flag = True
                break
        if flag:
            break
    print(dice.right())



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

int main(){
	static int n;
	static int a[100010];
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	
	static int cnt[100010]={};
	for(int i=0;i<n;i++)cnt[a[i]]++;
	
	int ret=0;
	for(int i=0;i+2<100010;i++){
		ret=max(ret,cnt[i]+cnt[i+1]+cnt[i+2]);
	}
	cout<<ret<<endl;
}



Measured memory_bytes: 4292
import heapq
X,Y,Z,K = map(int,input().split())
K = min(K,X*Y*Z)
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))


A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
set_ = set()
hq = [(-(A[0]+B[0]+C[0]),0,0,0)]
heapq.heapify(hq)
set_.add((0,0,0))
while K:
    val,i,j,k = heapq.heappop(hq)
    print(-val)
    K-=1
    if i+1<len(A) and (i+1,j,k) not in set_: 
        heapq.heappush(hq,(-(A[i+1]+B[j]+C[k]),i+1,j,k))
        set_.add((i+1,j,k))
    if j+1<len(B) and (i,j+1,k) not in set_: 
        heapq.heappush(hq,(-(A[i]+B[j+1]+C[k]),i,j+1,k))
        set_.add((i,j+1,k))
    if k+1<len(C) and (i,j,k+1) not in set_: 
        heapq.heappush(hq,(-(A[i]+B[j]+C[k+1]),i,j,k+1))
        set_.add((i,j,k+1))

Measured memory_bytes: 79696
N = int(input())
p_i = list(map(int, input().split()))

sorted_p = sorted(p_i)
count = 0

for i in range(N):
    if p_i[i] != sorted_p[i]:
        count += 1

if count == 0 or count == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
// B - Bitter Alchemy
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N,X; cin>>N>>X;
	int minM = INT_MAX;
	rpz(i, N){
		int m; cin>>m;
		X -= m;
		minM = min(minM, m);
	}
	cout<< N + X/minM <<endl;
}

Measured memory_bytes: 256
import math

n,d=map(int,input().split())
x=[]
for i in range(n):
  a=list(map(int,input().split()))
  x.append(a)

ans=0

for i in range(n):
  for j in range(i+1,n):
    temp=0
    for k in range(d):
      temp+=(x[i][k]-x[j][k])**2
    #print(math.sqrt(temp))
    temp=math.sqrt(temp)
    if temp==int(temp):
      ans+=1

print(ans)

Measured memory_bytes: 3064
n, k = input().split()
N = int(n)
K = int(k)
p = input().split()
P = list(map(int, p))
 
tmp = 0
num = 0
hoge = 0
ans = []
for i in range(N):
    tmp += (P[i] * (P[i] + 1) / 2 / P[i])
    ans.append(tmp)
    tmp -= tmp
    if i == (K-1):
        num = sum(ans[0:K])
        hoge = num
    elif i > (K-1):
        num = num - ans[i-K] + ans[i]
        if num > hoge:
            hoge = num
print(hoge)

Measured memory_bytes: 32612