akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

class UnionFind{
    vector<int> par;
    int all = 0;
    vector<int> siz;
    int treenum;

    public:UnionFind(int N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par.eb(i);
        for(int i = 0; i < N; i++) siz.eb(1);
        all = N;
        treenum = N;
    }

    public:int root(int x){
        if(par[x]==x) return x;
        else{
            par[x]=root(par[x]);
            return par[x];
        }
    }

    public:bool same(int x, int y){
        return root(x)==root(y);
    }

    public:void unite(int x, int y){
        if(same(x,y)) return;
        else{
            int rx=root(x);
            int ry=root(y);
            par[ry]=rx;
            siz[rx]=siz[rx]+siz[ry];
            siz[ry]=siz[rx];
            treenum--;
            return;
        }
    }

    public:int size(int x){
        siz[x]=siz[root(x)];
        return siz[x];
    }

    public:void sizall(){
        rep(i,all){
            siz[i] = siz[root(i)];
        }
    }

    public:int treenumber(){
        return treenum;
    }

    public:void add(){
        par.eb(all);
        siz.eb(1);
        all++;
        treenum++;
    }

    public:void del(int x){
        //xを木から外して単一ノードの木に分離する
        //子の検索にO(n)かける. UF木の弱点なので使用は推奨されない
        //根であれば繋ぎ直し、素集合としてみなさない.
        bool isroot=false;
        //あるノードの根であるかどうか.
        rep(i,all){
            if(root(i)==x) isroot=true;
        }
        if(!isroot){
            rep(i,all){
                if(par[i]==x){
                    par[i]=par[x];
                }
            }
            par[x]=x;
            return;
        }

        if(isroot){
            sizall();
            if(size(x)==1) return;
            rep(i,all){
                if(par[i]==x){
                    treenum++;
                    par[i]=i;
                }
            }
            return;
        }

    }

};

