akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const lint mod = 998244353;
lint emod(lint a) { return (a % mod + mod) % mod; }

lint powm(lint a, lint n) { return n ? powm(a * a % mod, n >> 1) * (n & 1 ? a : 1) % mod : 1; }

lint invm(lint a) {
  a %= mod;
  return a == 1 ? 1 : -mod / a * invm(mod % a) % mod;
}

unordered_map<lint, unordered_map<lint, lint> > _com;
lint com(lint n, lint r) {
  if (n < 0 or r < 0 or r > n) return 0;
  r = min(r, n - r);
  if (_com[n].count(r)) return _com[n][r];
  return _com[n][r] = r ? n * invm(r) % mod * com(n - 1, r - 1) % mod : 1;
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint k, n; cin >> k >> n;
  V<lint> res(k);
  for (lint i = 2; i < k + 1; i++) {
    if (i & 1) {
      lint m = (i - 1) / 2;
      for (lint j = 0; j < m + 1; j++) {
        res[i - 2] = (res[i - 2] + com(m, j) * powm(2, j) % mod * com(n + k - 2 * m - 1, k - 2 * m + j - 1)) % mod;
      }
    } else {
      lint m = (i - 2) / 2;
      for (lint j = 0; j < m + 1; j++) {
        res[i - 2] = (res[i - 2] + com(m, j) * powm(2, j) % mod * com(n + k - 2 * m - 2, k - 2 * m + j - 2)) % mod;
      }
      for (lint j = 0; j < m + 1; j++) {
        res[i - 2] = (res[i - 2] + com(m, j) * powm(2, j) % mod * com(n + k - 2 * m - 3, k - 2 * m + j - 2)) % mod;
      }
    }
  }
  lint i = k + 1;
  if (i & 1) {
    lint m = (i - 1) / 2;
    for (lint j = 1; j < m + 1; j++) {
      res[i - 2] = (res[i - 2] + com(m, j) * powm(2, j) % mod * com(n + k - 2 * m - 1, k - 2 * m + j - 1)) % mod;
    }
  } else {
    lint m = (i - 2) / 2;
    for (lint j = 1; j < m + 1; j++) {
      res[i - 2] = (res[i - 2] + com(m, j) * powm(2, j) % mod * com(n + k - 2 * m - 2, k - 2 * m + j - 2)) % mod;
    }
    for (lint j = 1; j < m + 1; j++) {
      res[i - 2] = (res[i - 2] + com(m, j) * powm(2, j) % mod * com(n + k - 2 * m - 3, k - 2 * m + j - 2)) % mod;
    }
  }
  for (int i = 0; i < k; i++) cout << emod(res[i]) << '\n';
  for (int i = k - 2; i >= 0; i--) cout << emod(res[i]) << '\n';
}


Measured memory_bytes: 76416
N = int(input())
A = sorted(list(map(int, input().split())))[::-1]
l1, l2 = 0, 0
flag = True
for i in range(N-1):
    if A[i] > A[i+1]:
        flag = True
        pass
    elif l1 == 0:
        l1 = A[i]
        flag = False
    elif l2 == 0 and flag:
        l2 = A[i]
        break
    else:
        flag = True

print(l1 * l2)


Measured memory_bytes: 14252
N, K, Q = list(map(int, input().split()))
A = []
for i in range(Q):
    A.append(int(input()) - 1)

counter = [0] * N
for a in A:
    counter[a] += 1

for i in range(N):
    if K - (Q - counter[i]) > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    vector<int> N(3);
    REP(i,3)N[i] = in();
    sort(ALL(N));
    bool ok = 1;
    REP(i,3){
        if(i <= 1){
            if(N[i] != 5)ok = 0;
        }else{
            if(N[i] != 7)ok = 0;
        }
    }
    cout << (ok ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cins(s);
    if(s.back()=='s')
        s+="es";
    else
        s+="s";
    cout<<s<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3660
#include <cstdio>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;

ll N, A, B, C, D;

int main()
{
  scanf( "%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D );
  rep( a, N-1 )
  {
    if( a*C-(N-1-a)*D <= B-A && B-A <= a*D-(N-1-a)*C )
    {
      puts( "YES" );

      return 0;
    }
  }

  puts( "NO" );

  return 0;
}

Measured memory_bytes: 128
import java.lang.StringBuilder

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}
    val A = readLine()!!.split(" ").map{it.toInt()}.sorted()

    val matches = arrayOf(100, 2, 5, 5, 4, 5, 6, 3, 7, 6)
    val dp = Array(M + 1) { Array(N + 1) {-1}  }
    val prev = Array(M + 1) { Array(N + 1) {Pair(-1, -1)}  }

    dp[0][0] = 0

    for (i in A.indices) {
        for (k in dp[i].indices) {
            dp[i + 1][k] = dp[i][k]
            prev[i + 1][k] = Pair(i, k)

            if (k >= matches[A[i]] && dp[i + 1][k] <= dp[i + 1][k - matches[A[i]]] + 1) {
                dp[i + 1][k] = dp[i + 1][k - matches[A[i]]] + 1
                prev[i + 1][k] = Pair(i + 1, k - matches[A[i]])
            }
        }
    }

    val res = StringBuilder()
    var p = Pair(A.size, N)

    while (p.first > 0) {
        val q = prev[p.first][p.second]
        if (p.first == q.first) {
            res.append(A[p.first - 1])
        }
        p = q
    }

    println(res.toString())
}


