akhauriyash/Code-Regression huggingface dataset:
w = input()
lst = [0] * 26

for i in range(len(w)):
    char_code = ord(w[i]) - ord("a")
    lst[char_code] += 1

sum = 0
for i in range(26):
    lst[i] %= 2
    sum += lst[i]

if sum == 0:
    print('Yes')
else:
    print('No')

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

constexpr int MAX = 200200;
constexpr int INF = (1 << 30);

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &e : a) cin >> e;
    
    vector<int> g[n];
    for (int i = 0; i < n - 1; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        g[s].emplace_back(t);
        g[t].emplace_back(s);
    }
    
    vector<int> dp(MAX, INF);
    vector<int> ans(n);
    stack<pair<int, pair<int, int>>> sta;
    sta.emplace(0, make_pair(0, 0));
    
    while (not sta.empty()) {
        int type = sta.top().first;
        if (type == 0) {
            int v, p; tie(v, p) = sta.top().second;
            sta.pop();
            auto it = lower_bound(dp.begin(), dp.end(), a[v]);
            sta.emplace(1, make_pair(it - dp.begin(), *it));
            *it = a[v];
            ans[v] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
            for (const int &u : g[v]) if (u != p) {
                sta.emplace(0, make_pair(u, v));
            }
        } else {
            int id, val;
            tie(id, val) = sta.top().second;
            sta.pop();
            dp[id] = val;
        }
    }
    
    for (const int &e : ans) cout << e << '\n';
    
    return 0;
}

Measured memory_bytes: 18872
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  int d, t, s;
  cin >> d >> t >> s;
  string ans = "No";
  if (s * t >= d) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int n;
    cin >> n;
    map<int, int> b, c;
    rep(i, n){
        int aa; cin >> aa;
        b[aa-i-1]++;
        c[aa+i+1]++;
    }


    ll ans =0 ;
    for (auto bi : b)
    {
        ans += (ll)c[-bi.first] * bi.second;
    }
    
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 29292
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 string s;
 cin>>s;
 if(s=="ABC")
    cout<<"ARC"<<endl;
 else
    cout<<"ABC"<<endl;

return 0;
}



Measured memory_bytes: 3644
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<62)-10e15;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
string S;
 
LL ans = INF;
 
void solve(){
	int s_seq = 0;
	ans = S.size();
	for(int i=0;i<S.size();i++){
		if(S[i]=='S') s_seq++;
		if(S[i]=='T'){
			if(s_seq>=1){
				s_seq--;
				ans -= 2LL;
			}
		}
	}
}
 
int main(){
    cin >> S;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int n, ans = 0;

void check(ll m) {  // 7,5,3のみからなる整数mが七五三数かどうか

    int flag3 = 0, flag5 = 0, flag7 = 0;

    while(m > 0) {

        if(m%10 == 3) {
            flag3 = 1;
        }
        else if(m%10 == 5) {
            flag5 = 1;
        }
        else if(m%10 == 7) {
            flag7 = 1;
        }

        m /= 10;
    }

    if(flag3 && flag5 && flag7) {
        ans++;
    }
}

void dfs(ll x) {

    if(n < x) {
        return;
    }

    check(x);

    dfs(10*x + 3);
    dfs(10*x + 5);
    dfs(10*x + 7);
}

int main() {

    cin >> n;

    dfs(0);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
public static void main (String[] args) {
Scanner scn= new Scanner(System.in);
		
            int x=scn.nextInt();
            int n=scn.nextInt();
            HashMap<Integer,Integer> map=new HashMap<> ();
            int min=Integer.MAX_VALUE;
            int max=Integer.MIN_VALUE;
		    int a[]= new int[n];
		    for(int i=0; i<n; i++){
                a[i]=scn.nextInt();
                map.put(a[i],1);
                min=Math.min(min,a[i]);
                max=Math.max(max,a[i]);
            }
            if(n==0){
                System.out.println(x);
            } else 
		    System.out.println(some(a,x,n,map,min,max));
		
	}
	public static int some(int a[],int x, int n,HashMap<Integer,Integer> map, int min, int max){
        // if(x<=min) return min-1;
        // if(x>=max) return max+1; 
        if(x<min){
            if((x-1)<=min){
                return x-1;
            } else {
                return x+1;
            } 
        }
        if(x>max){
            if((x-1)>max){
                return x-1;
            } else {
                return x+1;
            }
        }
        ArrayList<Integer> al=new ArrayList<> ();
        for(int i=min; i<=max; i++){
            if(!map.containsKey(i)){
                al.add(i);
            }
        }
        if(al.size()==0){
            if(Math.abs((min-1)-x)>Math.abs((max+1)-x)){
                return max+1;
            } else {
                return min-1;
            }
        }
        int mans=Integer.MAX_VALUE;
        int ans=0;
        Collections.sort(al);
        while(al.size()!=0){
            int p=al.get(0);
            int temp=Math.abs(x-p);
            if(temp<mans){
                mans=temp;
                ans=p;
            }     
            al.remove(0);
        }
        return ans;
	}
}


Measured memory_bytes: 26976
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

import static javax.swing.UIManager.put;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static String x;
    static String y;
    static Map<String,Integer> map = new HashMap<String,Integer>(){
        {put("A", 10);}
        {put("B", 11);}
        {put("C", 12);}
        {put("D", 13);}
        {put("E", 14);}
        {put("F", 15);}
    };


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

    public static void read() {
        x = sc.next();
        y = sc.next();
    }

    public static void solve() {
        if(map.get(x)>map.get(y)){
            System.out.println(">");
        } else if(map.get(x)<map.get(y)){
            System.out.println("<");
        }else {
            System.out.println("=");
        }
    }
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <string.h>
int main()
{
    int a,b,c,k;
    scanf("%d %d %d %d",&a,&b,&c,&k);

if(k<=a){
    printf("%d",k);
}
else if(k<=a+b){
    printf("%d",a);
}
else{
    printf("%d",a-(k-a-b));
}

    

  
    return 0;
}



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

int main() {
  	string s,t,ans;
  	int l;
  
  	cin >> s >> t;
  	
  	l = s.length();
  	if (s == t.substr(0,l))
      ans="Yes";
  	else
      ans = "No";

  	cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin>>n;

  ll ans=0;
  for(ll a=1; a<n; a++){
    ll kouho=n/a;
    if(n%a==0)
      kouho--;

    ans+=kouho;
  }

  cout<<ans<<endl;


}



Measured memory_bytes: 3648
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, n-1):
  if p[i-1] < p[i] < p[i+1]:
    ans += 1
  if p[i+1] < p[i] < p[i-1]:
    ans += 1

