akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>
#include <numeric>

using namespace std;

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

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const int MAX = 2000000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void com_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  REP(i, 2, MAX) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
  int X, Y, S;
  cin >> X >> Y;
  S = X + Y;
  if (S % 3 != 0 || X < S / 3 || Y < S / 3) {
    cout << 0 << endl;
  } else {
    com_init();
    cout << com(S / 3, X - S / 3) << endl;
  }
  return 0;
}


Measured memory_bytes: 47104
#include <algorithm>
#include <cassert>
#include <iostream>
#include <memory>
#include <numeric>

#include <array>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <ostream>
#include <type_traits>
#include <utility>
#include <chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize ("O3")
#pragma GCC target ("avx,avx2")
#endif

using namespace std;

using u64 = uint64_t;
using i64 = int64_t;
using u32 = uint32_t;
using vi = vector<int>;
using vi64 = vector<i64>;

#define seq(i,a,b) for (int i = (a); i < (b); ++i)
#define rev(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define sz(x) (x.size())
#define all(x) x.begin(), x.end()
#define dbg(x) {cerr << #x << ": " << x << endl;}

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n; cin >> n;
    vi H(n);
    for (auto &x : H) cin >> x;

    int a = 0, b = abs(H[1] - H[0]);
    seq(i,2,n) {
        a = min(a + abs(H[i] - H[i-2]), b + abs(H[i] - H[i-1]));
        swap(a,b);
    }
    cout << b << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n,ans = 0;
  string s,ss,sss;
  cin>>s;
  cout<<s[0]<<s[1]<<s[2]<<endl;
  return 0;
}


Measured memory_bytes: 3596
from collections import deque

X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

cand = sorted(p[:X] + q[:Y] + r, reverse=True)
print(sum(cand[:X+Y]))


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

int main()
{
    int same = 0;
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b)
        ++same;

    if (a == c)
        ++same;

    if (c == b)
        ++same;

    if (same == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N,M;
vector<P2> V[MC];
bool b[MC];
int x[MC];

bool dfs(int q){
	b[q] = 1;
	for(auto u : V[q]){
		if(b[u.first]){
			if(x[u.first] != x[q] + u.second) return 0;
			continue;
		} else {
			x[u.first] = x[q] + u.second;
			if(!dfs(u.first)) return 0;
		}
	}
	return 1;
}

int main(){
	cin >> N >> M;
	repp(i,0,M){
		int l,r,d;
		cin >> l >> r >> d;
		V[l].PB(MP(r,d));
		V[r].PB(MP(l,-d));
	}
	repp(i,1,N+1){
		if(b[i]) continue;
		if(!dfs(i)) return cout << "No" << endl , 0;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 11136
def cheat_solve(N, ABs):
    Ds = sorted([ab[0] + ab[1] for ab in ABs], reverse=True)
    bsum = sum([ab[1] for ab in ABs])
    dsum = sum(Ds[::2])
    return dsum - bsum

if __name__ == "__main__":
    N = int(input())
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N)]
    print(cheat_solve(N, ABs))


Measured memory_bytes: 21676
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int n;cin>>n;
    int c1 = n%10;
    n/=10;
    int c2 = n%10;
    n/=10;
    int c3 = n%10;
    if (c1<=c3 && c2<=c3){
        cout<<c3<<c3<<c3<<endl;
    }else{
        cout<<c3+1<<c3+1<<c3+1<<endl;
    }
    return 0;
}





Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
int main()
{
	long long n;
	scanf("%lld",&n);
	long long sqr=sqrt((double)n+1.0);
	for(long long i=sqr;i>=1;i--){
		if(n%i==0){
			long long x=n/i,y=i,cnt=0;
			if(x>y){
				while(x){
					x/=10;
					cnt++;
				}
			}else{
				while(y){
					y/=10;
					cnt++;
				}
			}
			printf("%lld\n",cnt);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int N;
  scanf("%d", &N);
  ll a[N],b[N],c[N];
  ll num = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &b[i]);
  }

  int ans = 0;
  FOR(i,0,N-1){
    c[i] = a[i] - b[i];
    if(c[i]<0) {
      num -= c[i];
      ++ans;
    }
  }

  sort(c,c+N,greater<ll>());

  if(num==0) {
    cout << 0 << endl;
    return 0;
  }
  else{
    FOR(i,0,N-1){
      ++ans;
      num -= c[i];
      if(num<=0) break;
    }
  }

  if(num>0) cout << -1 << endl;
  else cout << ans << endl;





}



