akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return [f = std::forward<F>(f)](auto&&... args) {
    return f(f, std::forward<decltype(args)>(args)...);
  };
}
template<typename T>
static inline T fin() { T t; cin >> t; return std::move(t); }

int main() {
  const i64 n = fin<i64>(), a = fin<i64>(), b = fin<i64>();
  cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	multiset<int> pos;
	pos.insert(a[0]);
	repn(i, 1, n){
		if(*pos.begin() >= a[i]) pos.insert(a[i]);
		else{
			auto ps = pos.ub(a[i] - 1);
			ps--;
			int cur = a[i];
			pos.erase(pos.find(*ps));
			pos.insert(cur);
		}
	}
	cout << pos.size() << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/



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

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

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        int[] a = new int[n];
        int ans = -1;
        for(int i=0;i<n;i++){
        	a[i] = sc.nextInt();
        }
        for(int i=0;i<n-1;i++){
        	if(a[i]+a[i+1]>=l){
        		ans = i+1;
        		break;
        	}
        }

        if(ans!=-1){
        	System.out.println("Possible");
        	for(int i=1;i<ans;i++){
        		System.out.println(i);
        	}
        	for(int i=n-1;i>=ans;i--){
        		System.out.println(i);
        	}
        }
        else{
        	System.out.println("Impossible");
        }
    }
}

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

using namespace std;

#define int long long

#define rep(i,x) for(int i=0;i<x;++i)

#define fst first
#define scd second


using vi=vector<int>;
using pii=pair<int,int>;
using vpii=vector<pii>;
//using data=pair<pii, int>;

const int inf = 3e18;

struct edge{int to,cost;};
vector<edge> G[100010];
int d[100010];
bool used[100010];

int n, m, c;