void solve(){

    int n,m;
    cin >> n >> m;
    int ans = 0;
    int a[60];
    int b[60];
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    rep(i,m){
        UnionFind uf(n);
        rep(j,m){
            if(i!=j) uf.unite(a[j],b[j]);
        }
        if(!uf.same(a[i],b[i])) ans++;
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace	std;

int main(){
  int a,b,answ;
  char op;

  while(true){
    cin>>a>>op>>b;
    if(op=='?')break;
    switch(op){
    case '+':
      answ=a+b;   
      break;
    case '-':
      answ=a-b;
      break;
    case '*':
      answ=a*b;
      break;
    case '/':
      answ=a/b;
      break;
    }
    printf("%d\n",answ);
  }
  return 0;
}


Measured memory_bytes: 3216
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = ReadLongs();
            var N = inputs[0];
            var H = inputs[1];
            var A = new long[N];
            var B = new long[N];
            for (int i = 0; i < N; i++)
            {
                inputs = ReadLongs();
                A[i] = inputs[0];
                B[i] = inputs[1];
            }

            var aMax = A.Max();
            var count = 0L;
            foreach (var b in B.Where(x => x > aMax).OrderByDescending(x => x))
            {
                count++;
                H -= b;
                if (H <= 0)
                {
                    return count;
                }
            }

            var aCount = H / aMax;
            count += aCount;
            H -= aCount * aMax;

            // だめおし
            if (H > 0)
            {
                count++;
                H -= aMax;
            }

            return count;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a, b, c;
  cin >> n;
  rep(i, n) {
    cin >> a >> b >> c;
    ll cnt = 0;
    while(a > 0 && b > 0 && c > 0) {
      a--, b--, c--;
      cnt++;
    }
    while(a >= 2 & b > 0) {
      a -= 2, b--;
      cnt++;
    }
    while(a >= 3) {
      a -= 3;
      cnt++;
    }
    cout << cnt << endl;
  }
	return 0;
}


Measured memory_bytes: 3136
#include <stdio.h>

int main(){
  int n;
  int m = 10000;
  scanf("%d",&n);
  int prime[m],prime_mod5[n];
  prime[0] = 2;
  prime_mod5[0] = 2;
  int flag;
  int count = 1;
  for(int i = 1; i < m; ++i){
	if(count == n) break;
	for(int j = prime[i-1] + 1; j < 55555; ++j){
      flag = 0;
	  for(int k = 0; k < i; ++k){
		//printf("%d %d %d\n",i,j,prime[k]);
		if(j % prime[k] == 0) flag = 1;
		if(flag == 1) break;
	  }
	  if(flag == 0){
		prime[i] = j;
		if(prime[i] % 5 == 1){
		  prime_mod5[count] = prime[i];
		  count++;
		}
		break;
	  }
	}
  }
  for(int i = 0; i < n - 1; ++i){
	printf("%d ",prime_mod5[i]);
  }
  printf("%d\n",prime_mod5[n-1]);
  return 0;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define dame "UNRESTORABLE"
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;

int main(){
	string s,t;
	cin >> s >> t;
	bool ok = false;
	for(int i = (int)s.size()-1; i >= 0; i--){
		if((int)s.size() - i >= (int)t.size() && ok == false){
			string check = s.substr(i, (int)t.size());
			bool change = true;
			for(int i = 0; i < (int)check.size(); i++){
				if(check[i] != '?' && check[i] != t[i])
					change = false;
			}
			if(change)
				s.replace(i, (int)t.size(), t), ok++;
		}
	}
	for(int i = 0; i < (int)s.size(); i++)
		if(s[i] == '?')
			s[i] = 'a';

	if(ok)
		cout << s << endl;
	else
		cout << dame << endl;

	return 0;
}

Measured memory_bytes: 256
n, l = map(int, input().split())

start, end = l, n+l - 1
if start*end < 0:
	print(sum(i for i in range(start, end+1)))
elif start < 0:
	print(sum(i for i in range(start, end)))
else:
	print(sum(i for i in range(start+1, end+1)))

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

int main() {
  char s;
  bool judge=true;
  cin >> s;
    switch(s){  
      case'a':break;
      case'i':break;
        case'u':break;
        case'e':break;
        case'o':break;
      default:judge=false;
    }
    if(judge ==true)
      cout << "vowel" << endl;
  else cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int x, y;
	cin >> x >> y;
	cout << x + (y / 2) << endl;
}

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


int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (auto& e : vec) {
		cin >> e;
	}
	for (int i = n - 1; i >= 0; i -= 2) {
		if (i != n - 1) cout << " ";
		cout << vec.at(i);
	}
	int i = n % 2 == 1 ? 1 : 0;

	for (; i < n; i += 2) {
		cout << " ";
		cout << vec.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 2944
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int n,d,x,a;
  cin >> n >> d >> x;
  int ans = x + n; // 残りのx個と初日に必ず食べるアメの個数を加算
  d--;//残りの日数
  for(int i = 0; i < n; i++){
    cin >> a;
    ans += d / a; //残りの日数で食べる個数を加算
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

class StronglyConnectedComponent {
public:
  const ll N;
  vector<vector<ll>> E, R;
  vector<ll> component;

  StronglyConnectedComponent(ll N): N(N), E(N), R(N), component(N) {}

  void add_edge(ll u, ll v) {
    E[u].push_back(v);
    R[v].push_back(u);
  }

  ll discomposit() {
    vector<ll> vs;
    vector<bool> used1(N, false);
    REP(i, 0, N) if(!used1[i]) dfs(i, vs, used1);

    vector<bool> used2(N, false);
    ll k = 0;
    for(ll i = vs.size() - 1; i >= 0; i--) if(!used2[vs[i]]) rdfs(vs[i], k++, used2);
    return k;
  }

private:
  void dfs(ll v, vector<ll> &vs, vector<bool> &used) {
    used[v] = true;
    REP(i, 0, E[v].size()) if(!used[E[v][i]]) dfs(E[v][i], vs, used);
    vs.push_back(v);
  }

  void rdfs(ll v, ll k, vector<bool> &used) {
    used[v] = true;
    component[v] = k;
    REP(i, 0, R[v].size()) if(!used[R[v][i]]) rdfs(R[v][i], k, used);
  }
};

const ll MOD = 1000000007;

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<ll> S(M), D(M);
  StronglyConnectedComponent scc(N);
  REP(i, 0, M) {
    cin >> S[i] >> D[i]; S[i]--; D[i]--;
    scc.add_edge(S[i], D[i]);
  }

  ll n = scc.discomposit();
  vector<pll> edge;
  REP(i, 0, M) edge.push_back(pll(scc.component[S[i]], scc.component[D[i]]));
  sort(edge.begin(), edge.end());
  edge.erase(unique(edge.begin(), edge.end()), edge.end());

  vector<vector<ll>> E(n), R(n);
  REP(i, 0, edge.size()) {
    ll s = edge[i].first, d = edge[i].second;
    if(s == d) continue;
    E[s].push_back(d);
    R[d].push_back(s);
  }

  vector<ll> cnt(n);
  REP(i, 0, n) cnt[i] = R[i].size();

  stack<ll> stk;
  REP(i, 0, n) if(cnt[i] == 0) stk.push(i);

  vector<ll> dp(n, 0);
  while(stk.size()) {
    ll v = stk.top();
    stk.pop();

    dp[v] = 1;
    REP(i, 0, R[v].size()) (dp[v] *= dp[R[v][i]]) %= MOD;
    (dp[v] += 1) %= MOD;

    REP(i, 0, E[v].size()) if(--cnt[E[v][i]] == 0) stk.push(E[v][i]);
  }

  ll ans = 1;
  REP(i, 0, n) if(E[i].size() == 0) (ans *= dp[i]) %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 3360
def main():
    import sys,heapq
    input = sys.stdin.buffer.readline

    h,w = map(int,input().split())
    cx,cy = map(int,input().split())
    dx,dy = map(int,input().split())
    cx -= 1
    cy -= 1
    dx -= 1
    dy -= 1

    start = cx*w + cy
    goal = dx*w + dy


    s = []
    for _ in range(h):
        s.append(list(input()))

    dg = 10**7


    edge = [[] for _ in range(h*w)]
    for xy in range(h*w):
        x,y = divmod(xy,w)
        if s[x][y] == 35:
            continue
        for i in range(-2,3):
            for j in range(-2,3):
                if i == 0 and j == 0:
                    continue
                if 0 <= x+i < h and 0 <= y+j < w and s[x+i][y+j] == 46:
                    #上下左右/ワープ
                    if (i == 0 and abs(j) == 1) or (j == 0 and abs(i) == 1):
                        edge[xy].append( (x+i)*w + y+j )
                    else:
                        edge[xy].append(dg + (x+i)*w + y+j )

    d = [10**6]*(h*w)
    d[start] = 0

    tank = []

    for e in edge[start]:
        heapq.heappush(tank,e)


    while tank:
        now = heapq.heappop(tank)
        cost,xy = divmod(now,dg)
        if d[xy] != 10**6:
            continue
        d[xy] = cost
        if xy == goal:
            break
        for nxt in edge[xy]:
            if nxt >= dg:
                if d[nxt-dg] == 10**6:
                    heapq.heappush(tank,(cost+1)*dg + nxt-dg)
            else:
                if d[nxt] == 10**6:
                    heapq.heappush(tank,cost*dg + nxt)

    if d[goal] == 10**6:
        print(-1)
    else:
        print(d[goal])

if __name__ == '__main__':
    main()

Measured memory_bytes: 217968
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 5e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pll             pair<ll,ll>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll lcm(ll a, ll b) { ll r=((a*b)/gcd(a,b)); return r; }
ll isOnBit(ll n, ll b) {return (n >> b) & 1;          }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll modinv(ll n) { ll ans = powm(n,mod-2); return ans; }
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll digsum(ll n)    { ll cnt=0; while(n){cnt+=(n%10); n/=10;} return cnt;}
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}

int main()
{
    fast
    ll n,m;
    cin>>n>>m;
    
    ll a;
    bool mark[n+1]={0};
    forn(i,0,m)
    {
        cin>>a;
        mark[a]=1;
    }

    ll dp[n+1]={0};
    dp[0]=1;
    dp[1] = !mark[1];
    //cout<<dp[1]<<" "<<dp[2]<<" ";
    forn(i,2,n+1)
    {
        if(mark[i])
            dp[i]=0;
        else
            dp[i]=add(dp[i-1],dp[i-2]);
        //cout<<dp[i]<<" ";
    }

    cout<<dp[n];

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b;
    cin >> a >> b;
    if(a<b)swap(a,b);
    if((a*b)%2==0) cout << "No" << endl;
    if((a*b)%2==1) cout << "Yes" << endl;
}


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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

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

	int n, k;
	sf("%d %d", &n, &k);
	bool ans[n + 7] = {0};
	while (k--) {
		int d;
		sf("%d", &d);
		while (d--) {
			int x;
			sf("%d", &x);
			ans[x] = true;
		}
	}

	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (ans[i]) ++cnt;
	}

	printf("%d", n - cnt);

	return 0;
}


Measured memory_bytes: 3824
#include<iostream>
#include<queue>

using namespace std;

static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s);

