akhauriyash/Code-Regression huggingface dataset:
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  1e6+5;
const ll   mod   =  1e9;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n;

void solve(){
	cin >> n;
	if(n >= 30) deb1("Yes")
	else deb1("No")
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

int main() {
    long long N;
    long long M;
    scanf("%lld", &N);
    vector<long long> A(N - 1 + 1);
    scanf("%lld", &M);
    for (int i = 0; i <= N - 1; i++) {
        scanf("%lld", &A[i]);
    }

    SORT(A);
    vector<ll> sum(N + 1);
    repn(i, N) { sum[i] = sum[i - 1] + A[i - 1]; }
    auto calc = [&](ll x) {
        ll res = 0, total = 0;
        rep(i, N) {
            res += N - POSL(A, x - A[i]);
            // if (x == 67)
            //     cout << i << "; " << POSL(A, x - A[i]) << res << " "
            //          << (sum[N] - sum[POSL(A, x - A[i])]) << " " << A[i] *
            //          res
            //          << endl;
            total += (sum[N] - sum[POSL(A, x - A[i])]) +
                     A[i] * (N - POSL(A, x - A[i]));
        }
        return P(res, total);
    };

    long long lb = -1, ub = 10000000000001;
    while (ub - lb > 1) {
        long long mid = (lb + ub) / 2;
        if (calc(mid).first >= M)
            lb = mid;
        else
            ub = mid;
    }
    ll c1 = calc(lb).first, c2 = calc(lb).second;
    // cout << c1 << " " << c2 << " " << lb << endl;
    cout << c2 - (c1 - M) * lb << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=100000+10;
int main()
{
    int n,a[N];
    while(~scanf("%d",&n)){
        int x=0,y=0,z=0;
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
            if(a[i]%4==0) z++;
            if(a[i]%4!=0&&a[i]%2==0) y++;
            if(a[i]%2==1) x++;
        }
        if(y%2+x<=z+1)
            printf("Yes\n");
        else
            printf("No\n");
    }

    return 0;
}


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

using namespace std;
using std::cin;
using std::cout;
vector<int> v;
#define pb push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
const int mn = 505;
int a[mn][mn];

void draw(vector<int> v, int depth) {
    if (sz(v) == 1) return;
    vector<int> l, r;
    for (int i = 0; i < sz(v); i++) {
        if (i % 2) l.pb(v[i]);
        else r.pb(v[i]);
    }
    for (int i = 0; i < sz(l); i++) {
        for (int j = 0; j < sz(r); j++) {
            a[l[i]][r[j]] =
            a[r[j]][l[i]] = depth;
        }
    }
    draw(l, depth + 1);
    draw(r, depth + 1);
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) v.pb(i);
    draw(v, 1);
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            printf("%d ", a[i][j]);
        }
        printf("%d\n", a[i][n]);
    }
}

Measured memory_bytes: 1536
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;


bool comp(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    ll maxi=0,f=0,sum=0,mini=INF;
    string str,str1,str2;
    ll i;
    double h;
    ll n,x,m;
    ll a,b,d,c,k;
    //multiset<pair<string,ll>> s;
    cin>>n>>k;
    vector<P> p(n);
    rep(i,n){
        cin>>a>>b;
        p[i]=P(a,b);
    }
    sort(all(p),comp);
    rep(i,n){
        sum+=p[i].second;
        if(sum>=k){
            cout<<p[i].first<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4776
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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 long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();

        int N;
        cin >> N;
        int K;
        cin >> K;
        vector<int> a(N);
        rep(i, 0, N) cin >> a[i];


        vector<int> dp(K + 1, 0);
        dp[0] = 0;

        for (int i = 0; i <= K; ++i) {
            for (int j = 0; j < N; ++j) {
                if (i - a[j] >= 0) {
                    if (dp[i - a[j]] == 0) {
                        dp[i] = 1;
                    }
                }
            }
        }

        if (dp[K] == 0) {
            cout << "Second" << endl;
        } else {
            cout << "First" << endl;
        }

    }
};


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

    Solve().solve();


    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}

//-----------------------------------------
struct point{
  ld x, y;
};

void pp(point p){
  cout << p.x << " " << p.y <<endl;
}