Measured memory_bytes: 42712
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define F(i, n) for(int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100000 + 47;

int A[MAX];

int main()
{
    //freopen("in.txt", "r", stdin);
    int n, c, k;
    scanf("%d", &n);
    FOR(i, 0, n)
        scanf("%d", A + i);
    sort(A, A + n);
    int bst = -1;
    LL sum = 0;
    FOR(i, 0, n-1)
    {
        sum += A[i];
        if (2 * sum < A[i+1])
            bst = i;
    }
    cout << n - bst - 1 << endl;
}



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


int main() {
    int n ;

    cin >> n ; 
    long long a,b,c;
    for(a = 1; a <= 3500; a++) {
        for(b = 1; b <= 3500; b++) {
            long long d = 4 * a * b - n * b - n * a;
            if (d != 0)
                if ((n * a * b) % d == 0) {
                    c = n * a * b / d;
                    if (c > 0) {
                        cout << a << " " << b << " " << c << endl;
                        return 0;
                    }
                }
        }
    }
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

int main() {
    int i, n = 0;
    int num[100] = {0};
    
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &num[i]);
    }
    
    for(i = i-1; i > 0; i--) {
        printf("%d ", num[i]);
    }
    printf("%d\n", num[i]);
    return 0;
}


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

int main() {

  string s;

  cin >> s;
  int len = s.length();
for(int i = 0;i < len ;i++){
    if(s.at(i) == ','){
        i++;
        cout << " ";
    }
    cout << s.at(i);
}



}

   

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

using namespace std;

int n, nums[100100], cnt[2][100100];

#define pii pair < int, int >

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

    for (int i = 0; i < n; i++) {
        scanf("%d", &nums[i]);
        cnt[i&1][nums[i]]++;
    }

    vector < pii > quant[2];
    for (int i = 1; i <= 100000; i++) {
        for (int j = 0; j < 2; j++) {
            if (cnt[j][i] > 0) {
                quant[j].push_back(pii(cnt[j][i], i));
            }
        }
    }
    sort(quant[0].begin(), quant[0].end());
    reverse(quant[0].begin(), quant[0].end());
    sort(quant[1].begin(), quant[1].end());
    reverse(quant[1].begin(), quant[1].end());

    if (quant[0].size() == 1 && quant[1].size() == 1 && quant[0][0].second == quant[1][0].second) {
        printf("%d\n", n/2);
    }
    else {
        int ans = 100000000;
        for (int i = 0; i < min((int)quant[0].size(), 5); i++)
            for (int j = 0; j < min((int)quant[1].size(), 5); j++)
                if (quant[0][i].second != quant[1][j].second) {
                    ans = min(ans, n - quant[0][i].first - quant[1][j].first);
                }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2428
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 int N =sc.nextInt();
         int K =sc.nextInt();
         int a = 0;
      for(int i=0; i<N; i++){
      int h =sc.nextInt();
        if(K<=h){
          a++;
        }
      }
        System.out.println(a);   
    }
}

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

#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second

using namespace std;
typedef pair<int,int>P;
typedef pair<P,P>P2;

struct Dinic{
  const int INF=1<<28;
  
  struct edge {
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<map<int,int> > M;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int sz):n(sz),G(n),M(n),level(n),iter(n){}
  
  void add_edge(int from,int to,int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.push(e.to);
        }
      }
    }
  }
  
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        int d = dfs(e.to,t,min(f,e.cap));
       if(d>0){
         e.cap-=d;
         G[e.to][e.rev].cap+=d;
         return d;
       }
      }
    }
    return 0;
  }
  
  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return fl;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,lim))>0){
       fl+=f;
       lim-=f;
      }
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }

  //cap==1 only
  bool back_edge(int s,int t,int from, int to){
    for(int i=0;i<(int)G[from].size();i++) {
      edge& e=G[from][i];
      if(e.to==to) {
        if(e.cap==0&&flow(from,to,1)==0) {
          flow(from,s,1);
          flow(t,to,1);
          return 1;
        }
      }
    }
    return 0;
  }
};

