akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using ll=long long;
int main(){
    int l;
    cin>>l;
    vector<ll> a(l);
    for(int i=0;i<l;i++) cin>>a[i];

    vector<vector<ll>> dp(l+1,vector<ll>(5,1e15));
    dp[0][0]=0;
    dp[0][0]=0;
    auto pena1=[&](int v){
        if(v==0) return 2;
        else return v%2;
    };
    auto pena2=[&](int v){
        return (int)(v%2==0);
    };
    for(int i=0;i<l;i++){
        for(int j=0;j<4;j++){
            dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
        }
        dp[i+1][0]=min(dp[i+1][0],dp[i][0]+a[i]);
        dp[i+1][1]=min(dp[i+1][1],dp[i][0]+pena1(a[i]));
        dp[i+1][1]=min(dp[i+1][1],dp[i][1]+pena1(a[i]));
        dp[i+1][2]=min(dp[i+1][2],dp[i][1]+pena2(a[i]));
        dp[i+1][2]=min(dp[i+1][2],dp[i][2]+pena2(a[i]));
        dp[i+1][3]=min(dp[i+1][3],dp[i][2]+pena1(a[i]));
        dp[i+1][3]=min(dp[i+1][3],dp[i][3]+pena1(a[i]));
        dp[i+1][4]=min(dp[i+1][3],dp[i][3]+a[i]);
        dp[i+1][4]=min(dp[i+1][3],dp[i][4]+a[i]);
    }
    cout<<*min_element(dp[l].begin(),dp[l].end())<<endl;
    
    

    return 0;
}

Measured memory_bytes: 15872
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     ll           long long int
#define     int          ll
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const ld pi=acos(-1);
const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    string s;
    cin>>s;

    int n=s.length();

    if(n%2==0)
    {
        cout<<"No";
        return;
    }

    string a=s.substr(0,n/2),b=s.substr(n/2+1,n/2);
    string c=a,d=b;

    string str=s;

    reverse(all(c));
    reverse(all(d));
    reverse(all(str));

    if(a==c && b==d && s==str)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int n;
    cin >> n;
    int L[n];
    for (int i = 0; i < n; i++)
    {
        cin >> L[i];
    }
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            for (int k = j+1; k < n; k++)
            {
                if(L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]){
                    if(L[i]+L[j]>L[k]&&L[j]+L[k]>L[i]&&L[k]+L[i]>L[j]){
                        res++;
                    }
                }
            }
            
        }
        
    }
    cout << res << endl;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
bool f(int l, int r){
    return l%10 > r%10;
}
int main(){
    vector<int> a;
    for(int i = 0; i < 5; i++){
        int x;
         cin >> x;
         a.pb(x);
    }
    int s = 0;
    for(int i = 0; i < a.size(); i++){
       if(a[i]%10 == 0) {
           s += a[i];
           a.erase(a.begin() + i);
           i--;
       }
    }
    if(a.size() != 0) {
        sort(a.begin(), a.end(), f);
    for(int i = 0; i < a.size()-1; i++){
        s += a[i] + 10 - a[i]%10;        
    }
        cout << s + a[a.size()-1];
    }
    else cout << s;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    long long N; cin>>N;
    vector<long long> pos(N,0);
    vector<long long> neg(N,0);
    for(long long i=0;i<N;i++){
        long long a; cin>>a;
        if(i-a>=0){
            neg[i-a]+=1;
        }
        if(i+a<=N-1){
            pos[i+a]+=1;
        }
    }
    long long ans = 0;
    for(int i=0;i<N;i++){
        ans += pos[i]*neg[i];
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;
    int a;
    vector<int> data;
    
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        data.push_back(a);
    }
    reverse(data.begin(), data.end());
    for (int i = 0; i < data.size(); i++){
        if(i == 0){
                cout << data.at(i);
        }else{
                cout << " " << data.at(i);
        }
    }
    cout << endl;
}





Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC131A - Security
  string S; cin >> S;
  bool flag = true;
  REP(i, 3){
    if(S[i] == S[i+1]) flag = false;
  }
  if(flag){
    cout << "Good" << endl;
  }else{
    cout << "Bad" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    lint A, B;
    cin >> A >> B;
    if((A + B) % 2){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (A + B) / 2 << endl;
    }
}


Measured memory_bytes: 256
n,y = map(int,input().split())
 
price = 0
ok = 0
 