print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=2e5+5,M=4000+5;
const ll mod=1000000007LL;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;int a[N],b[N];ll dp[M][M],fac[M<<1];ll ans;
ll power(ll x,ll k){
	if(k==1LL)return x;
	ll t=power(x,k/2LL);t*=t;t%=mod;
	if(k&1)t*=x,t%=mod;
	return t;
}
ll C(int i,int j){
	ll ans=fac[i];
	(ans*=power(fac[j],mod-2LL))%=mod;
	(ans*=power(fac[i-j],mod-2LL))%=mod;
	return ans;
}
int main(){
	n=read();rep(i,1,n)a[i]=read(),b[i]=read();
	rep(i,1,n)dp[2001-a[i]][2001-b[i]]+=1LL;
	rep(i,1,4001)rep(j,1,4001)
	 (dp[i][j]+=dp[i-1][j]+dp[i][j-1])%=mod;
	fac[0]=1LL;rep(i,1,8000)(fac[i]=fac[i-1]*i)%=mod;
	rep(i,1,n)(ans+=dp[2001+a[i]][2001+b[i]])%=mod;
	rep(i,1,n)(ans+=mod-C((a[i]+b[i])*2,a[i]*2))%=mod;
    (ans*=power(2LL,mod-2LL))%=mod;
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main()
{
    ll n, k; cin >> n >> k;
    vector<int> a(n), sorted(n), cnt(n); for(int i = 0; i < n; i++)cin >> a[i];
    sorted = a;
    sort(sorted.begin(), sorted.end());
    for(int i = 0; i < n; i++) {
        cnt[i] = sorted.end() - upper_bound(sorted.begin(), sorted.end(), a[i]);
    }
    //for(int i = 0; i < n; i++)cout << cnt[i] << endl;
    ll sum = 0;

    for(int i = 0; i < n; i++) {

        ll cur = ((k * (k - 1) / 2) % mod ) * cnt[i]; 
        cur %= mod;
        sum += cur; sum %= mod;
    }

    ll unit = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            if(a[i] > a[j])unit++;
        }
    }

    cout << (((unit * k) % mod) + sum) % mod << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000

ll solve(vector<pll> a,ll w,ll x,ll i){	// recursive solution
	if(x>w || i==a.size())	return 0;
	ll res1=0,res2=0;
	if(x+a[i].first<=w){
		res1 = solve(a,w,x+a[i].first,i+1)+a[i].second;
	}
	res2 = solve(a,w,x,i+1);
	return max(res1,res2);
}

ll knapsack(vector<pll> a,ll w,ll n){	// dp solution without using matrix as only 1 previous row is needed
	vector<ll> prev(w+1,0),nxt(w+1);
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=w;j++){
			if(a[i-1].first<=j){
				nxt[j] = max(prev[j],a[i-1].second + prev[j-a[i-1].first]);
			}
			else{
				nxt[j] = prev[j];
			}
		}
		prev = nxt;
	}
	return prev[w];
}