signed main()
{
	cin >> n >> m >> c;
	
	int sum = 0;
	
	rep(i, m) {
		int a, b, d; cin >> a >> b >> d;
		--a, --b;
		G[a].push_back(edge{b, d});
		G[b].push_back(edge{a, d});
		
		sum += d;
	}
	
	priority_queue<pii, vector<pii>, greater<pii>> q;
	q.push(pii(0, 0));
	
	fill_n(d, n+1, inf);
	d[0] = 0;
	
	int ans = inf;
	
	while (q.size()) {
		pii p = q.top(); q.pop();
		
		if (d[p.scd] == p.fst) {
			used[p.scd] = true;
			
			for (edge &e : G[p.scd]) {
				if (used[e.to]) sum -= e.cost;
			}
			
			ans = min(ans, p.fst * c + sum);
		}
		
		if (d[p.scd] < p.fst) {
			continue;
		}
		
		for (edge &e : G[p.scd]) {
			if (d[e.to] > d[p.scd] + e.cost) {
				d[e.to] = d[p.scd] + e.cost;
				q.push(pii(d[e.to], e.to));
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 17476
n = int(input())

d = []

for i in range(n):
	d.append(list(map(int,input().split())))

cnt = 0
flag = 0

for i in range(n):
	if d[i][0] == d[i][1]:
		cnt = cnt + 1
	else:
		cnt = 0

	if cnt == 3:
		flag = 1

if flag == 1:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 9192
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, D, A;
    cin >> N >> D >> A;
    vector<pll> XH(N);
    rep(i, N) {
        ll x, h;
        cin >> x >> h;
        XH[i] = MP(x, h);
    }
    sort(All(XH));
    vector<int> ridx(N);
    int left = 0, right = 0;
    while(left < N) {
        while(XH[right].first - XH[left].first <= 2 * D && right < N)
            right++;
        ridx[left] = right - 1;
        if(left == right)
            right++;
        left++;
    }
    vector<ll> dmg(N), d_sum(N + 1);
    ll res = 0;
    for(int i = 0; i < N; i++) {
        int idx = lower_bound(All(ridx), i) - ridx.begin();
        ll rest = max(0LL, XH[i].second - (d_sum[i] - d_sum[idx]));
        int cnt = rest / A + !!(rest % A);
        res += cnt;
        dmg[i] = A * cnt;
        d_sum[i + 1] = dmg[i] + d_sum[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
using namespace std;
int n,x;
const int maxn=100005;
int a[maxn];
int d[maxn];
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int main(){
	cin>>n>>x;
	int aa;
	for(int i=1;i<=n;i++){
		cin>>aa;
		d[i]=abs(aa-x);//只要差值,gcd
	}
	if(n==1)cout<<abs(x-aa)<<endl;
	else{
	int h=gcd(d[1],d[2]);
	for(int i=3;i<=n;i++){
		h=gcd(h,d[i]);
	}
	cout<<h<<endl;
	}
	return 0;
}

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

using ll = long long;

void RET () {
	cout << -1;
	exit (0);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector <int> a(n+1), ans;
	for (int i=1; i<=n; i++) {
		cin >> a[i];
	}
	for (int q=1; q<=n; q++) {
		bool find = 0;
		for (int i=n-q+1; i>=1; i--) {
			if (a[i] == i) {
				find = 1;
				a.erase(a.begin()+i);
				ans.push_back(i);
				break;
			}
		}
		if (!find) RET();
	}
	reverse (ans.begin(), ans.end());
	for (auto i:ans) {
		cout << i << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
K = int(input())
A, B = map(int, input().split())
X = int(A / K)
Y = K * X
CHECK = "OK"
while A==A:
 #   print(Y)
    if Y >= A and Y <= B:
        break
    elif Y < A:
        Y += K
    else:
        CHECK = "NG"
        break
print(CHECK)


Measured memory_bytes: 9096
#include <stdio.h>
int n,A[50];
int solve(int x, int y);
int main(){
    int i,a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++){
          scanf("%d",&A[i]);
    }
          scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d",&b);
        if(solve(0,b)){
            printf("yes\n");
        }
        else printf("no\n");
    }
    return 0;
}
int solve(int x, int y)
{
    if(y==0)return 1;
    if(x>=n)return 0;
    int c=solve(x+1,y) || solve(x+1,y-A[x]);
    return c;
}


Measured memory_bytes: 2108
# 1つ見れば、マス目に対する高さが確定する
# 100件についてテスト
import numpy as np
N = int(input())
U = 100
XYH = np.array([[int(x) for x in input().split()] for _ in range(N)])
XYH = XYH[np.argsort(-XYH[:,2])] # 高い順なので0番目は正

x0,y0,h0 = XYH[0]
dx = np.abs(np.arange(U+1) - x0)
dy = np.abs(np.arange(U+1) - y0)
# そこに頂上があるとするとその高さ
H = dx[:,None] + dy[None,:] + h0
possible = np.full_like(H, True)

for x,y,h in XYH[1:]:
  dx = np.abs(np.arange(U+1) - x)
  dy = np.abs(np.arange(U+1) - y)
  possible &= (np.maximum(H-dx[:,None]-dy[None,:],0) == h)

nz = possible.nonzero()
x,y = nz[0][0], nz[1][0]
h = H[x,y]
print(x,y,h)

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

int main(void) {
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's') {
    s += "es";
  } else {
    s += 's';
  }
  cout << s << '\n';
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
//#define m 1000000000000000007
/*vector<ll>prime(10000001,1);
vector<ll>sdf(10000001);
ll C[101][101];
int isprime(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
            {//cout<<i<<endl;
            return 0;}
    }
    return 1;
}
int isperfectsq(ll n)
{


    long double x;
    x=(long double)(sqrt((long double )(n)));
    ll y=sqrt(n);
    if(x==y)
        return 1;
        else
            return 0;
}
void ncr()
{
    C[0][0] = 1;
    for (int n = 1; n <= 100; ++n) {
        C[n][0] = C[n][n] = 1;
        for (int k = 1; k < n; ++k)
            C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
    }
}
void sieve()
{
    //cout<<"in1";
    ll i;
    for(i=0;i<=10000000;i++)
        sdf[i]=i;
    ll j;
    prime[0]=prime[1]=0;
    for(i=2;i*i<=10000000;i++)
    {
        if(prime[i]==1)
        {
            //isprime.push_back(i);
            for(j=i*i;j<=10000000;j+=i)
            {
                prime[j]=0;
                if(sdf[j]==j)
                {
                    sdf[j]=i;
                }
            }
        }
    }
}
long long modular_expo(long long x,long long y)
{

    if(y==0)
        return 1;
    if(y%2==0)
        return modular_expo(x*x,y/2);
    if(y%2==1)
        return x*modular_expo(x*x,(y-1)/2);


}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);



    string s,t;
    cin>>s>>t;
    int i;
    ll cnt=0;
    vector<int>a(26,0),b(26,0);
    for(i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
            cnt++;
    }

    cout<<cnt;


}


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

vector<ll> f(ll n) {
    vector<ll> res;
    for (ll a = 2; a*a <= n; a++) {
        if (n%a != 0) continue;
        while (n%a == 0) {
            n /= a;
        }
        res.push_back(a);
    }
    if (n != 1) res.push_back(n);
    return res;
} 

int main() {
    ll a, b;
    cin >> a >> b;
    auto ares = f(a);
    auto bres = f(b);
    int ans = 0;
    for (auto x : ares) {
        for (auto y : bres) {
            if (x == y) ans++;
        }
    }
    ans++;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

string S, T;
map<char, char> sused, tused;

int main() {
    cin >> S >> T;
    bool judge = true;
    REP(i, S.length()) {
        char s = S[i], t = T[i];
        if(sused.count(s) && sused[s] != t) {
            judge = false;
            break;
        }
        if(tused.count(t) && tused[t] != s) {
            judge = false;
            break;
        }
        sused[s] = t;
        tused[t] = s;
    }
    Yes(judge);
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define lowbit(x) (x&-x)
#define jh(x, y) x^=y^=x^=y
#define rg register
#define inl inline
typedef long long ll;
const int N = 5e5 + 5, mod = 998244353, INF = 0x3f3f3f3f;
using namespace std;
namespace fast_IO {
	inl ll read() {
		rg char c;
		rg ll x = 0;
		rg bool flag = false;
		while ((c = getchar()) == ' ' || c == '\n' || c == '\r');
		if (c == EOF)return c; if (c == '-')flag = true; else x = c ^ 48;
		while ((c = getchar()) != ' ' && c != '\n' && c != '\r'&&~c)
			x = (x << 1) + (x << 3) + (c ^ 48);
		if (flag)return -x; return x;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg ll x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
}
inl ll xorsum(rg ll n) { rg ll ans = 0; if (!(n & 1))++n, ans = n; return ans ^ 1 ^ ((n >> 1) & 1); }

int main(void)
{
	rg ll a = fast_IO::read(), b = fast_IO::read();
	fast_IO::write(xorsum(a - 1) ^ xorsum(b));
	return 0;
}

Measured memory_bytes: 256
# from collections import Counter
import itertools
ans=0
n=int(input())
ls=["M","A","R","C","H"]
# S=Counter([i for i in list(map(lambda x:x[0] ,[input() for i in range(n)])) if i in ls])
S = [input() for _ in range(n)]
# for i in itertools.combinations(S.values(),3):
#   ans+=i[0]*i[1]*i[2]
# print(ans)

march={i:0 for i in ls}
for s in S:
  if s[0] in ls:
    march[s[0]]+=1
# print(march)

for i,j,k in itertools.combinations(ls,3):
  ans+=march[i]*march[j]*march[k]
print(ans)


Measured memory_bytes: 9780
#include<stdio.h>

int main()
{
	int a, b,ans,i,kekka=0;

	scanf("%d%d", &a, &b);

	if (b % 100 == 0)
		ans = a * 1000 + b;
	else if (b / 10 < 10&&b/10>0)
		ans = a * 100 + b;
	else
		ans = a * 10 + b;

	for (i = 0; i < 350; i++)
	{
		if (i*i == ans)
		{
			kekka = 1;
			break;
		}
	}

	if (kekka == 1)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

vector<ll> primes;

void sieve(ll n)
{
	vector<bool> isprime(n+1);
	for (int i=0; i<=n; i++) {
		isprime[i] = true;
	}
	for (int i=2; i*i<=n; i++) {
		if (isprime[i]) {
			for (int j=i*i; j<=n; j+=i) {
				isprime[j] = false;
			}
		}
	}
	for (int i=2; i<=n; i++) {
		if (isprime[i]) {
			primes.push_back(i);
		}
	}
}

void solve()
{
	ll n;
	cin>>n;
	sieve(n);
	vector<ll> dp(n+1);
	ll ans = 0;
	dp[1] = 1;
	for (int i=1; i<=n/2; i++) {
		for (int p:primes) {
			if (i*p>n) {
				break;
			}
			int cnt = 0;
			int temp = i;
			while (temp%p==0) {
				temp /= p;
				cnt++;
			}
			dp[i*p] = (dp[i]/(cnt+1))*(cnt+2);
		}
	}
	for (int i=1; i<=n; i++) {
		ans += i*dp[i];
	}
	cout << ans << "\n";
}

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

Measured memory_bytes: 86560
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn = 1000005;
const int mod = 998244353;
ll dp[2222];
int main(){
    string s;cin >> s;
    int n=(int)s.size();
    dp[0]=1;int p=1,now=0;
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        now=((s[i]-'0')*p%2019+now)%2019;
        ans+=dp[now];
        dp[now]++;
        p=p*10%2019;
    }
    printf("%lld\n",ans);
    return 0;
}




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

using namespace std;

int P,N[6];
const int coin[6] = {1,5,10,50,100,500};

int calc(int x){
  int res = 0;
  for(int i = 5 ; i >= 0 ; i--){
    if(x >= coin[i]){
      res += x/coin[i];
      x %= coin[i];
    }
  }
  return res;
}

int c(int x){
  int res = 0;
  for(int i = 5 ; i >= 0 ; i--){
    int use = x/coin[i];
    if(use > N[i]){
      res += N[i];
      x -= N[i]*coin[i];
    }else{
      res += use;
      x %= coin[i];
    }
  }
  return res;
}

int main(){
  while(cin >> P){
    int end = P;
    for(int i = 0 ; i < 6 ; i++){
      cin >> N[i];
      end += N[i];
    }
    if(end == 0){ break; }
    int res = (1<<29);
    for(int i = P ; i <= 2*P ; i++){
      int x = c(i);
      res = min(res,x+calc(i-P));
    }
    cout << res << endl;
  }
  return 0;
}

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

using namespace std;

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

const int64_t INF = 0x100000000000000;

int main(){
  int n, m, p;
  cin >> n >> m >> p;
  vector<tuple<int, int, int> > e;
  REP(i, m){
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    c -= p;
    e.push_back(make_tuple(a, b, -c));
  }
  vector<int64_t> v(n);
  REP(i, n) if(i > 0) v[i] = INF;
  REP(i, n - 1){
    for(auto x: e){
      int s, t, c;
      tie(s, t, c) = x;
      v[t] = min(v[t], v[s] + c);
    }
  }
  vector<int64_t> vs = v;
  for(auto x: e){
    int s, t, c;
    tie(s, t, c) = x;
    if(v[s] < INF / 2 && v[s] + c < v[t]){
      vs[t] = -INF;
    }
  }
  REP(i, n - 0){
    for(auto x: e){
      int s, t, c;
      tie(s, t, c) = x;
      vs[t] = min(vs[t], vs[s] + c);
    }
  }
  vector<int64_t> v2(n);
  REP(i, n) if(i < n - 1) v2[i] = INF;
  REP(i, n - 1){
    for(auto x: e){
      int s, t, c;
      tie(s, t, c) = x;
      v2[s] = min(v2[s], v2[t] + c);
    }
  }
  vector<int64_t> vt = v2;
  for(auto x: e){
    int s, t, c;
    tie(s, t, c) = x;
    if(v2[t] < INF / 2 && v2[t] + c < v2[s]){
      vt[s] = -INF;
    }
  }
  REP(i, n - 1){
    for(auto x: e){
      int s, t, c;
      tie(s, t, c) = x;
      vt[s] = min(vt[s], vt[t] + c);
    }
  }
  REP(i, n){
    if(vs[i] < -INF / 2 && vt[i] < -INF / 2){
      cout << -1 << endl;
      return 0;
    }
  }
  if(vs[n - 1] < 0){
    cout << -vs[n - 1] << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#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;
long long co[100][3000];
bool bo[100][3000] = { false };
long long mi = 2600;
vector<vector<tuple<long long, long long,int>>> vec(100);
int main() {
	long long n, m, s;
	cin >> n >> m >> s;
	s = min(s, mi);
	for (int i = 0; i < m; i++) {
		int u, v;
		long long a, b;
		cin >> u >> v >> a >> b;
		vec[u].emplace_back(make_tuple(b, -a, v));
		vec[v].emplace_back(make_tuple(b, -a, u));
	}
	for (int i = 1; i <= n; i++) {
		long long c, d;
		cin >> c >> d;
		vec[i].emplace_back(make_tuple(d, c, i));
	}
	priority_queue<tuple<long long, long long, int>, vector<tuple<long long, long long,int>>, greater<tuple<long long, long long,int>>> que;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 3000; j++) {
			co[i][j] = 1000000000000000007;
		}
	}
	co[1][s] = 0;
	que.push(make_tuple(0, s, 1));
	while (!que.empty()) {
		tuple<long long, long long, int> t = que.top();
		int x = get<2>(t);
		long long y = get<1>(t);
		long long z = get<0>(t);
		que.pop();
		if (bo[x][y]) {
			continue;
		}
		bo[x][y] = true;
		for (int i = 0; i < vec[x].size(); i++) {
			tuple<long long, long long, int> tu = vec[x][i];
			int nx = get<2>(tu);
			long long ny = get<1>(tu);
			long long nz = get<0>(tu);
			long long ns = min(ny + y, mi);
			if (ns < 0) {
				continue;
			}
			if (co[nx][ns] <= nz + z) {
				continue;
			}
			co[nx][ns] = nz + z;
			que.push(make_tuple(z + nz, ns, nx));
		}
	}
	for (int i = 2; i <= n; i++) {
		long long ans = 1000000000000000007;
		for (int j = 0; j < 3000; j++) {
			if (ans > co[i][j]) {
				ans = co[i][j];
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n=s.size();
    bool flag;
    if (s[0]!=s[n-1]) {
        if (n%2==1) flag=true;
        else flag=false;
    } else {
        if (n%2==1) flag=false;
        else flag=true;
    }
    if (flag) cout << "First" << endl;
    else cout << "Second" << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N; cin >> N;

	P r[200], b[200];

	for (int i = 0;i < N;i++){
		cin >> r[i].first >> r[i].second;
	}

	for (int i = 0;i < N;i++){
		cin >> b[i].first >> b[i].second;
	}

	sort(r, r+N); sort(b, b+N);

	int ans = 0;

	for (int i = 0;i < N;i++){
		int highest = -1;
		int idx = -1;
		for (int j = 0;j < N;j++){
			if(r[j].first <= b[i].first && r[j].second <= b[i].second){
				if(highest < r[j].second){
					highest = r[j].second;
					idx = j;
				}
			}
		}
		if(highest != -1){
			ans++;
			r[idx] = P(INT_MAX, INT_MAX);
		}
	}	

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,cnt=0;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		if(i/100000) continue;
		else if(i/10000) cnt++;
		else if(i/1000) continue;
		else if(i/100) cnt++;
		else if(i/10) continue;
		else  cnt++;
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
//ABC160 C

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

int K,N;
int A[200000];
int ans = 0;

int main() {
  cin >> K >> N;
  
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  int max_dist = K - A[N-1] + A[0];
  for(int i=0;i<N-1;i++){
    max_dist = max(max_dist,A[i+1] - A[i]);
  }

  printf("%d\n",K-max_dist);

}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a=sc.nextInt();
        long b=sc.nextInt();
        long output=0;
        long[] nums=new long[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        for(int i=0;i<n-1;i++){
            output+=Math.min((nums[i+1]-nums[i])*a, b);
        }
        System.out.println(output);
    }
 
    
}

Measured memory_bytes: 59772
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)


int main()
{
    int n,m;
    map<string, int> ma;
    cin>>n;
    for(int i = 0; i < n; i++) {
        string s;cin>>s;
        ma[s]++;
    }
    cin>>m;
    for(int i = 0; i < m ;i++) {
        string t;cin>>t;
        ma[t]--;
    }
    int ans = -101;
    for(auto itr = ma.begin(); itr != ma.end(); itr++) {
        ans=max(itr->second,ans);
    }
    cout << (ans > 0?ans:0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

int main(){

  int n, a[100000], ans=0;
  map<int, int> cnt;

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

  for(int i=0;i<n;i++){
    if(cnt[a[i]]==0) continue;
    if(cnt[a[i]]>=a[i]){
      int diff=cnt[a[i]]-a[i];
      ans+=diff;
      cnt[a[i]]=a[i];
    }else{
      ans+=cnt[a[i]];
      cnt[a[i]]=0;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5120
/* ex 5_4
   L40S38 */

#include <stdio.h>
#define SIZE 11

int main(void){
    char input[SIZE],*ptr;
    //入力される文字列の文字数の最大値は10なので配列の大きさは11に設定
    int max=0,len=0;
    
    //文字列を入力
    scanf("%s",input);
    
    //inputの部分文字列の中でACGT文字列の長さを求める
    ptr=&input[0];
    
    while(*ptr){
        while(*ptr=='A'||*ptr=='C'||*ptr=='G'||*ptr=='T'){
            //*ptrが'A','C','G','T'のいずれかの場合、ptrを1文字分ずらしつつlenに1を加える
            len++;
            ptr++;
        }
        if(max<len){
            //maxよりlenの方が大きければmaxにlenを代入
            max=len;
        }
        //lenを初期化しptrを1文字分ずらす
        len=0;
        ptr++;
    }
    //結果を出力
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 1732
if __name__ == '__main__':
    while True:
        # ??????????????\???
        loop = int(input())
        if loop == 0:
            break
        data = [int(input()) for _ in range(loop)]

        # ???????????????
        max_total = max(data)  # ??£?¶?????????°???????????§????¨????
        total = 0
        for d in data:
            if d > 0:  # ??°??????+??§????????°?????±????°????
                total += d  # ????¨?????¶???????????¨?????????´??°????????????????¢????????????????
                if total > max_total:
                    max_total = total
            else:  # ??°??????-?????´?????????????????§????????£???????????????????????§??????????????????
                if total > abs(d):  # ???????????§??????????????????????????§????????°???total???????????????????¶??¶???????
                    total += d
                    # ???????????????????????????????????§???max_total?????´??°??????????????§?????????
                else:
                    total = 0  # ???????????????????????§??????????????????????????§??????????????§????¨??????????????????????????¬??????????????????????????????????

        # ???????????¨???
        print(max_total)

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  rep(i,1,n+1)if(to_string(i).size()&1)res++;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
word = 'keyence'
l = input()
i = l.find(word)
if i == 0 or i == (len(l)-len(word)) :
  print('YES')
  exit()

for i in range(1,len(word)):
  a = word[:i]
  b = word[i:]
  #print(l[:len(a)], l[-len(b):])
  if l[:len(a)] == a and l[-len(b):] == b:
    print('YES')
    exit()
print('NO')


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[9] = {1, 0, -1, 0, 0, 0, 2, -2, 0};
int dy[9] = {0, 1, 0, -1, 0, 2, 0, 0, -2};

int main(){
  int D;
  int sch[365][4][4] = {};
  while(cin>>D && D){
    bool goal = false;
    REP(i, D) REP(y, 4) REP(x, 4) cin>>sch[i][y][x];
    static bool used[366][16][2401];
    memset(used, 0, sizeof(used));
    queue<int> qd, qy, qx;
    queue< vector<int> > qv;
    vector<int> s(4, 0);
    qd.push(0); qx.push(1); qy.push(1); qv.push(s);
    while(!qd.empty()){
      int d = qd.front(); qd.pop();
      int x = qx.front(); qx.pop();
      int y = qy.front(); qy.pop();
      //printf("d = %d x = %d y = %d\n", d, x, y);
      vector<int> v = qv.front(); qv.pop();
      if(d == D){
        goal = true;
        break;
      }
      REP(i, 4) v[i]++;
      bool ok = true;
      REP(dy, 2)REP(dx, 2) if(sch[d][y + dy][x + dx] == 1) ok = false;
      if(x == 0 && y == 0) v[0] = 0;
      if(x == 2 && y == 0) v[1] = 0;
      if(x == 0 && y == 2) v[2] = 0;
      if(x == 2 && y == 2) v[3] = 0;
      REP(i, 4) if(v[i] >= 7) ok = false;
      if(!ok) continue;
      REP(r, 9){
        bool ok2 = true;
        int nx = x + dx[r];
        int ny = y + dy[r];
        REP(dx, 2)REP(dy, 2) ok2 &= valid(nx + dx, ny + dy, 4, 4);
        if(!ok2) continue;
        if(used[d + 1][ny + nx * 4][v[0] + 7 * v[1] + 49 * v[2] + 343 * v[3]]) continue;
        used[d + 1][ny + nx * 4][v[0] + 7 * v[1] + 49 * v[2] + 343 * v[3]] = true;
        qd.push(d + 1);
        qx.push(nx);
        qy.push(ny);
        qv.push(v);
      }
    }
    if(goal) cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 15128
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x%y);
}

int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

int vec_lcm(vector<int> v, int left, int right) {
	if (left + 1 == right) return v[left];
	//if ((right - left) % 2) return lcm(v[left], vec_lcm(v, left + 1, right));
	int c = (left + right) / 2;
	return lcm(vec_lcm(v, left, c), vec_lcm(v, c, right));
}

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

	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	cout << vec_lcm(a, 0, n) << "\n";
	
	return 0;
}



Measured memory_bytes: 3224
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
// #include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

fn main() -> int {
  int n, m;
  cin >> n >> m;
  vector<int> a_i, b_i, c_i, d_i;
  for(int cnt=0; cnt < n; cnt++){
    int a, b;
    cin >> a >> b;
    a_i.push_back(a);
    b_i.push_back(b);
  }
  for(int cnt=0; cnt < m; cnt++){
    int c, d;
    cin >> c >> d;
    c_i.push_back(c);
    d_i.push_back(d);
  }
  for(int cnt_out = 0; cnt_out < n; cnt_out++){
    vector<int> distance;
    for(int cnt_in = 0; cnt_in < m; cnt_in++){
      distance.push_back( abs(a_i[cnt_out] - c_i[cnt_in]) 
                        + abs(b_i[cnt_out] - d_i[cnt_in]));
    }
    iput(min_element(distance.begin(), distance.end()) - distance.begin() + 1);
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring> 
#include<vector>

using namespace std;

const int N=10;

int n,m;
int a[N+5][N+5];

bool Dis(int x,int y)
{
	int tot=0;
	for(int i=1;i<=m;i++)
		tot += (a[x][i]-a[y][i])*(a[x][i]-a[y][i]);
	return tot == (int)sqrt(tot)*(int)sqrt(tot);
}

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	int ans=0; 
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			ans += Dis(i,j);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define fi first
#define se second
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int num[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=0;i<q;i++)
	{
		int x;
		cin>>x;
		num[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(k>q-num[i]) cout<<"Yes"<<'\n';
		else cout<<"No"<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll x, y, res = 1LL<<60;

void solve(){
    if (x <= y) res = min(res, y-x);
    if (-x <= y) res = min(res, y+x+1);
    if (x <= -y) res = min(res, -y-x+1);
    if (-x <= -y) res = min(res, -y+x+2);

    cout << res << endl;
}

int main(){
    cin >> x >> y;

    solve();
}


Measured memory_bytes: 256
n = int(input())
l = [51] * 26
z = list('abcdefghijklmnopqrstuvwxyz')
for i in range(n):
    s = input()
    for j in range(26):
        l[j] = min(l[j],s.count(z[j]))

t = []
for i in range(26):
    if l[i] != 51:
        t.append((z[i]) * l[i])

print(''.join(t))

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main() {
  int N, K;
  map<int, int> cnt;
  cin >> N >> K;
  rep(i, N) {
    int a;
    cin >> a;
    if(cnt.count(a))
      cnt[a]++;
    else
      cnt[a] = 1;
  }
  vector<int> num;
  for(auto p : cnt)
    num.push_back(p.second);
  sort(all(num));
  auto it = num.end() - min(K, (int)num.size());
  num.erase(it, num.end());
  cout << accumulate(all(num), 0) << endl;
}

Measured memory_bytes: 10748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();
		int[][] rec = new int[H][W];
		for (int i = 0; i < N; i++) {
			int xi = sc.nextInt();
			int yi = sc.nextInt();
			int a = sc.nextInt();
			if (a == 1) {
				for (int j = 0; j < rec.length; j++) {
					for (int j2 = 0; j2 < xi; j2++) {
						rec[j][j2]++;
					}
				}
			} else if (a == 2) {
				for (int j = 0; j < rec.length; j++) {
					for (int j2 = xi; j2 < rec[j].length; j2++) {
						rec[j][j2]++;
					}
				}
			} else if (a == 3) {
				for (int j = 0; j < yi; j++) {
					for (int j2 = 0; j2 < rec[j].length; j2++) {
						rec[j][j2]++;
					}
				}
			} else if (a == 4) {
				for (int j = yi; j < rec.length; j++) {
					for (int j2 = 0; j2 < rec[j].length; j2++) {
						rec[j][j2]++;
					}
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < rec.length; i++) {
			for (int j = 0; j < rec[i].length; j++) {
				if (rec[i][j] == 0)
					ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23324
import java.util.Scanner;
public class Main{
	public static void main(String args[]){
    	Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	double ans=0;
      	double arr[]=new double[n+1];
      	for(int i=1;i<=n;i++) arr[i]=sc.nextDouble();
      	double grid[][]=new double[n+1][n+1];
      	for(int i=0;i<=n;i++){
        	for(int j=0;j<=n;j++){
            	if(i == 0 && j== 0) grid[i][j]=1;
              	else if(i == 0) grid[i][j]=0;
              	else if ( j == 0) grid[i][j]=grid[i-1][j]*(1-arr[i]);
              	else {
                	grid[i][j]=grid[i][j]+((1-arr[i])*grid[i-1][j] + (arr[i]*grid[i-1][j-1]));
                }
            }
        }
      	int start=n/2+1;
      	for(int i=start;i<=n;i++) ans+=grid[n][i];
      	System.out.println(ans);
          
    }
}


Measured memory_bytes: 125172
P=10**9+7
N,M=map(int,input().split())
X=sorted([int(i) for i in input().split()])
Y=sorted([int(i) for i in input().split()])
A=[i for i in X]
B=[i for i in Y]
if len(set(A))!=N or len(set(B))!=M:
    print(0)
    exit()
L=[]
x=0
y=0
D=N*M
while(len(A)>0 and len(B)>0):
    if max(A[-1],B[-1])==D:
        if A[-1]>B[-1]:
            A.pop()
            L.append(y)
            x+=1
        elif A[-1]<B[-1]:
            B.pop()
            L.append(x)
            y+=1
        else:
            A.pop()
            B.pop()
            x+=1
            y+=1
        D-=1
    else:
        C=max(A[-1],B[-1])+1
        tmp=x*y-(N*M-D)
        for i in range(C,D+1)[::-1]:
            L.append(tmp)
            tmp-=1
        D=max(A[-1],B[-1])
if len(A)>0:
    D=min(Y)-1
    while(len(A)>0):
        C=A[-1]+1
        tmp=x*y-(N*M-D)
        for i in range(C,D+1)[::-1]:
            L.append(tmp)
            tmp-=1
        D=A.pop()-1
        x+=1
        L.append(M)
if len(B)>0:
    D=min(X)-1
    while(len(B)>0):
        C=B[-1]+1
        tmp=x*y-(N*M-D)
        for i in range(C,D+1)[::-1]:
            L.append(tmp)
            tmp-=1
        D=B.pop()-1
        y+=1
        L.append(N)
m=min(min(X),min(Y))-1
for i in range(1,m+1):
    L.append(i)
ans=1
for i in L:
    ans*=i
    ans%=P
print(ans)


Measured memory_bytes: 42740
#include <bits/stdc++.h>
using namespace std;
int N;
int f[200][12];
int p[200][12];
int main () {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < 10; ++j) {
      cin >> f[i][j];
    }
  }
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j <= 10; ++j) {
      cin >> p[i][j];
    }
  }

  const int upper = (1 << 10) - 1;
  int ret = INT_MIN;
  for(int k = 1; k <= upper; ++k) {
   int r = 0;
   for(int i = 0; i < N; ++i) {
     int ct = 0;
     for(int j = 0; j < 10; ++j) {
       if (((1 << j) & k) && f[i][j]) ct++;
     }

     r += p[i][ct];
   }

   ret = max(ret, r);
  }

  cout << ret << endl;
}

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

#define mod 1000000007

#define rep(i, n) for(int i=1; i<=n; ++i)

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N, K;
	double ans = 0;
	
	cin >> N >> K;
	
	rep(i, N){
		double tmp = 1.0 / N;
		int score = i;
		while(score < K){
			score *= 2;
			tmp /= 2;
		}
		ans += tmp;
	}
	
	printf("%.12f\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int c500 = int.Parse(ReadLine());
        int c100 = int.Parse(ReadLine());
        int c50 = int.Parse(ReadLine());
        int total = int.Parse(ReadLine());
        int count = 0;
        for(int i=0;i<=c500;i++){
            for(int j=0;j<=c100;j++){
                for(int k=0;k<=c50;k++){
                    int kei = (i*500) + (j*100) + (k*50);
                    if(total == kei){
                        count++;
                    }
                    if(total < kei){
                        break;
                    }
                }
            }
        }
        WriteLine(count);
    }
}


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


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

    for (int i = 0;i < s.size();i++){
      if (i%2 == 0){
        cout << s.at(i);
      }
    }
    cout << endl;
    
  }       

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 1000000000000000000
#define N 2100

vector<ll> sl(N);
vector<ll> minl(N);
ll n, x, y, a;

int main(){
    cin >> n >> x;
    REP(i,n) cin >> sl[i];
    ll ans = 0;
    REP(i,n) minl[i]=sl[i];
    REP(i,n) ans+=sl[i];
    FOR(i,1,n-1){
        ll ansl = i*x;
        REP(j,n){
            if (j-i<0) y=n+j-i;
            else y=j-i;
            minl[j]= min(minl[j],sl[y]);
            ansl+=minl[j];
        }
        ans = min(ansl,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, y, a, b;
  
  cin >> x >> y;

  a = (4 * x - y) / 2;
  b = (y - 2 * x) / 2;
  
  if(a + b == x && a >= 0 && b >= 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 3628
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector<vector<char>> vviBinary(n,vector<char>(20));
    
    for(int i = 0; i < n; i++){
        int m;
        scanf("%d", &m);
        for(int j = 0; j < 20; j++){
            vviBinary[i][j] = m % 2;
            m /= 2;    //mi = Σ(2^j)・vviBinary[i][j]
        }
    }
    long int i = 0;
    long int j = 0;
    int aiSum[20] = {0};
    long int nCount = 0;

    while(j < n){
      bool bjAdd = true;
      for(int k = 0; k < 20; k++){
          if(aiSum[k] + vviBinary[j][k] >= 2){
              bjAdd = false;
              break;
          }
      }
      
      
      if(bjAdd){
          for(int k = 0; k < 20; k++){
              aiSum[k] += vviBinary[j][k];
          }
          nCount += (j - i + 1);
          j++;
      } else {
          for(int k = 0; k < 20; k++){
              aiSum[k] -= vviBinary[i][k];
          }
          i++;
      }
    }
    printf("%ld", nCount);
    return 0;
}


Measured memory_bytes: 11136
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
    int a, b, c;

    cin >> a >> b >> c;

    
    cout << max(c - (a - b), 0) << endl;
}



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

int main() {
    char ch;
    int cou[26] = {};
    
    while ((ch = getchar()) != EOF) {
        if (isalpha(ch)) {
            if (isupper(ch)) {
                ch = tolower(ch);
            }
            cou[ch -'a']++;
        }
    }
    
    for (int j=0; j<26; j++) {
        printf("%c : %d\n", 'a'+j, cou[j]);
    }
    
    return 0;
}


Measured memory_bytes: 2112
<?php
$p = trim(fgets(STDIN));
$s = trim(fgets(STDIN));

$p = $p.$p;
$lp = strlen($p);
$ls = strlen($s);

for ($i = 0;$i < $lp-$ls;$i++) {
    $tmp = substr($p, $i, $ls);
    if ($tmp == $s) {
        echo 'Yes'.PHP_EOL;
        return;
    }
}

echo 'No'.PHP_EOL;


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

int main(){
	int N,M;
	cin>>N>>M;
	//基礎タイム
	int t=M*1800+N*100;
	
	//期待値はNの数だけ倍々
	for(int i=1;i<=M;i++){t=t*2;}
	cout<<t;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T1, typename T2>
ostream& operator << (ostream& os, const map<T1, T2>& m){
  for (const auto [k, v] : m) os << "{" << k << "," << v << "} ";
  return os;
}

string dp[11][10001] = {};

string smax(const string& s1, const string& s2) {
  if (s1.size() > s2.size()) return s1;
  if (s1.size() < s2.size()) return s2;
  return max(s1, s2);
}

int main() {
  int B[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  int N, M; cin >> N >> M;
  map<int, int> m;  // cnt, value
  int mmin = 10;
  for (int i = 0; i < N; ++i) {
    int A; cin >> A;
    if (!m.count(B[A])) m[B[A]] = A;
    else                m[B[A]] = max(m[B[A]], A);
    mmin = min(mmin, B[A]);
  }

  map<int, int> m2;
  for (auto [k, v] : m) m2[v] = k;

  int i = 0;
  for (const auto& [number, cnt] : m2) {
    string ss;
    ss = number + '0';
    for (int j = 0; j <= N; j++) {
      dp[i + 1][j] = dp[i][j];
    }
    dp[i + 1][cnt] = smax(dp[i + 1][cnt], ss + dp[i + 1][0]);
    for (int j = cnt + 1; j <= N; j++) {
      if (!dp[i + 1][j - cnt].empty()) {
        dp[i + 1][j] = smax(dp[i + 1][j], ss + dp[i + 1][j-cnt]);
      }
    }
    ++i;
  }

  cout << dp[i][N] << endl;
}


Measured memory_bytes: 130444
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(1, N):
        if A[i] < A[i-1]:
            sh = A[i-1] - A[i]
            A[i] += sh
            ans += sh
    print(ans)


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string s;
  cin >> s;
  ll n = s.size() / 2;

  ll ans = 0;
  REP(i, n) {
    ll match = true;
    rep(j, i) {
      if (s[j] != s[i + j]) {
        match = false;
        break;
      }
    }

    if (match) {
      ans = i;
    }
  }

  cout << ans * 2 << endl;

  return 0;
}


Measured memory_bytes: 256