int n,m,S,T,s[3000],t[3000],d[3000],w[3000];
vector<int>v;
int di[100009];


int g[201][201];

int main(){
  r(i,200)r(j,200)g[i][j]=i==j?0:1e8;
  cin>>n>>m>>S>>T;S--;T--;
  r(i,m){
    cin>>s[i]>>t[i]>>d[i]>>w[i];
    s[i]--;
    t[i]--;
    g[s[i]][t[i]]=d[i];
  }
  r(o,n)r(i,n)r(j,n)g[i][j]=min(g[i][j],g[i][o]+g[o][j]);
  Dinic D(n);
  r(i,m){
    int flag=0;
    if(g[S][s[i]]+g[t[i]][T]+d[i]==g[S][T])flag++;
    if(flag)D.add_edge(s[i],t[i],w[i]);//cout<<1<<endl;
  }
  cout<<D.flow(S,T,1e9)<<endl;
}


Measured memory_bytes: 3444
S = str(input())
s = S[2:len(S)-1]
k = s.count("C")
def main(S):
    C_index = S.find("C")
    S = S[1:C_index]+S[C_index+1:]
    if S.lower() == S:
        return 1
    else:
        return 0

if S[0] != "A":
    print("WA")
elif k > 1 or k == 0:
    print("WA")
elif main(S) == 0:
    print("WA")
else:
    print("AC")


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

int main(void)
{
	double x, y;
	double a, b;
	double c;
	int ansx, ansy;
	
	x = y = 0;
	c = 0;
	while (1){
		scanf("%lf,%lf", &a, &b);
		if (a == 0 && b == 0){
			break;
		}
		
		x += cos((90 - c) * M_PI / 180) * a;
		y += sin((90 - c) * M_PI / 180) * a;
		
		c += b;
	}
	
	ansx = x;
	ansy = y;
	
	printf("%d\n", ansx);
	printf("%d\n", ansy);
	
	return (0);
}

Measured memory_bytes: 632
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const ll mod = 1e9 + 7;
const size_t SIZE = 2e5 + 10;
ll N;
V<ll> edges[SIZE], cnts[SIZE];
ll inv_max;
ll pow2[SIZE] = { 1 };
ll ans;

ll dfs(ll cur, ll pre) {
    ll ret = 1;
    cnts[cur].resize(edges[cur].size());
    ll pidx = -1;
    for(ll i = 0; i < edges[cur].size(); i++) {
        ll nxt = edges[cur][i];
        if(nxt == pre) {
            pidx = i;
            continue;
        }
        ll res = dfs(nxt, cur);
        cnts[cur][i] = res;
        ret += res;
    }
    if(pidx != -1) cnts[cur][pidx] = N - ret;
    ll num = pow2[N - 1] + mod - 1;
    for(ll i = 0; i < cnts[cur].size(); i++) {
        ll cnt = cnts[cur][i];
        ll rest = (N - 1) - cnt;
        num += mod - (pow2[cnt] - 1 + mod) % mod;
    }
    num %= mod;
    ans += num * inv_max % mod;
    return ret;
}

ll mod_pow(ll n, ll k) {
    ll ret = 1;
    ll cur = n;
    while(k) {
        if(k & 1) (ret *= cur) %= mod;
        cur = cur * cur % mod;
        k /= 2;
    }
    return ret;
}

ll mod_inv(ll n) { return mod_pow(n, mod - 2); }

int main() {
    cin >> N;
    for(ll i = 1; i < SIZE; i++) pow2[i] = 2 * pow2[i - 1] % mod;
    inv_max = mod_inv(pow2[N]);
    for(ll i = 0; i < N - 1; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    dfs(0, -1);
    cout << ans % mod << endl;
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    cin >> N;

    ll act[N][3];
    rep(i, N) {
        rep(j, 3) {
            cin >> act[i][j];
        }
    }

    vector< vector<ll> > dp(N+10, vector<ll>(3));

    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + act[i][k]);
            }
        }
    }

    ll res = 0;
    rep(j, 3) chmax(res, dp[N][j]);
    cout << res << endl;
}


Measured memory_bytes: 8064
import java.util.*;

public class Main{

    //int[][] memo;
    int[] square;