for i in range(n+1):
    for j in range(n+1-i):
            k = n - i - j
            if k < 0:
                break
 
            price = 10000 * i + 5000 * j + 1000 * k   
            
            if price == y and i+j+k == n and ok == 0:
                print(i, j, k)
                ok = 1
                break
 
    if ok == 1:
        break
 
if ok == 0:
    print(-1, -1, -1 )

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        s: String,
    }
	
  if s == String::from("ABC") {
    println!("ARC")
  } else {
     println!("ABC")
  }
}


Measured memory_bytes: 2104
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

const int INF=1<<30;

template <class RandomIt>
size_t msort(RandomIt first, RandomIt last) {
    if (first+1 >= last) return 0;

    using T=typename RandomIt::value_type;
    ptrdiff_t lhalf=(last-first)>>1;
    RandomIt mid=first+lhalf;

    size_t count_=0;
    count_ += msort(first, mid);
    count_ += msort(mid, last);

    ptrdiff_t rhalf=last-mid;
    vector<T> L(lhalf+1), R(rhalf+1);

    for (RandomIt in=first, out=L.begin(); in<mid; (++in, ++out))
        *out = *in;

    for (RandomIt in=mid, out=R.begin(); in<last; (++in, ++out))
        *out = *in;

    L[lhalf] = R[rhalf] = INF;

    RandomIt l=L.begin(), r=R.begin();
    for (RandomIt it=first; it<last; ++it) {
        *it = *(*l<=*r? l:r)++;
        ++count_;
    }

    return count_;
}

template <class RandomIt, class Comp>
size_t msort(RandomIt first, RandomIt last, Comp comp) {
    if (first+1 >= last) return 0;

    using T=typename RandomIt::value_type;
    ptrdiff_t lhalf=(last-first)>>1;
    RandomIt mid=first+lhalf;

    size_t count_=0;
    count_ += msort(first, mid, comp);
    count_ += msort(mid, last, comp);

    ptrdiff_t rhalf=last-mid;
    vector<T> L(lhalf+1), R(rhalf+1);

    for (RandomIt in=first, out=L.begin(); in<mid; (++in, ++out))
        *out = *in;

    for (RandomIt in=mid, out=R.begin(); in<last; (++in, ++out))
        *out = *in;

    L[lhalf] = R[rhalf] = INF;

    RandomIt l=L.begin(), r=R.begin();
    for (RandomIt it=first; it<last; ++it) {
        *it = *(!comp(*r, *l)? l:r)++;
        ++count_;
    }

    return count_;
}

int main() {
    size_t n;
    scanf("%zu", &n);

    vector<int> S(n);
    for (size_t i=0; i<n; ++i)
        scanf("%d", &S[i]);

    size_t t=msort(S.begin(), S.end(), less<int>());
    for (size_t i=0; i<n; ++i)
        printf("%d%c", S[i], i<n-1? ' ':'\n');

    printf("%zu\n", t);
    return 0;
}