void koc(int d, point lef, point rig){
  if(d == 0) return;
  double th = PI / 3;
  point s, t, u;
  s.x = (lef.x * 2 + rig.x) / 3;
  s.y = (lef.y * 2 + rig.y) / 3;
  t.x = (lef.x + rig.x * 2) / 3;
  t.y = (lef.y + rig.y * 2) / 3;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koc(d-1,lef,s);
  pp(s);
  koc(d-1,s,u);
  pp(u);
  koc(d-1,u,t);
  pp(t);
  koc(d-1,t,rig);
}
//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n;
  cin >> n;
  point a, b;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  pp(a);
  koc(n,a,b);
  pp(b);




  return 0;
}



Measured memory_bytes: 3528
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
for i in range(n-2):
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 62468
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int n,m;
     cin>>n>>m;
     vi vec(m);
     ll sum=0;
     rep(i,m) {
        cin>>vec[i];
        sum+=vec[i];
     }
     if(n-sum<0) cout<<-1<<endl;
     else cout<<n-sum<<endl;

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 3652
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=2
t=0
path=[]
s=set()
cycle=[]
while(c<=k):
    if a[t] in s:
        #print(path.index(a[t]),a[t])
        cycle=path[path.index(a[t]):]
        k-=c-1
        break
    path.append(a[t])
    s.add(a[t])
    t=a[t]-1
    c+=1
if cycle==[]:
    print(a[t])
else:
    print(cycle[k%len(cycle)])
    

Measured memory_bytes: 113896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;

int a[maxn];
int main()
{
    int n;
    cin >> n;
    int az = 1, af = 1, sum = 0, minabs = mod;
    for (int i = 0; i < n; ++i){
        cin >> a[i];
        if (a[i] > 0) af = 0;
        if (a[i] < 0) az = 0;
        sum += abs(a[i]);
        if (abs(a[i]) < minabs) minabs = abs(a[i]);
    }
    sort(a, a + n);
    if (!az && !af){
        cout << sum << '\n';
        if (n == 2) cout << a[1] << " " << a[0] << '\n';
        else{
        int cur = a[n - 1], p = 0;
        while (a[p] < 0 && a[p + 1] < 0){
            cout << a[n - 1] << " " << a[p] << '\n';
            a[n - 1] -= a[p];
            ++p;
        }
        for (int i = p + 1; i < n - 1; ++i){
            cout << a[p] << " " << a[i] << '\n';
            a[p] -= a[i];
        }
        cout << a[n - 1] << " " << a[p] << '\n';
        }
    }else if(az){
        cout << sum - 2 * minabs << '\n';
        if (n == 2) cout << a[1] << " " << a[0] << '\n';
        else{
        cout << a[0] << " " << a[1] << '\n';
        a[1] = a[0] - a[1];
        for (int i = 2; i < n - 1; ++i){
            cout << a[1] << " " << a[i] << '\n';
            a[1] -= a[i];
        }
        cout << a[n - 1] << " " << a[1] << endl;
        }
    }else{
        cout << sum - 2 * minabs << '\n';
        if (n == 2) cout << a[0] << " " << a[1] << '\n';
        else{
        cout << a[n - 1] << " " << a[n - 2] << '\n';
        a[n - 2] = a[n - 1] - a[n - 2];
        for (int i = n - 3; i >= 0; --i){
            cout << a[n - 2] << " " << a[i] << '\n';
            a[n - 2] -= a[i];
        }
        }
    }
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX_M 10000
#define MAX_N 25

int n, m, k;

int power_cache[MAX_M][MAX_N];
int power(int x, int p) {
    if (power_cache[x][p] > 0) return power_cache[x][p];
    return power_cache[x][p] = power(x, p-1) * x;
}

int cache[MAX_N][MAX_M*MAX_N];
int pat(int r, int s) {
    if (s < 0) return 0;
    if (r == 0) 
        return (s == 0 ? 1 : 0);
    if (cache[r][s] >= 0) return cache[r][s];
    int cnt = 0;
    for (int i = 1; i <= m; i++) 
        cnt += pat(r-1, s-i);
    return cache[r][s] = cnt;
}

int main() {
    for (int i = 0; i < MAX_M; i++) power_cache[i][0] = 1;
    while (cin >> n >> m >> k, n || m || k) {
        memset(cache, -1, sizeof(cache));
        double e = 0;
        for (int i = 1; i <= n*m; i++)
            e += (double)pat(n, i) / power(m, n) * max(i-k, 1);
        printf("%.10lf\n", e);
    }
    return 0;
}

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

int main() {
    int a[5];
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    int k;
    cin >> k;
    if (a[4] - a[0] > k) {
        cout << ":(" << endl;
        return 0;
    }
    cout << "Yay!" << endl;
}

Measured memory_bytes: 256
s = list(input())
size = len(s)
para = ["" for i in range(size-1)]
a = []
for i in range(size):
    if i == size-1:
        a.append(s[i])
    else:
        a.append(s[i])
        a.append(para[i])
ans = 0
for p in range(2**(size-1)):
    for j in range(size-1):
        if (p>>j) & 1 :
            a[2*j+1] = "+"
        else: 
            a[2*j+1] = ""
    ans += eval("".join(a))
print(ans)
    

Measured memory_bytes: 3064
import numpy as np

N=int(input())
A=np.array(input().split(),dtype=int)

DIV=10**9+7

ans=0
for i in range(60):
  bits=(A>>i)&1
  nonzero=np.count_nonzero(bits)
  zeros=N-nonzero
  pat=nonzero*zeros
  for p in range(i):
    pat*=2
  ans+=pat
  ans%=DIV
  
print(ans)


Measured memory_bytes: 62756
#include<iostream>
#include<cstdio>
#include<cmath>
typedef long long ll;
using namespace std;
ll n;
ll a[100010];
ll dis[100010];
int main()
{
    ll sum=0;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    ll k;
    if((2*sum%(n*(n+1)))!=0)
    {
        printf("NO");
        return 0;
    }
    k=2*sum/n/(n+1);
    for(int i=0;i<n;i++)
    {
        if(i==n-1)
            dis[i]=a[i]-a[0];
        else
            dis[i]=a[i]-a[i+1];
    }
    for(int i=0;i<n;i++)
    {
        if(dis[i]+k<0||(dis[i]+k)%n!=0)
        {
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, m;
  cin >> n >> m;
  i64 a = 0, b = n;
  for (i64 i = 0; i < m; ++i) {
    i64 l, r; cin >> l >> r;
    a = max(a, l);
    b = min(b, r);
  }
  cout << max(i64(0), b - a + 1) << '\n'; 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;


#define SIZE 1000000
ll kaijo[SIZE];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i < SIZE;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x%N;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N)*(y%N) % N;
		k /= 2;
	}
	return res;
}

ll inv1(ll x,ll p) {
	ll res = 1;
	ll k = p;
	ll y = x%N;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N)*(y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	if (n < 0 || k < 0 || (n - k) < 0)return 0;
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)) % N) % N;
}