Measured memory_bytes: 2560
import sys
input = lambda: sys.stdin.readline().rstrip()
D = {"AB": 2, "AC": 1, "BC": 0}
N, a, b, c = map(int, input().split())
X = [a, b, c]
S = [D[input()] for _ in range(N)]
ANS = []
if max(X) == 0 or X[S[0]-1] + X[S[0]-2] == 0:
    print("No")
    exit()

if sum(X) == 1:
    t = 0 if a else 1 if b else 2
    for s in S:
        if X[s]:
            print("No")
            exit()
        t ^= s ^ 3
        ANS.append(t)
        X[s-1] ^= 1
        X[s-2] ^= 1
else:
    for i, s in enumerate(S):
        if X[s-1] > X[s-2] or X[s-1] == X[s-2] and i < N - 1 and S[i+1] == (s-1) % 3:
            ANS.append((s-2) % 3)
            X[s-1] -= 1
            X[s-2] += 1
        else:
            ANS.append((s-1) % 3)
            X[s-1] += 1
            X[s-2] -= 1

print("Yes")
print("\n".join([chr(t+65) for t in ANS]))

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll c[4][4];
    string S;
    REPS(i,3){
        REPS(j,3){
            cin >> c[i][j];
        }
    }
    bool flag = true;
    ll tate_sa_1 = c[1][2] - c[1][1];
    ll tate_sa_2 = c[1][3] - c[1][2];
    for (ll i = 2; i <=3 ; i++) {
        if(c[i][2]-c[i][1]==tate_sa_1){
        }
        else{
            flag = false;
        }
    }
    for (ll i = 1; i <= 3; i++)
    {
        if (c[i][3] - c[i][2] == tate_sa_2)
        {
        }
        else
        {
            flag = false;
        }
    }

    ll yoko_sa_1 = c[2][1] - c[1][1];
    ll yoko_sa_2 = c[3][1] - c[2][1];
    for (ll i = 2; i <= 3; i++)
    {
        if (c[2][i] - c[1][i] == yoko_sa_1)
        {
        }
        else
        {
            flag = false;
        }
    }
    for (ll i = 1; i <= 3; i++)
    {
        if (c[3][i] - c[2][i] == yoko_sa_2)
        {
        }
        else
        {
            flag = false;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3612
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> D1(N);
  vector<int> D2(N);
  cin >> D1[0] >> D2[0];
  cin >> D1[1] >> D2[1];

  bool ok = false;
  for (int i = 2; i < N; ++i) {
    cin >> D1[i] >> D2[i];
    if (D1[i - 2] == D2[i - 2] && D1[i - 1] == D2[i - 1] && D1[i] == D2[i]) {
      ok = true;
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3648
import Data.List
main=do
 s<-getLine
 print$sum$map(\s->s*(s-1)`div`2)$map length$group$sort$0:f 0 1 s
f t p[]=[]
f t p(c:cs)=v:f v(p*202`mod`2019)cs where v=(t+p*(fromEnum c-48))`mod`2019

Measured memory_bytes: 33356
#include <iostream>
using namespace std;
int main()
{
    char c;
    int ans = 0;
    for(int i = 0; i < 3; i++){
        cin >> c;
        if('a' <= c && c <= 'c'){
            if(c == 'c') ans += 10;
            else         ans += c - 'a';
        }
    }
    if(ans == 11) cout << "Yes" << endl;
    else          cout << "No"  << endl;
    return 0;
}

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

int main(){
int casej[26][16];
for(int i=0;i<26;i++)
  for(int j=0; j<16; j++)
    casej[i][j]=i*4+j*7;
int n;
int f=0;
cin>>n;
for(int i=0;i<26;i++)
  for(int j=0; j<16; j++){
  if(casej[i][j]==n)
  {
   f=1;
   break;
  }
  if(f==1)
  break;
}

if(f==1)
cout<<"Yes";
else 
cout<<"No";
return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, f[1100];
int main(void){
        // Your code here!
        cin >> n;
        for (int i = 2; i <= n; i++) {
                int ans = 0;
                for (int j = 2; j < i; j++) {
                        if (i % j == 0) ans++;
                }
                if (ans == 0) f[i] = 1;
        }
        long long res = 1;
        for (int i = 1; i <= n; i++) {
                if (f[i] == 1) {
                        int num = i, cou = 1;
                        while (num <= n) {
                                cou += n / num;
                                num *= i;
                        }
                        res = res * cou % 1000000007;
                }
        }
        cout << res << endl;
}


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

using namespace std;

int main(){
    int n;
    float a;
    vector<float> v;

    cin >> n;
    for (int i=0;i<n;i++){
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        if(i==0){
            a = (v[0] + v[1])/2;
        }
        else if(i>1){
            a = (a + v[i])/2;
        }
    }
    cout << a << endl;
    return 0;
}

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

int main()
{
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d;
  cin >> n;
  ll a = 8 * q, b = 4 * h, c = s * 2;
  ll e = min(a, min(b, min(c, d)));
  ll f = min(a/2, min(b/2, c/2));
  if (n % 2 == 0)
  {
    cout << n * e / 2;
  }
    else
    {
      cout << ((n - 1) / 2) * e + f;
    }
  }



Measured memory_bytes: 3628
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
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;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 end


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    in >> n;
    vector<ll> a(n);
    ll a_tmp;
    in >> a[0];
    REP(i, n-1){
        in >> a_tmp;
        a[i+1] = a[i] + a_tmp;
    }
    ll a_max = a[n-1];
    ll ans = 1e10;
    REP(i, n-1){
        ans = min(ans, abs((a_max - a[i]) - a[i]));
    }
    out << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=Integer.parseInt(sc.next());
        int b=Integer.parseInt(sc.next());
        int h=Integer.parseInt(sc.next());
        sc.close();
        System.out.println((a+b)*h/2);

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int ans;
    for(int i = 0; i < 5; ++i){
        int x;
        cin >> x;
        if(x == 0)  ans = i + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

ll b(int x) {
  if(x == 1) return (ll)x;
  return (ll)x * b(x - 1);
}

int main() {
#ifdef HIRO
  ifstream cin("input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif

  char c;
  cin >> c;
  cout << ++c;
  return 0;
}



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

int main() {
    long double a, b, c; cin >> a >> b >> c;
    long double eps = 1.0E-14;
    if (sqrt(a) + sqrt(b) + eps < sqrt(c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
 var s = Number(chunk)
 var h = Math.floor(s / 3600)
 s = s % 3600
 var m = Math.floor(s / 60)
 s = s % 60
 console.log(h + ":" + m + ":" + s)

})

Measured memory_bytes: 15568
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N, K;cin>>N>>K; ll ans=INF;
    vector<ll> h;
    for(int i=0;i<N;i++){
      int p; cin>>p;
      h.push_back(p);
    }
    sort(h.begin(), h.end());
    for(int i=0;i<N-K+1;i++){
      ll d = h[i+K-1] - h[i];
      ans = min(ans, d);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    string s, t;
    cin >> s >> t;

    int n = s.size();
    bool flag = true;
    rep(i, n) if (s[i] != t[i]) flag = false;

    if (flag) cout <<  "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main()
{   int H,N,sum;
    scanf("%d%d",&H,&N);
    int arr[N];
    for(int i=0;i<N;i++)
    {
        scanf("%d",&arr[i]);
        sum+=arr[i];
    }
    if(sum>=H)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 2528
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n,m,Q; cin >> n >> m >> Q;
    vector<int> l(m),r(m);
    vector<int> p(Q),q(Q);

    for(int i = 0;i < m;i ++){
        cin >> l.at(i) >> r.at(i);
    }
    for(int i = 0;i < Q;i ++){
        cin >> p.at(i) >> q.at(i);
    }

    vector<vector<int> > a(501,vector<int>(501));
    
    for(int i = 0;i < m;i ++){
        a.at(l.at(i)).at(r.at(i))++;
    }

    vector<vector<int> > b(501,vector<int>(501));

    for(int i = 1;i < 501;i ++){
        for(int j = 1;j < 501;j ++){
            b.at(i).at(j) = b.at(i).at(j-1) + b.at(i-1).at(j) - b.at(i-1).at(j-1) + a.at(i).at(j);
        }        
    }

    for(int i = 0;i < Q;i ++){
        int ans = b.at(q.at(i)).at(q.at(i)) - b.at(p.at(i)-1).at(q.at(i)) - b.at(q.at(i)).at(p.at(i)-1) + b.at(p.at(i)-1).at(p.at(i)-1);
        cout << ans << endl;
    }
}

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

██╗    ██╗██████╗ ██╗████████╗████████╗███████╗███╗   ██╗    ██████╗ ██╗   ██╗
██║    ██║██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗  ██║    ██╔══██╗╚██╗ ██╔╝
██║ █╗ ██║██████╔╝██║   ██║      ██║   █████╗  ██╔██╗ ██║    ██████╔╝ ╚████╔╝
██║███╗██║██╔══██╗██║   ██║      ██║   ██╔══╝  ██║╚██╗██║    ██╔══██╗  ╚██╔╝
╚███╔███╔╝██║  ██║██║   ██║      ██║   ███████╗██║ ╚████║    ██████╔╝   ██║
 ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝   ╚═╝      ╚═╝   ╚══════╝╚═╝  ╚═══╝    ╚═════╝    ╚═╝

     ███╗   ███╗   ██╗██████╗ ██████╗  █████╗ ██╗  ██╗██╗███╗   ███╗
     ████╗ ████║   ██║██╔══██╗██╔══██╗██╔══██╗██║  ██║██║████╗ ████║
     ██╔████╔██║   ██║██████╔╝██████╔╝███████║███████║██║██╔████╔██║
     ██║╚██╔╝██║   ██║██╔══██╗██╔══██╗██╔══██║██╔══██║██║██║╚██╔╝██║
     ██║ ╚═╝ ██║██╗██║██████╔╝██║  ██║██║  ██║██║  ██║██║██║ ╚═╝ ██║
     ╚═╝     ╚═╝╚═╝╚═╝╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚═╝     ╚═╝
*/
#define speed  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(n) for(int i=0;i<n;i++)
#define For(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define E "\n"
#define all(e) e.begin(),e.end()
#define F first
#define S second
#define pi (acos(-1))
#define rad(x) ((x*pi)/(ld)(180))
#define perc(x) fixed<<setprecision(x)
/*****
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define rot(p,angle) (p)*polar((double)(1),angle)
#define rot2(p,angle,a) ((p)-(a)) *(polar((ld)(1),angle)+ (a))
#define x real()
#define y imag()
*****/
typedef long long int ll; typedef unsigned long long ull; typedef long double ld;typedef complex<ld> point; typedef tuple<double,double,double> line;
ll gcd(ll x,ll y){if(!y)return x; return gcd(y,x%y);};   ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}

ll dp[100005][4],n,arr[100005][3];

ll solve(int i,int j)
{
    if(dp[i][j]!=-1 and i!=0)return dp[i][j];
    if(i==n)return 0;

    ll ret = -1;

    if(j!=0)
    ret = max(ret,solve(i+1,0)+arr[i][0]);
    if(j!=1)
    ret = max(ret,solve(i+1,1)+arr[i][1]);
    if(j!=2)
    ret = max(ret,solve(i+1,2)+arr[i][2]);

    return dp[i][j]=ret;
}

int main(){ speed;
memset(dp,-1,sizeof dp);

cin>>n;


FOR(n)cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

cout<<solve(0,-1);

return 0;}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// 01Trie BIT CHT DFT FFT avl cmd cusum dijkstra dinic geo2 gin graph kruskal lca lcm matrix ncm next_combination ppuf segtree st tmp topcoder uf vi 

int fact[1145140];
int pascal_table[100][100];

/*
 * tableをdoubleにしてncmの割合も求められる
 * 1/2して下ってゆくように書き換えてその場で作る.
 */
void make_pascal(int mod)
{
    rep(i, 100) {
        pascal_table[i][0] = 1;
        for (int j = 1; j < i; j++) {
            pascal_table[i][j] = (pascal_table[i-1][j-1] +
                    pascal_table[i-1][j]) % mod;
        }
        pascal_table[i][i] = 1;
    }
}

int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a%b); }

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else { x = 1; y = 0; }
    return d;
}

int repow(int x, int n, int mod)
{
    if (n == 0) return 1;
    int res = repow(x * x % mod, n / 2, mod);
    if (n & 1) res = res * x % mod;
    return res;
}

int mod_inverse(int a, int m)
{
    int x, y;
    extgcd(a, m, x, y);
    return ( m + x % m ) % m;
}

int table(int n, int p)
{
    int sum = 1;
    fact[0] = 1;
    Rep(i, n+2) {
        sum *= i;
        sum %= p;
        fact[i] = sum;
    }
}

int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0) return 1;
    int res = mod_fact(n / p, p, e);
    e += n / p;

    if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}

/*
 * nCr mod p
 * nHr = (n+r-1)Cr
 * 必ずtable()を呼んでから使う.
 * n = 1001000くらいで
 */
int mod_comb(int n, int k, int p) {
    if (n < 0 || k < 0 || n < k) return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n-k, p, e3);
    if (e1 > e2 + e3) return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

int ncm(int n, int r)
{
    if (r == 0) return 1;
    return (n-r+1) * ncm(n, r-1) / r;
}

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

    int2(n, k);

    cout << n - k + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    S = I()
    
    if N==S:
        print(N+1)
        return 

    def check(N,b):
        res = 0
        while N:
            res += N%b
            N//=b
        return res == S


    for b in range(2,int(sqrt(N)+1)):
        if check(N,b):
            print(b)
            return
    for p in range(1,int(sqrt(N)+1))[::-1]:
        b = (N-S)//p + 1
        q = S - p
        N_ = N - q

        if N_ % p == 0 and 0 <= q < N_//p and p!=N_//p:
            print(N_//p)
            return
    print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 70124
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] lines = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        Array.Sort(lines);

        Console.WriteLine(lines[0] + " " + lines[1] + " " + lines[2]);
        //Console.WriteLine($"{} {} {}");
    }
}

Measured memory_bytes: 9616
#include <stdio.h>

int main(void)
{
	long a[10000],i,n,mb,ms,sum=0;
	scanf("%ld",&n);
	for (i = 0; i < n; i++){
		scanf("%ld",&a[i]);
		sum += a[i];
	}
	mb = ms = a[0];
	for (i = 1; i < n; i++){
		if (mb < a[i]){
			mb = a[i];
		}
	}
	for (i = 1; i < n; i++){
		if (ms > a[i]){
			ms = a[i];
		}
	}
	printf("%ld %ld %ld\n",ms,mb,sum);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  lb a,b,c;cin>>a>>b>>c;

  lb S=a*b/2*sin(M_PI*c/180);
  out(fixed<<setprecision(10)<<S);
  out(fixed<<setprecision(10)<<a+b+sqrt(a*a+b*b-2*a*b*cos(M_PI*c/180)));
  out(fixed<<setprecision(10)<<2*S/a);

  return 0;
}



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

const int N=3e3+20;

int n,m,k,x,y,v,a[N][N];
long long dp[N][N][4];

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	while(k--)
	{
		scanf("%d%d%d",&x,&y,&v);
		a[x][y]=v;
	}

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			long long pv=0;
			for(int k=1;k<=3;k++) pv=max(pv,dp[i-1][j][k]+a[i][j]);
			for(int k=1;k<=3;k++)
			{
				dp[i][j][k]=max(pv,dp[i][j-1][k]);
				dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+a[i][j]);
			}
		}
	}

	long long ans=0;
	for(int k=1;k<=3;k++) ans=max(ans,dp[n][m][k]);
	printf("%lld",ans);
}