Measured memory_bytes: 6380
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
  if(a+b+c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

ll pow_m(ll x, ll n) {
    ll ans = 1;
    ll xx = x % MOD;
    for (ll m = n; m != 0; m >>= 1) {
        if (m & 1) {
            ans = (ans * xx) % MOD;
        }
        xx = (xx * xx) % MOD;
    }
    return ans;
}

vector<ll> fact_memo(1e5 + 10, -1);
ll fact_m(ll n) {
    if (fact_memo[n] != -1) {
        return fact_memo[n];
    }
    if(n < 0){
        return 0;
    }
    if(n <= 1){
        return fact_memo[n] = 1;
    }
    return fact_memo[n] = (n * fact_m(n - 1)) % MOD;
}

ll inverse_m(ll n) { return pow_m(n, MOD - 2); }

ll comb_m(ll n, ll r) {
    if(n < r){
        return 0;
    }
    ll ans = 1;
    ans *= fact_m(n);
    ans %= MOD;
    ans *= inverse_m(fact_m(n - r));
    ans %= MOD;
    ans *= inverse_m(fact_m(r));
    ans %= MOD;
    return ans;
}

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

    vector<int> a(n + 1);
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
    }

    vector<int> a_sorted(a);
    sort(a_sorted.begin(), a_sorted.end());

    int x = -1;
    for (int i = 0; i < n; i++) {
        if (a_sorted[i] == a_sorted[i + 1]) {
            x = a_sorted[i];
            break;
        }
    }

    int l = -1;
    for (int i = 0; i < n + 1; i++) {
        if (a[i] == x) {
            l = i;
            break;
        }
    }

    int r = -1;
    for (int i = n; i >= 0; i--) {
        if (a[i] == x) {
            r = i;
            break;
        }
    }

    for (int k = 1; k <= n + 1; k++) {
        cout << (comb_m(n + 1, k) + MOD - comb_m(l + n - r, k - 1)) % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 4984
n, k = map(int, input().split())
mod = 10**9 + 7

list_size = 4*10**5 + 1
 
f_list = [1] * list_size
f_r_list = [1] * list_size
 
for i in range(list_size-1):
	f_list[i+1] = (f_list[i] * (i+1)) % mod
 
f_r_list[-1] = pow(f_list[-1], mod - 2, mod)
 
for i in range(list_size-2, -1, -1):
	f_r_list[i] = (f_r_list[i+1] * (i+1)) % mod
 
def comb(n, r, mod):
	if n < r or r < 0:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (f_list[n] * f_r_list[n-r] * f_r_list[r]) % mod


if k < n-1:
    ans = 0
    for i in range(k+1):
        ans += (comb(n-1, i, mod)*comb(n, i, mod))%mod
    print(ans%mod)
else:
    print((comb(2*n-1, n, mod))%mod)

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

#define ll long long
#define pb push_back

const int maxn = 3e5 + 20;

int a[maxn] , b[maxn];

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

	int n;
	cin >> n;

	vector<pair<int , int> > tmp;

	for(int i = 0; i < n; i++)
		cin >> a[i] >> b[i] , tmp.pb({b[i] , a[i]});

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

	for(int i = 0; i < n; i++)
		a[i] = tmp[i].second , b[i] = tmp[i].first;

	ll nw = 0;
	for(int i = 0; i < n; i++)
	{
		nw += a[i];
		if(nw > b[i])
			return cout << "No" << endl , 0;
	}

	cout << "Yes" << endl;
}










 


Measured memory_bytes: 3568
import Control.Applicative
import Text.Printf

distance :: Floating a => [a] -> a
distance [x1, y1, x2, y2] = sqrt $ (x2 - x1) ^ 2 + (y2 - y1) ^ 2

main :: IO ()
main = printf "%.8f\n" =<< (distance . map (read :: String -> Double) . words) <$> getLine

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    ll n, u, v;
    cin >> n >> u >> v;

    vector<vector<ll>> g(n + 1);
    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<ll> q;
    q.push(u);

    ll distance_t[n + 1] = {}, distance_a[n + 1] = {};

    rep(i, n + 1) {
        distance_t[i] = -1;
        distance_a[i] = -1;
    }

    distance_t[u] = 0;
    distance_a[v] = 0;

    q.push(u);
    while (!q.empty()) {
        ll now = q.front();
        q.pop();
        ll distance_now = distance_t[now];
        rep(i, g[now].size()) {
            ll next = g[now][i];
            if (distance_t[next] == -1) {
                q.push(next);
                distance_t[next] = distance_now + 1;
            }
        }
    }

    q.push(v);
    while (!q.empty()) {
        ll now = q.front();
        q.pop();
        ll distance_now = distance_a[now];
        rep(i, g[now].size()) {
            ll next = g[now][i];
            if (distance_a[next] == -1) {
                q.push(next);
                distance_a[next] = distance_now + 1;
            }
        }
    }

    // rep(i, n + 1) { cout << distance_t[i] << " " << distance_a[i] << endl; }

    ll ans = 0;
    repd(i, 1, n + 1) {
        if (distance_a[i] > distance_t[i]) {
            // ll d = distance_a[i] - distance_t[i];
            // ll ans_temp = distance_t[i] + d / 2;
            // cout << "here" << i << " " << ans_temp << endl;
            ans = max(ans, distance_a[i] - 1);
        }
    }

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



Measured memory_bytes: 8064
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	string S;

	cin >> S;

	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int x, y, a[13]={0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  scanf("%d %d", &x, &y);

  printf("%s\n", a[x]==a[y] ? "Yes": "No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int X,A,B;
    cin >> X >> A >> B;
    
    int ans = X;
    ans -= A;
    while(ans>=B){
        ans -= B;
    }
    
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << setprecision(15) << W*H/2 << " ";
    
    if(x*2==W && y*2==H) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }


    return 0;
    
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int64_t> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());

  int64_t ans= vec.at(n-1);
  for (int i = 0; i+k-1< n; i++) {
    ans = min(ans, vec.at(i+k-1) - vec.at(i));
  }

  cout << ans << endl;
}


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