int main () {
    int u, k, v;

    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while (!q.empty()) {
        u = q.front(); q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}


Measured memory_bytes: 3140
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    long n;
    long a,b;
    string sb;
    cin >> n;
    long ans=20000000000;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            a=i;
            b=n/i;
            sb=to_string(b);
        }
        if((char)(sb).size()<ans){
            ans=(char)(sb).size();
    }
    }
    cout << ans <<  endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
vector<ll>vec(100);
ll get(ll i,ll n){
	if(i==0){
		if(vec[i]<vec[i+1]){
			return 0;
		}
	}
	if(i==n-1){
		return -1;
	}
	ll j;
	for(j=i;j<n;j++){
		if(vec[j]<=vec[j+1] && vec[j]<=vec[j-1]){
			return j;
		}
	}
	return -1;
}
ll get2(ll i,ll n){
	if(i==n-1){
		if(vec[i]>vec[i-1]){
			return n-1;
		}
	}
	if(i==0){
		return -1;
	}
	ll j;
	for(j=i;j<n;j++){
		if(vec[j]>=vec[j+1] && vec[j]>=vec[j-1]){
			return j;
		}
	}
	return -1;
}
void solve(){
	ll n,i,j,k;
	in(n);
	
	nfl(i,n){
		cin>>vec[i];
	}
	ll profit=0;
	ll money=1000;
	i=0;
	while(i<n){

		ll buy=get(i,n);

		ll sell=get2(buy+1,n);


		// cout<<buy<<sp<<sell<<endl;
		if(sell!=-1 && buy!=-1){
			ll nums=money/vec[buy];
			money%=vec[buy];
			money+=vec[sell]*nums;
			i=sell;
		}
		else{
			i++;
		}

	}

	cout<<money<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M, 0);
    for (auto &&b: B){
        cin >> b;
    }

    vector<vector<int>> A(N, vector<int>(M,0));
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < M; ++j){
            cin >> A[i][j];
        }
    }

    int cnt = 0;

    for (int i = 0; i < N; ++i){
        int sum = C;
        for (int j = 0; j < M; ++j){
            sum += A[i][j] * B[j];
        }

        if( sum > 0)
            cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, m;
  cin >> n >> m;
  priority_queue<pair<ll, ll>> pq;
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin>>a;
    pq.emplace(a,1);
  }
  for(int i=0;i<m;++i)
  {
    int b,c;
    cin>>b>>c;
    pq.emplace(c,b);
  }

  ll ans=0, cnt=0;
  while(!pq.empty())
  {
    pair<ll,ll>p=pq.top();
    pq.pop();
    if(cnt==n)break;
    if(cnt+p.second>n)
    {
      ans+=p.first*(n-cnt);
      cnt=n;
    } else {
      ans+=p.first*p.second;
      cnt+=p.second;
    }
  }
  cout<<ans<<endl;

  return 0;
}


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

