akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//WA

int main(void){
	int N,M,d[100010]={},n[100010],x,y,ans=0;
	cin>>N>>M;
	reg(i,1,N)n[i]=1;
	d[1]=1;
	rep(i,M){
		cin>>x>>y;
		if(d[x]!=0){
			d[y]=1;
		}
		n[y]++;
		n[x]--;
		if(n[x]==0)d[x]=0;
	}
	reg(i,1,N){
		if(d[i]!=0)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    ll max1, min1;
    ll max2, min2;
    max1=max2=-1e10;
    min1=min2=1e10;
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        chmax(max1, x+y);
        chmin(min1, x+y);
        chmax(max2, x-y);
        chmin(min2, x-y);
    }
    cout << max(max1-min1, max2-min2) << endl;    

    return 0;

}


Measured memory_bytes: 3608
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}



void solve()
{
    ll n,s;cin>>n>>s;
    ll a[n+3];for(ll i=1;i<=n;i++)cin>>a[i];
    ll dp[n+2][s+3];
    
    memset(dp,0,sizeof dp);
    dp[0][0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=s;j++)
        {
            (dp[i][j] += 2*dp[i-1][j])%=newMOD;
            if(j+a[i]<=s)
            {
                (dp[i][j+a[i]] += dp[i-1][j])%=newMOD;
            }
        }
    }
    ll ans =0;
    
    cout<<dp[n][s]<<endl;
        
    
}
signed main()
{
   Need_for_speed(activated);
    
//satisfy
//    {
//   solve();
//   }

    solve();
    return 0;
}


Measured memory_bytes: 74068
def solve():
    N = int(input())
    S = input()
    ans = 0
    for i in range(1, N):
        cnt = 0
        for c in list(set(S[:i])):
            if c in list(set(S[i:])):
                cnt += 1
        ans = max(ans, cnt)
    print(ans)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 9092
s = input()
n = len(s)


def palindrome(string):
    if string == string[::-1]:
        return 1
    else:
        return 0


a = s[:int((n-1)/2)]
b = s[int((n+3)/2-1):]

if palindrome(s) + palindrome(a) + palindrome(b) == 3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val ignore = readLine()
    val numbers = readLine()
        ?.split(" ")
        ?.map { it.toInt() }
        ?.sortedDescending()
        ?: return

    var alice = 0
    var bob = 0

    for ((i, num) in numbers.withIndex()) {
        if ((i % 2) == 0) {
            alice += num
        } else {
            bob += num
        }
    }

    println(alice - bob)
}

Measured memory_bytes: 36088
n, m = gets.split.map(&:to_i)
a, b = m.times.map{ gets.strip.split.map(&:to_i) }.transpose

ab = (a + b)
foo = (1..n).to_a
result = []
for var in foo do
    baz = ab.count(var)
    result.push(baz)
end

puts result


Measured memory_bytes: 1788
N,M=map(int,input().split())
A=list(map(int,input().split()))
p=[(A[i],1) for i in range(N)]
for j in range(M):
    B,C=map(int,input().split())
    p.append((C,B))
p.sort()
p.reverse()
ans,cnt=0,N
for (v,c) in p:
    use=min(c,cnt)
    ans+=use*v
    cnt-=use
print(ans)


Measured memory_bytes: 77080
#include <iostream>
#include <vector>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int n, p;
	while(cin >> n >> p, n||p){
		int sum = p;
		int idx = 0;
		vector<int> a(n, 0);
		while(true){
			if(sum == 0){
				sum = a[idx];
				a[idx] = 0;
			}else{
				sum--;
				a[idx]++;
			}
			if([&]() -> bool {
					int cnt = 0;
					rep(i,n){
						if(a[i] == 0) cnt++;
					}
					return n - 1 == cnt and sum == 0;
					}()
			  ){
				break;
			}
			idx++;
			idx %= n;
		}
		cout << idx << endl;
	}
}