ll knapsack2(vector<pll> a,ll w,ll n){
	vector<ll> dp(N,INF),tmp;
	dp[0] = 0;
	for(ll i=1;i<=n;i++){
		tmp = dp;
		for(ll j=1;j<=N;j++){
			if(a[i].second<=j){
				dp[j] = min(tmp[j],tmp[j-a[i].second]+a[i].first);
			}
		}
	}
	for(ll i=N-1;i>=0;i--){
		if(dp[i]<=w){
			// cout<<dp[i]<<endl;
			return i;
		}
	}
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,w;
	cin>>n>>w;
	vector<pll> a(N);
	for(ll i=1;i<=n;i++){
		cin>>a[i].first>>a[i].second;
	}
	cout<<knapsack2(a,w,n)<<endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;cin>>x;
    ll m=100;
    ll cnt = 0;
    while(m<x){
        m=m+m/100;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  string T="CODEFESTIVAL2016";
  int Ans=16;
  for(int i=0; i<16; i++){
    if(S.at(i)==T.at(i)){
      Ans--;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,res=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int l,r;
        cin>>l>>r;
        res+=r-l+1;
    }
    cout<<res<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
import java.lang.reflect.Array;
import java.util.*;

public class Main {

 public static int Appearance(int noi1, List<String> los1, int noi2, List<String> los2) {
	int count= 0; 
	 for(int i = 0; i < noi2; i++) {
		 for(int j = 0; j < noi1; j++) {
			 if(los2.get(i).equals(los1.get(j))){
				 count++;
				 break;
			 }
		 }
	 }
	 return count;
 }
 public static List<String> Strtolist(String los) {
	 String arr[] = los.split(" ");
		List<String> newarr = new ArrayList<String>();
		newarr = Arrays.asList(arr);
	 return newarr;
 }

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int noi1 = 0, noi2 = 0;
		String sos1 = "", sos2 = "";
		while (input.hasNextLine()) {
			noi1 = input.nextInt();
			input.nextLine();
			sos1 = input.nextLine();
			noi2 = input.nextInt();
			input.nextLine();
			sos2 = input.nextLine();
			List<String> los1 = Strtolist(sos1);
			List<String> los2 = Strtolist(sos2);
			System.out.println(Appearance(noi1, los1, noi2, los2 ));
		}
		input.close();
	}
}



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

#define fi first
#define se second

const int N = 100100;

using namespace std;

int n;
long long a[N];
long long d[N];
long long E, T;
long long pref[N];

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

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n >> E >> T;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
        }
        long long inf = 1e18;
        pref[0] = inf;
        for(int i = 1, h = 0; i <= n; i++){
                d[i] = inf;
                pref[i] = pref[i - 1];
                while(2 * (a[i] - a[h + 1]) >= T){
                        h += 1;
                }
                if(h > 0){
                        d[i] = 3 * a[i] + pref[h];
                }

                for(int dx = -50; dx <= 50; dx++){
                        int j = h + dx;
                        if(j < 1 || j > i){
                                continue;
                        }
                        long long D = a[i] - a[j];
                        d[i] = min(d[i], d[j - 1] + D + max(D * 2, T) + a[j] - a[j - 1]);
                }
                pref[i] = min(pref[i], - 2 * a[i] - a[i - 1] + d[i - 1]);
        }
        cout << d[n] + E - a[n] << "\n";
}


Measured memory_bytes: 2688
import java.util.*

object MainKt {
    @JvmStatic
    fun main(args: Array<String>) {
        val scanner = Scanner(System.`in`)
        val n = scanner.nextInt()
        val m = scanner.nextInt()

        val arr = BooleanArray(m){true}

        for (i in 0..n-1){
            val tmp = BooleanArray(m){false}
            val k = scanner.nextInt()
            for (j in 0..k-1){
                val a = scanner.nextInt()
                tmp[a-1] = true
            }
            for (j in 0..m-1){
                arr[j] = arr[j] && tmp[j]
            }
        }

        var ans = 0
        arr.forEach { if(it) ans++ }
        println(ans)

    }
}