static const int MAX = 1001;
bool isPrime[MAX];
 
void aryPrime() {
  for (int i = 0; i < MAX; i++) isPrime[i] = true;
  isPrime[0] = false;
  isPrime[1] = false;
  int n = sqrt(MAX);
  for (int i = 2; i <= n; i++) {
    if (!isPrime[i]) continue;
    for (int j = i * 2; j < MAX; j += i) {
      isPrime[j] = false;
    }
  }
}

int main() {
    int N;
    cin >> N;
    ll mod = pow(10, 9) + 7;
    if (N == 1) {
        cout << "1\n";
        return 0;
    }
    aryPrime();
    vector<int> p;
    for (int i = 2; i <= N; i++) {
        if (isPrime[i]) p.push_back(i);
    }
    ll a[p.size()]{};
    for (int i = 0; i < p.size(); i++) {
        for (int j = 2; j <= N; j++) {
            int t = j;
            while (t % p[i] == 0) {
                a[i]++;
                t /= p[i];
            }
        }
    }
    ll ans = 1;
    for (ll i : a) {
        ans *= (i + 1);
        ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  int x = n * 800;
  int y = n/15 * 200;
  cout << x-y << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <bitset>
#define SIZE 200002

using namespace std;

int main(){
    int x[5],zr=-1;
    for(int i = 0 ; i < 5 ; i++){
        cin >> x[i];
        if(x[i] == 0){
            zr = i;
        }
    }
    switch(zr){
        case 0:
            cout << zr+1 << endl;
            break;
        case 1:
            cout << zr+1<< endl;
            break;
        case 2:
            cout << zr+1<< endl;
            break;
        case 3:
            cout << zr+1<< endl;
            break;
        case 4:
            cout << zr+1<< endl;
            break;
        default:
            break;
    }
    return 0;
}

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

int machi;
int jigoku;
int d[1002];
int tsu[1002];
int a[1002][1002];
int main(){
	cin >> machi >> jigoku;
	for (int i = 0; i < machi; i++){
		cin >> d[i];
	}
	for (int j = 0; j < jigoku; j++){
		cin >> tsu[j];
	}
	for (int i = 0; i < machi+1; i++){
		for (int j = 0; j < jigoku+1; j++){
			a[i][j] = 1145141919;
			a[1][1] = d[0] * tsu[0];
		}
	}
	for (int i = 0; i < machi; i++){
		for (int j = i; j < jigoku; j++){
		if(i==0){a[i + 1][j + 1] = min(d[i] * tsu[j], a[i + 1][j]);
		}else{
			a[i + 1][j + 1] = min(a[i][j] + d[i] * tsu[j], a[i + 1][j]);
		}
		
		}
	}
	cout << a[machi][jigoku] << endl;
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int co[200020] = { 0 };
int main() {
	int n, k;
	cin >> n >> k;
	set<int> st;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		co[a - 1]++;
		st.insert(a);
	}
	sort(co, co + n);
	int ans = 0;
	if (st.size() > k) {
		int s = st.size();
		for (int i = 0; i < s - k; i++) {
			if (co[i] != 0) {
				ans += co[i];
			}
			else {
				s++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 10368
#include <cstdio>
#include <cstring>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn = 200000+5;
typedef long long ll;
ll sen[maxn], a[maxn];
ll sum = 0;
int n;
ll t;
int main(){
    scanf("%lld%lld",&n, &t);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld", &sen[i]);

    }
    for(int i = 1; i < n; i++)
    {
        a[i] = sen[i] - sen[i-1];
        
    }
    sum = 0LL;
    int i = 0;
    while(i < n){
        if(t + sen[i] > sen[i+1]) sum+=a[i+1];
        else sum+=t;
        i++;
    }
    sum+=t;
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 3328
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    loop {
        let mut v = read_vec::<u32>();
        if v[0] == 0 && v[1] == 0 { break; }

        v.sort();
        println!("{} {}", v[0], v[1]);
    }
}



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

int main() {
  int N, A;
  cin >> N >> A;

  //500円以上の処理
  if (N >= 500) {
    //500円だけで支払える時
    if (N % 500 == 0) {
      cout << "Yes" << endl;
    }
    else if (A >= N % 500) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;    
    }
  }
  //500円以下の処理
  else {
    if (A >= N) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    for(char& c : s) c -= ('A' - 1);
    for(char& c : t) c -= ('A' - 1);
    s.insert(s.begin(), 0);
    t.insert(t.begin(), 0);
    vector<int> ss(s.size()), tt(t.size());
    copy(s.begin(), s.end(), ss.begin());
    copy(t.begin(), t.end(), tt.begin());
    partial_sum(ss.begin(), ss.end(), ss.begin());
    partial_sum(tt.begin(), tt.end(), tt.begin());
    int q;
    cin >> q;
    while(q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << ((ss[b] - ss[a-1]) % 3 == (tt[d] - tt[c-1]) % 3? "YES" : "NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 1744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define iFOR(idx, from, upto) for (int  idx = from; idx < upto; ++idx)
#define lFOR(idx, from, upto) for (long idx = from; idx < upto; ++idx)

#define ll long long

using namespace std;

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

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

using i64 = long long int;

int imos[100005]={0};

int main(){
    int n, t;
    cin >> n >> t;
    for(int i=0;i<n;++i){
        int l, r;
        cin >> l >> r;
        imos[l]++;
        imos[r]--;
    }

    int acc = 0, ans = 0;
    for(int i=0;i<=t;++i){
        acc += imos[i];
        ans = max(ans, acc);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3476
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x:x[0])

remain = M
cost = 0

for a, b in AB:
    if remain <= b:
        cost += remain * a
        break
    else:
        cost += a * b
        remain -= b


print(cost)


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

using namespace std;

#define ll long long

const int mod  = 1e9 + 7;
const ll INF = 1e14;

void solve(){

    int x, y; cin >> x >> y;

    if(((4*x - y >= 0 ? 4*x - y : 1) % 2 == 0) && ((y - 2*x >= 0 ? y - 2*x : 1) % 2 == 0))
        cout << "Yes";
    else cout << "No";

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();

	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    vector<string> s(n);
    rep0(i, n)cin >> s[i];
    sort(all(s));
    s.erase(unique(all(s)), s.end());
    pf(s.size());
    return 0;
}



Measured memory_bytes: 9544
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int N, M; cin >> N >> M;
  
  vector <bool> OUT(N + 1);
  for (int i = 0; i < M; i++){
    int A; cin >> A; OUT[A] = true;
  }
  
  ll DP[N + 1];
  DP[0] = 1;
  if (OUT[1] == true){
    DP[1] = 0;
  }else{
    DP[1] = 1;
  }
  
  for (int i = 2; i < N + 1; i++){
    DP[i] = DP[i - 1] + DP[i - 2];
    if (OUT[i] == true){
      DP[i] = 0;
    }
    DP[i] %= nmax;
  }
  cout << DP[N] << endl;

  

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;
long mod = 1000000007;
/* C++の構造体 メンバがpublicなclass */
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

mint ans = 0;
vector<vector<int>> graph;
int k;
void dfs(int now, int parent){
    int color_rem = k;
    int child_size = graph[now].size();
    if (parent == -1){
        color_rem -= 1;
    } else {
        color_rem -= 2;
        child_size -= 1;
    }
//    cout << now << ":" << color_rem<< endl;
    if (color_rem < child_size){
        ans *= 0;
    } else {
        rep(i, child_size) {ans *= color_rem-i;}
    }
    for(auto next: graph[now]){
        if (next == parent) continue;
        dfs(next, now);
    }
    return;
}

int main()
{
    int n;cin >> n >> k;
    graph = vector<vector<int>>(n);
    rep(i, n - 1){ 
        int a, b; cin>>a>>b;a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    ans = k;    
    dfs(0, -1);
    cout << ans.x << endl;
}



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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

char grid[100][100];
int A, B;
pii changeable[550];

signed main() {
    cin >> A >> B;
    rep(y, 100) {
        rep(x, 50) {
            grid[y][x] = '.';
            grid[y][x + 50] = '#';
        }
    }
    int k = 0;
    for (int y = 0; y <= 99; y += 2) {
        for (int x = 1; x <= 48; x += 2) {
            changeable[k++] = pii(y, x);
            if (k == 510)goto a;
        }
    }
    a:
    rep(i, B - 1) {
        int y = changeable[i].first;
        int x = changeable[i].second;
        grid[y][x] = '#';
    }

    rep(i, A - 1) {
        int y = changeable[i].first;
        int x = changeable[i].second + 50;
        grid[y][x] = '.';
    }

    cout << "100 100" << endl;
    rep(i, 100) {
        rep(j, 100) {
            cout << grid[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll N,h,n,w;
int main(){
  cin>>N;
  for(ll i=1;i<=3500;i++)
    for(ll j=1;j<=3500;j++)
      if(N*(i+j)<(4*i*j) && (N*i*j)%(4*i*j-N*(i+j))==0){
      h=i;n=j;w=(N*i*j)/(4*i*j-N*(i+j));
      }cout<<h<<" "<<n<<" "<<w<<endl;
  return 0;
}

Measured memory_bytes: 3632
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			if (cin.ReadInt() >= 1200) Console.WriteLine("ARC");
			else Console.WriteLine("ABC");
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

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

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

		public string Read() => ReadString();

		public string ReadString()
		{
			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 ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

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

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

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

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

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

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));
	}
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stack>
using namespace std;
#define rep(i,l,p) for(int i=l;i<=p;i++)

int n;
string s1,s2,s3;
inline bool check(int x){
    if(s1[x] == s2[x] || s1[x] == s3[x] || s2[x] == s3[x]) return 1;
    return 0;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    cin >> s1 >> s2 >> s3;
    int ans = 0;
    rep(i,0,n-1){
        if(s1[i] == s2[i] && s2[i] == s3[i]) continue;
        else if(check(i)) ans++;
        else ans += 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)


using namespace std;

typedef long long ll;

int ans, D, N;


int main(void) {
    scanf("%d %d", &D, &N);

    int base = 1;
    if (D == 1) base = 100;
    else if (D == 2) base = 10000;

    int cnt = 0;
    while (cnt < N) {
    	ans += base;
    	if ( ans % base == 0 && ans % (base*100) != 0) cnt++;
    } 
    
    printf("%d\n", ans);

	return 0;
}


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

 int main() {
int a, b, c, k;
cin >> a >> b >> c >> k;
 if(k <= a) 
   cout << k;
 else if(k <= a + b) 
   cout << a << endl;
 else 
   cout << a - (k - a - b) << endl;
 return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
ll dp[100100];
char mas[51][51]; 
int main() {
     int n;
     cin >>n;
     vector<int>a(n);
     rep(i,n) cin >>a[i];
     vector<int>b =a;
     sort(b.rbegin(),b.rend());
     rep(i,n){
         if(a[i]!=b[0])cout<<b[0]<<endl;
         else cout<<b[1]<<endl;
     }
}

Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if (str[2] <= str[1])
            {
                Console.WriteLine("delicious");
            }
            else if (str[0] >= str[2] - str[1])
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("dangerous");
            }
        }
    }
}

Measured memory_bytes: 11092
using System;

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

        long ans = 1;
        for (int i = 2; i <= n; i++)
        {
            ans = ans * i % p;
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <cmath>
#include <iostream>

int main(){
  int n;
  int x[200000];
  int max = -1e9;
  int min = 1e9;

  std::cin >> n;
  std::cin >> x[0];
  min = x[0];
  
  for(int i=1; i < n; i++){
    std::cin >> x[i];
    max = std::max(x[i]-min, max);
    min = std::min(x[i], min);  
  }
  std::cout << max << std::endl;

}



Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


ll T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    cout << abs(n - 2) * abs(m - 2) << endl;
    return 0;
}


Measured memory_bytes: 256
import math
def main():
    N = int(input())
    A = list(map(int, input().split()))

    has_stock = False
    money = 1000
    stock = 0
    for day_i in range(N-1):
        if not has_stock:
            if A[day_i] < A[day_i + 1]:
                has_stock = True
                num = math.floor(money / A[day_i])
                stock += num
                money -= num * A[day_i]
                # print(day_i, "buy", money, stock)
        else:
            if A[day_i] > A[day_i + 1]:
                has_stock = False

                money += stock * A[day_i]
                stock = 0
                # print(day_i, "sell", money, stock)
    
    if has_stock:
        money += stock * A[N-1]
    print(money)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int N=105;
const int M=1e5+10;
ll w[N],v[N],dp[M];
int main()
{
	int n,W,i,j;
	ll ans=0;
	memset(dp,inf,sizeof(dp));
	dp[0]=0;
	scanf("%d%d",&n,&W);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&w[i],&v[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=1e5;j>=v[i];j--)
		{
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			if(dp[j]<=W) ans=max(ans,(ll)(j));
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int n;    cin >> n;
    double t, a; cin >> t >> a;
    vector<double> h(n);
    rep(i, n) cin >> h[i];

    double dis = 1000.0, tem = 0.0;
    int ids = 0;
    rep(i, n){
        tem = t - h[i]*0.006;
        if(abs(a - tem) < dis){
            dis = abs(a - tem); ids = i+1;
        }
    }
    cout << ids << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep(i,j,n) for(int i=(j);i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	string s;
	cin >> s;
	int a[26] = {};
	for(int i = 0;i < s.size();i++){
		a[s[i] - 'a']++;
	}
	for(int i = 0;i < 26;i++){
		if(a[i] % 2 == 1){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

int main() {
    Int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        print("A");
    } else {
        print("B");
    }
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<pair<pair<string,ll>,ll>> v;
  ll n;cin >> n;
  rep(i,n){
      string s;
      int p;
      cin >> s >> p;
      v.push_back(mp(mp(s,-p),i+1));

  }
  sort(all(v));
  rep(i,n){
      cout << v[i].second << endl;
  }
}

Measured memory_bytes: 256