akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
using vi=vector<ll>;

string f(ll n){
	string s=to_string(n);
	string ret;
	rep(i,6-(int)s.size())ret.push_back('0');
	ret+=s;
	return ret;
}

bool solve(){
	ll n;cin>>n;
	ll sum=0;
	map<ll,ll>mp;
	rep(i,100000){
		sum+=i+1;
		mp[sum]=i+1;
	}

	if(mp[n]==0)cout<<"No"<<endl;
	else{
		ll x=mp[n]+1;
		vector<ll>ans[x];
		ll index=1;
		for(int i=0;i<x;i++){
			for(int j=i+1;j<x;j++){
				ans[i].push_back(index);
				ans[j].push_back(index);
				index++;
			}
		}
		cout<<"Yes"<<endl;
		cout<<x<<endl;
		rep(i,x){
			cout<<ans[i].size()<<" ";
			for(auto&&j:ans[i])cout<<j<<" ";
			cout<<endl;
		}
	}
	return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 9472
#include<stdio.h>
long long fan(long long a,long long b)
{
    if(b==0)
        return a;
    else
        return fan(b,a%b);
}
int main()
{
    long long a,b;
    while(scanf("%lld%lld",&a,&b)!=EOF)
    printf("%lld %lld\n",fan(a,b),a/fan(a,b)*b);
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int n;
	cin >> n;
	ll a[n];
	FOR(i,n) cin >>a[i];
	sort(a,a+n);
	int j=n-1;
	while(j>=1 && a[j]!=a[j-1]) j--;
	if(j==0) {
		cout <<0;
		return 0;
	}
	else {
		int k=j-2;
		while(k>=1 && a[k]!=a[k-1]) k--;
		if(k==0) {
			cout << 0;
			return 0;
		}
		else cout << a[j]*a[k];
	}

	return 0;
}

Measured memory_bytes: 1024
import sys
N = int(input())
A = list(map(int, input().split()))

for a in A:
    if a == 0:
        print(0)
        sys.exit(0)

ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        sys.exit(0)

print(ans)


Measured memory_bytes: 84732
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define Rep(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  string s;
  cin>>s;
  int l=s.size();
  int j=1000;
  rep(i,l-2){int k=100*(s[i]-'0')+10*(s[i+1]-'0')+s[i+2]-'0';
             j=min(j,abs(753-k));}
  cout<<j<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	int s[n];
	rep(i, n){
		cin >> s[i];
		dp[i] = 1e9;
	}
	dp[0] = 0;
	repn(i, 1, n){
		repn(j, 1, 3) if(i - j >= 0){
			dp[i] = min(dp[i], dp[i - j] + abs(s[i] - s[i - j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
//ll arr[1000002];
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
string s;
cin>>s;
ll a,b;
a=(s[0]-'0')*10 +(s[1]-'0');
b=(s[2]-'0')*10 +(s[3]-'0');
if(a>=1 && a<=12 && b>=1 && b<=12)
    cout<<"AMBIGUOUS"<<endl;
else if(a>=1 && a<=12 && (b<1 || b>12))
    cout<<"MMYY"<<endl;
else if(b>=1 && b<=12 && (a<1 || a>12))
    cout<<"YYMM"<<endl;
else if((a<1 || a>12) && (b<1 || b>12))
    cout<<"NA"<<endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N = 200010;

int n;
int a[N];
bool st[N];

bool check(int x)
{
	int mi = 2 * n - 1;
	bool res;
	for (int i = 1; i <= 2 * n - 1; i++)
	{
		if (a[i] >= x) st[i] = true;
		else st[i] = false;
		if (st[i] != st[i - 1]) continue;

		if (i <= n)
		{
			if (n - i < mi)
			{
				mi = n - i;
				res = st[i];
			}
		}
		else
		{
			if ((i - 1) - n < mi)
			{
				mi = i - 1 - n;
				res = st[i];
			}
		}
	}

	if (mi > n)
	{
		res = st[1];
	}

	return res;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n - 1; i++)
	{
		scanf("%d", &a[i]);
	}

	int l = 0, r = 0x3f3f3f3f;
	while (l < r)
	{
		int mid = (l + r + 1) >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	printf("%d", r);
}

Measured memory_bytes: 4772
from collections import deque

N = int(input())
P = list(map(int,input().split()))

MAP = [min(i, j, N-i-1, N-j-1) for i in range(N) for j in range(N)]

d = [1] * (N ** 2)

ans = 0

def update(np, p):
    if MAP[np] > MAP[p] + d[p]:
        q.append(np)
        MAP[np] = MAP[p] + d[p]

for p in P:
    p -= 1
    
    d[p] = 0
    
    ans += MAP[p]
    
    q = deque()
    
    q.append(p)
    
    while len(q) != 0:
        p = q.popleft()
        if p % N != N-1:
            update(p+1, p)
        if p % N != 0:
            update(p-1, p)
        if p // N != N-1:
            update(p+N, p)
        if p // N != 0:
            update(p-N, p)

print(ans)

Measured memory_bytes: 114248
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N+1];
  int key;
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  for(i = 1;i <= n;i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = key;
    trace(A,n);
  }
  
  return 0;
}

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

int main()
{
	int n;
	string s;
	long long D[5];
	int P[10] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 };
	int Q[10] = { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 };
	int R[10] = { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 };

	cin >> n;

	long long m = 0, a = 0, r = 0, c = 0, h = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> s;

		if (s[0] == 'M') m++;
		if (s[0] == 'A') a++;
		if (s[0] == 'R') r++;
		if (s[0] == 'C') c++;
		if (s[0] == 'H') h++;
	}

	D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
	long long ans = 0;

	for (int i = 0; i < 10; i++)
	{
		ans += D[P[i]] * D[Q[i]] * D[R[i]];
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define int long long
#define ll long long
#define us unsigned
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define nin(ary, n) for (int i = 0; i < (n); i++) cin >> ary[i]
#define nnin(ary, h, w) for (int i = 0; i < (h); ++i) for (int j = 0; j < (w); ++j) cin >> ary[i][j]
#define opt(conditions, a, b) cout << ((conditions) ? #a : #b) << endl
using namespace std;
const double PI = acos(-1.0);
const int MOD = 1e9 + 9;

int max_n(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_o(int ary[], int length) {
	int max;
	max = max_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_n(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_o(int ary[], int length) {
	int min;
	min = min_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while (k != 0);
	return result;
}

int gcm_n(int ary[], int length) {
	int g = ary[0];
	for (int i = 0; i < length; i++)
		g = gcm(g, ary[i]);
	return g;
}

int lcm(int a, int b) {
	int g, n;
	g = gcm(a, b);
	n = gcm(a, g);
	a = a / n;
	b = b / (g / n);
	return a*b;
}

int lcm_n(int ary[], int length) {
	int l = ary[0];
	for (int i = 0; i < length; i++)
		l = lcm(l, ary[i]);
	return l;
}

signed main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b))
		cout << 'A' << endl;
	else
		cout << 'B' << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long ary[100001] = {0};
    long long k;
    int n, a, b;
    long long sum = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        ary[a] += b;
    }
    for(int i = 1; i <= 100000; i++){
        sum += ary[i];
        if(sum >= k){
            cout << i;
            break;
        }
    }
    return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  ll x; cin>>x;
  int cnt=0;
  while (x>=1) {
    cnt++;
    x=x/2;
  }

  ll ans = (1LL<<cnt) - 1;
  out(ans);
  

  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    if len(s) == 1:
        if s[0] == 's':
            print('ses')
        else:
            print(s+'s')
    else:
        if s[-1] == 's':
            r = s + 'es'
            print(r)
        else:
            r = s + 's'
            print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
n, m, x = map(int, input().split())

a = [[0 for j in range(m)] for i in range(n)]
cost = [0 for j in range(n)]

for i in range(n):
	xx = list(map(int, input().split()))
	cost[i] = xx[0]
	for j in range(m):
		a[i][j] = xx[j + 1]

best_cost = sum(cost) + 1

#print(a)

for mask in range(2**n):
	mm = mask
	knowledge = [0 for i in range(m)]
	total_cost = 0
	book_number = 0 
	#print('start')
	while mask > 0:
		#print(mask)
		if (mask % 2) == 1:
			total_cost += cost[book_number]
			for j in range(m):
				knowledge[j] += a[book_number][j]

		mask = mask // 2
		book_number += 1

	#print(mm, knowledge, total_cost)

	ok = True
	for j in range(m):
		if knowledge[j] < x:
			ok = False 
			break

	if ok:
		#print(mm)
		best_cost = min(best_cost, total_cost)

if best_cost < sum(cost) + 1:
	print(best_cost)
else:
	print(-1)

Measured memory_bytes: 68480
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<class T> inline bool chmin(T& a, T b) {
        if (a > b) {
            a = b;
            return true;
        }
        return false;
    }
    template<class T> inline bool chmax(T& a, T b) {
        if (a < b) {
            a = b;
            return true;
        }
        return false;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl Ans(100004,0);
        rep(i,n){
            ll a;
            cin>>a;
            Ans[a]++;
            Ans[a+1]++;
            Ans[a+2]++;
        }
        sort(rall(Ans));
        cout<<Ans[0]<<endl;
    }

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  string s;
  cin >> s;

  vector<int> v(n, 0);
  if (s[0] == 'E') v[0] = 1;
  else v[0] = -1;
  FOR (i, 1, n) {
    if (s[i] == 'E') v[i] = v[i - 1] + 1;
    else v[i] = v[i - 1] - 1;
  }

  auto itr = max_element(v.begin(), v.end());

  int cnt = 0;
  for (auto it = v.begin(); it < itr; it++) {
    if (s[it - v.begin()] == 'W') cnt++;
  }

  for (auto it = itr + 1; it < v.end(); it++) {
    if (s[it - v.begin()] == 'E') cnt++;
  }

  printf("%d\n", cnt);
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n,m;cin>>n>>m;
    vector<int> g[n];
    for (int i=0;i<m;i++) {
        int a,b;cin>>a>>b;a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    int vis[n]{1};
    int ans[n];
    while (q.size()) {
        int v=q.front();q.pop();
        for (int u:g[v])
            if (!vis[u]) {
                ans[u]=v+1;
                vis[u]=1;
                q.push(u);
            }
    }
    cout<<"Yes"<<endl;
    for (int i=1;i<n;i++)
        cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 10748
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, M = N << 1;

int n, k;
int a[N], b[N];
char s[N];

int main()
{
    n = gi(), k = gi();
    for (int i = 1; i <= k; i+=1)
    {
        int d = gi();
        for (int j = 1; j <= d; j+=1)
            a[j] = gi(), ++b[a[j]];
    }
    int cnt = 0;
    for (int i = 1; i <= n; i+=1) cnt += (b[i] == 0);
    cout << cnt << endl;
    return 0;
}

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

int main(void){
	string s, t;
	cin >> s >> t;
	map<char, char> t_map;
	map<char, char> s_map;


	bool f = true;
	for(int i=0; i<s.size(); i++){
		if(!t_map.count(t[i])){
			t_map[t[i]] = s[i];
		}else{
			if(t_map[t[i]] != s[i]){
				f = false;
			}
		}
	}
	for(int i=0; i<s.size(); i++){
		if(!s_map.count(s[i])){
			s_map[s[i]] = t[i];
		}else{
			if(s_map[s[i]] != t[i]){
				f = false;
			}
		}
	}

	if(f) puts("Yes");
	else puts("No");
	
	return 0;
}


Measured memory_bytes: 900
#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>;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll sum = 0;
    ll tallest = 0;
    for(int i=0; i<N; i++){
        if( A[i] > tallest ) tallest = A[i];
        else sum += tallest - A[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
    }
    return ans;
}

ll sub_kai[1000001];
ll kai[1000001];

void init_comb(){
    kai[0]=1;
    rep(i,1,1000000){
        kai[i]=mod(kai[i-1]*i);
    }
    sub_kai[0]=1;
    rep(i,1,1000000){
        sub_kai[i]=mod(sub_kai[i-1]*hpow(i,i_7-2));
    }
}

ll comb(ll n,ll k){
    ll ans=mod(kai[n]*sub_kai[k]);
    ans=mod(ans*sub_kai[n-k]);
    return ans;
}
ll P(ll n,ll k){
    ll ans=mod(kai[n]*sub_kai[n-k]);
    return ans;
}

int main(){fastio
    init_comb();
    ll n,m;cin>>n>>m;
    ll sum=P(m,n);
    rep(k,1,n){
        sum-=mod(powl(-1,k-1)*comb(n,k)*P(m-k,n-k));
        sum=mod(sum);
    }
    cout<<mod(P(m,n)*sum)<<endl;
    
    return 0;
}



Measured memory_bytes: 19268
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


int N, ope = 0;
VI p(100002, 0);
vector<bool> visited(100001, false);

bool calc(int i) {
  if (visited[i]) return false;

  visited[i] = true;

  if (p[i] != i) {
    return false;
  } else {
    visited[i + 1] = true;
    return true;
  }
}

int main() {
  cin >> N;
  NREP(i, N) {
    cin >> p[i];
  }

  NREP(i, N) {
    if (calc(i)) ope++;
  }

  cout << ope << endl;
  return 0;
}

Measured memory_bytes: 640
/*input

*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int n, W;
	cin >> n >> W;
	ll w[n+1], v[n+1];
	rep(i, n) cin >> w[i+1] >> v[i+1];
	ll dp[n+1][W+1];
	rep(i, n+1) {
		rep(j, W+1) {
			if(!i || !j) dp[i][j]=0;
			else dp[i][j]=dp[i-1][j];
			if(i && j-w[i]>=0) dp[i][j]=max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
		}
	}
	cout << dp[n][W];
	return 0;
}

Measured memory_bytes: 82428
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	string s;cin>>s;
	rep(i,s.size()){
		if(i%2==0 && s[i]=='L'){
			cout<<"No"<<endl;return 0;
		}
		
		if(i%2==1 && s[i]=='R'){
			cout<<"No"<<endl;return 0;
		}
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, sum, prise;
	while (1){
		scanf("%d", &sum);
		
		if (sum == 0){
			break;
		}
		
		for (i = 0; i < 9; i++){
			scanf("%d", &prise);
			sum -= prise;
		}
		printf("%d\n", sum);
	}
	return (0);
}

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

using namespace std;

int main(){
  int a,b;
  cin >> a >>b;
  if(a<=b){
      for(int i=0;i<b;i++){
          cout << a;
      }
      cout << endl;
      return 0;
  }
  for(int i=0;i<a;i++){
      cout << b;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    ll n;
    cin >> n;
    map<ll, ll> col;
    ll cnt = 0;
    for (int i = 0; i < n; i++)
    {
        ll k;
        cin >> k;
        if (k < 3200)
            col[k / 400]++;
        else
            cnt++;
    }
    ll res = 0;
    for(int i = 0; i <= 7; i++){
        if(col[i] != 0)
        res++;
    }
    cout << max<ll>(1,res) << " " << res + cnt << endl;
}


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

signed main(void)
{
	long long a, b;
	cin >> a >> b;
	if (a * b <= 0)
		cout << "Zero" << endl;
	else if (a > 0)
		cout << "Positive" << endl;
	else if (b < 0)
	{
		if ((long long)(abs(a) - abs(b) + 1) % 2 == 0)
			cout << "Positive" << endl;
		else
			cout << "Negative" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    mon = 100
    ans = 0
    x = int(input())
    while mon < x:
        mon *= 1.01
        mon = math.floor(mon)
        ans += 1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

map<char, char> mp = {{'A', 'T'}, {'C', 'G'}, {'G', 'C'},{'T', 'A'}};

int main(){
  char b;
  cin >> b;
  cout << mp[b] << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    string str;
    cin>>str;
    int a = 0,b = 0,c = 0;
    for (auto it : str)
    {
        a += it == 'a';
        b += it == 'b';
        c += it == 'c';
    }
    puts(max({a,b,c}) - min({a,b,c}) <= 1 ? "YES" : "NO");
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<pair<pair<string,int>,int>> SP(N);
  for(int i=0;i<N;i++){
    cin>>SP[i].first.first>>SP[i].first.second;
    SP[i].first.second=-SP[i].first.second;
    SP[i].second=i+1;
  }
  sort(SP.begin(),SP.end());
  for(int i=0;i<N;i++){
    cout<<SP[i].second<<endl;
  }
}


Measured memory_bytes: 256
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <climits>

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

#define int long long

using namespace std;

int N;
int A[100010];
map<int, int> cnt;

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    cin >> N;
    rep(i,N) {
        cin >> A[i];
        cnt[A[i]]++;
        if (cnt[A[i]] >= 3) {
            cnt[A[i]] -= 2;
        }
    }

    int two_cnt = 0;
    int ans = 0;
    for (auto it=cnt.begin(); it!=cnt.end(); it++) {
        ans++;
        if (it->second == 2) two_cnt++;
    }
    if (two_cnt % 2 == 0) {
        cout << ans << endl;
    } else {
        cout << ans - 1 << endl;
    }
}


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

using namespace std;

int main()
{
    int n,r;
    cin>>n>>r;
    if(n>=10)
    {
        cout<<r;
    }
    else
    {
        int x=100*(10-n);
        cout<<r+x;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N, M; cin >> N >> M;
	ll a[51], b[51], c[51], d[51];

	rep(i, 1, N + 1) {
		cin >> a[i] >> b[i];
	}
	rep(i, 1, M + 1) {
		cin >> c[i] >> d[i];
	}

	int minID;
	rep(i, 1, N + 1) {
		ll minCheck = 1 << 30;
		rep(j, 1, M + 1) {
			//for (int j = M; j > 0; j--) {
			ll A = (a[i] - c[j]);
			A = (A < 0) ? -A : A;
			ll B = (b[i] - d[j]);
			B = (B < 0) ? -B : B;

			if (minCheck > A + B) {
				minCheck = A + B;
				minID = j;
			}
		}
		cout << minID << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

ll n,a,b,c,d;
map<ll,ll> m;

ll dp(ll i){
	//cerr<<i<<endl;
	if (i==0) return 0;
	if (i==1) return d;
	if (i==2) return min(a,d)+d;
	if (m.count(i)) return m[i];
	
	ll best;
	if ((double)d*i<1e18) best=d*i;
	else best=1e18;
	
	best=MIN(best,dp(i/2)+a+d*(i%2),dp(i/2+1)+a+d*(2-i%2));
	best=MIN(best,dp(i/3)+b+d*(i%3),dp(i/3+1)+b+d*(3-i%3));
	best=MIN(best,dp(i/5)+c+d*(i%5),dp(i/5+1)+c+d*(5-i%5));
	
	//cout<<i<<" "<<best<<endl;
	return m[i]=best;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int TC;
	cin>>TC;
	while (TC--){
		m.clear();
	
		cin>>n>>a>>b>>c>>d;
		
		cout<<dp(n)<<endl;
	}
	
	
}


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

int main(){
  long long n,max_index,quo,div;
  cin >> n;
  max_index = std::pow(10,6);
  quo = 1000000000000;
  div = 1000000000000;
  for (int i=1;i<=max_index;i++){
    if ((n%i==0) && (min(div+quo,i+(n/i)) == i+(n/i))){
      div = i;
      quo = n/i;
    }
  }
  cout << div+quo-2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back

struct NMT {
	static const int M=131072;
	vector<int> tree[M<<1];
	void put_point(int x, int y){
		x += M;
		while(x) tree[x].pb(y), x>>=1;
	}
	void build(){ for(auto& v:tree) sort(all(v)); }
	
	int vcnt(vector<int>& v, int d, int u){
		return upper_bound(all(v), u) - lower_bound(all(v), d);
	}
	int rcnt(int l, int r, int d, int u){
		l+=M; r+=M;
		int ret=0;
		while(l<=r){
			if(l%2==1) ret+=vcnt(tree[l++], d, u);
			if(r%2==0) ret+=vcnt(tree[r--], d, u);
			l>>=1; r>>=1;
		}
		return ret;
	}
} s2;

int n, m;

int main()
{
    read(n, m);
    for(int i=1; i<=n; ++i){
		int x, y; read(x, y);
		s2.put_point(x, y);
    }
    s2.build();
    for(int d=1; d<=m; ++d){
		int cx = 0;
		int ret = n;
		while(true){
			if(cx + d > m) break;
			ret -= s2.rcnt(cx+1, m, 1, cx+d-1);
			cx += d;
		}
		ret -= s2.rcnt(cx+1, m, 1, m);
		printf("%d\n", ret);
    }
    return 0;
}


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

    vector<vector<char>> vvcd(h+2, vector<char>(w+2));
    vector<vector<int>> vvd(h+2, vector<int>(w+2)); 

    rep(i,h){
        rep(j,w){
            cin >> vvcd.at(i+1).at(j+1);
        } 
    }


    rep(i,h+2){
        rep(j,w+2){
            if(vvcd.at(i).at(j) == '#'){                
                vvd.at(i-1).at(j-1)++; //左上
                vvd.at(i  ).at(j-1)++;   //真上
                vvd.at(i+1).at(j-1)++; //右上
                vvd.at(i-1).at(j)++;
                vvd.at(i+1).at(j)++;
                vvd.at(i-1).at(j+1)++;
                vvd.at(i  ).at(j+1)++;
                vvd.at(i+1).at(j+1)++;
                //cout << i << " " << j << " " << endl;
            } 
        }
    }

   rep(i,h+2){
        rep(j,w+2){

            if(i < h && j < w){
                if(vvcd.at(i+1).at(j+1) == '#') cout << "#";
                else                        cout << vvd.at(i+1).at(j+1);
            }
        }
        cout << endl;
   }
    return 0;
}

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

using namespace std;

const int N = 2e5 + 5;
int n, m, par[N], siz[N];

int find(int v){
    if(par[v] == v){
        return v;
    } else {
        return (par[v] = find(par[v]));
    }
}

void unite(int a, int b){
    a = find(a);
    b = find(b);
    if(a != b){
        if(siz[a] < siz[b]){
            swap(a, b);
        }
        siz[a] += siz[b];
        par[b] = a;
    }
}

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

    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        par[i] = i;
        siz[i] = 1;
    }
    for(int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        unite(a, b);
    }

    int fmax = -1;
    for(int i = 1; i <= n; i++){
        if(find(i) == i){
            fmax = max(fmax, siz[i]);
        }
    }

    cout << fmax << '\n';
    return 0;
}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int N;
    cin >> N;
    vector<int> n(N);
    rep(i,N) cin >> n[i];

    sort(all(n));
    vector<pair<int, P>> diff;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            diff.push_back({n[j]-n[i],{j,i}});
        }
    }

    double ans = 0;

    for(auto p : diff){ 
        int i = p.second.second, j = p.second.first, k = 0;
        int sum = 0, d = p.first;
        for(int m = N-1; m >= 0; m--){
            if(m != i && m != j) {
                sum += n[m];
                k = m;
                break;
            }
        }
        for(int m = N-1; m >= 0; m--){
            if(m != i && m != j && m != k) {
                sum += n[m];
                break;
            }
        }
        double a = (double)sum / (double)d ;
        ans = max(ans, a);
    } 

    cout << setprecision(15) << ans << endl;
}



Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1000000007;
int main(){
    int N,K;
    cin>>N>>K;
    unordered_map<int,int> mp;
    int l=1,r=2,count=0;
    mp[0]=1;
    while(r<=N){
        count++;
        l=r;
        r=N/(N/l)+1;
        mp[count]=r-l;
    }
    long long dp[120][100000];
    for(int i=0;i<K;i++){
        long long sum=0;
        for(int j=count;j>=0;j--){
            if(i==0){
                dp[0][j]=mp[j];
                continue;
            }
            long long a=mp[j];
            sum+=dp[i-1][count-j];
            sum%=MOD;
            dp[i][j]=sum*a;
            dp[i][j]%=MOD;
        }
    }
    long long answer=0;
    for(int i=0;i<=count;i++){
        answer+=dp[K-1][i];
        answer%=MOD;
    }
    cout<<answer<<endl;
}

Measured memory_bytes: 55888
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    rep(i,1,sqrt(m)/1+1){
        if (m%i == 0 && i <= m/n){
            chmax(ans,i);
            if (m/i <= m/n) chmax(ans,m/i);
        }
    }
    PRINT(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    int N;string S;cin>>N>>S;
    bool ok=true;
    for(int i=0;i<N/2;i++) if(S[i]!=S[i+N/2]) ok=false;
  
  if(N%2==1) ok=false;
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=2e5+5;
vector< set<int> > adj(N);
vector<bool> vis(N,false);
set<int> S;
void dfs(int s){
	vis[s]=1;
	for(auto  it:adj[s]){
		if(!vis[it]){
			S.insert(it);
			dfs(it);
		}
	}

}
void solve()
{
	int n,m;cin>>n>>m;
	f(i,1,m){
		int u,v;cin>>u>>v;
		adj[u].insert(v);
		adj[v].insert(u);
	}
	f(i,1,n){
		dfs(i);
		for(auto it:S)
		adj[i].insert(it);
		S.clear();
	}
	int mx=-1;
	f(i,1,n){
		mx=max(mx,(int)adj[i].size());
	}
	++mx;
	cout<<mx<<'\n';
}
int main()
{	Fast;
//	int t;cin>>t;
//	while(t--)
	solve();
}

Measured memory_bytes: 59440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_N = 1e2 + 10, INF = 1e15, MOD = 1e9 + 7, max_K = 1e5 + 50;
ll N, K, arr[max_N];
bool DP[max_K];

int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; ++i)
        cin >> arr[i];
    sort(arr, arr + N);
    // DP[i] = true, if currPlayer WINS else LOSES
    DP[0] = false;
    for (int i = 1; i <= K; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if (arr[j] > i)
                break;
            if (!DP[i - arr[j]])
            {
                DP[i] = true;
                break;
            }
        }
    }
    cout << (DP[K] ? "First" : "Second") << "\n";
    return 0;
}

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

using namespace std;

int main() {
    int c[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int a;
    cin >> a;
    cout << c[a-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}


#define T vel
T mul(T &a,T &b) {//calcureate a(b(x))
	int sz = a.size();
	vel c(sz);
	rep(i, sz) { c[i] = a[b[i]]; }
	return c;
}
T rui1(T &a, int n) {
	if (n == 1) { return a; }
	T x = rui1(a, n / 2);
	x = mul(x, x);
	if (n % 2 == 1) { x = mul(x, a); }
	return x;
}

signed main(){
	int n; cin >> n;
	int x; cin >> x;
	if (x == 1 || x == 2*n - 1) {
		cout << "No" << endl; return 0;
	}
	cout << "Yes" << endl;
	vel ans(2 * n - 1);
	ans[n - 2] = x - 1;
	ans[n - 1] = x;
	ans[n] = x + 1;
	vel list;
	for (int i = 1; i < 2 * n; i++){
		if (abs(i - x) > 1) { list.push_back(i); }
	}
	vel ex;
	for (int i = 0; i < 2 * n-1; i++) {
		if (abs(i - n+1) > 1) { ex.push_back(i); }
	}
	rep(i, 2 * n - 4) {
		ans[ex[i]] = list[i];
	}
	rep(i, 2 * n - 1) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 8688
#include<bits/stdc++.h>
#define int  long long 

using namespace std;
int32_t  main(){
     int n,r;
    cin>>n>>r;
    int x,y,c=0;

    while(n--){
        cin>>x>>y;
      
        if((double) pow(x,2)+pow(y,2)<= pow(r,2) ){
     c++;
        }
    }
    cout<<c;
   return 0;
}

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

#define ll long long
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define mp make_pair
#define pb push_back

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s,t;
	cin >> s;
	cin >> t;
	bool flag = 1;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] != t[i]) {flag = 0; break;}
	}
	if (flag) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, length;
  char S[100000];
  cin >> N;
  for(int i=0;i<N;i++){cin >> S[i];}
  length=N;
  for(int j=0;j<N;j++){if(S[j]==S[j+1]){length--;}}
  cout << length << endl;
}

Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

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

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

	string t = { "-+" };
	string s;
	cin >> s;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				if (s[0] - '0' + (i * 2 - 1)*(s[1] - '0') + (j * 2 - 1)*(s[2] - '0') + (k * 2 - 1)*(s[3] - '0') == 7) {
					cout << s[0] << t[i] << s[1] << t[j] << s[2] << t[k] << s[3] << "=7" << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int,input().split()))

hako = [0]*(N+1)

for i in range(N, 0, -1):
    cnt = 0
    j = i
    x = j
    while j <= N:
        cnt += hako[j]
        j += x
    
    if cnt%2 != A[i]:
        hako[i] = 1


print(hako.count(1))
s = ""
for i, x in enumerate(hako):
    if x == 1:
        s += str(i) + " "

print(s)

Measured memory_bytes: 9132
package main

import (
	"fmt"
	"math"
)

func main() {
	N := scanInt()
	A := scanInts(N)

	res := 0
	for i := 0; i < N; i++ {
		res += A[i] - 1
	}
	fmt.Println(res)
}

/*
	Snippets
*/
func scanInt() (n int) {
	fmt.Scan(&n)
	return
}
func scanInts(n int) []int {
	N := make([]int, n)
	for i := 0; i < n; i++ {
		N[i] = scanInt()
	}
	return N
}
func scanInts2(n int) ([]int, []int) {
	N1, N2 := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		N1[i] = scanInt()
		N2[i] = scanInt()
	}
	return N1, N2
}
func scanInts3(n int) ([]int, []int, []int) {
	N1, N2, N3 := make([]int, n), make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		N1[i] = scanInt()
		N2[i] = scanInt()
		N3[i] = scanInt()
	}
	return N1, N2, N3
}
func scanMatrix(n, m int) [][]int {
	M := make([][]int, n)
	for i := 0; i < n; i++ {
		M[i] = scanInts(m)
	}
	return M
}
func scanStr() (s string) {
	fmt.Scan(&s)
	return
}
func scanStrs(n int) []string {
	S := make([]string, n)
	for i := 0; i < n; i++ {
		S[i] = scanStr()
	}
	return S
}
func getAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func getPow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}
func getMin(nums ...int) (int, int) {
	if len(nums) == 0 {
		panic("funciton getMin() requires at least one argument.")
	}
	min := nums[0]
	pos := 0
	for i := 1; i < len(nums); i++ {
		if min > nums[i] {
			min = nums[i]
			pos = i
		}
	}
	return min, pos
}
func getMax(nums ...int) (int, int) {
	if len(nums) == 0 {
		panic("funciton getMax() requires at least one argument.")
	}
	max := nums[0]
	pos := 0
	for i := 1; i < len(nums); i++ {
		if max < nums[i] {
			max = nums[i]
			pos = i
		}
	}
	return max, pos
}
func getGcd(a, b int) int {
	if b == 0 {
		return a
	}
	return getGcd(b, a%b)
}
func getLcm(a, b int) int {
	return a * b / getGcd(a, b)
}

/*
	Sort template
*/
type sortType struct {
	a int
	b int
}
type byA []sortType

func (s byA) Len() int {
	return len(s)
}
func (s byA) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
func (s byA) Less(i, j int) bool {
	return s[i].a < s[j].a
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define F(i,n) for(int i=0; i<n; i++)

int main()
{
    int N; cin >> N;
    vector<int> a(N), b(N), c(N); F(i,N) cin >> a[i] >> b[i] >> c[i];
    vector<int> DPa(N,0), DPb(N,0), DPc(N,0); DPa[0] = a[0]; DPb[0] = b[0]; DPc[0] = c[0];

    for(int i=0; i<N-1; i++)
    {
        DPa[i+1] = max(DPb[i], DPc[i]) + a[i+1];
        DPb[i+1] = max(DPa[i], DPc[i]) + b[i+1];
        DPc[i+1] = max(DPa[i], DPb[i]) + c[i+1];
    }
    cout << max({DPa[N-1], DPb[N-1], DPc[N-1]});
}

Measured memory_bytes: 2560