akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());

    string[] str1 = Console.ReadLine().Split(' ');
    int[] a = new int[n + 1];
    for(int i = 0; i < n + 1; i++)
    {
      a[i] = int.Parse(str1[i]);
    }

    string[] str2 = Console.ReadLine().Split(' ');
    int[] b = new int[n];
    for(int i = 0; i < n; i++)
    {
      b[i] = int.Parse(str2[i]);
    }

    long ans = 0;
    for(int i = 0; i < n; i++)
    {
      ans      += Math.Min(a[i]    , b[i]);
      b[i]     -= Math.Min(a[i]    , b[i]);
      ans      += Math.Min(a[i + 1], b[i]);
      a[i + 1] -= Math.Min(a[i + 1], b[i]);
    }

    Console.WriteLine(ans.ToString());
  }
}


Measured memory_bytes: 34980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
      
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		double total = 0;
		int count = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			total += a[i];
		}
		for (int i = 0; i < n; i++) {
			if (total / 4 / m <= a[i]) {
				count++;
			}
		}
		if (count < m)
			System.out.println("No");
		else
			System.out.println("Yes");
	}

}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}


void solve()
{
   ll n, k; cin >> n >> k;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  // vector<ll> a(n); rep(i, n) cin >> a[i];
  // ll ans = 0;
  // bool ok = false;
  
   cout << n *k << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 3624
def double_landscape(N: int, M: int, A: list, B: list) -> int:
    if not (is_unique(A) and is_unique(B)):
        return 0

    A = sorted(A, reverse=True)
    B = sorted(B, reverse=True)
    i_a, i_b = 0, 0

    count = 1
    NM = N*M
    for x in range(NM, 0, -1):
        availables = 0
        if i_a < N and i_b < M and x == A[i_a] and x == B[i_b]:
            availables = 1
            i_a += 1
            i_b += 1
        elif i_a < N and x == A[i_a]:
            availables = i_b
            i_a += 1
        elif i_b < M and x == B[i_b]:
            availables = i_a
            i_b += 1
        else:
            availables = i_a * i_b - (NM - x)

        if availables <= 0:
            return 0

        count *= availables
        count %= 10**9 + 7

    return count


def is_unique(l: list) -> bool:
    return len(l) == len(set(l))


if __name__ == "__main__":
    N, M = [int(s) for s in input().split()]
    A = [int(s) for s in input().split()]
    B = [int(s) for s in input().split()]

    print(double_landscape(N, M, A, B))


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int count = 0;
  int answer = 0;
  for(int i =0;i < N;i++) {
    if(S.at(i) == 'I') {
      count = count + 1;
      if(answer < count){
        answer = count;
      }
    }
    if(S.at(i) == 'D') {
      count = count - 1;
    }
  }
    cout << answer << endl;
  }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define M_PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int A[100000];
int v[100000] = { 0 };

