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

using namespace std;

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

using ll = long long;

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

constexpr char sp = ' ';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inv(ll n, ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __{ __(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15); } };

vector<bool> done;
vector<int> cnt;
int main(){

    int n, m;
    int ac = 0, pen = 0;
    scanf("%d%d", &n, &m);
    done.resize(n, false);
    cnt.resize(n);
    rep(i, m){
        int p; string s;
        cin >> p >> s;
        --p;
        if(done[p]){
            continue;
        }
        if(s == "AC"){
            done[p] = true;
            ++ac; pen += cnt[p];
        }
        else{
            ++cnt[p];
        }
    }

    cout << ac << ' ' << pen << '\n';
    


    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    int now = 1;
    int count = 0;
    for(int i = 0; i < N; i++){
        now = A[now - 1];
        count++;
        if(now == 2){
            cout << count << endl;
            return 0;
        }
    }
    puts("-1");
}


Measured memory_bytes: 3764
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES

using namespace std;



int main()
{
    char c;cin>>c;
    if(c>=97)cout<<'a'<<endl;
    else cout<<'A'<<endl;
}




Measured memory_bytes: 3568
from itertools import accumulate
N, W = map(int, input().split())
w_0, v_0 = map(int, input().split())
v_list = [[] for _ in range(4)]
v_list[0].append(v_0)

for _ in range(N - 1):
    w_in, v_in = map(int, input().split())
    v_list[w_in - w_0].append(v_in)
v_list = [[0] + list(accumulate(sorted(v, reverse=True))) for v in v_list]
ans = 0

#print(v_list)

for i in range(len(v_list[0])):
    for j in range(len(v_list[1])):
        for k in range(len(v_list[2])):
            for l in range(len(v_list[3])):
                if (i * w_0) + (j * (w_0 + 1)) + (k * (w_0 + 2)) + (l * (w_0 + 3)) <= W:
                    ans = max(ans, v_list[0][i] + v_list[1][j] + v_list[2][k] + v_list[3][l])
                else:
                    break
print(ans)



Measured memory_bytes: 3064
using System;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            
            while(true){

                int input = int.Parse(Console.ReadLine());

                if (input == -1)
                {
                    break;
                }

                string answer = string.Empty;
                int n = (int)Math.Log(input, 4.0);

                for (int i = n; i >= 0; i--)
                {
                    answer += (input / (int)Math.Pow(4, i)).ToString();
                    input %= (int)Math.Pow(4, i);
                }

                Console.WriteLine(answer);

            }


        }
    }
}

Measured memory_bytes: 5776
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod2 1000000007
#pragma GCC optimize ("-O3")
#define mod 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m=mod){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}

// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }

int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    fastio;
    int t;
    // cin>>t;	
    t=1;
	while(t--){
        lli x;
        cin>>x;
        cout<<(x/500)*(1000)+((x%500)/5)*5<<"\n";
    }   
    return 0; 	
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int N, C;
  cin >> N >> C;
  int D[C][C], c[N][N];
  for (int i = 0; i < C; i++)
  {
    for (int j = 0; j < C; j++)
      cin >> D[i][j];
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      cin >> c[i][j];
      c[i][j]--;
    }
  }
  int sum[3][C];
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < C; j++)
      sum[i][j] = 0;
  }
  for (int h = 0; h < C; h++)
  {
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < N; j++)
        sum[(i + j) % 3][h] += D[c[i][j]][h];
    }
  }
  int ans = INT32_MAX;
  for (int i = 0; i < C; i++)
  {
    for (int j = 0; j < C; j++)
    {
      for (int k = 0; k < C; k++)
      {
        if (i == j || j == k || k == i)
          continue;
        ans = min(ans, sum[0][i] + sum[1][j] + sum[2][k]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

vector<bool> isp;

void sieve(int x=pow(10,6)+10) {
  isp.resize(x,true); 
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=x; i++) {
    if (isp[i]) for(int j=2; i*j<=x; j++) isp[i*j] = false;
  }
}

int main() {
  int N; cin >> N;
  ll A[N], B[N]; rep(i,N) { cin >> A[i]; B[i] = A[i]; }

  sieve();
  ll lcm = 1;
  rep(i,1000) {
    if (!isp[i]) continue;
    ll tmax = 0;
    rep(j,N) {
      ll ttmp = 0;
      while (B[j]%i==0) {
        ttmp++;
        B[j] /= i;
      }
      tmax = max(tmax, ttmp);
    }
    rep(j,tmax) lcm = (lcm*i)%MOD;
  }
  map<ll, int> left;
  rep(i,N) left[B[i]] = 1;
  for (auto x: left) lcm = (lcm*x.first)%MOD;
  // cout << lcm << endl;
  ll result = 0;
  rep(i,N) result = (result + lcm*inv(A[i]))%MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int h,w;

void print(vector<vector<int>> ver, vector<vector<int>> hor) {
  REP(i,h+1) {
    REP(j,w+1) { cout << ver[i][j] << " "; }
    cout << endl;
  }
  cout << endl;
  REP(i,h+1) {
    REP(j,w+1) { cout << hor[i][j] << " "; }
    cout << endl;
  }
  cout << endl;
}

int main() {
  IOS;
  cin >> h >> w;
  vector<string> s(h);
  REP(i,h) cin >> s[i];

  vector<vector<int>> ver(h+1,vector<int>(w+1));
  vector<vector<int>> hor(h+1,vector<int>(w+1));
  REP(i,h) REP(j,w) {
    if (s[i][j] == '#') continue;
    ver[i+1][j+1] = ver[i][j+1]+1;
    hor[i+1][j+1] = hor[i+1][j]+1;
  }

  // print(ver, hor);

  for (int i = h; i > 0; i--) {
    for (int j = w; j > 0; j--) {
      if (ver[i-1][j-1] == 0) continue;
      if (ver[i][j-1] != 0) ver[i-1][j-1] = ver[i][j-1];
      if (hor[i-1][j] != 0) hor[i-1][j-1] = hor[i-1][j];
    }
  }

  // print(ver, hor);

  int ans = 1;
  REP(i,h) REP(j,w) {
    chmax(ans, ver[i+1][j+1] + hor[i+1][j+1] - 1);
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 38820
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==a[i+1])
        {   cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  for(int i=1; i<=N; i++){
    cin >> A[i];
  }
  vector<bool> ball(N+1, false);
  vector<int> ans;
  int ans_count=0;
  for(int i=N; i>0; i--){
    int count=0;
    for(int j=2*i; j<=N; j+=i){
      if(ball[j]){
        count++;
      }
    }
    if(count%2 != A[i]){
      ball[i] = true;
      ans.push_back(i);
      ans_count++;
    }
  }
  cout << ans_count << endl;
  for(int i: ans){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2428
/**
*    created: 21.06.2020 21:00:41
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    char a;
    cin >> a;
    if (isupper(a)) cout << 'A' << endl;
    else cout << 'a' << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
    int i;

    int weight;
    int bundou_weight;
    int bundou_list[10];
    int cnt;
    while (scanf("%d", &weight) != EOF) {
        cnt = 0;
        for (bundou_weight = 1; bundou_weight <= 512; bundou_weight *= 2) {
            if (weight % (bundou_weight * 2) != 0) {
                bundou_list[cnt++] = bundou_weight;
                weight -= bundou_weight;
            }
            if (weight == 0) {
                break;
            }
        }
        for (i = 0; i < cnt; i++) {
            if (i != 0) {
                printf(" ");
            }
            printf("%d", bundou_list[i]);
        }
        printf("\n");
    }

    return 0;
}

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

int main(void) {
    string S;cin>>S;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) printf("%c", S[i]);
    }
    cout << endl;
    return 0;
}

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

int n;
int ans = 0;
vector<int> d(110);

void input(){
  cin >> n;
  rep(i, n){
    cin >> d.at(i);
  }
}

void solve(){
  input();
  int sum = 0;
  for( int i = 1; i < n; i++ ){
    sum += d.at(i-1);
    ans += sum * d.at(i);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N; ll W;
    cin >> N >> W;
    ll v[N], w[N];
    rep(i, N) cin >> v[i] >> w[i];
    map<ll, ll> mp;
    int n = N/2, m = N-n;
    rep(i, 1<<m){
        ll sv = 0, sw = 0;
        rep(j, m){
            if(i&(1<<j)) sv += v[n+j], sw += w[n+j];
        }
        chmax(mp[sw], sv);
    }
    ll now = 0;
    for(auto &e: mp){
        chmax(now, e.second);
        e.second = now;
    }
    ll ans = 0;
    rep(i, 1<<n){
        ll sv = 0, sw = 0;
        rep(j, n){
            if(i&(1<<j)) sv += v[j], sw += w[j];
        }
        map<ll, ll>::iterator it = mp.upper_bound(W-sw);
        if(it == mp.begin()) continue;
        chmax(ans, sv+(--it)->second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 68640
/* 入力配列を配列末尾の値を基準値としてそれより大きいか小さいかで分ける */

#include <iostream>
using namespace std;
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
	int x, i, j, t;
	x = A[r]; // 配列の末尾要素を保持
	i = p - 1;
	for (j = p; j < r; j++) {
		if (A[j] <= x) { // 参照キーより小さいなら大きいグループの先頭と交換
			i++;
			swap(A[i], A[j]);
		}
		// jはforでインクリメントされるのでj++しなくてよい
	}
	swap(A[i + 1], A[j]); // 最後に基準要素と大きいグループの先頭を交換
	return i + 1; // 基準要素の位置
}

int main() {
	int i, q;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> A[i];

	q = partition(0, n - 1);

	for (i = 0; i < n; i++) {
		if (i) cout << " ";
		if (i == q) cout << "[";
		cout << A[i];
		if (i == q) cout << "]";
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;


ll tableF[400010];
ll tableI[400010];

ll modfact(ll a,ll m){
   if(tableF[a] != -1){
      return tableF[a];
   }
   if(a == 1){
      tableF[a] = 1;
      return tableF[a];
   }
   ll res = 1;
   res = a * modfact(a-1,m);
   res %= m;
   tableF[a] = res;
   return res;
}

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   if(n < 200010){
   ll res = 1;
   if(n < 0 || r < 0 || n < r){
      return 0;
   }
   res *= tableF[n];
   res %= m;
   res *= tableI[r];
   res %= m;
   res *= tableI[n-r];
   res %= m;
   return res;
   }else{
   ll res = 1;//tableを持ってないときよう
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
   }
}

void modfill(ll m){//忘れない　約200ms
   fill(tableF,tableF+400010,-1);
   fill(tableI,tableI+400010,-1);
   tableF[0] = 1;
   tableI[0] = 1;
   for(int i = 1;i < 200010;i++){
      tableF[i] = modfact(i,m);
      tableI[i] = modinv(tableF[i],m);
   }
}


int main(){
    ll N,M,K;
    cin >> N >> M >> K;
    modfill(MOD);
    ll ans = 0;
    rep(i,N) {
        rep(j,M){
            ll A0 = ((M-j-1)*(M-j) / 2 + j * (j+1) / 2);
            ll D = N * A0 + ((N-i-1)*(N-i) / 2 + i * (i+1) / 2) * M;
            D %= MOD;
            D *= modCON(N*M-2,K-2,MOD);
            D %= MOD;
            ans += D;
            ans %= MOD;
        }
    }
    cout << (ans * modinv(2,MOD)) % MOD << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  ll n, m; cin >> n >> m;
  /*
  int ans = (n-2)*(m-2);
  if(n==1 || m==1) ans = n*m-2;
  if(n==1 && m==1) ans = 1;
  if(n==2 || m==2) ans = 0;  
  */
  //cout << ans;
  cout << abs((n-2)*(m-2));
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
  long long N, P, i, j, ans = 1;
  scanf("%lld%lld", &N, &P);

  if(N == 1){
    printf("%lld\n", P);
    return 0;
  }

  for (i = 2; i*i <= P; i++) {
    for (j = 0; P%i == 0 ; j++) P /= i;
    ans *= (long long)pow(i, j/N);
  }

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int x,y;
	cin>>s>>x>>y;
	s=s+'T';
	int dt=0;
	set<int>dx;
	set<int>dy;
	dx.insert(0);
	dy.insert(0);
	int t=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!='T')
			t++;
		if(s[i]=='T')
		{
			int val = t;
			
			set<int>st;
			if(dt%2==0)
			{
				for(auto p : dx)
				{
					st.insert(p+val);
					if(dt!=0)
						st.insert(p-val);
				}
				dx=st;

			}
			else
			{
				for(auto p :dy)
				{
					st.insert(p+val);
					st.insert(p-val);

				}
				dy=st;
			}
			dt++;t=0;
		}
	}
	if(dx.count(x)>0&&dy.count(y)>0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	

}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


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

	ll N,suma=0,sumb=0;
	cin >> N;
	vector<ll> A(N,0),B(N,0),AmB(N,0);
	FOR(i,0,N)cin>>A[i];
	FOR(i,0,N)cin>>B[i];
	FOR(i,0,N){
		sumb += B[i];
		suma += A[i];
		AmB[i] = A[i] - B[i];
	}
	if(suma<sumb){
		cout << -1 << endl;
		return 0;
	}
	SORT(AmB);
	vector<ll> AmBsum(N,0);
	AmBsum[0] = AmB[0];
	FOR(i,1,N)AmBsum[i] += AmB[i]+AmBsum[i-1];

	/*FOR(i,0,N){
		cout << AmB[i] << " ";
	}
	FOR(i,0,N){
		cout << AmBsum[i] << " ";
	}return 0;*/

	ll mi = 0;
	ll i = 0;
	while(AmB[i]<0){
		mi += AmB[i];
		i++;
	}
	if(i==0){
		cout << 0 << endl;
		return 0;
	}
	FOR(j,0,N){
		ll k = AmBsum[N-1] - AmBsum[N-1-j];
		if(k+mi>=0){
			cout << j+i << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 3328
#
# abc046 b
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 10"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 8"""
        output = """322828856"""
        self.assertIO(input, output)


def resolve():
    N, K = map(int, input().split())
    print(K*(K-1)**(N-1))


if __name__ == "__main__":
    # unittest.main()
	resolve()

Measured memory_bytes: 16120
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin

  int N=in(); string S; cin >> S;
  vi cw(N,0);
  int q=0;
  for(int i=N-1; i>=0; --i){
    if(S[i]=='.') q++;
    cw[i] = q;
  }
  vi cb(N,0);
  int p=0;
  rep(i,N){
    cb[i] = p;
    if(S[i]=='#') p++;
  }

  int m=numeric_limits<int>::max();
  rep(i,N){
    if(m>cw[i]+cb[i]) m=cw[i]+cb[i];
  }
  m = min(m, p);
  dump(cb, cw);
  cout << m << endl;

  return 0;
}


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

typedef struct{
  int num;
  int i;
  string ans;
} Data;

int main(){
  int n;
  cin >> n;
  queue<Data> que;

  Data d;
  d.num = n;
  d.i = 0;
  d.ans = "";

  que.push(d);

  Data tmp;

  while(1){
    d = que.front();
    que.pop();
    if(d.num == 0){
      cout << d.ans << endl;
      return 0;
    }
    d.i++;

    tmp = d;
    tmp.num += pow((double)3,(double)d.i-1);
    tmp.ans = "-" + tmp.ans;
    que.push(tmp);

    tmp = d;
    tmp.num -= pow((double)3,(double)d.i-1);
    tmp.ans = "+" + tmp.ans;
    que.push(tmp);

    tmp = d;
    tmp.ans = "0" + tmp.ans;
    que.push(tmp);
  }
}




Measured memory_bytes: 96740
#pragma optimization_level 3
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

#define MOD 1000000007

struct BIT {
  int n;
  vector<int> xs;

  BIT(int n) : n(n) {
    xs.resize(n+1);
  }

  int sum(int i) {
    int s = 0;
    for (int x=i+1; x>0; x-=x&-x) s = (s + xs[x]) % MOD;
    return s;
  }

  int sum(int a, int b) {
    if (a > b) return 0;
    return (0LL + MOD + sum(b) - sum(a-1)) % MOD;
  }

  void add(int i, int v) {
    for (int x=i+1; x<=n; x+=x&-x) xs[x] = (xs[x] + v) % MOD;
  }
};

int N;
long long A, B;
long long S[100001];

signed main() {
  cin >> N >> A >> B;
  if (A > B) swap(A, B);
  S[0] = -(1LL<<60);
  for (int i=1; i<=N; i++) cin >> S[i];

  BIT dp0(N+1), dp1(N+1);
  dp0.add(0, 1);
  dp1.add(0, 1);

  int l0 = 0, l1 = 0;
  for (int i=1; i<N; i++) {
    int uj1 = min(i, (int)(upper_bound(S, S+N+1, S[i+1]-A) - S) - 1);
    int uj2 = min(i, (int)(upper_bound(S, S+N+1, S[i+1]-B) - S) - 1);
    int s1 = dp1.sum(l1, uj1), s2 = dp0.sum(l0, uj2);
    if (S[i+1]-S[i] < A) l0 = i;
    if (S[i+1]-S[i] < B) l1 = i;
    dp0.add(i, s1);
    dp1.add(i, s2);
  }

  cout << (dp0.sum(l0, N) + dp1.sum(l1, N)) % MOD << "\n";
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

public class Main {
	static int[] memo = new int[100000];
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++)
			h[i] = sc.nextInt();
		
		int ans = 1;
		int max = h[0];
		for(int i = 1; i < n; i++) {
			if (max <= h[i]) {
				max = h[i];
				ans++;
			}
		}
		out.println(ans);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 22740
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
   ll N,D,x[200010],y[200010],cnt=0;
   cin>>N>>D;
   rep(i,N){
       cin>>x[i]>>y[i];
       if(sqrt(x[i]*x[i]+y[i]*y[i])<=D) cnt++;

   }
   cout<<cnt<<endl;



}

Measured memory_bytes: 6664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll N,M;
ll gcd(ll a,ll b){
  return b==0?a:gcd(b,a%b);
}

ll lcm(ll a,ll b){
  if(a>M||b>M) return -1;
  else return a*b/gcd(a,b);
}

int main(){
  cin>>N>>M;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  ll lc=A[0]/2;
  rep(i,N){
    lc=lcm(lc,A[i]/2);
    if(lc==-1){
      cout<<0<<endl;
      return 0;
    }
  }

  rep(i,N){
    ll z=lc/(A[i]/2);
    if(z%2==0){
      cout<<0<<endl;
      return 0;
    }
  }

  ll ans=M/lc-M/(2*lc);
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>

using namespace std;

int main()
{
    string s; 
    while (cin >> s) {
        bool have[26] = { false };
        for (int i = 0; i < s.length(); i++) {
            if (!have[s[i] - 'a']) have[s[i] - 'a'] = true;
        }
        bool Finded = false;
        for (int i = 0; i < 26; i++) {
            if (!have[i]) {
                cout << (char)(i + 'a') << endl;
                Finded = true;
                break;
            }
        }
        if (!Finded) cout << "None" << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n;
    cin >> n;
    map<char, int> m;
    while(n--){
        char c;
        cin >> c;
        if(m[c]==0) m[c]++;
    }
    cout << (m.size()==3? "Three":"Four") << endl;
}

Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
  
    ll x[7],ans=0,i;
    for(i=1;i<=5;i++)
    {
    	cin>>x[i];
    	if(x[i]==0)
    	{
    		ans = i;
    	}
    }
    cout<<ans;


}

Measured memory_bytes: 3632
def main():
    H, W = map(int, input().split())
    mat = []
    for _ in range(H):
        mat.append(input())

    mv = [[1,0],[-1,0],[0,1],[0,-1]]
    for i in range(H):
        for j in range(W):
            if mat[i][j] == "#":
                isBlack = False
                for di, dj in mv:
                    if 0 <= i+di < H and 0 <= j+dj< W:
                        if mat[i+di][j+dj] == "#":
                            isBlack = True
                            break
                if not isBlack:
                    return "No"

    return "Yes"

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
char s[N];
int d[N] = {};

int main(){
	// fill(d, d+N, -1);
	int n, m; scanf("%d%d%s", &n, &m, s);
	REP(i, N) s[i] -= '0';
	{
		int p = max(n - m, 0), q = n - 1;
		while(p < n && s[p]) p++;
		d[n] = 0;
		for(int i = n; i > 0; i--){
			if(i-m >= 0 && !s[i-m]) p = i-m;
			if(p == i) {
				printf("-1\n");
				return 0;
			}
			while(p <= q) d[q--] = d[i] + 1;
		}
	}
	REP(i, n+1) DEBUG("%d ", i); DEBUG("\n");
	REP(i, n+1) DEBUG("%d ", !s[i] ? d[i] : 0); DEBUG("\n");
	{
		int p = 0;
		while(p < n){
			int q = p;
			while(s[q] || d[p] - 1 != d[q]) q++;
			printf("%d ", q-p);
			p = q;
		}
	}
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

LLI N,A,B,C;

LLI f(vector<LLI> &l){
  LLI ret = 1e9;
  int n = l.size();
  REP(i,n){
    FOR(j,i+1,n){
      FOR(k,j+1,n){
	chmin(ret, abs(l[i]-A) + abs(l[j]-B) + abs(l[k]-C));
	chmin(ret, abs(l[i]-A) + abs(l[j]-C) + abs(l[k]-B));
	chmin(ret, abs(l[i]-B) + abs(l[j]-A) + abs(l[k]-C));
	chmin(ret, abs(l[i]-B) + abs(l[j]-C) + abs(l[k]-A));
	chmin(ret, abs(l[i]-C) + abs(l[j]-B) + abs(l[k]-A));
	chmin(ret, abs(l[i]-C) + abs(l[j]-A) + abs(l[k]-B));
      }
    }
  }
  return ret;
}

map<vector<LLI>, LLI> dp;

LLI rec(vector<LLI> l){
  if(EXIST(dp,l)) return dp[l];
  
  LLI ret = 1e9;
  
  if(l.size() > 3){
    REP(i,l.size()){
      FOR(j,i+1,l.size()){
	vector<LLI> t;

	REP(k,l.size()){
	  if(k==i) t.push_back(l[i]+l[j]);
	  else if(k!=j) t.push_back(l[k]);
	}
	
	sort(ALL(t));
	
	chmin(ret, rec(t)+10);
      }
    }
  }

  chmin(ret, f(l));
  
  return dp[l] = ret;
}

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

  while(cin >> N >> A >> B >> C){
    vector<LLI> l(N); cin >> l;
    sort(ALL(l));
    
    LLI ans = rec(l);
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int d[300][300]={},fin=10000000000000,n,r,m,x[20],a[40000],b[40000],c[40000];
//ダイクストラ
void dijkstra() {

	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

void solve2(long long int kazu,bool check[],long long int id,long long int res){
    if(kazu==0){
        fin=min(fin,res);
    }
    
    bool tmp[10];
    for(int i=0;i<r;i++){
        tmp[i]=check[i];
    }
    for(int i=0;i<r;i++){
        if(tmp[i]){
            tmp[i]=false;
            solve2(kazu-1,tmp,i,res+d[x[id]][x[i]]);
            tmp[i]=true;
        }
    }
}

void solve(long long int kazu){
    bool check[10];
    for(int i=0;i<r;i++){
        check[i]=true;
    }
    for(int i=0;i<r;i++){
        check[i]=false;
        solve2(kazu-1,check,i,0);
        check[i]=true;
    }
}


int main() {
    const long long int mod = 1000000007,INF=50000000000000;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
    string str[120];
    
    
    cin>>n>>m>>r;
    for(int i=0;i<r;i++){
        cin>>x[i];
    }

    for(int i=0;i<=200;i++){
        for(int j=0;j<=200;j++){
            d[i][j]=INF;
        }
    }

    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        d[a[i]][b[i]]=c[i];
        d[b[i]][a[i]]=c[i];
    }
    dijkstra();

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
        }
    }

    solve(r);
    cout<<fin<<endl;

} 


Measured memory_bytes: 1152
M = 10 ** 9 + 7

def mod_combination(n, r, mod):
    numerator = 1
    for i in range(n-r+1, n+1):
        numerator = (i * numerator) % mod
    denominator = 1
    for i in range(1, r+1):
        denominator = (i * denominator) % mod
    fermat = pow(denominator, mod-2, mod)
    return (numerator * fermat) % mod

def solve(n, a, b):
    k = pow(2, n, M)
    ac = mod_combination(n, a, M)
    ab = mod_combination(n, b, M)

    ans = k - ac - ab - 1
    while ans < 0:
        ans += M
    return ans

if __name__ == "__main__":
    n, a, b = tuple(map(int, input().split(" ")))
    print(solve(n, a, b))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
const int N = 100010;
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main()
{

    char a[2], b[2];
    while (~scanf("%s%s", a, b))
    {
        if (a[0] == 'H')
            printf("%c\n", b[0]);
        else if (b[0] == 'H')
            printf("D\n");
        else
            printf("H\n");

    }
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = [0] + list(map(float, input().split()))
for i in range(1, n + 1):
    p[i] = ((p[i] * (p[i] + 1)) / 2) / p[i]
    p[i] += p[i - 1]
sol = 0
for i in range(1, n - k + 2): sol = max(sol, p[i + k - 1] - p[i - 1])
print(sol)


Measured memory_bytes: 23140
#include<iostream>
#include<vector>
#include<queue>
#include<string>


int main(){
    std::vector<int> tiles;
    std::queue<int> unvisited_tile_q;
    int width, height, counter, pos;
    std::string line;

    while(true){
        std::cin >> width >> height;
        if( width == 0 && height == 0 ) break;
        tiles.resize(width*height);
        pos = 0;
        for( int h = 0; h < height; h++ ){
            std::cin >> line;
            for(std::string::iterator it = line.begin(); it != line.end(); ++it) {
                switch(*it){
                    case '#':
                        tiles[pos] = 0;
                        break;
                    case '@':
                        unvisited_tile_q.push(pos);
                    case '.':
                        tiles[pos] = 1;
                }
                pos++;
            }
        }

        counter = 0;
        while( !unvisited_tile_q.empty() ){
            pos = unvisited_tile_q.front();
            unvisited_tile_q.pop();
            if( tiles[pos] == 1 ){
                counter++;
                tiles[pos] = -1;
            } else continue;
            //left
            if ( pos - 1 >= 0 && pos % width > 0 && tiles[pos-1] == 1 ) unvisited_tile_q.push(pos-1); 
             //right
            if ( pos + 1 <= tiles.size() && pos % width < width - 1 && tiles[pos+1] == 1 ) unvisited_tile_q.push(pos+1);
            //up
            if ( pos - width >= 0 && tiles[pos-width] == 1 ) unvisited_tile_q.push(pos-width);
            //down
            if ( pos + width < tiles.size() && tiles[pos+width] == 1 ) unvisited_tile_q.push(pos+width);
        }
	    //output result
	    std::cout << counter << std::endl;
    }   
    return 0;
}


Measured memory_bytes: 3080
n, m = map(int, raw_input().split())
deg = [0]*n
for i in xrange(m):
    a, b = map(int, raw_input().split())
    deg[a-1] += 1
    deg[b-1] += 1
print "YES"*all(d % 2 == 0 for d in deg)or"NO"

Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m=0;
  cin>>n>>m;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  int sum;
  for(int i=0;i<n;i++){
    sum+=vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  if(sum%(4*m)==0){
    if(vec.at(m-1)>=sum/4/m){
      cout<<"Yes";
    }else{
      cout<<"No";
    }
  }else{
    if(vec.at(m-1)>=(sum/4/m)+1){
      cout<<"Yes";
    }else{
      cout<<"No";
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
int main()
{
	boost
	ll t,i;
	cin>>t;
	cout<<t*t*t<<endl;
	return 0;
}

Measured memory_bytes: 256
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

char A[1111][1111];

int main()
{
    int H, W;
    cin >> H >> W;
    for (int i = 0 ; i != H ; i++) {
        scanf("%s", A[i]);
    }
    set<pair<int, int>> S;
    for (int i = 0 ; i != H ; i++) {
        for (int j = 0 ; j != W ; j++) {
            if (A[i][j] == '#') {
                S.insert({i, j});
            }
        }
    }
    const int sx[] = {0, -1, 0, 1};
    const int sy[] = {1, 0, -1, 0};
    for (int ans = 0 ; ; ans++) {
        set<pair<int, int>> next;
        for (auto p: S) {
            for (int k = 0 ; k != 4 ; k++) {
                int nx = sx[k] + p.first;
                int ny = sy[k] + p.second;
                if (nx < 0 || nx >= H)
                    continue;
                if (ny < 0 || ny >= W)
                    continue;
                if (A[nx][ny] != '.')
                    continue;
                next.insert({nx, ny});
                A[nx][ny] = '#';
            }
        }
        S = next;
        if (S.size() == 0) {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}




Measured memory_bytes: 49152