Measured memory_bytes: 3068
#include<stdio.h>
int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	
	if(x!=2 || y!=2){
	if(x==1&&y==3 || x==1&&y==5 || x==1&&y==7 || x==1&&y==8 || x==1&&y==10 || x==1&&y==12){
	printf("Yes\n");}else if(x==3&&y==5 || x==3&&y==7 || x==3&&y==8 || x==3&&y==10 ||x==3&&y==12){
	printf("Yes\n");}else if(x==5&&y==7 || x==5&&y==8 || x==5&&y==10 || x==5&&y==12){
	printf("Yes\n");}else if(x==7&&y==8 || x==7&&y==10 ||x==7&&y==12){
	printf("Yes\n");}else if(x==8&&y==10 || x==8&&y==12){
	printf("Yes\n");}else if(x==10&&y==12){
	printf("Yes\n");}else if(x==4&&y==6 || x==4&&y==9 || x==4&&y==11){
	printf("Yes\n");}else if(x==6&&y==9||x==6&&y==11){
	printf("Yes\n");}else if(x==9&&y==11){
	printf("Yes\n");}else{printf("No\n");}}
	else{printf("No\n");}
	return 0;
}

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

int D;
vector<long long> c(26);
long long s[366][26];
long long score=0;
vector<int> last(26,0);
vector<int> ans;

int main(){
	cin >> D;
	for(int i=0;i<26;i++)cin >> c[i];
	for(int d=1;d<=D;d++)for(int i=0;i<26;i++)cin >> s[d][i];
	
	for(int d=1;d<=D;d++){
		long long add=-999999999999;
		int maxx=-1;
		for(int x=0;x<26;x++){
			long long tmp=s[d][x];
			for(int i=0;i<26;i++){
				if(i!=x)tmp-=c[i]*(d-last[i]);
			}
			if(tmp>add){
				add=tmp;
				maxx=x;
			}
		}
		score+=add;
		last[maxx]=d;
		ans.push_back(maxx);
	}
	for(auto i:ans)cout << i+1 << endl;
	return 0;
}

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