ll suml[200010];
ll sumr[200010];

int main(void){
    ll n,k;
    cin>>n>>k;
    sumr[0]=0;
    suml[0]=0;
    ll ans = 0;
    for(ll i=0;i<=n;i++)suml[i+1]=suml[i]+i;
    for(ll i=n;i>=0;i--)sumr[n-i+1]=sumr[n-i]+i;
    for(ll i=k;i<=n+1;i++){
        ll l = suml[i];
        ll u = sumr[i];
        ans = (ans+u-l+1)%N;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6712
def solve():
    N, M, X = map(int, input().split())
    AC = []
    ans = 10**8
    for n in range(N):
        AC.append(list(map(int, input().split())))
    for i in range(2**N):
        level = [0]*M
        cost = 0
        for j in range(N):
            if ((i >> j) & 1):
                for l in range(M):
                    level[l] += AC[j][l+1]
                cost += AC[j][0]
        if (min(level) >= X) and (ans > cost):
            ans = cost
    if ans == 10**8:
        print(-1)
    else:
        print(ans)


solve()


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

int main(){
	
	int N;
	cin >>N;
	bool A=0;
	
	
	for(int i=0; i<9; i++){
	
		if(N%(i+1)==0&&N/(i+1)<10){
			
			A=1;
			
		}
		
	}
	
	if(A){
		
		puts("Yes");
		
	}
	else{
		
		puts("No");
		
	}
	
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	for i := range as {
		if as[i] == 0 {
			fmt.Println(0)
			return
		}
	}

	ret := 1
	for i := range as {
		if as[i] <= 1000000000000000000/ret {
			ret *= as[i]
		} else {
			fmt.Println(-1)
			return
		}

	}

	fmt.Println(ret)
}

Measured memory_bytes: 6304
#A
a,b = map(int,input().split())
cnt = 0
if a > b:
    cnt += a
    a -= 1
else:
    cnt += b
    b -= 1
   
if a > b:
    cnt += a
    a -= 1
else:
    cnt += b
    b -= 1
    
print(cnt)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main{

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      boolean[][] checkCards = new boolean[4][13];
      for( int i = 0; i < 4; i++ ) {
        Arrays.fill(checkCards[i], false);
      }
      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int a,b;

      for(int i = 0; i < n; i++) {
        lines = br.readLine().split(" ");
        a = suitToInt(lines[0]);
        b = Integer.parseInt(lines[1]);
        checkCards[a][b-1] = true;
      }

      for(int i = 0; i < 4; i++ ) {
        for( int j = 0; j < 13; j++ ) {
          if(!checkCards[i][j]) System.out.println(intToSuit(i) + " " + (j+1));
        }
      }
    }
  }

  public static int suitToInt( String suit ) {
    switch( suit ) {
      case "S": return 0;
      case "H": return 1;
      case "C": return 2;
      default : return 3;
    }
  }
  public static String intToSuit( int r ) {
    switch( r ) {
      case 0  : return "S";
      case 1  : return "H";
      case 2  : return "C";
      default : return "D";
    }
  }
}