Measured memory_bytes: 29468
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
char a[30000 + 5];
//实际上是子序列个数
//题解1：本来的o（n^2）会超时，但是根本不需要。
//本来我是枚举所有方案，重复则跳过，这样共cn3的情况。
//然而，答案不会超过1000；我只要验证1000种是否成立就可以了。（简化枚举量）
void solve1()
{
	int ans = 0;
	for (int i = 0; i <= 1000; i++)
	{
		int f = 0;
		int b[3] = { i / 100,(i / 10) % 10,i % 10 };
		for (int i = 0; i < strlen(a); i++)
		{
			if (a[i] - '0' == b[f])
				f++;
			if (f == 3) break;
		}
		if (f == 3) ans++;
	}
	printf("%d \n", ans);
}
int main()
{
	int n;
	cin >> n >> a;
	solve1();
	return 0;
}
//失败的深搜
/*void find(int i,int n,int tep=0)
{
	if (n == 3)
	{
		for (; i < strlen(a); i++)
		{
			if (!vis[3][a[i]-'0']) {
				vis[3][a[i]-'0'] = 1;
				find(i + 1, 2,tep*10+a[i]);
			}
		}
	}
	if (n == 2)
	{
		for (; i < strlen(a); i++)
		{
			if (!vis[2][a[i]-'0']) {
				vis[2][a[i]-'0'] = 1;
				find(i + 1, 1, tep*10 + a[i]-'0');
			}
		}
		memset(vis[2], 0, sizeof(vis[2]));
	}
	if (n == 1)
	{
		for (; i < strlen(a); i++)
		{
			if (!vis[1][a[i]-'0'] and !vis_[tep * 10 + a[i]-'0'])
			{
				vis_[tep * 10 + a[i]-'0']=1;
				vis[1][tep * 10 + a[i] - '0'];
				ans++;
			}
		}
		memset(vis[1], 0, sizeof(vis[1]));
	}
	return;
}*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		
		b = Math.max(Math.min(a + b - k, b), 0);
		a = Math.max(a - k, 0);
		
		System.out.println(a + " " + b);
		
		sc.close();
	}
	
}




Measured memory_bytes: 27088
import fractions
N,X = map(int,input().split())

x = list(map(int,input().split()))

x.insert(0,X)
diff = []
for i in range(len(x)-1):
	diff.append(abs(x[i+1]-x[i]))

ans = diff[0]
for i in range(1,len(diff)):
	ans = fractions.gcd(ans,diff[i])
    
print(ans)

Measured memory_bytes: 16240
function Main(input) {
  /** @type {number[]} */
  const aList = input[1].split(' ').map(Number);

  var nextBrick = 1;
  for (var i = 0; i < aList.length; i++) {
    if (aList[i] === nextBrick) {
      nextBrick++;
    }
  }

  const answer = nextBrick > 1 ? (aList.length - (nextBrick - 1)) : -1;

  console.log(answer);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

Measured memory_bytes: 22244
n,y=map(int,input().split())

pattern=0


if 10000*n==y:
  print(n,0,0)
  
  
else:
    for yukichi in range(n):
      if y-10000*yukichi<0:
          print(-1,-1,-1)
          break
          
      elif y-10000*n==0:
          print(n,0,0)
          break
    
      elif y-10000*yukichi-5000*(n-yukichi)==0:
        print(yukichi,n-yukichi,0)
        break
        
      else:      
        for higuchi in range(n-yukichi):
          if y-10000*yukichi-5000*higuchi-1000*(n-yukichi-higuchi)==0:
              print(yukichi,higuchi,n-yukichi-higuchi)
              break
        else:
            continue
        break
    else:
        print(-1,-1,-1)

      

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