int main() {
	string a,b,c;
	string ans;
	cin >> a>> b>>c;
	if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) {
		ans = "YES";
	}
	else {
		ans = "NO";
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
struct _IO { _IO() { ios::sync_with_stdio(false); cin.tie(nullptr); } }_io;
typedef long long ll; typedef long double db;

ll exgcd(ll a, ll b, ll& x, ll& y)
{
	if (!b)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll d = exgcd(b, a % b, x, y);
	ll t = x;
	x = y;
	y = t - (a / b) * y;
	return d;
}
ll getInv(ll a, ll mod)
{
	ll x, y;
	return exgcd(a, mod, x, y) == 1 ? (x % mod + mod) % mod : -1;
}

int main()
{
	ll n, ans = 0;
	cin >> n;
	for (ll a = 1; a <= n; ++a)
		for (ll b = 1; b <= n; ++b)
		{
			if (a * b >= 0 && a * b <= n - 1) ++ans;
			else break;
		}
	cout << ans << endl;
	return 0;
}

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

#define endl "\n"
#define int long long
#define vec(x) vector<x>
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
const int MOD = 1e9 + 7; 
const double pi = acos(-1);
int power(int a,int b,int m=MOD)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}
int dir[]={-1, 0, 1, 0, -1};
int dx[]={1,1,0,-1,-1,-1, 0, 1};
int dy[]={0,1,1, 1, 0,-1,-1,-1};

const int N = 1e5+1;
int dp[N][105];
int wt[105],val[105];
int n,W;

int helper(int v,int i)
{
	if(v<=0)
	return 0;
	if(i==n)
	return INF;
	if(dp[v][i]!=-1)
	return dp[v][i];
	dp[v][i]=min(helper(v,i+1),wt[i]+helper(v-val[i],i+1));
	return dp[v][i];
}

void solve()
{
	int i,sum=0;
	cin>>n>>W;
	for(i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
		sum+=val[i];
	}
	mem(dp,-1);
	for(i=sum;i>=0;i--)
	if(helper(i,0)<=W)
	{
		cout<<i<<endl;
		return;
	}
	cout<<0<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	t=1;
	//cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 82304
def partition(A,p,r):
    x=A[r][1]
    i=p-1
    for j in range(p,r):
        if A[j][1]<=x:
            i+=1
            m=A[i]
            A[i]=A[j]
            A[j]=m
    m=A[i+1]
    A[i+1]=A[r]
    A[r]=m
    return i+1
def quicksort(A,p,r):
    if p<r:
        q=partition(A,p,r)
        quicksort(A,p,q-1)
        quicksort(A,q+1,r)
n=int(input())
A=[]
for _ in range(n):
    card=input().split()
    A.append([card[0],int(card[1])])
Acopy=A.copy()
quicksort(A,0,n-1)
ans="Stable"
for i in range(n-1):
    if A[i][1]==A[i+1][1]:
        if Acopy.index(A[i+1])<Acopy.index(A[i]):
            ans="Not stable"
            break
print(ans)
for i in range(n):
    print(*A[i])


Measured memory_bytes: 18840
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
using namespace std;
int main()
{
    int n, m, a, b;
    cin>>a>>b;
    n=2*b;
    if(a>n)
        cout<<a-n<<endl;
    else
        cout<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys


def main():
  n = int(input())
  card = sorted(list(map(int, input().split(' '))), reverse=True)
  A = []
  B = []
  
  for i in range(n):
    if i % 2 == 0:
      A.append(card[i])
    
    else:
      B.append(card[i])
      
  print(sum(A) - sum(B))
  
  return 0


if __name__ == '__main__':
  main()

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

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

inline void solve() {
    int K;
    cin >> K;

    int A, B;

    cin >> A >> B;

    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return;
        }
    }

    cout << "NG" << endl;

}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int n, k;

// NB: prefixDP[i][j] takes the first j terms of possibility on prefix
// NB: 0 is the first term
int prefixDP[5005][5005];
int suffixDP[5005][5005];

bool prefixPossible[5005][5005];
bool suffixPossible[5005][5005];


/*
isPossiblePrefix(n, k) -> true if there is a subset of the first
n integers that sums to k
isPossibleSuffix(n, k) -> true ...


[prefix] (idx) [suffix]



*/
int l[5005];