Measured memory_bytes: 24344
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <functional>
#include <string.h>
#include <cmath>

using namespace std;

int gcd(int a, int b)
{
    while(b){
        a %= b;
        a ^= b ^= a ^= b;
    }
    return a;
}

int main()
{
    int a, b;
    while(cin>>a>>b){
        int g = gcd(a, b);
        cout << g << " " << a/g*b << endl;
    }
}

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

const int MAXN = 100005;

int N, M, A[MAXN];
int main(){
	scanf("%d %d", &N, &M);
	
	multiset <int> S;
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
		S.insert(A[i]);
	}
	
	while(M--){
		int x = *prev(S.end());
		S.erase(prev(S.end()));
		S.insert(x / 2);
	}
	
	long long sum = 0;
	for(int x : S)sum += x;
	
	printf("%lld\n", sum);
	
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(void){
	int a,b;
	cin>>a;
	cout<<(a<1000?"ABC":"ABD")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll da[100100];
ll db[100100];
ll dc[100100];

ll f(ll d, ll y1, ll y2, ll z1, ll z2, ll y, ll z){
  ll a = db[y1+d]-db[y1];
  ll dd = y - (y1+d);
  if(dd>z2)return -1000000000000000000LL;
  ll b = dc[z1+dd]-dc[z1];
  return a+b; 
}

int main(){
  ll x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<ll> va,vb,vc;
  rep(i,0,a){
    ll d;
    cin>>d;
    va.pb(d);
  }
  rep(i,0,b){
    ll d;
    cin>>d;
    vb.pb(d);
  }
  rep(i,0,c){
    ll d;
    cin>>d;
    vc.pb(d);
  }
  sort(all(va));
  sort(all(vb));
  sort(all(vc));
  reverse(all(va));
  reverse(all(vb));
  reverse(all(vc));
  clr(da,0);
  clr(db,0);
  clr(dc,0);
  rep(i,0,va.sz){
    da[i+1] += da[i]+va[i];
  }
  rep(i,0,vb.sz){
    db[i+1] += db[i]+vb[i];
  }
  rep(i,0,vc.sz){
    dc[i+1] += dc[i]+vc[i];
  }
  ll mx = 0;
  rep(i,0,x+1){
    ll ans = 0;
    ans += da[i];
    ll x1 = i;
    ll x2 = x-i;
    ll z1 = x2;
    if(z1>c)continue;
    ans += dc[z1];
    ll z2 = c-z1;
    ll y1 = max(0LL,y-z2);
    ans += db[y1];
    ll y2 = b-y1;
    long long left = 0;
    long long right = y-y1;
    ll e = 0;
    while(left != right){
      long long d = (right - left) / 3;
      long long l = f(left + d,y1,y2,z1,z2,y,c);
      long long r = f(right - d,y1,y2,z1,z2,y,c);
      if(d == 0){
        if(l < r)left++;
        else right--;
      }
      else{
        if(l < r)left = left + d;
        else right = right - d;
      }
    }
    mx = max(ans+f(left,y1,y2,z1,z2,y,c),mx);
  }
  cout << mx << endl;
  return 0;
}

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

int main(){
  int N, otsuri = 0;
  
  cin >> N;
  
  if(N % 1000 != 0){
    otsuri = 1000 - N % 1000;
  }
  
  cout << otsuri << endl;
  
  return 0;
}

Measured memory_bytes: 3628
a = input().split()
#a[0]:W a[1]:H a[2]:x a[3]:y a[4]:r
if 0<=int(a[2])-int(a[4]) and int(a[2])+int(a[4])<=int(a[0]) and\
    0<=int(a[3])-int(a[4]) and int(a[3])+int(a[4])<=int(a[1]):
        print("Yes")
else:
        print("No")



Measured memory_bytes: 5596
a,b,k=map(int,input().split())
r=[]
for x in range(a,min(b,a+k)):
    r.append(x)
for x in range(max(a,b-k+1),b+1):
    r.append(x)
h=sorted(set(r))

for x in h:
    print(x)

Measured memory_bytes: 3060
N = int(input())
for h in range(1,3501):
  for n in range(1,3501):
    if 4*h*n!=(N*n)+(N*h):
      w=(N*h*n)//((4*h*n)-(N*n)-(N*h))
      if 4*h*n*w==N*(n*w+h*w+n*h) and w>0:
        break
  else:
    continue
  break
print(h,n,w)
      


Measured memory_bytes: 41196
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
def getlist2():
    return [int(x) * 100000 for x in input().split()]
import math
import bisect
import heapq
from decimal import Decimal
# from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15
def main():
    n,m = getlist()
    nums = getlist()
    sou = sum(nums)
    ans = 0
    for num in nums:
        if num >= sou / (4*m):
            ans += 1
    if ans >= m:
        print("Yes")
    else:
        print("No")
    return

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Measured memory_bytes: 61420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
using namespace std;

int main(){
    int n,q,t;
    string name;

    queue<pair<string,int>> Q;

    cin>>n>>q;

    for(int i=0;i<n;i++){
        cin>>name>>t;
        Q.push(make_pair(name,t));
    }

    pair<string,int> u;
    int elaps=0,a;

    while(!Q.empty()){
        u=Q.front();Q.pop();
        a=min(u.second,q);
        u.second-=a;
        elaps+=a;
        if(u.second>0){
            Q.push(u);
        }else{
            cout<<u.first<<" "<<elaps<<endl;
        }

    }

    return 0;
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    auto it=unique(all(a));
    a.resize(distance(a.begin(),it));
    rep(i,a.size()){
        cout<<(i?" ":"")<<a[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> num(N);
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> num[i];
		cnt += num[i];
	}
	int min = INT_MAX;
	int ret;
	for (int i = 0; i < N; i++) {
		if (abs(N * num[i] - cnt) < min) {
			min = abs(N * num[i] - cnt);
			ret = i;
		}		
	}
	cout << ret;
	return 0;

}

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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int ans = 0;
    int num = p[0];
    rep(i,n) {
        if(num >= p[i]) {
            num = p[i];
            ans += 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, q, l, r;
    string s;
    cin >> n >> q >> s;
    vi countAC(n, 0);
    for(int i = 0; i < n-1; i++) {
        countAC[i+1] += countAC[i];
        if(s[i] == 'A' && s[i+1] == 'C') countAC[i+1]++;
    }

    rep(i,q) {
        cin >> l >> r;
        cout << countAC[r-1] - countAC[l-1] << '\n';
    }
}

Measured memory_bytes: 1488
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

#define debug(var)  do{ std::cout << #var << " : "; view(var); }while(0)
using ll = long long;
using ld = long double;
inline int num (const std::string& S, int idx) noexcept { return S.at(idx) - '0'; }
inline int ctoi(char c) noexcept { return c - '0'; }
inline bool isNumber(char c) noexcept { return ('0'<c && c<'9'? true : false); }
inline int safeCtoi(char c) { if(isNumber(c)) { return ctoi(c); } else { throw 1; } }
inline char itoc(int i) noexcept { return i + '0'; }
inline unsigned int bitMask(int i) noexcept { return (1 << i); }
inline bool isTrue(unsigned int bit, int i) noexcept { return bit & bitMask(i); }
inline bool isEven(int num) noexcept { return !num%2; }
inline bool isOdd(int num) noexcept { return num%2; }
template<typename T> inline short sgn(T num) noexcept { return (num==0? 0 : (num>0? 1 : -1) ); }
template<typename T> inline bool isZero(T num) noexcept { return (num==0? true : false); }
template<typename T> inline bool isPositive(T num) noexcept { return (num>0? true : false); }
template<typename T> inline bool isNegative(T num) noexcept { return (num<0? true : false); }
template<typename T> void view(T e) noexcept { cout << e; }
template<typename T> void view(std::vector<T> v) noexcept { for(const auto& e : v) cout << e << " "; }
template<typename T> void view(std::vector<std::vector<T>> vv) noexcept { for(const auto& v : vv) view(v); }


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double r;
	cin >> r;
	cout << 2 * M_PI * r << endl;
	return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
  int main()
  {
      ll n,k;
      cin>>n>>k;

      vector<ll>v;
      for(ll i=0;i<n;i++)
      {
         ll x;
         cin>>x;
         v.push_back(x);
      }

      sort(v.begin(),v.end());
      ll s=0;
      for(ll i=0;i<k;i++)
      {
          s+=v[i];
      }
      cout<<s<<endl;
      return 0;
  }


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<ll> a(n);
    for(auto&i:a) in>>i;
    if(n&1){
        if(n==3) return cout<<max({a[0],a[1],a[2]})<<endl,0;
        auto c=vector(3,vector(n,-(1ll<<60)));
        c[0][0]=a[0];
        c[1][1]=a[1];
        c[0][2]=a[0]+a[2];
        c[2][2]=a[2];
        c[1][3]=max(a[0]+a[3],a[1]+a[3]);
        for(int i=4;i<n;++i){
            chmax(c[0][i],c[0][i-2]+a[i]);
            chmax(c[1][i],max(c[1][i-2]+a[i],c[0][i-3]+a[i]));
            chmax(c[2][i],max({c[2][i-2],c[1][i-3],c[0][i-4]})+a[i]);
        }
        cout<<max({c[2][n-1],c[1][n-2],c[0][n-3]})<<endl;
    }
    else{
        if(n==2) return cout<<max({a[0],a[1]})<<endl,0;
        auto c=vector(2,vector(n,-(1ll<<60)));
        c[0][0]=a[0];
        c[1][1]=a[1];
        c[0][2]=a[0]+a[2];
        for(int i=3;i<n;++i){
            chmax(c[0][i],c[0][i-2]+a[i]);
            chmax(c[1][i],max(c[1][i-2],c[0][i-3])+a[i]);
        }
        cout<<max({c[1][n-1],c[0][n-2]})<<endl;
    }
}


Measured memory_bytes: 11112
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<endl
using namespace std;

int n,m;
int c[21];
int dp[50001];
const int inf=999999999;

int main(){
 cin>>n>>m;
 for(int i=0;i<n;i++){
  cin>>c[i];
 }
 for(int i=0;i<50001;++i){
  dp[i]=inf;
 }
 dp[0]=0;
 for(int i=0;i<n;i++){
  for(int j=0;j<m;j++){
   if(i+c[j]<=n){
    dp[i+c[j]]=min(dp[i+c[j]],dp[i]+1);
   }
  }
 }
 cout<<dp[n]<<"\n";
 return 0;
}

Measured memory_bytes: 3308
n,m=map(int,raw_input().split())
v=[0]*n
a=[input() for i in [1]*n]
b=[input() for i in [1]*m]
for c in b:
	for i in range(n):
		if a[i]<=c:
			v[i]+=1
			break
print v.index(max(v))+1

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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define vi vector<int>
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6+5;
int A[N], B[N], P[N], ans[N];

int mat[1005][1005];
pint edges[N];
unordered_map<int, set<int>> m;

bool compare(vi a, vi b)
{
    return a[0] < b[0];
}

int mypow(int a, int x)
{
    if(a<=1 || x==1) return a;
    if(x==0) return 1;

    int temp = mypow(a,x/2);
    if(x%2==0) return ((temp%mod) * (temp%mod))%mod;
    else return (a%mod * ((temp%mod) * (temp%mod))%mod)%mod;
}

int count_bits(int n)
{
    int cnt = 0;
    while(n)
    {
        n = n & (n-1);
        cnt++;
    }return cnt;
}

void bfs(int src, int n)
{
    unordered_map<int, bool> visited;
    for(int i=0;i<n;i++) visited[i] = false;
    queue<int> q;
    q.push(src);
    visited[src] = true;

    while(!q.empty())
    {
        int curr = q.front();
        q.pop();
        B[curr] -= min(B[curr], A[src]);
        //cout<<curr<<" "<<endl;

        for(auto neigh: m[curr])
        {
            if(visited[neigh] == false)
            {
                //cout<<neigh<<endl;
                q.push(neigh);
                visited[neigh] = true;
                m[src].erase(neigh);
                m[neigh].erase(src);
            }
        }
    }
}

/*void void_solve(int n)
{

}*/

int int_solve(int n)
{
    stack<int> st;
    int i,ans = 0;
    st.push(A[0]);

    for(i=1;i<n;i++)
    {
        if(A[i] > st.top())
        {
            st.pop();
            st.push(A[i]);
        }
        else ans += st.top() - A[i];
    }return ans;
}

/*string string_solve(int n)
{

}*/

bool bool_solve(string s)
{
    int sum = 0;
    int i;
    for(i=0;i<s.length();i++) sum += (s[i] - '0');
    return !(sum % 9);
}

int32_t main()
{
    //code
	IOS;

    int t,n,m,a,b,x,y,i,j,z;
    //cin>>t;
    t = 1;
    while(t--)
    {
        cin>>n;
        for(i=0;i<n;i++) cin>>A[i];
        cout<<int_solve(n)<<endl;
    }

	return 0;
}


Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    ll maxx = -10;
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        maxx = max(a.at(i),maxx);
        if(i!=0&&a.at(i)==0){
            cout<<0<<endl;
            return 0;
        }
    }
    if(a.at(0)!=0){
        cout<<0<<endl;
        return 0;
    }
    map<ll,ll>ma;
    for(int i=0;i<n;i++){
        if(ma.count(a.at(i))){
            ma.at(a.at(i))++;
        }
        else{
            ma[a.at(i)]=1;
        }
    }
    ll ans = 1;
    ll waru =998244353;
    for(int i=1;i<=maxx;i++ ){
        if(ma.count(i)){
            ll che = modpow(ma.at(i-1),ma.at(i),waru);
            if(che==0)continue;
            ans*=che;
            ans = ans%waru;
        }
        else{
            cout<<0<<endl;
            return 0;
        }
        }
        cout<<ans<<endl;
}
    



Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 28)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int n;
int memo[32];
int dfs(int now){
	if(now > n)return false;
	if(now == n)return true;
	if(memo[now] != -1)return memo[now];
	int sum = dfs(now+1) + dfs(now+2) + dfs(now+3);
	return memo[now] = sum;
}