int main()
{
	int N, T;
	int ans = 1;

	cin >> N >> T;
	rep(i, N) cin >> A[i];

	rrep(i, N - 1) {
		v[i] = max(v[i + 1], A[i + 1]);
	}

	rep(i, N - 1) {
		v[i] = max(0, v[i] - A[i]);
	}

	sort(v, v + N - 1, greater<int>());

	rep(i, N - 2) {
		if (v[i] == v[i + 1]) ans++;
		else break;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
using ll=long long;
ll n,m;
unordered_map<ll, vector<ll>> adj_list;
// map<ll,bool> vis;
ll dp[10000007];
ll  dfs(ll node){
    if(dp[node]!=-1){
        return dp[node];
    }
    // if(vis[node])
    //     return -1;
    // vis[node]=1;
    ll ans = -1;
    for(ll ngbr : adj_list[node]){
        ans = max(dfs(ngbr)+1,ans);
    }
    return dp[node]=ans;
}
int main(){
    cin>>n>>m;
    for(ll i=1;i<=m;i++){
        ll x,y;
        cin>>x>>y;
        // if(adj_list[x]==null){
        //     adj_list[x] = vector<ll>();
        // }
        adj_list[x].pb(y);
    }
    // dp.fill(-1);
    for(int i=0;i<10000007;i++){
        dp[i]=-1;
    }
    ll ans = - 1e18L;
    for(ll i=1;i<=n;i++){
        // if(!vis[i]){
        ans = max(dfs(i)+1,ans);
        // }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 89252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  in(n);
  if(n < 1000){
    out("ABC");
  }
  else{
    n = n - 999;
    out("ABD");
  }
  memi;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

struct Prime {
  int n;
  vector<int> pri;
  Prime() : n(0) {}
  Prime(int n) : n(n) {
    vector<bool> f(n, true);
    f[0] = f[1] = false;
    for (int i = 2; i < n; i++) {
      if (!f[i]) continue;
      pri.push_back(i);
      for (int j = i * 2; j < n; j += i) {
        f[j] = false;
      }
    }
  }
  bool is(int x) {
    if (n > x) {
      return binary_search(pri.begin(), pri.end(), x);
    }
    if (x < 2) return 0;
    for (int i = 2; i * i <= x; i++) {
      if (x % i == 0) return false;
    }
    return true;
  }
  map<i64, int> factor(i64 k) {
    map<i64, int> so;
    for (auto p : pri) {
      while (k % p == 0) k /= p, so[p]++;
    }
    if (k != 1) so[k] = 1;
    return so;
  }
};

void solve() {
  i64 n;
  cin >> n;
  auto prime = Prime(1000001);
  i64 ans = 0;
  {
    auto mp = prime.factor(n - 1);
    i64 cnt = 1;
    each(m, mp) {
      cnt *= m.second + 1;
    }
    cnt -= 1;
    ans += cnt;
  }
  ans += 1;
  {
    vi64 v;
    for (i64 i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        v.push_back(i);
        if (i != n / i) v.push_back(n / i);
      }
    }
    sort(all(v));
    auto judge = [&](i64 x) {
      i64 nn = n;
      while (nn % x == 0) nn /= x;
      return nn % x == 1;
    };
    rep(i, sz(v)) {
      if (judge(v[i])) ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[]A = new int[N];
		int[]B = new int[N];
		string[] str1 = Console.ReadLine().Split();
		string[] str2 = Console.ReadLine().Split();
		int[]C = new int[N];
		int[]D = new int[N];
		bool flag = true;
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str1[i]);
			B[i] = int.Parse(str2[i]);
			C[A[i]-1]++;
			D[B[i]-1]++;
		}
		for(var i=0;i<N;i++){
			if(C[i]+D[i]>N){
				flag = false;
			}
		}
		if(!flag){
			Console.WriteLine("No");
		} else {
			Console.WriteLine("Yes");
			int a1 = 0;
          	int a2 = 0;
			var list = new List<int>();
			for(var i=0;i<N;i++){
				int nct = 0;
				while(A[i] == a1+1 || D[a1]==0){
					a1 = (a1 + 1) % N;
					nct++;
					if(nct>=N){
						break;
					}
				}
				if(nct>=N){
					while(A[a2]==A[i] || list[a2]==A[i]){
                      	a2 = (a2 + 1) % N;
                    }
					int t = list[a2];
                  	list[a2] = A[i];
                  	list.Add(t);
					D[A[i]-1]--;
                } else {
					list.Add(a1+1);
					D[a1]--;
                }
			}
			if(!flag){
              	Console.WriteLine("No");
			} else {
				Console.Write(list[0]);
				for(var i=1;i<N;i++){
					Console.Write(" "+list[i]);
				}
            }
			Console.WriteLine();
		}
	}
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if (K <= A) {
        cout << K << '\n';
    } else if (K <= A + B) {
        cout << A << '\n';
    } else {
        cout << A - (K - A - B) << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

bool check(string &S, int begin, int end)
{
    while (begin < end) {
        if (S[begin] != S[end-1]) {
            return false;
        }
        begin++;
        end--;
    }

    return true;
}

int main()
{
    string S;
    cin >> S;
    size_t size = S.length();
    if (check(S, 0, size) 
        && check(S, 0, (size-1)/2) && check(S, (size+3)/2-1, size)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
info_l = list(list(map(int, input().split())) for _ in range(n))

rooms = [[[0]*10, [0]*10, [0]*10],
        [[0]*10, [0]*10, [0]*10],
        [[0]*10, [0]*10, [0]*10],
        [[0]*10, [0]*10, [0]*10]]

for info in info_l:
    b = info[0]
    f = info[1]
    r = info[2]
    v = info[3]
    rooms[b-1][f-1][r-1] += v

cnt = 0
for room in rooms:
    cnt += 1
    for i in room:
        print(' ' + ' '.join(map(str, i)))
    if cnt != 4:
        print('#'*20)




Measured memory_bytes: 5612
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)



class DP{
public:
	ll cost;
	int x;
	
	DP(){}
	DP(int xx, ll cc){
		cost = cc;x=xx;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};
const ll INF = 1000000000000000000LL;
ll visit[100001];
int N, M, X;
main(){
	int i,j;
	scanf("%d%d%d", &N, &M, &X);
	vector<int> H(N);
	vector< vector<pii> > g(N);
	REP(i, N) cin >> H[i];
	REP(i, M){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		if(H[a-1]>=c) g[a-1].push_back(pii(b-1, c));
		if(H[b-1]>=c) g[b-1].push_back(pii(a-1, c));
	}

	priority_queue<DP> dp;
	DP S;
	dp.push(DP(0LL, 0));
	REP(i, N) visit[i] = INF;
	while(!dp.empty()){
		S = dp.top();
		dp.pop();
		if(S.cost > visit[S.x]) continue;
		if(S.x == N-1) break;
		FOR(it, g[S.x]){
			DP T = S;
			T.x = it->first;
			T.cost += it->second;
			if(X - T.cost > H[T.x]) T.cost = X - H[T.x];
			if(T.cost < visit[T.x]){
				visit[T.x] = T.cost;
				dp.push(T);
			}
		}
	}
	if(S.x == N-1) cout << S.cost + abs(X - S.cost - H[N-1]) << endl;
	else cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 12880
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,k,m,n,cnt=0,wa[110000],tr[110000];
pair<int,string> ab[110000];
string s,t;
char c;
signed main()
{
	cin>>n>>m;
	rep(i,m){
		cin>>ab[i].first>>ab[i].second;
		if(tr[ab[i].first-1]==0){
			if(ab[i].second=="WA"){
				wa[ab[i].first-1]++;
			}else{
				tr[ab[i].first-1]=1;
			}
		}
	}
	rep(i,n){
		cnt+=tr[i];
	}
	cout<<cnt;
	cnt=0;
	rep(i,n){
		if(tr[i]==1){
			cnt+=wa[i];
		}
	}
	cout<<' '<<cnt;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define m_p make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll isp[1000010];
vector<ll> primes;
vector<P> mine;
const ll mod = 1000000007;
int main()
{
	ll n,k;
	cin>>n>>k;
	if(n == 1)
	{
		cout<<k<<endl;
		return 0;
	} 
	isp[0] = isp[1] = 1;
	for(ll i = 2;i<=1e6;i++)
	{
		if(!isp[i])
			primes.push_back(i);
		for(ll j = i*i;j<=1e6;j+=i)
			isp[j] = 1;
	}
	ll tmp = k;
	for(int i=0;i<primes.size();i++)
	{
		ll cnt = 0;
		while(tmp%primes[i] == 0)
		{
			tmp/=primes[i];
			cnt++;
		}
		if(cnt>=n)
			mine.push_back(P(cnt,primes[i]));
	}
	ll gcd = 1;
	for(int i=0;i<mine.size();i++)
	{
		ll pows = mine[i].first/n;
		ll cheng = 1;
		for(int j=0;j<pows;j++)
			cheng*=mine[i].second;
		gcd*=cheng;
	}
	cout<<gcd<<endl;
	return 0;
}

Measured memory_bytes: 9208
N=int(input())
A=[0]*N
B=[0]*N
C=[0]*N
for i in range(N):
  A[i],B[i] = map(int,input().split())
  C[i] = [A[i],B[i]]

t=0
C.sort(key=lambda x: x[1])

ans="No"
for i,item in enumerate(C):
  if item[0]+t<=item[1]:
    t += item[0]
  else:
    break
else:
  ans="Yes"
  
print(ans)

Measured memory_bytes: 41256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a;
  int miVal=1000,miIndex=0;
  for(int i=0;i<n;i++){
      int x;
      cin>>x;
      a.push_back(x);
      if(a[i]<miVal){
        miVal=a[i];
        miIndex=i;
      }
  }
  int ball=miIndex;
  int times=k;
  int old=-1;

  vector<int> ans;
  while(times>=0){
      int mi=1000,index=0;
      for(int i=0;i<n;i++){
        if(i==old) continue;
        if(a[i]==0){
          cout<<-1<<endl;
          return 0;
        }
        if(i==ball) continue;
        ans.push_back(i);
        a[i]--;
      }

      for(int i=0;i<n;i++){
        if(i==ball) continue;
        if(mi>a[i]){
          mi=a[i];
          index=i;
        }
      }

      ans.push_back(ball);
      a[ball]--;
      old=ball;
      ball=index;
      times--;
  }

  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i]+1<<" ";
  }
  cout<<endl;

  return 0;
}


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

#define ll long long
#define v vector

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

    string s;
    cin >> s;

    if(s[0] == s[1]) {
        cout << 1 << " " << 2 << endl;
        return 0;
    }
    for(ll i = 2; i < s.size(); i ++) {
        if(s[i] == s[i-2]) {
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
        if(s[i] == s[i-1]) {
            cout << i << " " << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
X,N=map(int, input().split())
p=list(map(int,input().split()))   
if N==0:
    print(X)
else:
    for k in range(0,51):
        if not X-k in p:
            print(X-k)
            break 
        elif not X+k in p:
            print(X+k)
            break

Measured memory_bytes: 9172
import collections

N = int(input())
S = [input() for _ in range(0, N)]
mc = collections.Counter(S).most_common()
c = mc[0][1]

s = map(lambda x: x[0], filter(lambda x: x[1] == c, mc))
s = list(s)
s.sort()

print("\n".join(s))

Measured memory_bytes: 121168
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  600005

ll int expo(ll int base,ll int exponent,ll int mod){
    ll int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

ll int fac[N];

ll int ncr(ll int n,ll int r)
{
	ll int ret=fac[n];
	ret=(ret*expo(fac[r],hell-2,hell))%hell;
	ret=(ret*expo(fac[n-r],hell-2,hell))%hell;
	return ret;
}

int main()
{
	fac[0]=1;
	for(ll int i=1;i<N;i++) fac[i]=(fac[i-1]*i)%hell;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n,k;
		cin>>n>>k;
		ll int ans=0;
		for(ll int e=0;e<=min(k,n);e++)
		{
			ll int ne=n-e;
			ans=(ans+(ncr(n-1,ne-1)*ncr(n,ne))%hell)%hell;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 4992
#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;

int main(){
    int N,M,sumAC,sumWA;
    cin>>N>>M;
    sumAC=0;
    sumWA=0;
    vector<int> p(M);
    vector<bool> ans(N+1,false);
    vector<int> AC(N+1);
    vector<int> WA(N+1);

    vector<string> S(M);
    for(int i=0;i<M;i++)cin>>p.at(i)>>S.at(i);
    for(int i=0;i<M;i++){
        if(ans.at(p.at(i))==false & S.at(i)=="AC"){
            sumAC=sumAC+1;
            sumWA=sumWA+WA.at(p.at(i));
            ans.at(p.at(i))=true;
        }
        else if(ans.at(p.at(i))==false & S.at(i)=="WA") WA.at(p.at(i))++;
    }
    cout<<sumAC<<" "<<sumWA<<endl;
}

Measured memory_bytes: 6912
a, b, c, d = map(int, input().split())
turn_t = True
while True:
    if turn_t:
        c -= b
        if c <= 0:
            print('Yes')
            break
    else:
        a -= d
        if a <= 0:
            print('No')
            break
    turn_t = not turn_t


Measured memory_bytes: 9172
#include<stdio.h>

int main(){
	for(;;){
		int t,n,s,f,m,o=0;
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		for(m=0;m<n;m++){
			scanf("%d%d",&s,&f);
			o+=f-s;
		}
		if(o>=t)printf("OK\n");
		else printf("%d\n",t-o);
	}
	return 0;
}



Measured memory_bytes: 2724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n+2];
    map<ll,ll>mp;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(int i=0;i<n;i++){
        if(mp[a[i]]>1)return 0*puts("NO");
    }
    puts("YES");
}


Measured memory_bytes: 17692
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> check;

    rep(i, N) {
        cin >> A[i];
        if (check.count(A[i]) == 0) {
            check[A[i]] = 1;
        }
        else {
            check[A[i]]++;
        }
    }

    int kind = (int)check.size();

    cout << ((kind % 2) ? kind : kind - 1) << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<string.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#define lli long long int
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define fo(i,n) for(int i=0;i<(n);i++)
using namespace std;

int f(int idx , string &s , string &t){
    int cnt = 0;
    for(int i = 0;i<t.length();i++ ){
        if(s[i+idx] != t[i]){
            cnt++;
        }
    }
    return cnt;
}


void solve(){
   string s , t;
   cin>>s>>t;
   int ans = f(0,s,t);
   for(int i = 1;i+t.length() < s.length();i++){
       ans = min(ans , f(i  , s,t));
   }
   cout<<ans<<endl;



}

int main(){
    ULTRA_INSTINCT;
    int t =1;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	float w;
	while(scanf("%f",&w)!=EOF){
		if(w<=48.0){
			printf("light fly");
		}else if(w<=51.0){
			printf("fly");
		}else if(w<=54.0){
			printf("bantam");
		}else if(w<=57.0){
			printf("feather");
		}else if(w<=60.0){
			printf("light");
		}else if(w<=64.0){
			printf("light welter");
		}else if(w<=69.0){
			printf("welter");
		}else if(w<=75.0){
			printf("light middle");
		}else if(w<=81.0){
			printf("middle");
		}else if(w<=91.0){
			printf("light heavy");
		}else{
			printf("heavy");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2672
($N,$K)=split " ",<STDIN>;
$K2=$K*2;
for($i=0;$i<$N;$i++){
	($x,$y,$c)=split " ",<STDIN>;
	$x=$x%$K2;
	$y=$y%$K2;
	$v=($c eq "B")?1:-1;
	if ($x>=$K) { $x=$x-$K; $v=-$v; }
	if ($y>=$K) { $y=$y-$K; $v=-$v; }
	$ddv[$x][$y] +=$v*4;
}

$v=0;
for($y=0;$y<$K;$y++){ $sdv[$y]=0;$vmp[$y]=0;$vmm[$y]=0;$v[$y]=0; }

for($x=0;$x<$K;$x++){
	$dv=0;for($y=0;$y<$K;$y++){ $dv+=$ddv[$x][$y]; } $dv=-$dv/2;
	for($y=0;$y<$K;$y++){
		$dv+=$ddv[$x][$y];
		$v=$v[$y]+$dv;$v[$y]=$v;
		$sdv[$y]+=$dv;
		if ($vmp[$y]<$v) { $vmp[$y]=$v; }
		if ($vmm[$y]>$v) { $vmm[$y]=$v; }
	}
}
$s=0;
for($y=0;$y<$K;$y++){
	$vv=-$sdv[$y]/2;
	$vmp=$vmp[$y]+$vv;
	$vmm=$vmm[$y]+$vv;
	if($s< $vmp){$s= $vmp;}
	if($s<-$vmm){$s=-$vmm;}
}

$ss=($s+$N)/2;
print $ss;


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

using namespace std;
using ll = long long;

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

	int n;
	string s;
	cin >> n >> s;

	for (auto el : s) {
		int num = el - 'A';
		num += n;
		num %= 26;
		cout << (char)('A' + num);
	}
}

Measured memory_bytes: 3620
l = []
for _ in range(5):
  l.append(int(input()))
can = []
for i in range(5):
  tmp = 0
  for j in range(5):
    if j == i:
      tmp += l[j]
    else:
      tmp += ((l[j]-1) // 10 + 1) * 10
  can.append(tmp)
print(min(can))

Measured memory_bytes: 3060
import java.util.Scanner;
class Main{
	public static void main(String[] args){
    	Scanner console = new Scanner(System.in);
    	int X = console.nextInt();
      int Y = console.nextInt();
      int Z = console.nextInt();
      System.out.println(Z + " " + X + " " + Y);
	}
	
}

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

int main() {

    int N;
    string S;
    cin >> N >> S;


    for(int i=0; i<S.size(); i++) {
        if(S[i] + N <= 90)
            S[i] += N;
        else
            S[i] = 64 + S[i] + N - 90;
    }

    cout << S;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int s3[3][3]={
{1,1,0},
{0,0,2},
{0,0,2}
};
int s4[4][4]={
{1,1,5,6},
{2,2,5,6},
{3,4,7,7},
{3,4,8,8}
};
int s5[5][5]={
{1,8,8,7,7},
{1,9,0,0,6},
{2,9,0,0,6},
{2,0,10,10,5},
{3,3,4,4,5}
};
int s6[6][6]={
{5,5,6,1,1,0},
{8,0,6,0,0,2},
{8,7,7,0,0,2},
{1,1,0,5,5,6},
{0,0,2,8,0,6},
{0,0,2,8,7,7}
};
int s7[7][7]={
{0,4,4,5,5,6,6},
{3,1,1,2,0,0,0},
{3,4,0,2,0,0,0},
{2,4,3,3,0,0,0},
{2,0,0,0,1,1,2},
{1,0,0,0,4,0,2},
{1,0,0,0,4,3,3}
};

void f(int x){putchar(x?x-1+'a':'.');}

int a[1010][1010];

int main(){
	int n;
	scanf("%d",&n);
	if(n==2){
		puts("-1");
		return 0;
	}
	if(n==3){
		rep(i,0,n)rep(j,0,n)a[i][j]=s3[i][j];
	}else{
		int nn=n;
		while(nn>7){
			rep(i,0,4)rep(j,0,4)a[nn-1-i][nn-1-j]=s4[i][j];
			nn-=4;
		}
		if(nn==4)rep(i,0,nn)rep(j,0,nn)a[i][j]=s4[i][j];
		else if(nn==5)rep(i,0,nn)rep(j,0,nn)a[i][j]=s5[i][j];
		else if(nn==6)rep(i,0,nn)rep(j,0,nn)a[i][j]=s6[i][j];
		else if(nn==7)rep(i,0,nn)rep(j,0,nn)a[i][j]=s7[i][j];
	}
	
	
	
	rep(i,0,n){
		rep(j,0,n)f(a[i][j]);
		puts("");
	}
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int ans=0;
  rep(i,0,n-1){
    bool a[26];
    bool b[26];
    rep(j,0,26){
      a[j]=false;
      b[j]=false;
    }
    rep(j,0,n){
      if(j<=i){
        a[(int)s[j]-97]=true;
      }
      else{
        b[(int)s[j]-97]=true;
      }
    }
    int cur=0;
    rep(j,0,26){
      if(a[j] && b[j]){
        cur++;
      }
    }
    ans=max(ans,cur);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n+1) {
		if (i*i <= n) {
			ans = i * i;
		}
		if (i*i >= n) break;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

template <typename T>
struct LazySegtree {
	private:
		size_t n;
		vector<T> node, lazy;
		T M0, L0;

	public:
		LazySegtree(size_t sz, T m0, T l0) {
			n = 1;
			M0 = m0;
			L0 = l0;
			while (n < sz) { n *= 2; }
			node.assign(2*n - 1, M0);
			lazy.assign(2*n - 1, L0);
		}

		T merge(T a, T b) { return min(a, b); }
		void updateNode(int k, T x) { lazy[k] = min(lazy[k], x); }
		void propagate(int k) { node[k] = min(node[k], lazy[k]); }

		void eval(int k, int l, int r) {
			if (lazy[k] == L0) { return; }
			propagate(k);
			if (r - l > 1) {
				updateNode(2*k + 1, lazy[k]);
				updateNode(2*k + 2, lazy[k]);
			}
			lazy[k] = L0;
		}

		void update(int a, int b, T x, int k=0, int l=0, int r=-1) {
			if (r < 0) { r = n; }
			eval(k, l, r);
			if (r <= a || b <= l) { return; }
			if (a <= l && r <= b) {
				updateNode(k, x);
				eval(k, l, r);
			} else {
				update(a, b, x, 2*k + 1, l, (l + r) / 2);
				update(a, b, x, 2*k + 2, (l + r) / 2, r);
				node[k] = merge(node[2*k + 1], node[2*k + 2]);
			}
		}

		T query(int a, int b, int k=0, int l=0, int r=-1) {
			if (r < 0) { r = n; }
			eval(k, l, r);
			if (r <= a || b <= l) { return M0; }
			if (a <= l && r <= b) { return node[k]; }
			T vl = query(a, b, 2*k + 1, l, (l + r) / 2);
			T vr = query(a, b, 2*k + 2, (l + r) / 2, r);
			return merge(vl, vr);
		}
};

int main() {
	const ll INF = 1e18;
	int N, Q;
	cin >> N >> Q;
	vector<ll> S(N);
	vector<ll> T(N);
	vector<ll> X(N);
	for (int i = 0; i < N; ++i) {
		cin >> S[i] >> T[i] >> X[i];
	}
	vector<ll> D(Q);
	for (int i = 0; i < Q; ++i) { cin >> D[i]; }

	vector<ll> unzip;
	unzip.push_back(-INF);
	unzip.push_back(INF);
	for (int i = 0; i < N; ++i) {
		unzip.push_back(S[i] - X[i]);
		unzip.push_back(T[i] - X[i]);
	}
	for (auto d : D) { unzip.push_back(d); }
	sort(unzip.begin(), unzip.end());
	unzip.erase(unique(unzip.begin(), unzip.end()), unzip.end());
	map<ll, int> zip;
	for (int i = 0; i < unzip.size(); ++i) {
		zip[unzip[i]] = i;
	}

	LazySegtree<ll> seg(unzip.size() + 1, INF, INF);
	for (int i = 0; i < N; ++i) {
		seg.update(zip[S[i] - X[i]], zip[T[i] - X[i]], X[i]);
	}

	for (int i = 0; i < Q; ++i) {
		int idx = zip[D[i]];
		ll res = seg.query(idx, idx + 1);
		if (res == INF) { res = -1; }
		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 83944
using System;

class program
{
    public static void Main()
    {
        while (true)
        {
            var str = Console.ReadLine().Split(' ');
            var H = int.Parse(str[0]);
            var W = int.Parse(str[1]);

            if (H == 0 && W == 0) break;

            for (int height = 0; height < H; height++)
            {
                for (int width = 0; width < W; width++)
                {
                    if (height == H - 1 || height == 0 || width == W - 1 || width == 0)
                    {
                        Console.Write('#');
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5292
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

//#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int N,M;
	cin >> N >> M;
	vector<int> num;
	vector<string> result;
	vector<int> ac(N,0);
	num.resize(M);
	result.resize(M);
	int p = 0;
	int s = 0;

	rep(i, M) {
		cin >> num[i]>>result[i];
	}

	rep(i, M) {
		if (result[i] == "AC" && ac[num[i] - 1] == 0) {
			p++;
			ac[num[i] - 1] = 1;
		}
		if (result[i] == "WA" && ac[num[i] - 1] == 0)s++;
	}
	rep(i,M){
		if (result[i] == "WA" && ac[num[i] - 1] == 0)s--;
	}
	print(p);
	print(s);
}

Measured memory_bytes: 6528
program sample
	implicit none
    integer :: x,y
    
    read(*,*) x
    
    y=mod(x,10)
    
    if (y==2 .or. y==4 .or. y==5 .or. y==7 .or. y==9) then
    	write(*,*) 'hon'
    else if (y==3) then
    	write(*,*) 'bon'
    else
    	write(*,*) 'pon'
	end if

    stop
end program sample

Measured memory_bytes: 2776
MOD = 10**9 + 7
N, M = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())

A.sort(reverse=1); B.sort(reverse=1)
A.append(0)
B.append(0)

i = j = 0
ans = 1
for k in range(N*M):
    m = N*M - k
    if A[i] < m > B[j]:
        ans = ans * (i*j - k) % MOD
    elif A[i] == m == B[j]:
        i += 1; j += 1
    elif A[i] == m:
        i += 1
        ans = ans * j % MOD
    elif B[j] == m:
        j += 1
        ans = ans * i % MOD
    else:
        ans = 0
print(ans)

Measured memory_bytes: 3188
//************************
//*  Date: 2018.8.3      *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int n,ans=0;
	cin>>n;
	repn(i,n)
	{
		int d=0;
		for(int j=1;j<=i;j++) if(i%j==0) d++;
		if(d==8&&i%2==1) ans++;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
int main()
{
  char c; cin>>c;
  if(c<=90)cout<<'A';
  else cout<<'a';
  return 0;
}

Measured memory_bytes: 3592
using System;

class Atcoder112
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split('/');
        int year = int.Parse(input[0]);
        int month = int.Parse(input[1]);
        int day = int.Parse(input[2]);

        if (year < 2019)
            Console.WriteLine("Heisei");
        else if (year == 2019 && month < 4)
            Console.WriteLine("Heisei");
        else if (year == 2019 && month == 4 && day <= 30)
            Console.WriteLine("Heisei");
        else
            Console.WriteLine("TBD");
    }
}

Measured memory_bytes: 11092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    //const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int a = cin.NextInt();
        int b = cin.NextInt();
        int c = cin.NextInt();

        Console.WriteLine(Math.Max(0, c - (a - b)));
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 200010;

int N;
int A[MN];

int main() {
	cin >> N;
	rep(i, N) cin >> A[i];

	bool ok = (A[0] == 0);

	rep(i, N-1) {
		if (A[i] < A[i+1] - 1) {
			ok = 0;
		}
	} 

	if (!ok) {
		puts("-1");
		return 0;
	}

	ll ret = 0;

	set<int> s;

	for (int i = N-1; i >= 0; --i) {
		s.insert(A[i] - i);
		while (s.size() && *s.begin() <= -i) {
			s.erase(s.begin());
		}
		ret += (int)s.size();
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = 3.141592653589793;

int main() {
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  h %= 12;
  double minites = h*60+m;
  double spdh = 360.0 / (12 * 60);
  double spdm = 360.0 / 60;
  double hw = spdh * minites;
  double mw = spdm * m;
  double diff = abs(hw-mw);
  double w = min(diff, 360-diff);

  double ans;
  if (w == 0) {
    ans = abs(a-b);
  } else {
    // cout << " cos: " << cos(w*pi/180.0) << endl;
    // cout << a*a + b*b - 2*a*b*cos(w*pi/180.0) << endl;;
    ans = sqrt(a*a + b*b - 2*a*b*cos(w*pi/180.0));
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 4160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int ans = 0, l = 0, r = n - 1;
		if(n == 1) {
			System.out.println(0);
			return;
		}
		for(; ; ) {
			if(s.charAt(l) == s.charAt(r)) {
				l++; r--;
				if(l >= r) {
					System.out.println(ans);
					return;
				}
			} else {
				if(s.charAt(l) != 'x' && s.charAt(r) != 'x') {
					System.out.println(-1);
					return;
				} else {
					if(s.charAt(l) == 'x') {
						l++;
						ans++;
						if(l == r) {
							System.out.println(ans);
							return;
						}
					}
					if(s.charAt(r) == 'x') {
						r--;
						ans++;
						if(l == r) {
							System.out.println(ans);
							return;
						}
					}
				}
			}
		}
	}
}


Measured memory_bytes: 25636
def main():
    N, K = list(map(int, input().split()))

    haved = [0] * N
    ans = 0
    for i in range(1, K+1, 1):
        d = int(input())
        ai = list(map(int, input().split()))
        for j in range(0, d, 1):
            x = ai[j] - 1
            haved[x] = haved[x] + 1

    for i in range(0, N, 1):
        if haved[i] == 0:
            ans = ans+1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

ll *min_data,*max_data,*add_data;
ll first_table[500000];
int N = 1;

void init(ll first_N){
	while(N < first_N)N *= 2;
}

void add(int left,int right,ll value,int node_id,int node_left,int node_right){

	if(right < node_left || left > node_right){
		return;
	}
	else if(left <= node_left && right >= node_right){

		add_data[node_id] += value;

		while(node_id != 0){

			node_id = (node_id-1)/2;
			min_data[node_id] = min(min_data[2*node_id+1]+add_data[2*node_id+1],min_data[2*node_id+2]+add_data[2*node_id+2]);
			max_data[node_id] = max(max_data[2*node_id+1]+add_data[2*node_id+1],max_data[2*node_id+2]+add_data[2*node_id+2]);
		}
	}else{

		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2+1,node_right);
	}
}

ll getMin(int left,int right,int node_id,int node_left,int node_right){
	if(right < node_left || left > node_right)return BIG_NUM;
	else if(left <= node_left && right >= node_right){
		return min_data[node_id]+add_data[node_id];

	}else{

		ll  left_min  = getMin(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		ll  right_min = getMin(left,right,2*node_id+2,(node_left+node_right)/2+1,node_right);
		return min(left_min,right_min)+add_data[node_id];
	}
}

ll getMax(int left,int right,int node_id,int node_left,int node_right){
	if(right < node_left || left > node_right)return -BIG_NUM;
	else if(left <= node_left && right >= node_right){
		return max_data[node_id]+add_data[node_id];

	}else{

		ll  left_max  = getMax(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		ll  right_max = getMax(left,right,2*node_id+2,(node_left+node_right)/2+1,node_right);
		return max(left_max,right_max)+add_data[node_id];
	}
}

int main(){

	int first_N,Q;
	scanf("%d %d",&first_N,&Q);

	init(first_N);

	min_data = new ll[2*N-1];
	max_data = new ll[2*N-1];
	add_data = new ll[2*N-1];

	for(ll i = 0; i <= 2*N-2; i++){
		min_data[i] = 0;
		max_data[i] = 0;
		add_data[i] = 0;
	}

	int command,left,right;
	ll value;

	for(int loop = 0; loop < Q; loop++){
		scanf("%d",&command);

		if(command == 0){
			scanf("%d %d %lld",&left,&right,&value);
			add(left,right,value,0,0,N-1);
		}else{
			scanf("%d %d",&left,&right);
			printf("%lld\n",getMin(left,right,0,0,N-1));
		}
	}

	return 0;
}



Measured memory_bytes: 9364
#include <iostream>
#include <stdio.h>
#include<math.h>
#include <vector>
#include <cctype>
#include <algorithm>

using namespace std;


int main()
{
	int N;
	cin >> N;
	long long a;
	vector<long long> aa;

	for (int i = 0; i < N; i++) {
		cin >> a;
		aa.push_back(a);
	}

	sort(aa.begin(), aa.end(), std::greater<long long>());

	size_t n_count = std::count(aa.begin(), aa.end(), 0);

	if (n_count > 0) {
		cout << 0 << endl;
	}
	else{
		long long sum = 1;
		for (int i = 0; i < N; i++) {
			if (aa[i] <= 1000000000000000000 / sum) {
				sum = sum * aa[i];
				if (i == N - 1) {
					cout << sum << endl;
				}
			}
			else {
				cout << -1 << endl;
				break;
			}

		}

	}
	return 0;

}

Measured memory_bytes: 4232
#ifndef ONLINE_JUDGE
#endif
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <string>
using namespace std;
const int maxn = 1e4;
bitset<maxn>b[maxn];

int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	#endif
	int r, c;
	while(scanf("%d%d", &r, &c) && r){
		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				int t;
				scanf("%d", &t);
				b[i][j] = t;
			}
		}
		int ans = 0;
		for(int i = 0; i < (1<<r); i++){
			for(int j = 0; j < r; j++){
				if(i & (1 << j)){
					b[j].flip();
				}
			}
			int sum = 0;
			for(int j = 0; j < c; j++){
				int t = 0;
				for(int k = 0; k < r; k++){
					if(b[k][j]) t++;
				}
				sum += min(t, r-t);
			}
			ans = max(ans, r*c-sum);
			for(int j = 0; j < r; j++){
				if(i & (1 << j)){
					b[j].flip();
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3072