bool isUnnecessary(int idx) {
  for(int prefSum = 0; prefSum <= k; prefSum++) {
    if(!prefixPossible[idx][prefSum]) continue;
    // prefSum + suffSum < k <= prefSum + suffSum + l[idx]
    int minSuffSum = max(0, k - prefSum - l[idx]);
    int maxSuffSum = k - prefSum - 1;
    if(minSuffSum > maxSuffSum || maxSuffSum < 0) continue;
    if(suffixDP[n-idx-1][maxSuffSum + 1] - suffixDP[n-idx-1][minSuffSum]) {
      return false;
    }
  }
  return true;
}

void fillPrefix() {
  prefixPossible[0][0] = true;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= k; j++) {
      prefixPossible[i+1][j] |= prefixPossible[i][j];
      prefixPossible[i+1][min(k, j + l[i])] |= prefixPossible[i][j];
    }
  }
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= k; j++) {
      prefixDP[i][j+1] = prefixDP[i][j];
      if(prefixPossible[i][j]) {
        prefixDP[i][j+1]++;
      }
    }
  }
}

void fillSuffix() {
  suffixPossible[0][0] = true;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= k; j++) {
      suffixPossible[i+1][j] |= suffixPossible[i][j];
      suffixPossible[i+1][min(k, j + l[n-1-i])] |= suffixPossible[i][j];
    }
  }
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= k; j++) {
      suffixDP[i][j+1] = suffixDP[i][j];
      if(suffixPossible[i][j]) {
        suffixDP[i][j+1]++;
      }
    }
  }
}