int main(){
    long long i, j, k;
    long long N, Q;
    cin >> N >> Q;
    vector<long long> a(2*N), b(2*N);
    for(i=0; i<2*N; i++) cin >> a[i];
    for(i=0; i<2*N; i++) cin >> b[i];
    long long asum = 0;
    for(i=0; i<2*N; i++) asum += a[i];
    priority_queue<long long> neg;
    priority_queue<long long, vector<long long>, greater<long long>> pos;
    long long psum = 0, np = 0;
    for(i=1; i<2*N-1; i++){
        if(a[i] < b[i]){
            pos.push(b[i] - a[i]);
            psum += b[i] - a[i];
            np += 1;
        }else{
            neg.push(b[i] - a[i]);
        }
    }
    map<long long, long long> del;

    for(i=0; i<Q; i++){
        long long p, x, y;
        cin >> p >> x >> y;
        p -= 1;
        asum += x - a[p];
        long long prev = b[p] - a[p];
        long long now = y - x;
        a[p] = x;
        b[p] = y;

        if(0 < p && p < 2*N-1){
            if(prev > 0){
                psum -= prev;
                np -= 1;
            }
            if(now > 0){
                psum += now;
                np += 1;
                pos.push(now);
            }else{
                neg.push(now);
            }
            if(!pos.empty() && prev == pos.top()){
                pos.pop();
                while(!pos.empty() && del[pos.top()] > 0){
                    del[pos.top()] -= 1;
                    pos.pop();
                }
            }else if(!neg.empty() && prev == neg.top()){
                neg.pop();
                while(!neg.empty() && del[neg.top()] > 0){
                    del[neg.top()] -= 1;
                    neg.pop();
                }
            }else{
                del[prev] += 1;
            }
        }

        long long ans;
        if(np % 2 == 0){
            ans = asum + psum;
        }else{
            ans = asum + psum + max(-pos.top(), neg.top());
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 12772
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void){
    int N;
    vector <string> s;
    string str;
    bool judge = true;
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> str;
        s.push_back(str);
    }
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++){
            if(s[j] == s[i]){
                judge = false;
            }
        }
        
        for(int j = i + 1; j < N; j++){
            if(s[j] == s[i]){
                judge = false;
            }
        }
        
        if(!judge){
            break;
        }
    }
    
    for(int i = 1; i < N; i++){
        if(s[i - 1][s[i - 1].length() - 1] != s[i][0]){
            judge = false;
        }

        if(!judge){
            break;
        }    
    }
    
    if(judge){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  rep(i,3){
    int h1,h2,m1,m2,s1,s2;
    cin>>h1>>m1>>s1>>h2>>m2>>s2;
    int sum=(h2*3600+m2*60+s2)-(h1*3600+m1*60+s1);
    cout<<sum/3600<<" ";
    sum%=3600;
    cout<<sum/60<<" ";
    sum%=60;
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 3092
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	while (N) {
		int num[50] = {};
		int box = M;
		for (int i = 0; i < 10000000; i++) {
			if (box) {
				num[i%N]++;
				box--;
				if (num[i%N] == M) {
					cout << i%N << endl;
					break;
				}
			}
			else {
				box += num[i%N];
				num[i%N] = 0;
			}
		}
		cin >> N >> M;
	}
	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	sint N = read<sint>();
	sint K = read<sint>();
	sint Q = read<sint>();
	vector<sint> As;
	for (sint i = 0; i < Q; ++i) {
		As.push_back(read<sint>());
	}

	vector<sint> scores(N, 0);
	for (sint a: As) {
		++scores[a - 1];
	}

	for (sint i = 0; i < N; ++i) {
		if (K - Q + scores[i] > 0) {
			writeln("Yes");
		}
		else {
			writeln("No");
		}
	}
}

Measured memory_bytes: 2292
#include <bits/stdc++.h>
#define fi first
#define sc second
#define forn(i,p,k) for(int (i)=(p);(i)<=(k);++(i))
using namespace std;
typedef long long ll;
const int MM=200013;
const int bs=(1<<18);
ll T[bs<<1];
ll Query(int p, int k)
{
    if(p>k) return 0;
    ll wyn=0;
    for(p+=bs-1,k+=bs+1;p+1!=k;p>>=1,k>>=1)
    {
        if((p&1)==0)    wyn=max(wyn,T[p+1]);
        if((k&1)==1)    wyn=max(wyn,T[k-1]);
    }
    return wyn;
}
void Upd(ll v, int ind)
{
    for(ind+=bs;ind;ind>>=1)    T[ind]=max(T[ind],v);
}
int h[MM],war[MM];
int main()
{
    ios_base::sync_with_stdio(0);
    int n,a,b;
    cin>>n;
    forn(i,1,n) cin>>h[i];
    forn(i,1,n) cin>>war[i];
    forn(i,1,n) Upd(Query(1,h[i]-1)+war[i],h[i]);
    cout<<Query(1,n);
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define FOR(a,b,n) for(int a=b;a<=b;a++)
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("d",&a,&b)
#define sccc(a,b,c) scanf("d%d",&a,&b,&c)
#define sccs(s) scanf("%s",s)
#define pccs(s) printf("%s",s)
#define debug printf("---debug---");
#define pcc(a,b) printf("d",a,b)
#define pccc(a,b,c) printf("d%d",a,b,c)
#define pb push_back
typedef long long ll;
const int MAXN_1e5=1e7+500;
const int MAXN_2e5=2e5+5;
const int MAXN_3e5=3e5+5;
const int MAXN_4e5=4e5+5;
const int MAXN_5e5=5e5+5;
const int INF_INT=0x3f3f3f3f;
const long long INT_LL=2e18;
int main()
{
    ll a,b;
    while(cin>>a>>b)
    {
        ll g=__gcd(a,b);
        int cnt=1;
        int c=sqrt(g);
        for(int i=2;i<=c;i++)
        {
            if(g%i==0)
            {
                cnt++;
                while(g%i==0)g/=i;
            }
        }
        if(g!=1)cnt++;
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N,M,X;  cin >> N >> M >> X;

  int costleft = 0;
  int costright = 0;
  for(int i = 0;i < M;i++){
    int mass; cin >> mass;
    if(mass < X)costleft++;
    else costright++;
  }

  cout << min(costleft,costright) << endl;



}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	int S = 0;
	int n = N;
	while (n != 0) {
		S += n % 10;
		n /= 10;
	}
	if (N % S == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*k+(j))

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  qsort(a,n,sizeof(int),cmp);
  int *dp=(int *)malloc(sizeof(int)*k);
  int l=-1;
  int r=n;
  while(r-l>1){
    int m=(l+r)/2;
    for(i=0;i<k;i++) dp[i]=0;
    dp[0]=1;
    for(i=0;i<n;i++){
      if(i==m) continue;
      int j;
      for(j=k-1;j>=a[i];j--){
	if(dp[j-a[i]]==0) continue;
	dp[j]=1;
      }
    }
    for(i=k-1;dp[i]==0;i--);
    if(i+a[m]>=k){
      r=m;
    } else {
      l=m;
    }
  }
  printf("%d\n",l+1);
}

int main(void){
  run();
  return 0;
}


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

struct CARD{
    char symble;
    int value;
};

void print_array(struct CARD a[],int n){
    for(int i=0;i<n;i++){
        if(i != 0) cout<<' ';
        cout<<a[i].symble<<a[i].value;
    }
    cout<<'\n';
}
void bubble_sort(struct CARD a[],int n){
    int start = 0;
    int flag = 1;
    while (flag){
        flag = 0;
        for (int j=n-1;j>start;j--){
            if (a[j].value<a[j-1].value){
                CARD t = a[j];
                a[j]=a[j-1];
                a[j-1]=t;
                flag = 1;
            }
        }
        start++;
    }
    print_array(a,n);
}
void selection_sort(struct CARD a[],int n){
    for(int i=0;i<n;i++){
        int min_key = i;
        for(int j=i;j<n;j++){
            if(a[j].value<a[min_key].value) {min_key = j;}
        }
        CARD t = a[i];
        a[i]=a[min_key];
        a[min_key]=t;
    }
    print_array(a,n);
}
bool compare_array(struct CARD a[],struct CARD b[],int n){
    for(int i=0;i<n;i++){
        if(a[i].symble != b[i].symble) {return false;}
    }
    return true;
}

int main(){
    CARD A[100],B[100];
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i].symble>>A[i].value;
    }
    for(int i=0;i<N;i++){
        B[i]=A[i];
    }
    bubble_sort(A,N);
    cout<<"Stable"<<'\n';
    selection_sort(B,N);
    if(compare_array(A,B,N)){
        cout<<"Stable"<<'\n';
    }else{
        cout<<"Not stable"<<'\n';
    }
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<stdlib.h>

struct Node{
  int key;
  struct Node *r,*l,*p;
};

 struct Node *B,*NIL;

void insert(int k){
   struct Node *y = NIL;
   struct Node *x = B;
   struct Node *z;

   z = (struct Node *)malloc(sizeof(struct Node));
   z->key = k;
   z->l = NIL;
   z->r = NIL;

   while(x!=NIL){
     y = x;
     
     if(z->key < x->key){
       x = x->l;
     }
     else x = x->r;
   }
   
   z->p = y;
   if(y == NIL ){
     B=z;
   }
   else if(z->key < y->key){
       y->l = z;
     }
   else y->r = z;
}




void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u == NIL )return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  
  int i,x,y;
  char G[8];
  scanf("%d",&x);
  
  for(i=0;i<x;i++){
    scanf("%s",&G);
    
    if(G[0] == 'i'){
      scanf("%d",&y);
      insert(y);
    }
    
    else if(G[0] == 'p'){
      inorder(B);
      printf("\n");
      preorder(B);
      printf("\n");
    }
  }
  return 0;
}

  