int main(void){
	while(cin >> n, n){
		fill_n(memo, 32, -1);
		cout << dfs(0)/3650+1 << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main() {
	int n = in(), k = in();
	bitset<28>b_bs;
	REP(i, k) {
		b_bs.set(in());
	}
	int b = b_bs.to_ulong();
	REP(i, pow(2, n)) {
		if ((i | b) == b) {
			cout << i << ':';
			int i_copy = i;
			for (int j = 0; i_copy > 0; ++j) {
				if (i_copy % 2 == 1)cout << ' ' << j;
				i_copy >>= 1;
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3260
// AOJ 2303 Marathon Match
// 2018.4.11 bal4u

#include <stdio.h>
#include <math.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define EPS 1e-8
int N, M;
int p[102], t[102], v[102];
double comb[52][52];
double ps[102][52], ss[102][52], ts[102][52];

int binarySearch(double *a, double x)
{
	int m, l = 0, r = M+1;

    while (l < r) {
        m = (l+r) >> 1;
        if (a[m] < x+EPS) l = m + 1; else r = m;
    }
	return l;
}

int main()
{
	int i, j, k, f;
	double L, pp, x, ans;

	for (i = 0; i <= 50; i++) comb[i][0] = 1;
	for (i = 1; i <= 50; i++) for (j = 1; j <= i; j++)
		comb[i][j] = comb[i-1][j-1] + comb[i-1][j];

	N = in(), M = in(), L = in();
	f = 0; 
	for (i = 0; i < N; i++) {
		p[i] = in(), t[i] = in(), v[i] = in();
		if (v[i]) f = 1;
	}
	if (!f) {
		for (i = 0; i < N; i++) puts("0.00000000");
		return 0;
	}


	for (i = 0; i < N; i++) for (j = 0; j <= M; j++) {
		ps[i][j] = pow(p[i]/100.0, j) * pow((100-p[i])/100.0, M-j) * comb[M][j];
		if (!j) ss[i][j] = ps[i][j];
		else    ss[i][j] = ss[i][j-1] + ps[i][j];
		ts[i][j] = L/v[i] + t[i]*j;
	}

	for (i = 0; i < N; i++) {
		ans = 0;
		for (j = 0; j <= M; j++) {
			pp = 1, x = ts[i][j];
			for (k = 0; k < N; k++) if (k != i) {
				if (f = binarySearch(ts[k], x)) pp *= 1 - ss[k][f-1];
			}
			ans += ps[i][j] * pp;
		}
		printf("%.8f\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2196
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN=7e8;
bool b[MAXN];
char c[15];
int f () {
	int len=strlen(c),ret=0;
	for (int i=0;i<len;i++) {
		ret*=5;
		ret++;
		switch (c[i]) {
			case 'C':
				ret++;
			case 'G':
				ret++;
			case 'T':
				ret++;
		}
	}
	return ret;
}
int main () {
	int n;
	scanf ("%d",&n);
	for (int i=0;i<n;i++) {
		scanf ("%s",c);
		if (c[0]=='i') {
			scanf ("%s",c);
			b[f()]=true;
		} else {
			scanf ("%s",c);
			if (b[f()]) printf ("yes\n");
			else printf ("no\n");
		}
	}
    return 0;
}


Measured memory_bytes: 7724
import bisect
N = int(input())
A = sorted([int(_) for _ in input().split()])
i = bisect.bisect_left(A, 0)
if i == N:
    i -= 2
elif i:
    i -= 1
now = A[i]
ans = []
for a in A[i + 1:N - 1]:
    ans += [[now, a]]
    now -= a
ans += [[A[N - 1], now]]
now = A[N - 1] - now
for a in A[:i]:
    ans += [[now, a]]
    now -= a
print(now)
[print(*xy) for xy in ans]


Measured memory_bytes: 23860
chkA ('>':'\'':s)   = chkA_1 s
chkA s              = False

chkA_1 ('=':s)      = chkA_2 n $ dropWhile (== '=') s
  where
    n = 1 + (length . takeWhile (== '=')) s
                        
chkA_1 s            = False
  
chkA_2 n ('#':s)    = chkA_3 n s
chkA_2 n s          = False

chkA_3 n ('=':s)    = if n == m
                      then chkA_4 $ dropWhile (== '=') s
                      else False
  where
    m = 1 + (length . takeWhile (== '=')) s
                        
chkA_3 n s          = False

chkA_4 ('~':[])     = True
chkA_4 s            = False

chkB ('>':'^':s)    = chkB_1 s
chkB s              = False

chkB_1 ('Q':'=':s)  = chkB_2 s
chkB_1 s = False

chkB_2 ('Q':'=':s)  = chkB_2 s
chkB_2 ('~':'~':[]) = True
chkB_2 s = False


ans s =
  let a = chkA s
      b = chkB s
  in
    if a
    then "A"
    else if b
         then "B"
         else "NA"

main = do
  n <- getLine
  c <- getContents
  let n'= read n :: Int
      i = take n' $ lines c
      o = map ans i
  mapM_ putStrLn o

Measured memory_bytes: 4148
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=100000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
inline int add(int a,int b){return (a+=b)>=P?a-P:a;}
inline int sub(int a,int b){return (a-=b)<0?a+P:a;}
inline int mul(int a,int b){return 1LL*a*b%P;}
int n;
ll x;
map<ll,int>mp;
int main(){
    int cnt=0;
    read(n);
    for (int i=1;i<=n;i++){
        read(x);
        if (!mp[x]){
            cnt++;
            mp[x]=1;
        }
        else{
            cnt--;
            mp[x]=0;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 6528