int main() {
  scanf("%d%d", &n, &k);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  fillPrefix();
  fillSuffix();
  int ret = 0;
  for(int i = 0; i < n; i++) {
    if(isUnnecessary(i)) {
      ret++;
    }
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 244736
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

void y(bool c) {
	if (c)print("Yes");
	else print("No");
}
void solve() {
	vector<int>v(3);
	REP(i, 3)cin >> v[i];
	VSORT(v);
	ll ans = 1e9;
	if (v[0] % 2 == v[1] % 2) {
		if (v[1] % 2 == v[2] % 2) {
			int res = (v[2] - v[0]) / 2 + (v[2] - v[1]) / 2;
			ans = min(ans, res);
		}
		else {
			v[0]++, v[1]++;
			int res = 1;
			res+= (v[2] - v[0]) / 2 + (v[2] - v[1]) / 2;
			chmin(ans, res);
		}
	}
	else if (v[1] % 2 == v[2] % 2) {
		int res = 1;
		v[1]++, v[2]++;
		res += (v[2] - v[0]) / 2 + (v[2] - v[1]) / 2;
		chmin(ans, res);
	}
	else {
		int res = 1;
		v[0]++, v[2]++;
		res += (v[2] - v[0]) / 2 + (v[2] - v[1]) / 2;
		chmin(ans, res);
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abc088/tasks/abc088_b
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
  int N;
  cin >> N;
  vector<int> cards(N);

  int BobsP = 0, AlicesP = 0;

  for (int i = 0; i < N; i++)
    cin >> cards.at(i);

  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());

  for (int i = 0; i < N; i++){
    if (i % 2 == 0)
      AlicesP += cards.at(i);
    else
      BobsP += cards.at(i);
  }

  cout << AlicesP - BobsP << endl;
}

Measured memory_bytes: 256
import queue

k=int(input())

cnt=0
q=queue.Queue()

for i in range(1,10):
    q.put(i)

while True:
    dq=q.get()
    if dq%10!=0:
        q.put(10*dq+dq%10-1)
    q.put(10*dq+dq%10)
    if dq%10!=9:
        q.put(10*dq+dq%10+1)
    cnt+=1
    if cnt==k:
        print(dq)
        break
    

Measured memory_bytes: 12452
H, W = map(int, input().split())

M = [list("." + input() + ".") for i in range(H)]
M.insert(0, list(("."*(W+2))))
M.append(list("."*(W+2)))

cnt = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == ".":
            for k in range(-1, 2):
                if M[i+k][j-1] == "#":
                    cnt += 1
                if M[i+k][j] == "#":
                    cnt += 1
                if M[i+k][j+1] == "#":
                    cnt += 1
            print(cnt, end = "")
            cnt = 0
        else:
            print("#", end = "")
    print()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
using namespace std;
typedef long long ll;
int main(){
	int n; cin >>n;
	int a[n];
	rep(i,0,n) cin >>a[i];
	
	sort(a,a+n);
	cout << a[n-1]- a[0];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;



int main() {
  int n;
  cin >> n;
  int d[n];
  rep (i,n) cin >> d[i];
    ll sum = 0;

  rep (i,n){
      for (int j = i+1;j < n;j++){
          sum += d[i]*d[j];
      }
  }
    cout << sum << endl;
   
  

}



Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	cin >> n;
	vector<LL> v(n);
	for(int i = 0; i < n; ++i){
		cin >> v[i];
	}

	LL ans = 0;
	while(1){
		int k = max_element(ALL(v)) - v.begin();
		if(v[k] < n){ break; }
		LL c = v[k] / n;
		for(int i = 0; i < n; ++i){
			v[i] += c;
		}
		v[k] -= c * (n + 1);
		ans += c;
	}
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 256
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=100000;

int main(){
    
    int c[maxn]={0};
    int n,m=-1;
    
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        m=max(m,a);
        c[--a]++;
    }
    
    int doub=0;
    
    rep(i,m){
        doub+=max(0,c[i]-1);
    }
    
    if(doub%2==0){
        cout << n-doub<<endl;
    }else{
        cout << n-doub-1<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;


void solve(){
    int n;cin>>n;
    long long ans;
    if (n<2){
        ans = n==0?2:1;
    }else{
        long long a=2,b=1;
        for(int i=2;i<=n;i++){
            ans = a+b;
            a = b;
            b = ans;
        }
    }
    cout << ans << endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    char s[105];
    int count=0;
    int ans=0;
    cin>>s;
    for(int i=0;s[i]!='\0';i++){
        count+=1;
    }
    for(int i=0;i<count/2;i++){
        if(s[i]!=s[count-1-i]){
            ans+=1;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 10000000
using namespace std;
typedef long long ll;
const int MAXN=1e9+10;
const int MAX=1e6+10;
const double eps=1e-6;




int main(){


    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


string s;
i64 dp[101010];

int main(){
	cin >> s;
	int n = s.size();
	
	i64 ans = 1, cnt = 2;
	dp[0] = 1;
	for(int i = 1; i < n; i++){
		dp[i] = dp[i-1]*2;
		dp[i] %= INF;
	}
	for(int i = 0; i < n-1; i++){
		ans += cnt;
		ans %= INF;
		dp[i+1] = ans;
		cnt *= 3;
		cnt %= INF;
	}
	//10110
	ans += 2;
	cnt = 1;
	for(int i = 1; i < n; i++){
		if(s[i] == '1'){
			cnt*=2;
			cnt%=INF;
			ans += (dp[n-i-1]+1)*cnt;
		}
		ans %= INF;
	}
	//0 1 10 11 100 101 110 111 1000 1001 = 1 3 5 9 11 15 19 27 29 33
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1280
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Flatten
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10000;
const int MAX_P = 1000000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

bool primes[MAX_P + 1];
int pnums[MAX_P];
int as[MAX_N];

/* subroutines */

int gen_primes(int maxp, int pnums[]) {
  memset(primes, true, sizeof(primes));
  primes[0] = primes[1] = false;

  int p, pn = 0;
  for (p = 2; p * p <= maxp; p++)
    if (primes[p]) {
      pnums[pn++] = p;
      for (int q = p * p; q <= maxp; q += p) primes[q] = false;
    }
  for (; p <= maxp; p++)
    if (primes[p]) pnums[pn++] = p;
  return pn;
}

void prime_decomp(int n, int pn, int pnums[], vpii& pds) {
  pds.clear();

  for (int i = 0; i < pn && pnums[i] * pnums[i] <= n; i++) {
    int pi = pnums[i];

    if (n % pi == 0) {
      int fi = 1;
      n /= pi;
      while (n % pi == 0) n /= pi, fi++;
      pds.push_back(pii(i, fi));
    }
  }

  if (n > 1) {
    int k = lower_bound(pnums, pnums + pn, n) - pnums;
    pds.push_back(pii(k, 1));
  }
}

void printpds(int pnums[], vpii &pds) {
  for (int i = 0; i < pds.size(); i++) {
    if (i) putchar('*');
    printf("%d", pnums[pds[i].first]);
    if (pds[i].second > 1)
      printf("^%d", pds[i].second);
  }
  putchar('\n');
}

void calc_lcm(vpii &a, vpii &b, vpii &c) {
  c.clear();
  vpii::iterator ait = a.begin(), bit = b.begin();

  while (ait != a.end() && bit != b.end()) {
    if (ait->first < bit->first)
      c.push_back(*(ait++));
    else if (ait->first > bit->first)
      c.push_back(*(bit++));
    else {
      c.push_back(pii(ait->first, max(ait->second, bit->second)));
      ait++, bit++;
    }
  }
  while (ait != a.end()) c.push_back(*(ait++));
  while (bit != b.end()) c.push_back(*(bit++));
}

int powmod(int a, int b) {
  int p = 1;
  while (b > 0) {
    if (b & 1) p = (ll)p * a % MOD;
    a = (ll)a * a % MOD;
    b >>= 1;
  }
  return p;
}

/* main */

int main() {
  int pn = gen_primes(MAX_P, pnums);
  //printf("pn=%d\n", pn);

  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  vpii pa, pb, pc;
  prime_decomp(as[0], pn, pnums, pa);

  for (int i = 1; i < n; i++) {
    prime_decomp(as[i], pn, pnums, pb);
    calc_lcm(pa, pb, pc);
    swap(pc, pa);
  }

  int lcm = 1;
  for (vpii::iterator vit = pa.begin(); vit != pa.end(); vit++) {
    int pm = powmod(pnums[vit->first], vit->second);
    lcm = (ll)lcm * pm  % MOD;
  }
  //printf("lcm=%d\n", lcm);

  int sum = 0;
  for (int i = 0; i < n; i++) {
    int bi = (ll)lcm * powmod(as[i], MOD - 2) % MOD;
    sum = (sum + bi) % MOD;
  }

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 3712
fun main(args: Array<String>) {
    var N = readLine()!!.toLong()
    val bin = mutableListOf<Int>()
    if (N == 0L) {
        println(0)
        return
    }
    var b = 1L
    while(N != 0L) {
        if (Math.abs(N) % Math.abs(b*2) == 0L) {
            bin.add(0)
        }
        else {
            bin.add(1)
            N -= b
        }
        b *= -2
    }
    bin.reverse()
    for (x in bin) {
        print(x)
    }
}

Measured memory_bytes: 31916
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=998244353;

const int N=2e5+5;

#define NCR
#define PRIME	M
int pw(int a,int p=M-2,int MOD=M){
	int result = 1;
	while (p > 0) {
		if (p & 1)
			result = a * result % MOD;
		a = a * a %MOD;
		p >>= 1;
	}
	return result;
}
int fact[N],invfact[N];
void init(){
	int p=PRIME;
	fact[0]=1;
	int i;
	for(i=1;i<N;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=pw(fact[i],p-2,p);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
int ncr(int n,int r){
	return (((fact[n]*invfact[r])%PRIME)*invfact[n-r])%PRIME;
}

void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	
	int ans=0;
	n--;
	
	rep(i,0,k+1){
		ans += ncr(n,i)*pw(m-1,n-i)%M;
		ans %= M;
	}
	
	ans*=m;
	ans%=M;
	cout<<ans;
	
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 6776
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int temp, cnt = 0;
		int x[] = new int[3000], y[] = new int[3000];
		
		while(true){
			x[cnt] = sc.nextInt();
			y[cnt] = sc.nextInt();
			
			if(x[cnt] == 0 && y[cnt] == 0)
				break;
			
			if(x[cnt] > y[cnt]){
				temp = x[cnt];
				x[cnt] = y[cnt];
				y[cnt] = temp;
			}
			
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++)
			System.out.println(x[i] + " " + y[i]);
	}
}

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


int main(){
    int A,P;
    cin >> A >> P;
    int kakera=0;
    kakera += A*3;
    kakera += P;
	if(kakera<2){
      cout << 0;
    }else if(kakera%2==0){
    cout << kakera/2;
    }else if(kakera%2==1){
      cout << kakera/2;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

#define LL long long

const int MAXN = 2000000 + 5;

bool b[MAXN];

int main()
{
    int K, i, m;
    cin >> K;
    memset (b, 0, sizeof(b));
    for (i = 0, m = 7; b[0] == false; m = m * 10 + 7){
        i ++;
        m = m % K;
        if (b[m] == true){
            break;
        }
        b[m] = true;
    }
    if (b[0]){
        cout << i;
    }
    else{
        cout << "-1";
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 5688