Measured memory_bytes: 322316
#include<bits/stdc++.h>
using namespace std;
#define ll long long

struct Count{
	int rc;
	int gc;
	int bc;

};


int main(){

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

    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;

    vector<Count> v(n);
    ll a = 0;
    ll b = 0;
    ll c = 0;
    for(ll i=n-1;i>=0;--i){
    	v[i].rc = a;
    	v[i].gc = b;
    	v[i].bc = c;

    	if(s[i] == 'R'){
    		a++;
    	}
    	else if(s[i] == 'G'){
    		b++;
    	}
    	else{
    		c++;
    	}

    }

    // for( auto a : v){
    // 	cout << a.rc << " " << a.gc << " " << a.bc << endl;
    // }

    for(ll i=0;i<(n-3);i++){
    	map<char,int>m;
    	m[s[i]]++;
    	for( ll j = i+1 ;j<n;++j){
    		if(m[s[j]] == 0){
    			m[s[j]] = 1;

    			if(m['R'] == 0){
	    			ans += v[j].rc;
	    			ll d = j-i;
	    			if((j+d < n) && (s[j+d] == 'R') ){
	    				ans--;
	    			}
	    		}
	    		if(m['G'] == 0){
	    			ans += v[j].gc;
	    			ll d = j-i;
	    			if((j+d < n) && (s[j+d] == 'G') ){
	    				ans--;
	    			}
	    		}
	    		if(m['B'] == 0){
	    			ans += v[j].bc;
	    			ll d = j-i;
	    			if((j+d < n) && (s[j+d] == 'B') ){
	    				ans--;
	    			}
	    		}
	    	
	    		m[s[j]] = 0;


    		}


    	}
    }

    cout << ans << "\n";

	return 0;
}

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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define space ' '
#ifdef ONLINE_JUDGE
#define enter '\n'
#else
#define enter std::endl
#endif
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 204001, mod = 1e9 + 7;
 long long x;
 void Fakemain( )
 {
  IOS;
  cin >> x;
  int L = 1, R = 1e5, ans = -1;
  while( L <= R )
  {
   int mid = L + R >> 1;
   if( 1LL * mid * ( mid + 1 ) / 2 < x )
    L = mid + 1;
   else
    R = mid - 1, ans = mid;
  }
  cout << ans;
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 3652
using System;

namespace ABC152A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            if (a == b)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,m,i,a[50],s=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(i=n;i>=1;i--)
	{
		m--;
		s+=a[i];
		if(m==0)
		{
			break;
		}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    int tige;cin>>tige;
    rep(hogehoge,tige){
        int x,y,w,h;cin>>x>>y>>w>>h;
        int cat; cin>>cat;
        vector<pii>v(cat);
        rep(i,cat)cin>>v[i].first>>v[i].second;
        int ans=0;
        rep(i,cat)if(x<=v[i].first&&v[i].first<=x+w&&y<=v[i].second&&v[i].second<=y+h)ans++;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2996
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n,a,b = m()

if (a + b) % 2 == 0:
    print(abs(a-b)//2)
else:
    print(min((a+b)//2,(n+(n-b+1) - a)//2))



Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
int fx4[] = {1 , -1 , 0 , 0};
int fy4[] = {0 , 0 , 1 , -1};
int Kfx[]= {-2,-2,2,2,1,1,-1,-1}; ///knight move x - exis
int Kfy[]= {1,-1,1,-1,2,-2,2,-2}; ///knight move y- exis
int fx8[]= {1,1,1,0,0,-1,-1,-1};
int fy8[]= {0,1,-1,1,-1,0,1,-1};
#define ll long long int
#define pii pair<int,int>
#define llu unsigned long long
#define inf 1<<28
#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define all(r)(r).begin(),(r).end()
/*
bool status[mx];
void sieve(){
   long long int  i,j;
    for(i=2;i<=mx;i++)
    {
        status[i]=0;
    }
    for( i=2;i<=sqrt(mx);i++){
        if(status[i]==0)
        {
            for(j=i*i;j<=mx;j+=i){
                status[j]=1;
            }
        }
    }
}*/
ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;

    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}
#define dd double
#define sc scanf
#define pr printf
#define VI vector<int>
#define VS vector<string>
#define VC vector<char>
#define VLL vector<long long int>
#define FILE freopen("input.txt","rt",stdin); freopen("output.txt","w",stdout);
#define p_b push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define F(i,a,b) for(i=a;i<=b;i++)
#define sc1(a) scanf("%d",&a)
#define scL1(a) scanf("%lld",&a)
#define scL2(a,b) scanf("%lld%lld",&a,&b)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define sqr(x)           (x)*(x)
#define TEST int test,te=0;cin>>test;
#define segment_tree int l=(n*2),r=(n*2)+1,mid=(l+r)/2
#define Mx 100005
#define mx 10005

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);///Beware of use it, if u use it dont use scanf or printf
    int n,m;
    cin>>n>>m;
    int sum=(n*(n-1))/2;
    sum+=((m*(m-1))/2);
    cout<<sum<<endl;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  
  return x;
}

Node treeMaximum(Node x){
 while(x->right != NIL){
    x = x->right;
  }
  
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)return u;

  if(k < u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL)x = y->left;
  else x = y->right;

  if(x != NIL)x->parent = y->parent;

  if(y->parent == NIL)root = x;
  else if(y == y->parent->left)y->parent->left = x;
  else y->parent->right = x;

  if(y != z)z->key = y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL)root = z;
  else if(z->key < y->key)y->left = z;
  else y->right = z;

}

void inorder(Node u){
 
  if(u == NIL)return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
 
  if(u == NIL)return;
  
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    } 
  }

  return 0;
}



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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 2e5 + 1;