int main()
{
    string S,T;cin >> S >> T;
    int n=S.size();
    bool can=true;
    for (int i=0;i<n;i++)
    {
        if (S[i]!=T[i]) can=false;
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3620
//ΔAGC029D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n,m,k,a[N];
int main()
{
	int i,x,y;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;i=i+1)
		a[i]=m+1;
	while(k--){
		scanf("%d%d",&x,&y);
		a[x]=min(a[x],y);
	}
	a[n+1]=1;
	x=1,y=1;
	for(i=1;i<=n;i=i+1){
		x++;
		if(a[x]<=y){
			cout<<i;
			return 0;
		}
		if(a[x]>y+1)
			y++;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>P2;
int dx[]={1,-1,2,-2,1,-1};
int dy[]={-1,-1,0,0,1,1};
int a[101][101],h,n;
string s[1001];
int sol(int yw,int xw){
    memset(a,0,sizeof(a));
    r(i,h)r(j,s[i].size()){
        if(s[i][j]=='0'){
            queue<P2>q;
            q.push(P2(P(i,j),'0'));
            while(!q.empty()){
                P2 p=q.front();q.pop();
                int y=p.first.first;
                int x=p.first.second;
                r(k,6){
                    int yy=y+dy[k];
                    int xx=x+dx[k];
                    if(yy<0||xx<0||s[yy].size()<=xx||yy>=h)continue;
                    if(isdigit(s[yy][xx])&&!a[yy][xx]){
                        if(p.second=='0'||s[yy][xx]==p.second){
                            a[yy][xx]=1;
                            q.push(P2(P(yy,xx),s[yy][xx]));
                        }
                    }
                }
            }
        }
    }
    queue<P2>q;
    q.push(P2(P(yw,xw),n+'0'));
    if(!a[yw][xw])while(!q.empty()){
        a[yw][xw]=2;
        P2 p=q.front();q.pop();
        int y=p.first.first;
        int x=p.first.second;
        r(k,6){
            int yy=y+dy[k];
            int xx=x+dx[k];
            if(yy<0||xx<0||s[yy].size()<=xx||yy>=h)continue;
            if(isdigit(s[yy][xx])&&!a[yy][xx]){
                if(s[yy][xx]==p.second){
                    a[yy][xx]=2;
                    q.push(P2(P(yy,xx),s[yy][xx]));
                }
            }
        }
    }
    int ans=0;
    r(i,h)r(j,s[i].size())if(isdigit(s[i][j])&&s[i][j]!='0')
      if(a[i][j]==0)ans++;
      else if(a[i][j]==2)ans--;
    return ans;
}
void solve(){
    int ans=-1e8;
    r(i,h)r(j,s[i].size()){
        if(s[i][j]=='0'){
            s[i][j]=n+'0';
            ans=max(ans,sol(i,j));
            s[i][j]='0';
        }
    }
    cout<<ans<<endl;
}
main(){
    while(cin>>h>>n,h){
        getline(cin,s[0]);
        r(i,h)getline(cin,s[i]);
        solve();
    }
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <set>

#define INF 1000000

using namespace std;

int H, W;

int main() {
  int N;
  vector<int> a;
  multiset<int> used1, unused1, used2, unused2;
  long long diff, diff_max;

  cin >> N;
  a.resize(N * 3);
  for (int i = 0; i < N * 3; i++) {
    cin >> a[i];
  }

  diff = 0;

  for (int i = 0; i < N; i++) {
    used1.insert(a[i]);
    diff += a[i];
  }
  multiset<int> S;
  for (int i = N; i < N * 3; i++) {
    S.insert(a[i]);
  }
  int cnt = 0;
  for (multiset<int>::iterator itr = S.begin(); itr != S.end(); itr++) {
    if (cnt < N) {
      used2.insert(*itr);
      diff -= *itr;
    } else {
      unused2.insert(*itr);
    }
    cnt++;
  }

  diff_max = diff;

  for (int i = 1; i <= N; i++) {    
    if (a[N + i - 1] >= *(used1.begin())) {
      diff += a[N + i - 1] - *(used1.begin());
      unused1.insert(*(used1.begin()));
      used1.erase(used1.begin());
      used1.insert(a[N + i - 1]);
    } else {
      unused1.insert(a[N + i - 1]);
    }

    if (a[N + i - 1] <= *(--used2.end())) {
      diff += a[N + i - 1] - *(unused2.begin());
      used2.insert(*(unused2.begin()));
      unused2.erase(unused2.begin());
      used2.erase(used2.find(a[N + i - 1]));
    } else {
      unused2.erase(unused2.find(a[N + i - 1]));
    }

    if (diff_max < diff) {
      diff_max = diff;
    }
  }

  cout << diff_max << endl;

  return 0;
}


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

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

int main() {

    int n, m; cin >> n >> m;

    int max_l = 0;
    int min_r = INF;

    for (int i = 0; i < m; ++i) {
        int l, r; cin >> l >> r;

        max_l = max(max_l, l);
        min_r = min(min_r, r);
    }

    if (max_l > min_r) {
        cout << 0 << endl;
    } else {
        cout << min_r - max_l + 1 << endl;
    }
}

Measured memory_bytes: 256
S = input()
T = input()
N = len(S)
num_swap = 0
for i in range(N):
    if num_swap > 24:
        print('No')
        break
    if S[i] != T[i]:
        s, t = S[i], T[i]
        S = S.replace(s, '0')
        S = S.replace(t, s)
        S = S.replace('0', t)
        num_swap += 1
else:
    if S == T:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3632
#include <iostream>
#include <set>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;

const int MAX = 100005;
int V, E, s, t, color[MAX], timer;
int prenum[MAX], parent[MAX], lowest[MAX];
vector<int> G[MAX];

//prenum[i]为dfs中点i的访问顺序
void dfs(int current, int prev)
{
    prenum[current] = lowest[current] = timer;//初始赋值prenum[current] = lowest[current]
    timer++;
    color[current] = 1;
    int next;

    for(int i=0; i<G[current].size(); i++)//遍历其所有的邻接点
    {
        next = G[current][i];//邻接点
        if(!color[next])//没有访问过，则可以建立生成树
        {
            parent[next] = current;//记录父节点
            dfs(next, current);//递归DFS
            lowest[current] = min(lowest[current], lowest[next]);//要与其
        }
        else if(next!=prev)
        {
            lowest[current] = min(lowest[current], prenum[next]);
        }
    }
}
void art_points()
{
    memset(color, 0, sizeof(color));
    timer = 1;
    dfs(0, -1);
    int p, ans = 0;
    set<int> S;
    for(int i=1; i<V; i++)
    {
        p = parent[i];
        if(p==0) ans++;
        else if(prenum[p]<=lowest[i]) S.insert(p);
    }
    if(ans>1) S.insert(0);
    set<int>::iterator it;
    for(it=S.begin(); it!=S.end(); it++)
    {
        printf("%d\n", *it);
    }
}
int main()
{
    scanf("%d %d", &V, &E);
    for(int i=0; i<E; i++)
    {
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
        G[t].push_back(s);
    }
    art_points();
    return 0;
}



Measured memory_bytes: 7408
/*
Submitted With (^^) by -> Hossam ^_^
 _____________________
|     ___     ___     |
|    (^_^)   (^_^)    |
|   /( | )\_/( | )\   |
|_____|_|_____|_|_____|
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;

inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};

#define X first
#define Y second
#define endl '\n'
#define ll long long
#define inf (0x7fffffffffffffff)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << (x) << "\n";
#define ZXC cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl;

// const int mod = (int)1e9 + 7;
const int mod = 998244353;
const int MX = (int)1e5 + 10;

int main()
{
    prep();

    int a[5] = {};
    for(int i = 0; i < 3; ++i){
        int x, y;
        cin >> x >> y;
        a[x]++;
        a[y]++;
    }

    sort(a + 1, a + 5);

    if(a[1] + a[2] == 2 && a[3] == 2) puts("YES");
    else puts("NO");


    return 0;
}

Measured memory_bytes: 256
X,Y=map(int,input().split())
mod=pow(10,9)+7
m=(2*X-Y)//3
n=(2*Y-X)//3
if  m==(2*X-Y)/3 and n==(2*Y-X)/3 and m>=0 and n>=0:
    bunsi = 1
    bunbo = 1
    for i in range(0, n):
        bunsi = (bunsi * (m + 1 + i)) % mod
        bunbo = (bunbo * (1 + i)) % mod
    print((bunsi * pow(bunbo, mod - 2, mod)) % mod)

else:
    print(0)

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

int main() {
  int n;
  while (cin >> n, n) {
    int matrix[n + 1][n + 1];
    for (int i = 0; i < n + 1; ++i) for (int j = 0; j < n + 1; ++j) matrix[i][j] = 0;
    
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
	cin >> matrix[i][j];
	matrix[i][n] += matrix[i][j];
	matrix[n][j] += matrix[i][j];
      }
    }
    
    for (int i = 0; i < n; ++i) matrix[n][n] += matrix[n][i];
    
    for (int i = 0; i < n + 1; ++i) {
      for (int j = 0; j < n + 1; ++j) {
	printf("%5d", matrix[i][j]);
      }
      printf("\n");
    }
  }
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{
    public void AtCoder()
    {
        int p = 1000000000 + 7;
        int n = int.Parse(Console.ReadLine());
        int[] c = new int[n+1];
        List<int>[] list = new List<int>[200010];
        for (int i = 0; i < 200010; i++) list[i] = new List<int>();
        for (int i = 1; i <= n; i++)
        {
            c[i] = int.Parse(Console.ReadLine());
            list[c[i]].Add(i);
        }
        long[] dp = new long[n + 1];
        dp[0] = 1;
        dp[1] = 1;
        long[] ac = new long[200010];
        ac[c[1]] = 1;
        for (int i = 2; i <= n; i++)
        {
            if (c[i - 1] == c[i]) dp[i] = dp[i - 1];
            else
            {
                ac[c[i]] += dp[i - 1];
                ac[c[i]] %= p;
                dp[i] = ac[c[i]];
            }
        }

        Console.WriteLine(dp[n]);
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 38128
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0; char ch = getchar();
	while( ch < '0' || ch > '9' ) ch = getchar();
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc;
}

const int MAXN = 100010;

vector < int > G[MAXN];
int f[MAXN], n;

inline void dfs(int x, int fa)
{
	for( auto y : G[ x ] ) if( y ^ fa ) dfs( y, x );
	int d = 20;
	for( ; ~d ; d-- )
	{
		int c = 0;
		for( auto y : G[ x ] ) if( y ^ fa ) if( f[ y ] >> d & 1 ) c++;
		if( c >= 2 ) { f[ x ] += 1 << d + 1; break; }
		else if( c == 1 ) f[ x ] |= 1 << d;
	}
	if( d == -1 ) f[ x ]++;
}

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d", &n );
	for( int i = 1, x, y ; i < n ; i++ ) scanf( "%d%d", &x, &y ), G[ x ].pb( y ), G[ y ].pb( x );
	dfs( 1, 0 );
	int ret = 0;
	while( ( 1 << ret + 1 ) <= f[ 1 ] ) ret++;
	cout << ret << endl;
}


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

using namespace std;

int maximo(int a, int b){
  if(a > b)
    return a;
  return b;
}

int main() {
  int a, b, flag =0;
  cin >> a >> b;
  for(int i = 1; i <= 3; i++){
    if((a * b * i)%2 != 0){
      flag = 1;
    }
  }

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

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <unistd.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    ll N;
    cin >> N;
    FOR(h,1,3501){
        FOR(n,1,3501){
            ll k = 4*h*n-N*n-N*h;
            ll l = N*h*n;
            if(0<k&&0<l&&l%k==0){
                ll w = l/k;
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int h,w,n;
  cin >> h >> w >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  vector<vector<int>> res(h,vector<int>(w));
  int nowh = 0;
  int noww = 0;
  int muki = 0;
  muki = 1;
  for(int i = 0;i < n;i++){
    while(1){
      //cout << i << " "<< nowh << " " << noww << endl;
      res[nowh][noww] = i + 1;
      a[i]--;
      nowh += muki;
      if(nowh > h - 1 || nowh < 0){
        noww++;
        muki *= -1;
        nowh += muki;
      }
      if(a[i] < 1)break;
    }
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cout << res[i][j];
      if(j == w - 1)cout << endl;
      else cout << " ";
    }
  }
}

Measured memory_bytes: 384
<>;
for(<>){
	($A,$B)=sort{$a-$b}glob;
	if($A==$B){
		print$A+$B-2,$/
	}elsif($A+1==$B){
		print$A+$B-3,$/
	}else{
		$C=int(sqrt($A*$B));
		$C-=$C*$C==$A*$B;
		if($C*($C+1)>=$A*$B){
			print$C*2-2,$/
		}else{
			print$C*2-1,$/
		}
	}
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m, k;
  cin >> n >> m >> k;
  vector<string> a(n);
  int sx, sy;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'S') {
        sx = i, sy = j;
      }
    }
  }
  int dx[] = {-1, 0, 0, 1};
  int dy[] = {0, -1, 1, 0};
  queue<pair<int, int>> q;
  vector<vector<int>> dis(n, vector<int>(m, -1));
  dis[sx][sy] = 0;
  q.push({sx, sy});
  while (!q.empty()) {
    auto u = q.front();
    q.pop();
    int x = u.first, y = u.second;
    for (int i = 0; i < 4; i++) {
      int tx = x + dx[i], ty = y + dy[i];
      if (tx >= 0 && tx < n && ty >= 0 && ty < m && a[tx][ty] == '.' && dis[tx][ty] == -1) {
        dis[tx][ty] = dis[x][y] + 1;
        q.push({tx, ty});
      }
    }
  }
  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (dis[i][j] != -1 && dis[i][j] <= k) {
        int minn = min(i, n - 1 - i);
        minn = min(minn, min(j, m - 1 - j));
        ans = min(ans, minn / k + (minn % k > 0));
      }
    }
  }
  cout << ans + 1 << endl;
  return 0;
}



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

#define rep(n) for(ll i=0;i<n;i++)
#define repp(j, n) for(ll j=0;j<n;j++)
#define reppp(i, m, n) for(ll i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 1e-10;

ll comb(ll fact[], ll rfact[], ll n, ll r){
    return (((fact[n] * rfact[r]) % MOD) * rfact[n-r]) % MOD;
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin >> n;
    
    ll fact[n+1], rfact[n+1];
    fact[0] = fact[1] = 1LL;
    rfact[0] = rfact[1] = 1LL;
    reppp(i, 2, n+1){
        fact[i] = (fact[i-1] * (ll)i) % MOD;
        rfact[i] = 1LL;
        ll k = MOD-2LL;
        ll a = fact[i];
        while(k > 0LL){
            if(k & 1LL){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }

    ll ans = 0LL, p_prev = 0LL;
    ll k = (n+1)/2;
    reppp(i, k, n){
        ll p = (((comb(fact, rfact, i-1, n-1-i) * fact[i]) % MOD) * fact[n-1-i]) % MOD;
        ans = (ans + (i * (p - p_prev + MOD)) % MOD) % MOD;
        p_prev = p;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, X, A_sum, B_sum, C_sum;
  int count = 0;
  int sum;
  cin >> A; 
  cin >> B;
  cin >> C;
  cin >> X;
  for (int i=0; i<=A; i++) {
    A_sum = 500 * i;
    for (int j=0; j<=B; j++) {
      B_sum = 100 * j;
      for (int k=0; k<=C; k++) {
        C_sum = 50 * k;
        sum = A_sum + B_sum + C_sum;
        if (X == sum) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,z;
    string y;
	cin >> x>> y>> z;
    int ans;
    if(y=="+")ans=x+z;
    else ans = x-z;
      cout << ans << endl;
}


Measured memory_bytes: 256
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
#define all(x) x.begin(), x.end()
 
using namespace std;    
const int N = int(1e5) + 12, mod = int(1e9)  + 7; 

int n,x,a[N],dp[202][N], obr[N];

ll modpow(ll a, ll b){
	ll res = 1;
	while(b){
		if(b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

int calc(int i,int x){
	if(i > n) return x;
	if(dp[i][x] != -1) return dp[i][x];
	int res = 1ll * calc(i + 1, x) * (n - i) % mod;
	res += calc(i + 1, x % a[i]);
	if(res >= mod) res -= mod;
	return dp[i][x] = 1ll * res * obr[n - i + 1] % mod;
}

void solve(){
	scanf("%d%d", &n, &x);

	int f = 1;

	memset(dp, -1, sizeof(dp));

	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		f = 1ll * f * i % mod;
		obr[i] = modpow(i, mod - 2);
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	printf("%d\n", 1ll * calc(1,x) * f % mod);

}

int main () {
	int T = 1;
	//scanf("%d", &T);

	while(T--){
		solve();
	}

return 0;
}

Measured memory_bytes: 82704
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define mian() main()
#define greater greater<int>()
VI findAll(string S,string pattern){VI P;ll pos=(ll)S.find(pattern);
while(pos!=string::npos){P.push_back(pos);pos=(ll)S.find(pattern,pos+1);}return P;}
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
bool is_prime(ll n){if(n<2)return 0;for(int i=2;i*i<n;i++)if(n%i==0)return 0;return 1;}
inline void eratosthenes(VB& p){rep(i,SZ(p))p[i]=1;p[0]=p[1]=0;
rep(i,SZ(p)/2+1){if(p[i])for(ll j=i+i;j<SZ(p);j+=i)p[j]=0;}}
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
using Graph=vector<vector<P> >;

int main(){
    ll n,x,a[MAX];cin>>n>>x;
    rep(i,n)cin>>a[i];
    ll ans=0;
    for(int i=1;i<n;i++){
        ll d=a[i]+a[i-1];
        if(d<=x){
            continue;
        }
        else {
            ll t=d-x;
            ans+=t;
            if(a[i]>=t){a[i]-=t;}
            else {a[i]=0;a[i-1]-=t-a[i];}
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

mod = 998244353

n, m, k = [int(x) for x in input().split()]

def make_tables(n, mod = 998244353):
    fac = [1, 1] # 階乗テーブル
    finv = [1, 1] #逆元の階乗テーブル
    inv = [0, 1] #逆元テーブル

    for i in range(2, n + 1):
        fac.append((fac[-1] * i) % mod)
        inv.append((mod -inv[mod % i] * (mod // i)) % mod)
        finv.append((finv[-1] * inv[-1]) % mod)
    return fac, finv

def nCk(n, k, mod = 998244353):
    k = min(k, n-k)
    return fac[n] * finv[k] * finv[n-k] % mod

fac, finv = make_tables(n)
cal = m
ans = 0
for i in range(n - 1 - k):
    cal *= m - 1
    cal %= mod
ans += cal * nCk(n - 1, k)
ans %= mod
for i in range(1, k + 1):
    cal *= (m - 1)
    cal %= mod
    ans += cal * nCk(n - 1, k - i)
    ans %= mod
print(ans)


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

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

    for (int i=0; i<s.size(); i++) {
        int rot = min(26 - (s.at(i) - 'a'), K);
        if (((s.at(i) - 'a' + rot) % 26) < (s.at(i) - 'a')) {
            s.at(i) = ((s.at(i) - 'a' + rot) % 26) + 'a';
            K -= rot;
        }
    }

    if (K > 0) {
        s.at(s.size()-1) = ((s.at(s.size()-1) - 'a' + K) % 26) + 'a';
        K = 0;
    }

    cout << s << endl;
    
    return 0;
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++) cin >> h[i];
    int ans = 0, cnt = 1;
    for(int i = 1; i < n; i++){
        if(h[i-1] >= h[i]) cnt++;
        else ans = max(cnt, ans), cnt = 1;
    }
    ans = max(cnt, ans);

    cout << ans-1;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	ll N, M;
	cin >> N >> M;
	vector<pair<ll, pll>> RCL(M);
	rep(i, M) {
		cin >> RCL[i].second.second >> RCL[i].first >> RCL[i].second.first;
		RCL[i].second.second--;
	}
	sort(RCL.begin(), RCL.end(), less <pair<ll, pll>>());       // <<<<<<<
	vl dist_min(N, pow(10, 18));
	dist_min[0] = 0;
	rep(i, M) {
		ll L = RCL[i].second.second;
		ll R = RCL[i].first + 2;
		while (1) {
			ll m = (L + R) / 2;
			if (L == m)
				break;
			if (m >= N)
				break;
			ll dist_new = dist_min[RCL[i].second.second] + RCL[i].second.first;
			if (dist_new > dist_min[m]) {
				L = m + 1;
			}
			else
				R = m;
		}
		for (int rtmp = L; rtmp < RCL[i].first; rtmp++) {
			if (rtmp >= N)
				break;
			dist_min[rtmp] = min(dist_min[rtmp], dist_min[RCL[i].second.second] + RCL[i].second.first);
		}
	}
	if (dist_min[N-1] > pow(10, 15))
		dist_min[N-1] = -1;
	cout << dist_min[N-1] << endl;
	return 0;
}

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

int main()
{
    int score;
    cin >> score;

    if(score < 1200) {
        cout << "ABC" << endl;
    } else if(score < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
a = set()
b = set()

A,B,K = map(int,input().split())

for i in range(1,max(A,B) + 1):
  if A % i == 0: a.add(i)
  if B % i == 0: b.add(i)

c = sorted(list(b.intersection(a)),reverse=True)

print(c[K - 1])


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{ int n;
int min=1000000, max=-1000000; 
long sum=0; cin >> n; 
for(int i=0; i<n; i++)
{ int in;
cin >> in;
if(in<min) min = in; 
if(in>max) max = in;
sum += in;
 } cout << min << " " << max << " " << sum << endl; }


Measured memory_bytes: 3116