Measured memory_bytes: 25124
N = int(input())
opens = [list(input().split()) for _ in range(N)]
values = [list(map(int, input().split())) for _ in range(N)]

ans = -(10**9)
for time in range(1, 2**10):
  sum_v = 0
  for idx, open in enumerate(opens):
    open_str = ''.join(open)
    bin_str = format(time, '010b')
    both_open = int(bin_str, 2)&int(open_str, 2)
    cnt = 0
    for char in format(both_open, '010b'):
      if char == '1':
        cnt += 1
    sum_v += values[idx][cnt]
  ans = max(ans, sum_v)
print(ans)
      

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){


	int n;cin>>n;
	int cnt[n+1];
	memset(cnt,0,sizeof(cnt));
	for(int i=2;i<=n;i++){
		int x;cin>>x;
		cnt[x]++;
	}
	rep(1,n+1) cout<<cnt[i]<<endl;

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


Measured memory_bytes: 5164
#include <iostream>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
  tmp = a;
  a = c;
  c = tmp;
  cout << a << " " << b << " " << c << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,x,t = map(int,readline().split())
#print((n+x-1)//x*t)

n = input()
v = sum(int(i) for i in n)
if v%9==0:
    print("Yes")
else:
    print("No")







Measured memory_bytes: 9248
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    for (int i = 1; i <= 3500; i++) {
        for (int j = 1; j <= 3500; j++) {
            int x = lcm(lcm(i, j), n);
            int a = 4 * (x / n), b = x / i, c = x / j;
            if (a - b - c > 0 && x % (a - b - c) == 0) {
                cout << i << " " << j << " " << x / (a - b - c) << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first 
#define S second 
#define inf INFINITY
#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ; 
#define pb push_back
#define pf push_front  
#define mp make_pair
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define Rep(i,a,b) for ( int i = a ; i < b ; i++)
#define range(i,s) for ( auto i : s) 
#define sor(v) sort ( v.begin() , v.end()) ;
#define rev(v) reverse(v.begin() , v.end()) ; 
#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define _3102_ main()
typedef long long ll ;
typedef long double ld ; 
using namespace std ;
const int N = 1e5 + 100  ; 
const ll mod = 1e9 + 7  ;

ll n , arr[N] , ans[N]= { }  ; 

 

int _3102_ {
    Gamed    
    cin >> n ; 
    for ( int i = 0 ; i < n ; i ++){
        cin >> arr[i] ; 
    }
    for( int i = 0 ; i < n ; i ++){
        if ( i == 0 ){
            ans[i] = 0 ; 
        }
        else if ( i == 1 ){
            ans[i] =  abs(arr[1]-arr[0]); 
        }
        else {
            if ( ans[i-1]+abs(arr[i]-arr[i-1]) <= ans[i-2]+abs(arr[i]-arr[i-2])){
                ans[i] += ans[i-1]+ abs ( arr[i]-arr[i-1]) ; 
            }
            else {
                ans[i] += ans[i-2]+ abs ( arr[i]-arr[i-2]) ; 
            }
        }
    } 
    cout << ans[n-1] ; 
    return 0 ;  

}


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

int main() {
  int N;
  scanf("%d", &N);
  vector<int> a(N), dp(N);
  for (int &x : a) {
    scanf("%d", &x);
  }

  dp[0] = 0;
  fill(dp.begin() + 1, dp.end(), 2e9);
  for (int i = 0; i < N; ++i) {
    if (i <= N - 3) {
      dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
    }
    if (i <= N - 2) {
      dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
    }
  }

  printf("%d\n", dp[N - 1]);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        main_ITP1_1_C(args);
    }

    public static void main_ITP1_1_C(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(String.format("%d %d", a * b, (a + b) * 2));
    }
}



Measured memory_bytes: 26176
S = list(map(int, input()))
ans1 = 0
ans2 = 0
for i in range (len(S)):
  if i % 2 == 0:
    if S[i] == 0:
      ans1 += 1
  else:
    if S[i] == 1:
      ans1 += 1
for i in range(len(S)):
  if i % 2 == 0:
    if S[i] == 1:
      ans2 += 1
  else:
    if S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;
map<int,int> m;
int n,a[222222];
signed main(void){
   cin>>n;
   rep(i,n)cin>>a[i];
   rep(i,n){
       m[a[i]]++;
   }
   int f=0;
   for(auto x:m){
       if(x.second>1)f=1;
   }
   if(f)cout<<"NO"<<endl;
   else cout<<"YES"<<endl;
}


Measured memory_bytes: 14336
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*A = map(int,read().split())

rest = 0
answer = 0
for x in A:
    if not x:
        rest = 0
        continue
    if rest:
        x -= 1
        answer += 1
    q,rest = divmod(x,2)
    answer += q

print(answer)

Measured memory_bytes: 12512
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007

void add(ll &a,ll b)
{
    a = (a + b) % MOD;
}

int main()
{
    string K; cin>>K;
    ll D; cin>>D;
    ll N = K.length();
    
    ll dp[N][D][2]; //dp[i][j][k]: k tells whether (till i) there is some digit smaller than K[i]  
    memset(dp,0,sizeof(dp));
    
    //cout<<dp[1][0][1]<<endl;
    
    //base case
    dp[0][(K[0] - '0') % D][1] = 1;
    for(ll i=0;i<(K[0] - '0');++i)
        dp[0][i%D][0]++;
    
    //cout<<dp[0][0][0]<<endl;
    
    for(ll i=1;i<N;++i)
    {
        for(ll s=0;s<D;++s)
        {
            //cout<<"For: "<<i<<" "<<s<<" "<<endl;
            for(ll d = 0;d<10;++d)
            {
                if(K[i] - '0' == d)
                    add(dp[i][s][1],dp[i - 1][(s - d%D + D) % D][1]);
                else if(K[i] - '0' > d)
                    add(dp[i][s][0],dp[i - 1][(s - d%D + D) % D][1]);
                    
                add(dp[i][s][0],dp[i - 1][(s - d%D + D) % D][0]);
            }
            
            
        }
    }
    
    cout<<((dp[N - 1][0][0]%MOD + dp[N - 1][0][1]%MOD - 1 + MOD) % MOD)<<endl;
}

Measured memory_bytes: 19180
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<f64>();
    let t = v[0];
    let x = v[1];
    println!("{}", t / x);
}


Measured memory_bytes: 4352
#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>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int digits(long long n){
	if(n == 0) return 1;
	int res = 0;
	while(n > 0){
		n /= 10;
		res++;
	}
	return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int s[m];
    char c[m];
    rep(i,m) cin >> s[i] >> c[i];
    rep(i,1000){
    	if(digits(i) != n) continue;
    	bool ok = true;
    	string t = to_string(i);
    	rep(j,m){
    		if(t[s[j]-1] != c[j]) ok = false;
    	}
    	if(ok){
    		cout << t << endl;
    		return 0;
    	}
    }
    cout << -1 << endl;
    return 0;
}


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

int main()
{
        ll N,M;
        cin>>N>>M;
        if(M/2<=N){
            cout<<M/2<<endl;
        }
        else{
            ll ans=N;
            M=M-2*N;
            ans=ans+M/4;
            cout<<ans<<endl;
        }
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n;
    scan(n);

    writeln(n / 100 == n % 10 ? "Yes" : "No");
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;

  vector<int> v(n);
  int mx = 0;
  int tmp = 0;

  for(int i=0; i<n; i++){
    cin >> v[i];
    tmp += v[i];
    if(i>k-1) tmp -= v[i-k];

    mx = max(mx, tmp);
  }

  double predict = (double)(mx + k)/2.0;
  printf("%.10f\n", predict);
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
using namespace std;
#define mod 1000000007
#define N 200050
int n,m,dp[N][2][2],fg,mx,fg2,dp2[N],su[N],as;
char s[N];
int main()
{
	scanf("%d%d%s",&n,&m,s+1);
	for(int i=2;i<=m;i++)if(s[i]!=s[i-1])fg=1;
	if(!fg)
	{
		dp[1][1][1]=dp[1][0][0]=1;
		for(int i=2;i<=n;i++)
		dp[i][0][0]=(dp[i-1][0][0]+dp[i-1][1][0])%mod,
		dp[i][0][1]=(dp[i-1][0][1]+dp[i-1][1][1])%mod,
		dp[i][1][0]=dp[i-1][0][0],
		dp[i][1][1]=dp[i-1][0][1];
		printf("%lld\n",(1ll*dp[n][0][0]+dp[n][0][1]+dp[n][1][0])%mod);
		return 0;
	}
	int su1=0;
	for(int i=1;i<=m;i++)
	if(s[i]==s[1])su1++;
	else
	{
		if((su1&1)&&mx>su1)mx=su1;
		if(!fg2)mx=su1+1;
		fg2=1;su1=0;
	}
	if(mx>n)mx=n;
	if(~mx&1)mx--;
	dp2[1]=1;su[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(i-mx>3)dp2[i]=(su[i-2]-su[i-mx-3]+mod)%mod;
		else dp2[i]=su[i-2];
		su[i]=(su[i-2]+dp2[i])%mod;
	}
	for(int i=1;i<=mx;i+=2)as=(as+1ll*dp2[n-i]*(i+1))%mod;
	printf("%d\n",as);
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  char t;
  bool a[4]={};
  for(;cin>>t;){
    if(t=='N') a[0]=1;
    if(t=='S') a[1]=1;
    if(t=='E') a[2]=1;
    if(t=='W') a[3]=1;
  }
  cout<<(!(a[0]^a[1])&&!(a[2]^a[3])?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    s = input()
#    s = "FT"*4000
    x,y = map(int,ipt().split())
#    x = 2000
#    y = 2000

    move = [[],[]]
    p = 0
    nm = 0
    for i in s:
        if i == "T":
            move[p].append(nm)
            nm = 0
            p = 1-p
        else:
            nm += 1
    move[p].append(nm)

    st = set([move[0][0]])
    for i in move[0][1::]:
        nst = set()
        for j in st:
            nst.add(j+i)
            nst.add(j-i)
        st = nst.copy()
    if not x in st:
        print("No")
        exit()

    st = set([0])
    for i in move[1]:
        nst = set()
        for j in st:
            nst.add(j+i)
            nst.add(j-i)
        st = nst.copy()
    if not y in st:
        print("No")
        exit()

    print("Yes")

    return None

if __name__ == '__main__':
    main()


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

mint choose(int n,int k,int type=0){
	if(k==0) return 1;
	if(n< k) return 0;
	if(type==0){
		return fact(n)*fact_inverse(k)*fact_inverse(n-k);
	}
	else{
		if(k>n-k) k=n-k;
		mint res=fact_inverse(k);
		rep(i,k) res*=n-i;
		return res;
	}
}

int main(){
	int n,m; cin>>n>>m;

	mint res=0;
	rep(k,n+1) res+=(k%2==0?1:-1)*choose(n,k)*choose(m-k,n-k)*fact(n-k);
	cout<<res*choose(m,n)*fact(n)<<'\n';

	return 0;
}


Measured memory_bytes: 8972
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <iomanip>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
    unsigned long long int n, k;
    cin >> n >> k;
    unsigned long long int a;
    while (n > 0) {
        n /= k;
        ++a;
    }
    cout << a;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char* a[]={".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
int main()
{
    int n;
    scanf("%d", &n);
    while (n--) {
        char s[1100];
        int i, k=-1;
        scanf("%s", s);
        for(i=0;s[i];++i) {
            int c;
            if (s[i]=='0') {
                if (k>=0) {
                    putchar(a[c][k%strlen(a[c])]);
                    k=-1;
                }
            }
            else {
                ++k;
                c=s[i]-'1';
            }
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 592
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    X = ii()
    print(10 - X//200)




main()



Measured memory_bytes: 9980
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 10005;
int c[MAX];
int main(void)
{int n;
	int *a, *b;
	scanf("%d", &n);
	a = new int[n + 1];
	b = new int[n + 1];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
		++c[a[i]];
	}
	int i;
	bool flag = false;
	for (i = 0; i <= MAX; ++i)
	{
		while (c[i])
		{
			--c[i];
			printf("%d", i);
			flag = true;
			break;
		}
		if (flag)
			break;
	}
	for (; i <= MAX; ++i)
	{
		while (c[i])
		{
			--c[i];
			printf(" %d", i);
		}
	}
	
	
	putchar('\n');
	return 0;
}

Measured memory_bytes: 10992
#include<iostream>
using namespace std;
using ll=long long;
ll n,a[2000],b[2000],ans,x,y;
int i;
int main(){
cin>>n;
while(i<n)cin>>a[i]>>b[i],++i;

x=y=1;i=0;
while(i<n){
ll r=max((x+a[i]-1)/a[i],(y+b[i]-1)/b[i]);
x=a[i]*r,y=b[i]*r;++i;
}ans=x+y;
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
//#define int long long
//#define double long double
#define pb push_back


const int N = 2e5 + 51 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

//gp_hash_table<int, int> table;

int dp[100][1000001];

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vi a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vi pref, pref1;
    for (int i = 0; i <= a[0]; i++) dp[0][i] = 1, pref.pb(i + 1);
    while (pref.size() != k + 1) pref.pb(pref.back());

    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            if (j <= a[i]) {
                int delta = pref[j];
                pref1.pb(delta);
                dp[i][j]+= delta;
                dp[i][j] %= MOD;
            }
            else {
                //    cout << pref[j] << ' ' << i;
            //return 0;
                int delta = (pref[j] - pref[j - a[i] - 1] + MOD) % MOD;
                pref1.pb(delta);
                dp[i][j]+= delta;
                dp[i][j] %= MOD;
            }
        }
        //for (auto to : pref1) cout << to << ' ';
       // return 0;
        pref.clear();
        for (auto to : pref1) {
            if (pref.empty()) {
                pref.pb(to);
            }
            else {
                int kk = pref.back() + to;
                kk%= MOD;
                pref.pb(kk);
            }
        }
        pref1.clear();
    }
    cout << dp[n - 1][k];

}


Measured memory_bytes: 245240
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = [(1 + p[i]) * 0.5 for i in range(n)]
s = 0.0
for i in e[:k]:
    s += i
t = s
for i in range(n - k):
    t = t - e[i] + e[k + i]
    s = max(s, t)
print(s)

Measured memory_bytes: 25060
#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(void) {
  int N, Y;
  cin >> N >> Y;
  
  for (int i = 0;i <= N;i++) {
    for (int ii = 0; ii <= N - i;ii++) {
      int iii = N - i - ii;
      if (10000 * i + 5000 * ii + 1000 * iii == Y) {
        cout << i << " " << ii << " " << iii << endl;
        return 0;
      }
    }
  }
  
  cout << -1 << " " << -1 << " " << -1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
struct student{
  int start[1000];
  bool used[721];
};
student S[10000];
int main(){
  int N,M;
  while(cin>>N>>M){
    if(N==0)break;
    int r,q;
    memset(S,0,sizeof(S));  
    cin>>r;
    for(int i=0;i<r;i++){
      int t,n,m,s;
      cin>>t>>n>>m>>s;
      t-=540;m--;
      if(s==1){
	S[m].start[n]=t;
      }else{
	while(t>0 && S[m].start[n]<t)
	  S[m].used[--t]=true;
      }
    }
    cin>>q;
    for(int i=0;i<q;i++){
      int ts,te,m,ans=0;
      cin>>ts>>te>>m;
      ts-=540;te-=540;m--;
      for(int i=ts;i<te;i++){
	if(S[m].used[i]==true)ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 47300