ll N;
ll A[MAX_N];

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

  bool zero_flag = true;
  cin >> N;
  REP(i, N) {
    cin >> A[i];
    if (A[i] != 0) zero_flag = false;
    // bitset< 4 > a(A[i]);
    // debug(a);
  }

  if (zero_flag) {
    cout << N * (N + 1) / 2 << endl;
    return 0;
  }

  ll ans = 0ll;
  int ub = 0;
  ll sm = 0ll;
  REP(lb, N) {
    if (lb == ub) {
      sm += A[lb];
    }
    ub = max(lb + 1, ub);

    while (ub < N) {
      if (sm + A[ub] > (sm xor A[ub])) break;

      sm += A[ub];
      ub++;
    }
    ans += ub - lb;
    sm -= A[lb];
    /*
    debug(sm);
    debug(ans);
    debug(lb);
    debug(ub);
    cout << endl;
    */
  }

  cout << ans << endl;
  

  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

ll modpow(ll a,ll n,ll m=inf){
    ll res=1;
    while(n){
        if(n&1)res=res*a%m;
        a=a*a%m;
        n>>=1;
    }
    return res;
}

int main(){
    int n;cin>>n;
    vll c(n);rep(i,n)cin>>c[i];
    sort(all(c));
    if(n==1)cout<<(2*c[0])%inf<<endl;
    else{
        ll ans=(ll)0;
        rep(i,n){
            ans+=c[i]*(ll)(n-i-1+2);
            ans%=inf;
        }
        ans*=modpow(2,n-2);ans%=inf;
        ans*=modpow(2,n);ans%=inf;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4732
# 走査した部分列の最小値を覚えておけば、それ以降の走査においてはその最小値との差のみ調べればいい

n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))