    void solve(){
        Scanner sc = new Scanner(System.in);

        //memo = new int[100000][5];
        //for(int i=0; i<=(2^15); i++) Arrays.fill(memo[i],-1);
        square = new int[(int)Math.sqrt(32768)+1];
        for(int i=0; i<square.length; i++) square[i] = i*i;

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            int ans = rec(n,0,(int)Math.sqrt(n));
            System.out.println(ans);
        }
    }

    int rec(int num, int cnt, int x){
        //if(memo[num][cnt]!=-1) return memo[num][cnt];
        if(num==0) return 1;
        if(cnt>=4) return 0;

        int res = 0;
        for(int i=x; i>=1; i--){
            if(num-square[i]>=0) {
                res += rec(num-square[i],cnt+1,i);
            }
        }

        return res;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

int main() {
  ios::sync_with_stdio(false);

  int N, M, L, R, X, Y;
  cin >> N >> M >> L >> R;
  X = L, Y = R;

  for (int i = 1; i < M; i++) {
    cin >> L >> R;
    X = max(X, L);
    Y = min(Y, R);
    if (Y < X || Y < L || R < X) {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << Y - X + 1 << endl;
}

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

long long mod = 1000000000+7;

long long power(long long a, long long b) {
  long long res = 1;
  while(b > 0) {
    if (b & 1) res = ((res%mod) * (a%mod)) % mod;
    a = ((a%mod) * (a%mod)) % mod;
    b >>= 1;
  }
  return (res%mod);
}

void solver() {
  long long n , k;
  cin >> n >> k;

  long long ans = 0;
  long long minS = 0;
  long long maxS = 0;
  for (int i = 0; i < k; i++) {
    minS += i;
  }
  for(int i = 0; i < k; i++) {
    maxS += n - i;
  }

  ans = (maxS - minS + 1)%mod;

  for (int i = k; i < n + 1; i++) {
    minS += i;
    maxS += n - i;
    ans = (ans + (maxS - minS + 1)%mod)%mod;
  }

  cout << ans << "\n";
}

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


Measured memory_bytes: 3592
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pf push_front
#define NMSL cout << "NMSL" << endl;
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x, y) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define debug3(x, y, z) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define debug4(a, b, c, d) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define fio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in128 __int128_t
using namespace std;
const int N = 2e5+10;
const int INF = 0x7f7f7f7f;
const double EPS = 1e-3;
const long double PI = 3.14159265358979323846;
signed main()
{
    fio
    string ss;
    cin>>ss;
    int len=ss.length();
    if(ss[len-1]=='s')ss+="es";
    else ss+='s';
    cout<<ss;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
#define Sart(a) sort(a, sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n, m, c;

	cin >> n >> m >> c;

	int b[m];
	int a;
	int ans = 0;
	int sum;

	int i;

	rep(i, m) cin >> b[i];

	while (n--) {
		sum = 0;

		rep(i, m) {
			cin >> a;

			sum += a * b[i];
		}

		if (0 < sum + c) ans++;
	}

	Out(ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

int N;

int main() {
	cin >> N;
	for (int a = 1; a <= 9; a++) {
		for (int b = 1; b <= 9; b++) {
			if (N == a * b) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x; cin>>x;
    cout<<x*x*x<<endl;
    return 0;
}



Measured memory_bytes: 3176
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>

using namespace std;

int main(){

	int num,E,from,to,table[10000],tmp;
	vector<int> V[10000];
	queue<int> Q;

	for(int i = 0; i < 10000; i++)table[i] = 0;

	scanf("%d %d",&num,&E);

	for(int i = 0; i < E; i++){
		scanf("%d %d",&from,&to);
		V[from].push_back(to);
		table[to]++;
	}

	for(int i = 0; i < num; i++){
		if(table[i] == 0){
			Q.push(i);
		}
	}

	while(!Q.empty()){
		tmp = Q.front();
		Q.pop();
		printf("%d\n",tmp);
		for(int i = 0; i < V[tmp].size(); i++){
			table[V[tmp][i]]--;
			if(table[V[tmp][i]] == 0){
				Q.push(V[tmp][i]);
			}
		}
	}

	return 0;
}



Measured memory_bytes: 3420
# -*- coding: utf-8 -*-

import queue
ans = [0]*1000001
done = [0]*100001
dict = {}
next = []
q = queue.Queue()

def nanka(before, now):
    #print(before,now)
    if ans[now-1] == 0:
        ans[now-1] = before
        done[now] = 1
        for tt in dict[now]:
            if done[tt] == 1:
                continue
            elif tt not in next:
                q.put([now,tt])

def main():
    N ,M  =  [int(i) for i in input().split()]

    road = []
    for i in range(M):
        a, b = [int(i) for i in input().split()]
        if a not in dict.keys():
            dict[a] = [b]
        else:
            dict[a].append(b)
        if b not in dict.keys():
            dict[b] = [a]
        else:
            dict[b].append(a)
    #road = sorted(road)

    mins = [1000000] * N

    for j in dict[1]:
        before = 1
        now = j
        nanka(1,j)
    while not q.empty():
        kk = q.get()
        nanka(kk[0],kk[1])
        
    if 0 in ans[1:N]:
        print("No")
    else:
        print("Yes")
        for i in ans[1:N]:
            print(i)
    #print(ans[1:N])


if __name__ == "__main__":
    main()


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

int main() {
    vector<vector<int>> A(3, vector<int>(3, 0));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }
    vector<vector<bool>> hole(3, vector<bool>(3, false));
    int N;
    cin >> N;
    vector<int> B(N);
    for (int i = 0; i < N; i++) cin >> B[i];
    
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < N; k++) {
                if (A[i][j] == B[k]) hole[i][j] = true;
            }
        }
    }
    bool bingo = false;
    for (int i = 0; i < 3; i++) {
        if (hole[i][0] && hole[i][1] && hole[i][2]) bingo = true;
        if (hole[0][i] && hole[1][i] && hole[2][i]) bingo = true;
    }
    if (hole[0][0] && hole[1][1] && hole[2][2]) bingo = true;
    if (hole[0][2] && hole[1][1] && hole[2][0]) bingo = true;
    if (bingo) cout << "Yes\n";
    else cout<< "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  
  sort(h.begin(),h.end());
  
  int ans = 1e9;
  for (int i = 0; i < N - K + 1; i++) ans = min(ans,h[K-1+i]-h[i]);
  
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

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

    int cnt = 0;
    REP(i, 10) {
        int ipos = s.find(to_string(i));
        if (ipos == -1) continue;
        REP(j, 10) {
            int jpos = s.find(to_string(j), ipos+1);
            if (jpos == -1) continue;

            V<bool> found(10, false);
            REP2(k, jpos+1, s.size()) {
                if (!found[s[k] - '0']) {
                    found[s[k] - '0'] = true;
                    cnt++;
                }
            }
        }
    }
    std::cout << cnt << '\n';

    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a > b)
    cout << "a > b" << endl;
  else if (a < b)
    cout << "a < b" << endl;
  else
    cout << "a == b" << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

struct kraw
{
    int a, c;
};

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector< vector<kraw> > G(n);
    for (int i = 0; i < m; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        G[a].push_back({b, c});
        G[b].push_back({a, -c});
    }
    vector<bool> odw(n, false);
    stack<int> S;
    vector<int> odl(n, 0);
    for (int i = 0; i < n; ++i)
    {
        if (!odw[i])
        {
            odw[i] = true;
            S.push(i);
            vector<int> wie;
            while (!S.empty())
            {
                int akt = S.top();
                S.pop();
                wie.push_back(akt);
                for (int j = 0; j < G[akt].size(); ++j)
                {
                    if (!odw[G[akt][j].a])
                    {
                        odw[G[akt][j].a] = true;
                        odl[G[akt][j].a] = odl[akt] + G[akt][j].c;
                        S.push(G[akt][j].a);
                    }
                }
            }
            for (int j = 0; j < wie.size(); ++j)
            {
                int a = wie[j];
                for (int k = 0; k < G[a].size(); ++k)
                {
                    int b = G[a][k].a, c = G[a][k].c;
                    if (odl[b] - odl[a] != c)
                    {
                        cout << "No";
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 9980
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		int count = 0;
		for(int i=0; i<n-1; i++){
			if(s.charAt(i) == s.charAt(i+1)){
				count++;
			}
		}
		int ans = Math.min(count+k*2, n-1);
		System.out.println(ans);
	}
}


Measured memory_bytes: 25904
n,m = map(int,input().split())
s = []
for i in range(m):
  s.append(list(map(int,input().split()))[1:])
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
  lst = [0]*(m)
  for j in range(1,n+1):
    w = ((i >> (j-1)) & 1)
    for k in range(m):
      if j*w in s[k]:
        lst[k] += 1
  flag = 1
  for j in range(m):
    if lst[j]%2 != p[j]:
      flag = 0
  if flag == 1:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int n; ll a, b, c;
vector<string> s;
vector<string> ans;
bool found = false;
void dfs(int id) {
  if (id == n) {
    found = true;
    return;
  }
  if (s[id] == "AB") {
    a++; b--; ans[id] = "A"; if (b >= 0)dfs(id + 1);
    if (found)return; a--; b++;
    b++; a--; ans[id] = "B"; if (a >= 0)dfs(id + 1);
    if (found)return; b--; a++;
  }
  else if (s[id] == "BC") {
    b++; c--; ans[id] = "B"; if (c >= 0)dfs(id + 1);
    if (found)return; b--; c++;
    c++; b--; ans[id] = "C"; if (b >= 0)dfs(id + 1);
    if (found)return; c--; b++;
  }
  else if (s[id] == "AC") {
    c++; a--; ans[id] = "C"; if (a >= 0)dfs(id + 1);
    if (found)return; c--; a++;
    a++; c--; ans[id] = "A"; if (c >= 0)dfs(id + 1);
    if (found)return; a--; c++;
  }
}

int main() {
  cin >> n >> a >> b >> c;
  s.resize(n); ans.resize(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  dfs(0);
  if (found) {
    cout << "Yes" << endl;
    for (string ch : ans)cout << ch << endl;
  } else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 12760
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int arr[]=new int[n];
		int max=(int)-1e9;
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		int mid=n-1;
		while(mid>=1)
		{
			if(arr[mid]<arr[mid-1])
			{
				arr[mid-1]--;
			}
			mid--;
		}
//		System.out.println(Arrays.toString(arr));
		mid=0;
		while(mid<=arr.length-2)
		{
			if(arr[mid]>arr[mid+1])
			{
				System.out.println("No");
				System.exit(0);
			}
			mid++;
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 59324
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
int main(void)
{
   int ans = INF;
   int n,T;
   cin>>n>>T;
   while(n--){
      int a,b;
      cin>>a>>b;
      if(b <= T){
         ans = min(ans,a);
      }
   }
   if(ans == INF)
       cout<<"TLE"<<endl;
   else
      cout<<ans<<endl;


   return 0;
}

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

using namespace std;

int main()
{
	int w, h, n;
	cin >> w >> h >> n;
	int x0 = 0, x1 = w, y0 = 0, y1 = h;
	for (int i = 0; i < n; i++)
	{
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1)
			x0 = max(x0, x);
		else if (a == 2)
			x1 = min(x1, x);
		else if (a == 3)
			y0 = max(y0, y);
		else
			y1 = min(y1, y);
	}
	cout << max(0, x1 - x0) * max(0, y1 - y0) << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

N, W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(N)]

max_value, max_weight = 0, 0
for w, v in wv:
    max_weight += w
    max_value += v
wv.sort()

dp = np.ones(max_value + 1, dtype=int) * max_weight

for w, v in wv:
    np.minimum(dp[v:] - w, dp[:-v], out=dp[:-v])

ans = 0
for i in range(max_value + 1):
    if dp[i] <= W:
        ans = i

print(ans)


Measured memory_bytes: 21272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll n;
vector<vector<ll>> g, wf;
vector<ll> color;

bool dfs(int v, int c) {
    color[v] = c;
    rep(i, sz(g[v])) {
        if (color[g[v][i]] == c) return false;
        if ((color[g[v][i]] == 0) && (!dfs(g[v][i], -c))) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    const ll inf = numeric_limits<ll>::max() / 2 - 1;
    cin >> n;
    g.resize(n);
    color.resize(n, 0);
    wf.resize(n, vector<ll>(n, inf));
    rep(i, n) {
        string s;
        cin >> s;
        wf[i][i] = 0;
        rep(ii, n) {
            if (s[ii] == '1') {
                g[i].push_back(ii);
            }
            ll v = s[ii] - '0';
            if (v == 1) wf[i][ii] = 1;
        }
    }
    if (!dfs(0, 1)) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, n) {
        rep(ii, n) {
            rep(iii, n) {
                wf[ii][iii] = min(wf[ii][iii], wf[ii][i] + wf[i][iii]);
            }
        }
    }
    ll ans = 0;
    rep(i, n) {
        rep(ii, n) {
            if (wf[i][ii] == inf) continue;
            ans = max(ans, wf[i][ii]);
        }
    }
    cout << (ans + 1) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int t = 1;
	while(1)
	{
		if(t == 1)
		{
			c -= b;
			if(c <= 0)
			{
				cout << "Yes\n";
				return 0;
			}
		}
		else
		{
			a -= d;
			if(a <= 0)
			{
				cout << "No\n";
				return 0;
			}
		}
		t = 1 - t;
	}
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  map<string,int> map;
  vector<string> S(N);
  for (int i=0;i<N;i++){
    cin>>S.at(i);
  }
  
  for(int i=0;i<N;i++){
    if(map.count(S.at(i))){
      map.at(S.at(i))++;
    }
    else{
      map[S.at(i)]=1;
    }
  }
  
  int max=0;
  for (auto p : map){
    auto k = p.first;
    auto v = p.second;
    if(max<v){
      max=v;
    }
  }
  vector<string> out;
  for (auto p : map){
    auto k=p.first;
    auto v=p.second;
    if(v==max){
      out.push_back(k);
    }
  }
  sort(out.begin(),out.end());
  for(int i=0;i<out.size();i++){
    cout<<out.at(i)<<endl;
  }
}

Measured memory_bytes: 28916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main(){
  int N, ans = 0 ;
  cin >> N ;
  vector<int> A(N);
  vector<int> B(N-1);
  rep (i,N-1) cin >> B.at(i) ;
  A.at(0) = B.at(0) ; 
  A.at(N-1) = B.at(N-2);
  for(int i = 1; i< N-1 ; i++) A.at(i) = min( B.at(i),B.at(i-1) ) ;
  rep (i,N) ans += A.at(i) ;
  //rep (i,N) cout << A.at(i)<< ' ' ;
  //cout << endl ;
  cout << ans << endl ;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stdint.h>

const int64_t MOD=1e9+7;

int64_t as[100005];
int64_t f[100005];

int main(){
  int64_t N;
  scanf("%ld",&N);
  for(int64_t i=0;i<N;i++){
    scanf("%ld",&as[i]);
  }
  f[N]=1;
  for(int64_t i=N;i>0;i--){
    f[i-1]=f[i]*i%MOD;
  }
  int fact=1;
  for(int64_t i=1;i<=N;i++){
    f[i]=f[i]*fact%MOD;
    fact=fact*i%MOD;
  }
  int64_t scale=0;
  for(int64_t i=1;i<=N;i++){
    //printf("f[%ld]=%ld\n",i,f[i]);
    scale=(scale+f[i])%MOD;
  }
  int64_t ans=0;
  for(int64_t i=0;i<N;i++){
    //printf("+%ld*%ld\n",as[i],scale);
    ans=(ans+as[i]*scale)%MOD;
    scale=(scale+MOD-f[N-i]+f[i+2])%MOD;
  }
  printf("%ld\n",ans);
  return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    if(n <= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

ll a[400000];
signed main() {
	ll n; cin >> n;
	rep(i, 3 * n) {
		scanf("%lld", &a[i]);
	}
	sort(a, a + 3 * n);
	ll sum = 0;
	for (int i = 3 * n - 2, j = 0; j < n; i -= 2, j++)sum += a[i];
	printf("%lld\n", sum);
}

Measured memory_bytes: 2560
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int x;
	cin >> x;
	if (x == 0) cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    // n枚、Y円
    int n, Y;
    scanf("%d%d", &n, &Y);

    // 10000円札x枚、5000円札y枚、1000円札z枚
    // x + y + z = N
    // 10000x + 5000y + 1000z = Y
    // 3重ループだとTLEするので
    // z = N - x - y => 10000x + 5000y + 1000(N - x - y) = Y

    rep(x, n + 1) {
        rep(y, n + 1) {
            int z = n - (x + y);
            if (10000LL * x + 5000LL * y + 1000LL * z == Y && z >= 0) {
                printf("%d %d %d\n", x, y, z);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 3828
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional;

void main() {
  auto input = readln.split.to!(int[]);
  auto N = input[0], K = input[1], Q = input[2];
  auto A = new int[Q];
  foreach(i; 0..Q) {
    A[i] = readln.split[0].to!int - 1;
  }

  auto ps = new int[N];
  ps[] = K;

  foreach(a; A) {
    ps[a]++;
  }

  foreach(ref p; ps) {
    p-=Q;
  }

  foreach(p; ps) {
    if(p > 0) {
      writeln("Yes");
    } else {
      writeln("No");
    }
  }
}


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

int N, M, a;
long long sum;
priority_queue<int> pq;

int main() {
    cin >> N >> M;

    for (int i = 0;i < N; i++) {
        cin >> a;
        pq.push(a);
        sum += a;
    }

    for (int i = 0;i < M; i++) {
    	a = pq.top(); pq.pop();
    	sum -= (a * 0.5);
    	pq.push(a/2);
    }

    cout << sum << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
const ll mod = 1000000007;//998244353;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll t1, t2; cin >> t1 >> t2;
    ll a1, a2; cin >> a1 >> a2;
    ll b1, b2; cin >> b1 >> b2;
    ll p, q; p = (a1-b1)*t1; q = (a2-b2)*t2;
    ll ans;
    if (p>0){
        p *= -1;
        q *= -1;
    }
    if (p+q<0){
        cout << 0 << endl;
    }
    else if (p+q==0){
        cout << "infinity" << endl;
    }
    else {
        ll s = (-p)/(p+q);
        ll t = (-p)%(p+q);
        if (t != 0)
            cout << s*2+1 << endl;
        else 
            cout << s*2 << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
bool sortFunc (int a, int b) {
	return (a > b);
}

int main (int argc, char**argv) { 
	using namespace std;
	int reader;
	vector<int> vec(10, 0);
	for(int i = 0; i < 10; ++i) {
		fscanf(stdin, "%d", &reader);
		vec[i] = reader;
	}
	sort(vec.begin(), vec.end(), sortFunc);
	for (int i=0; i<3; i++) {
		printf("%d\n", vec[i]);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <cfloat>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    }
    else {
        return d < 0? -1 : 1;
    }
}

struct Vector {
    double x, y;
    Vector(double x = 0, double  y = 0):x(x), y(y) {
    }
     
    bool operator<(const Vector& other) const {
        return dcmp(x - other.x) < 0 || (dcmp(x - other.x) == 0 && dcmp(y - other.y) < 0);
    }
};

typedef Vector Point;

double dist(const Point& a, const Point& b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

bool cmpY(const Point& a,  const Point& b) {
    return dcmp(a.y - b.y) < 0 || (dcmp(a.y - b.y) == 0 && dcmp(a.x - b.x) < 0);
}

double combine(vector<Point>& p, int l, int m, int r, double leftSmall, double rightSmall) {
    double d = min(leftSmall, rightSmall);
    double x = (p.at(m).x + p.at(m + 1).x)/2;
    
    vector<Point> strip;
        
    for (int i = m; i >= l && dcmp(x - p.at(i).x - d) <= 0; i--) {
        strip.push_back(p.at(i));
    }
    for (int j = m + 1; j <= r &&dcmp(p.at(j).x - x - d) <= 0; j++) {
        strip.push_back(p.at(j));
    } 
    
    sort(strip.begin(), strip.end(), cmpY);
    
    int size = strip.size();
    
    for (int i = 0; i < size; i++) {
        for (int j = i+1; j < size && dcmp(strip[j].y - strip[i].y - d) < 0; j++) {
            if (dcmp(dist(strip[i], strip[j]) - d) < 0) {
                d = dist(strip[i], strip[j]);
            }
        }
    }
    return d;
}

//naive n^2 method
double combine1(vector<Point>& p, int l, int m, int r, double leftSmall, double rightSmall) {
    double d = min(leftSmall, rightSmall);
    double x = (p.at(m).x + p.at(m + 1).x)/2;
    
    double best = DBL_MAX;
    
    for (int i = m; i >= l && dcmp(x - p.at(i).x - d) <= 0; i--) {
        for (int j = m + 1; j <= r &&dcmp(p.at(j).x - x - d) <= 0; j++) {
            best = min(best, dist(p.at(i), p.at(j)));
        } 
    }
    return min(best, d);
}


double solve(vector<Point>& p, int l, int r) {
    if (l >= r) {
        return DBL_MAX;
    }
    int m = (l + r) / 2;
    
    double leftSmall = solve(p, l, m);
    double rightSmall = solve(p, m + 1, r);
    
    return combine(p, l, m, r, leftSmall, rightSmall);
}

int main() {
    int n; 
    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    
    sort(p.begin(), p.end());
    
    double ans = solve(p, 0, n - 1);
    
    cout << fixed << setprecision(8) << ans << endl;
    
    return 0;
}

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

map<long long, long long> prime_factors(long long n) {
  map<long long, long long> res;
  if (n == 1) {
    res[n] = 1;
    return res;
  }
  for (long long i = 2, _n = n; i * i <= _n + 1; ++i) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

int main() {
  long long N, P;
  cin >> N >> P;
  map<long long, long long> pf = prime_factors(P);

  long long res = 1;

  for (map<long long, long long>::iterator it = pf.begin(), end = pf.end();
       it != end; ++it) {
    it->second -= N;
    while (it->second >= 0) {
      res *= it->first;
      it->second -= N;
    }
  }

  cout << res << endl;

  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int>h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  vector<int>a(n);
  for(int i = 0; i < n; i++){
    if(i == 0)a[i] = 0;
    if(i == 1)a[i] = abs(h[i] - h[i-1]);
    if(i != 0 && i != 1)a[i] = min(abs(h[i] - h[i-1]) + a[i-1], abs(h[i] - h[i-2]) + a[i-2]);
  }
  cout << a[n-1] << endl;
}


Measured memory_bytes: 1024
s = input()
h = 1
if len(s)%2==0:
    for i in range(len(s)):
        if i%2==0:
            if s[i]!="h":
                h = 0
                break
        else:
            if s[i]!="i":
                h = 0
                break
else:
    h = 0
if h:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060