tmp = -1000000000
minv = A[0]
for i in range(1, n):
    if tmp < A[i] - minv:
        tmp = A[i] - minv
    if A[i] < minv:
        minv = A[i]

print(tmp)


Measured memory_bytes: 13592
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<array>
#include<bitset>
#include<cmath>

using namespace std;

#define square(s) ((s)*(s))
#define scast(type,e) static_cast<type>(e)
#define rep(i,n) for(decltype(n) i = 0; i < n;i++)
#define repp(i,s,u) for(decltype(s) i = s; i < u;i++)
#define range(a) a.begin(),a.end()
#define pr(l,r) make_pair((l),(r))
#define INF (1145141919)


template<class T>
using vec = vector<T>;
template<class T, size_t S>
using arr = array<T, S>;
template<class T1, class T2>
using pr = pair<T1, T2>;

using ll = long long;
using ull = unsigned long long;

template<class T>
void chmax(T& dest, const T& target) {
	dest = max(dest, target);
}
template<class T>
void chmin(T& dest, const T& with) {
	dest = min(dest, with);
}

int main() {
	int N, M;
	cin >> N >> M;
	vec<int> as(M);
	vec<bitset<12>> bits(M);
	vec<int> bs(M);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		as[i] = a;
		bs[i] = b;
		rep(j, b) {
			int c;
			cin >> c; c--;
			bits[i][c] = 1;
		}
	}
	
	arr<arr<int,(1 <<12)>,2> dp;
	fill(range(dp[0]), 1145141919);
	dp[0][0] = 0;

	rep(i, M) {
		rep(j, 1 << N) {
			dp[(i+1)&1][j] = min(dp[i&1][j], dp[i&1][j & (~bits[i]).to_ulong()] + as[i]);
		}
	}
	auto res = dp[M&1][(1 << N) - 1];
	if (res == 1145141919) {
		cout << -1;
	}
	else {
		cout << res << endl;
	}



	return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

count = 0
for t in T:
    l, r = bisect.bisect_left(S, t), bisect.bisect_right(S, t)
    if l < r:
        count += 1
print(count)


Measured memory_bytes: 16744
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n, m; cin >> n >> m;
    ll ans = max((ll)1, n-2) * max((ll)1, m-2);
    if(n==2 || m==2) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628