akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

ll n,m;
ll dp[50][1<<20]={};

VV<int> etoq;
VV<int> e;
map<Pi,int> eind,qind;

bool dfs(int now,int goal,int prev,int sta){
  rep(i,0,siz(e[now])){
    int nex=e[now][i];
    if(nex==prev)continue;

    if(nex==goal || dfs(nex,goal,now,sta)){
      etoq[eind[{min(nex,now),max(nex,now)}]].pb(qind[{min(sta,goal),max(sta,goal)}]);
      return true;
    }
  }
  return false;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  cin>>n;
  e.assign(n,V<int>(0));
  rep(i,0,n-1){
    int a,b;cin>>a>>b;a--;b--;
    e[a].pb(b);
    e[b].pb(a);
    eind[{min(a,b),max(a,b)}]=i;
  }

  cin>>m;
  etoq.assign(n-1,V<int>(0));

  
  rep(i,0,m){
    int a,b;cin>>a>>b;a--;b--;
    qind[{min(a,b),max(a,b)}]=i;
    dfs(a,b,-1,a);
  }


  dp[0][0]=1;
  rep(i,0,n-1){
    int flag=0;
    rep(j,0,siz(etoq[i])){
      flag|=(1<<etoq[i][j]);
    }

    rep(j,0,1<<m){
      dp[i+1][j|flag]+=dp[i][j];
      dp[i+1][j]+=dp[i][j];
    }
  }

  cout<<dp[n-1][(1<<m)-1]<<ENDL;

  
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 401664
nd = $stdin.gets.chomp.split(" ")
nd.map! do |a_j|
    a_j.to_i
end

n = nd[0]
d = nd[1]

arr = []
n.times do
    tmp = $stdin.gets.chomp.split(" ")
    tmp.map! do |a_j|
        a_j.to_i
    end
    arr << tmp
end

def isSquare(x)
    lim = 40 * 40 * 10
    for i in 0..lim
        if x == i * i
            return true
        end
    end
    return false
end

ans = 0
for i in 0..n-2
    for j in i + 1..n-1
        dist = 0
        for k in 0..d-1
            dist += (arr[i][k] - arr[j][k])**2
        end
        if isSquare(dist)
            ans += 1
        end
    end
end
puts ans

Measured memory_bytes: 3836
#include <stdio.h>
int main(){
  int n,d,x,i,r=0,a;
  scanf("%d%d%d",&n,&d,&x);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    r+=(d-1)/a+1;
  }
  printf("%d",r+x);
  return 0;
}

Measured memory_bytes: 128
import itertools

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

B = list(itertools.accumulate(A))
ans = 10000000000
for i in range(N-1):
    if ans > abs(B[-1] - 2*B[i]):
        ans = abs(B[-1] - 2*B[i])

print(ans)


Measured memory_bytes: 24172
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[100000],ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    ans+=a[i]-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range((N-1)//2):
  B.append(A[2*i] - A[2*i+1])

X = [sum(B)+A[N-1]]
for j in range(N):
  X.append(2*A[j]-X[j])

for k in range(N):
  print(X[k], end=" ")

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

int main(){
    int n,m,l,x,z = 0;
    int A[100] = {},B[100] = {},C[100] = {};
    cin >> n >> m; 
    for(int i = 0;i < m;i++){
        cin >> A[i];
    }
    cin >> l;
    for(int i = 0;i < l;i++){
        cin >> B[i];
    }
    cin >> x;
    for(int i = 0;i < x;i++){
        cin >> C[i];
    }
    for(int i = 0;i < x;i++){
        for(int k = 0;k < m;k++){
            if(C[i] == A[k])z -= 1;
            for(int j = 0;j < l;j++){
                if(C[i] == A[k] && C[i] == B[j])z += 1;
            }
        }
        z += 1;
    }
    cout << z << endl;
    return 0;
}




Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();

		if (A == B) {
			System.out.println("Draw");
		} else if (A == 1 && B >= 2 && B <= 13) {
			System.out.println("Alice");
		} else if (B == 1 && A >= 2 && B <= 13) {
			System.out.println("Bob");
		} else if (A > B) {
			System.out.println("Alice");
		} else if (A < B) {
			System.out.println("Bob");
		}

	}

}


Measured memory_bytes: 21844
#include<stdio.h>
#include<algorithm>
int main() {
	long long a[3]; scanf("%lld%lld%lld", &a[0], &a[1], &a[2]);
	std::sort(a, a + 3);
	if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0)printf("0");
	else printf("%lld", a[0] * a[1]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	int x=n/2;
	int i;
	string a,b;
	for(i=0;i<x;i++)
	a.push_back(s[i]);
	for(i=x;i<n;i++)
	b.push_back(s[i]);
	if(a==b){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int A,B;
    scanf("%d %d",&A,&B);
    if(A+B > A-B){
        if(A+B > A*B){
            printf("%d",A+B);
        }else{
            printf("%d",A*B);
        }
    }else{
        if(A-B > A*B){
            printf("%d",A-B);
        }else{
            printf("%d",A*B);
        }
    }
}

Measured memory_bytes: 128
N,M = map(int, input().split())

from collections import defaultdict
neighbor = defaultdict(list)
rev_neighbor = defaultdict(list)
E = []

for i in range(M):
  a,b,c = map(int, input().split())
  a,b = a-1, b-1
  E += [(a,b,c)]
  neighbor[a].append(b)
  rev_neighbor[b].append(a)

def reachable_vertices(neighbor, s):
  V = set()
  V.add(s)
  stack=[s]
  while stack:
    v = stack.pop()
    for u in neighbor[v]:
      if u not in V:
        V.add(u)
        stack.append(u)
  return V

# only vertices that are reachable from 1 or N
V = reachable_vertices(neighbor, 0) & reachable_vertices(rev_neighbor, N-1)

E = [(a,b,c) for a,b,c in E if a in V or b in V]
score = defaultdict(lambda: float('-inf'))
score[0] = 0


i = 0
updated=True
while updated:
  if i == len(V):
    print('inf')
    break

  updated = False
  for a,b,w in E:
    if score[b] < score[a] + w:
      score[b] = score[a] + w
      updated = True
  i += 1
else:
  print(score[N-1])

Measured memory_bytes: 4204
def mips():
  return map(int,input().split())
N,K = mips()
ans = 0
for i in range(K,N+1):
    Max_K = (i * (2*N - (i-1)))//2
    Min_K = (i * (2*0 + (i-1)))//2
    ans += (Max_K-Min_K) + 1
    ans %= (10**9 + 7)
print(ans+1)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
 
#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0
 
#define putb push_back
#define f first
#define s second
 
#define putf push_front
#define gainb pop_back
 
#define gainf pop_front
#define len(x) (ll)x.size()
 
typedef double db;
typedef long long ll;
 
const ll ary=1e4+5;
const ll mod=1e9+7;
const ll inf=1e18;
 
using namespace std;
ll n,t;
pair<ll,ll> p[ary];
ll dp[ary];
int main(){
  cin>>n>>t;
  for(int i=1;i<=n;i++){
    cin>>p[i].f>>p[i].s;
  }
  sort(p+1,p+n+1);
  ll ans=0;
  for(int i=1;i<=n;i++){
    for(int j=t;j>=1;j--){
      dp[j+p[i].f]=max(dp[j+p[i].f],dp[j]+p[i].s);
    }
  }
  for(int i=1;i<=10000;i++){
    ans=max(ans,dp[i]);
  }
  cout<<ans;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int a[1000001],n;
bool search(int key){
int right,left,mid;
	left=0;
	right=n;
	
	while(left<right){
	mid=(left+right)/2;
		if(a[mid]==key)
		return true;
		else{
			if(a[mid]>key)
			  right=mid;
			else if(a[mid]<key)
			left=mid+1;
			
			}
	}
	return false;
}
main(){
	int q,i,key,ans;
	ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&key);
		if(search(key))
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 3536
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x;
        }
        x = x*x;
        y/=2;
    }
    return res;
}
int fac[2500], finv[2500], inv[2500];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 2500; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
signed main() {
    COMinit();
    int n,k;cin >> n >> k;
    if(k&1) cout << mod_pow(n/k,3) << endl;
    else if(n*2<k) cout << "0\n";
    else cout << mod_pow(n/k,3)+mod_pow((n-k/2)/k+1,3) << endl;
    // cout << mod_pow(n/k,3) << 
    // cout << COM(9268,3) << endl;
    return 0;
}

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

int main() {
    int n, x;
    cin>>n>>x;
    int l[n];
    for(int i=0;i<n;i++) cin>>l[i];
    int d[n];
    d[0]=0;
    int ans=0;
    for(int i=0;i<n;i++) {
        d[i+1]=d[i]+l[i];
        if(d[i+1]<=x) ans++;
    }

    cout<<ans+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	bool ac[100010]={false};
	ll wa[100010]={};
	ll ans=0;
	for(ll i=0;i<k;i++){
		ll x;string s;
		cin>>x>>s;
		x--;
		if(ac[x]){
			continue;
		}
		if(s=="AC"){
			ac[x]=true;
			ans++;
		}
		else{
			wa[x]++;
		}
	}
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(ac[i]){
			cnt+=wa[i];
		}
	}
	cout << ans<<" "<<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 4476
#include<stdio.h>
#include<math.h>

int main() {
	long long  n, a, aa[100001] = {}, b[100000] = {}, c[100000] = {}, q;
	long long sum = 0;
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a);
		aa[a]++;
		sum += a;
	}
	scanf("%lld", &q);
	for (int i = 0; i < q; i++) {
		scanf("%lld%lld", &b[i], &c[i]);
	}
	for (int i = 0; i < q; i++) {
		sum += (c[i] - b[i]) * aa[b[i]];
		printf("%lld\n", sum );
		aa[c[i]] += aa[b[i]];
		aa[b[i]] = 0;
	}

	return 0;
}

Measured memory_bytes: 4420
def run():
  N, K = map(int, input().split())
  h_li = [int(h) for h in input().split()]
  cost_li = [0] * N
  cost_li[1] = abs(h_li[0] - h_li[1])
  for n in range(2, N):
    k = max(0, n - K)
    h = h_li[n]
    cost = min([cost_li[i] + abs(h_li[i] - h) for i in range(k, n)])
    cost_li[n] = cost
  print(cost_li[N-1])
  
if __name__ == '__main__':
  run()

Measured memory_bytes: 13980
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 500 + 10;
int a[maxn][maxn], n, m, q;
LL dp[maxn][maxn];
int main()
{
	cin >> n >> m >> q;
	int l, r;
	while (m--)
	{
		cin >> l >> r;
		a[l][r]++;
	}
	for (int l = n; l > 0; l--) for (int r = 1; r <= n; r++) dp[l][r] = a[l][r] + dp[l + 1][r] + dp[l][r - 1] - dp[l + 1][r - 1];
	while (q--)
	{
		LL ans = 0;
		cin >> l >> r;
		cout << dp[l][r] << endl;
	}
	return 0;
}

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

int main(){ 
	int n,q;
	cin >> n;
	long long arr[n+1];
	map<long long, long long> m;

	for(int i = 1;i <= n;i++){
		cin >> arr[i];
		m[arr[i]]++;
	}

	cin >> q;
	long long sum = accumulate(arr + 1, arr + 1 + n, (long long)0);
	while(q--){
		long long b,c;
		cin >> b >> c;
		sum += (c - b) * m[b];
		m[c] += m[b];
		m[b] = 0;
		cout << sum << "\n"; 
	}
}

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

int main(void) {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p.at(i);
  for (int i = 0; i <= 50; i++) {
    bool flag1 = true;
    bool flag2 = true;
    for (int j = 0; j < N; j++) {
      if (X - i == p.at(j)) {
        flag1 = false;
      }
      if (X + i == p.at(j)) {
        flag2 = false;
      }
    }
    if (flag1) {
      cout << X - i << endl;
      break;
    } else if (flag2) {
      cout << X + i << endl;
      break;
    }
  }
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



#define N 100010
vii G(N, vi());
set<int> st;
vll dp(N, vl(2));

vector<bool> used(N);

ll dfs(int now, int par=-1) {
  int cnt = 0;
  rep (i, G[now].size()) {
    if (G[now][i] == par) continue;
    dfs(G[now][i], now);
    cnt++;
  }
  if (cnt == 0) {
    dp[now][0] = 1;
    dp[now][1] = 1;
  }
  else {
    dp[now][0] = dp[now][1] = 1;
    rep (i, G[now].size()) {
      int v = G[now][i];
      if (v == par) continue;
      dp[now][0] = dp[now][0] * ((dp[v][0] + dp[v][1]) % MOD) % MOD;
      dp[now][1] = dp[now][1] * dp[v][0] % MOD;
    }
  }
}
  

int main() {
  int n;
  cin >> n;
  rep (i, n - 1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(0);
  cout << (dp[0][0] + dp[0][1]) % MOD << endl;
}


Measured memory_bytes: 15360
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a,b;
	for(int i = 0; i < n; i++){
		int temp;
		cin >> temp;
		if(i % 2 == 0){
			a.push_back(temp);
		}else{
			b.push_back(temp);
		}
	}

	if(n % 2 == 0){
		reverse(b.begin(), b.end());
		for(auto x : b){
			cout << x << " ";
		}
		for(auto y : a){
			cout << y << " ";
		}
	}else{
		reverse(a.begin(), a.end());
		for(auto x : a){
			cout << x << " ";
		}
		for(auto y : b){
			cout << y << " ";
		}

	}
}

Measured memory_bytes: 3188
while True:
    a,op,b=input().split()
    if op=='?': break
    elif op=='+': print( int(a) +  int(b) )
    elif op=='-': print( int(a) -  int(b) )
    elif op=='*': print( int(a) *  int(b) )
    elif op=='/': print( int(a) // int(b) )


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n];
    int s=0;
    for (int i=0;i<n;i++){
        cin>>arr[i];
        s+=arr[i];
    }unsigned long long ans1=0,ans2=0;
    int y=s/n;
    for (int i=0;i<n;i++){
        ans1+=(arr[i]-y)*(arr[i]-y);
    }int z=s/n+1;
    for (int i=0;i<n;i++){
        ans2+=(arr[i]-z)*(arr[i]-z);
    }
    cout<<min(ans1,ans2)<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<int> X(M);
  for(int i=0;i<M;++i) cin>>X[i];
  sort(X.begin(), X.end());
  vector<int> aida;
  for(int i=1;i<M;++i) aida.push_back(X[i]-X[i-1]);
  sort(aida.begin(), aida.end(), greater<int>());
  int ans = 0;
  for(int i=N-1;i<M-1;++i) ans += aida[i];
  cout<<ans<<endl;
}



Measured memory_bytes: 4212
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;


int x;
int main(){
    for(int i=0;i<5;i++){
        cin >> x;
        if(x == 0) cout << i+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            int[] arr = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            Rectangle rect = new Rectangle(arr[0], arr[1]);
            System.out.printf("%d %d%n", rect.getSurface(), rect.getLap());
        }

    }

}

class Rectangle {
    int a;
    int b;

    public Rectangle(int a, int b) {
        this.a = a;
        this.b = b;
    }

    public int getSurface() {
        return a * b;
    }

    public int getLap() {
        return (a + b) << 1;
    }
}


Measured memory_bytes: 31036
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
using namespace std;
typedef long long ll;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"in%s.txt",s);
	freopen(str,"r",stdin);
//	sprintf(str,"out%s.txt",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=100010;
int n,K,a[N],b[N],bin[31];

int main()
{
	bin[0]=1;fo(i,1,30)bin[i]=bin[i-1]<<1;
	n=rd();K=rd();
	fo(i,1,n)a[i]=rd(),b[i]=rd();
	ll ans=0;
	fo(i,1,n)if((a[i]|K)==K)ans+=b[i];
	fo(i,1,30){
		if((bin[i]&K)==0)continue;
		int hh=(K^bin[i])|(bin[i]-1);
		ll res=0;
		fo(i,1,n)if((hh|a[i])==hh)res=res+(ll)b[i];
		ans=max(ans,res);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
# coding: utf-8

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)


N, X = map(int, raw_input().split())

x = map(int, raw_input().split())
x.append(X)
x = sorted(x)

A = [ abs(x[i+1] - x[i]) for i in range(N)]


for i in range(len(A)):
    if i == 0:
        ans = A[i]
    else:
        ans = gcd(ans, A[i])

print ans

Measured memory_bytes: 12368
#include <iostream>
#include <map>

int n,m;

std::map<int,int> map;

int main() {
    
    std::cin>>n;
    
    int a;
    
    for(int i=0;i<n;++i){
        std::cin>>a;
        map[a]++;
    }
    
    std::cin>>m;
    
    for(int i=0;i<m;++i){
        std::cin>>a;
        if(map[a]>0){
            --map[a];
        }
        else{
            std::cout<<"NO"<<std::endl;
            return 0;
        }
    }
    
    std::cout<<"YES"<<std::endl;
    
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    string s1, s2;
    cin >> s1;
    while(s1[0] != '.'){
        cin >> s2;
        if(s1 == s2){
            cout << "IDENTICAL" << endl;
            cin >> s1;
            continue;
        }
        vector<string> t1, t2;
        string u1, u2;
        rep(i, s1.size()){
            if(s1[i] == '\"'){
                u1 += "/";
                string tmp = "";
                i++;
                while(s1[i] != '\"'){
                    tmp += s1[i];
                    i++;
                }
                t1.push_back(tmp);
            }else{
                u1 += s1[i];
            }
        }
        rep(i, s2.size()){
            if(s2[i] == '\"'){
                u2 += "/";
                string tmp = "";
                i++;
                while(s2[i] != '\"'){
                    tmp += s2[i];
                    i++;
                }
                t2.push_back(tmp);
            }else{
                u2 += s2[i];
            }
        }
        // cout << u1 << endl;
        // cout << u2 << endl;
        // repe(i, t1) cout << i << " / ";cout << endl;
        // repe(i, t2) cout << i << " / ";cout << endl;

        bool ans = 0;
        if(u1 == u2 &&t1.size() == t2.size()){
            int ct = 0;
            rep(i, t1.size()){
                if(t1[i] != t2[i]) ct++;
                if(ct >= 2) break;
            }
            if(ct == 1) ans = 1;
        }
        cout << (ans ? "CLOSE" : "DIFFERENT") << endl;

        cin >> s1;
    }
}


Measured memory_bytes: 3156
#%%
import bisect

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())

ans_list = [-1] * n
for i in range(n):
    tmp = bisect.bisect_left(ans_list, a[i])
    #print(tmp)
    if tmp == 0:
        ans_list.insert(0, a[i])
    else:
        ans_list[tmp-1] = a[i]
    #print(ans_list)

ans = 0
for i in range(n):
    if ans_list[i] != -1:
        ans += 1
print(ans)

    


Measured memory_bytes: 7796
import sys
N = int(input())
string = []

false = 0
for i in range(N):
    string += input().split()
    if i ==0:
        ans = list(string[0])
    elif string[i] in string[:-1]:
        false += 1
    else:
        get = list(string[i])
        if get[0] == ans[-1]:
            ans = get
        else:
            false+=1
if false > 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
PROGRAM c167a

IMPLICIT NONE
CHARACTER(LEN=10) :: S
CHARACTER(LEN=11) :: T
INTEGER :: b

READ *, S
READ *, T

b = LEN_TRIM(T)
 
 IF (T(1 : b-1) == TRIM(S)) THEN
  PRINT *, 'Yes'
 ELSE
  PRINT *, 'No'
 END IF
 
END PROGRAM c167a

Measured memory_bytes: 2856
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  string S;
  cin >> S;
  if(S=="Sunny") cout << "Cloudy" << endl;
  else if(S=="Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int a[20];
int x[20][20];
int y[20][20];

int main()
{
    int n; cin >> n;
    REP(i, n) {
        cin >> a[i];
        REP(j, a[i]) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bit=1; bit<(1<<n); bit++) {
        bool ok = true;
        REP(i, n) {
            if(!(bit&(1<<i))) continue;
            REP(j, a[i]) {
                if (((bit>>(x[i][j]-1))&1)!=y[i][j]) ok = 0;
            }
        }
        if (ok) {
            int count = 0;
            for (int i = 0; i < n; i++) {
                count += ((bit>>i)&1);
            }
            ans = max(count, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

	if(m%n==0) {
		cout << (m/n) << endl;
		return 0;
	}

	vector<int> arr;
	for(int i = 2; i < 100000; i++) {
		if(m%i==0) {
			arr.push_back(i);
			arr.push_back(m/i);
		}
		if(i*i>m) break;
	}

	int ans = 1;

	for(int num : arr) {
		int _var = m/num;
		if(_var>n) {
			ans = max(ans,num);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, m, l, a[100][100], b[100][100], i, t, k;
	long long int c[101][101] = { 0 };

	scanf("%d %d %d", &n, &m, &l);

	for (i = 0; i < n; i++)
	{
		for (t = 0; t < m; t++)
		{
			scanf("%d", &a[i][t]);
		}
	}

	for (i = 0; i < m; i++)
	{
		for (t = 0; t < l; t++)
		{
			scanf("%d", &b[i][t]);
		}
	}

	for (i = 0; i < n; i++)
	{
		for (t = 0; t < l; t++)
		{
			for (k = 0; k < m; k++)
			{
				c[i][t] = c[i][t] + a[i][k] * b[k][t];
			}
		}
	}

	for (i = 0; i < n; i++)
	{
		for (t = 0; t < l; t++)
		{
			printf("%lld", c[i][t]);

			if (t < l-1)
			{
				printf(" ");
			}

		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>

int solve(int,int);
int n,A[2001],mi,i;

main(){
  int q,s;
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&mi);

    s = solve(0,mi);

    if(s != 0)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  if(m == 0)return 1;
  if(i >= n)return 0;
  return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

Measured memory_bytes: 584
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<array<int, 3>> abcs(n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> abcs[i][j];
        }
    }
    array<int, 3> ar;
    for (int i = 0; i < 3; ++i) {
        ar[i] = abcs[0][i];
    }
    for (int i = 1; i < n; ++i) {
        array<int, 3> new_ar = ar;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                new_ar[j] = max(new_ar[j], ar[k] + abcs[i][j]);
            }
        }
        ar = new_ar;
    }
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        ans = max(ans, ar[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N; cin >> N;
  set<string> s;
  string before, now;
  bool ok = false;
  for (int i = 0; i < N; i++) {
    before = now;
    cin >> now;
    if (s.count(now) == 0) {
      s.insert(now);
      if (i >= 1 && now.at(0) == before.back()) {
        ok = true;
      }
      else if (i == 0) {
        ok = true;
        continue;
      }
      else if (i >= 1 && now.at(0) != before.back()) {
        ok = false;
        break;
      }
    }
    else {
      ok = false;
      break;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}    

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

int main(){
	int a , b ;
	cin >> a >> b ;

	int c =  a * b  ;
	
	if(c % 2 == 0){
	cout << "Even" << endl ;
	}
	else
	{
	cout << "Odd" << endl;
	}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main()
{
    string x ;
    cin >> x ;
    int a = 700 ;

    if(x == "xxo" || x == "xox" || x == "oxx")
    a = 800 ;
    else if(x == "xoo" || x == "oox" || x == "oxo")
    a = 900 ;
    else if(x == "ooo")
    a = 1000 ;

    cout << a ;

    return 0 ;
}


Measured memory_bytes: 256
func pow(x: Int, _ y: Int) -> Int {
  return (0..<y).reduce(1){i,_ in i*x}
}
let N = Int(readLine()!)!
let n = readLine()!.characters.split(" ").filter{Int(String($0))!%2==0}.count
print(pow(3,N)-pow(2,n))

Measured memory_bytes: 4208
w = list(input())
alphabet = list(chr(ord("a") + i) for i in range(26))
enumerate = [0]*26

for x in w:
    for i in range(26):
        if x == alphabet[i]:
            enumerate[i] += 1

ans = 0
for i in range(26):
    if enumerate[i]%2 != 0 and enumerate[i] > 0 :
        ans = 1

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	int n;
	cin >> n;
	int a[100005] = {};

    int ma = 0;
	rep(i,0,n){
	    cin >> a[i];
	}

	sort(a,a+n);

	map<int,int> m;

	rep(i,0,n){
        m[a[i] + 1] ++;
        m[a[i] ] ++;
        m[a[i] -1] ++;
	}
	
	int ans = 0;

	for(auto it: m){
	   // cout << it.ft << " " << it.sd << endl; 
        if(ma <= it.sd){
            ma = it.sd;
            ans = it.ft;
        }
	}
	P(ma);
	

	return  0;
}

Measured memory_bytes: 5120
N, Q = map(int, input().split())
s = " " + input() + " "
td = []
for i in range(Q):
    td.append(input().split())
#print("td = {}".format(td))

llim = 0
rlim = N + 1
for t, d in reversed(td):
    if((s[llim + 1] == t) and ("L" == d)):
        llim += 1
    elif((s[llim] == t) and ("R" == d)):
        llim -= 1
    if((s[rlim - 1] == t) and ("R" == d)):
        rlim -= 1
    elif((s[rlim] == t) and ("L" == d)):
        rlim += 1
#    print("td = {}, llim = {}, rlim = {}".format([t, d], llim, rlim))

print(str(max(0, rlim - llim - 1)))


Measured memory_bytes: 39344
#include <bits/stdc++.h>
#define pb push_back
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int MAXN = (1<<30);
const int maxn = 200000 + 50;
const int mod = 1e9+7;
int a[maxn], n;
int main(){
//freopen("input.txt", "r", stdin);
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  if(n&1){
    for(int i = n; i >= 1; i-=2)
      cout << a[i] << " ";
    for(int i = 2; i <= n-1; i+=2)
      cout << a[i] << " ";
  }
  else{
     for(int i = n; i >= 2; i-=2)
      cout << a[i] << " ";
    for(int i = 1; i <= n-1; i+=2)
      cout << a[i] << " ";
  }
  return 0; 
}

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

using ll = long long int;
using ull = unsigned long long int;

constexpr ll MODS[2] = {ll(1e9+7), ll(1e9+9)};

struct RollingHash{
    vector<vector<ll> > powb, rhash;
    void build(string &str, const ll base = ll(1e5+7)) {
        int N = str.size();
        int M = 2;
        powb.resize(M);
        rhash.resize(M);
        for(int k=0;k<M;k++){
            powb[k].resize(N+1);
            rhash[k].resize(N+1);
            powb[k][0] = 1;
            rhash[k][0] = 0;
            for (int i = 0; i < N; i++) {
                rhash[k][i+1] = (str[i] + rhash[k][i] * base) % MODS[k];
                powb[k][i+1] = powb[k][i] * base % MODS[k];
            }
        }
    }

    //[l,r)
    ll get_hash(int k, int l, int r) { return (rhash[k][r] - rhash[k][l]*powb[k][r-l]%MODS[k]+MODS[k])%MODS[k]; }
    
    bool match(int l1, int r1, int l2, int r2){
        bool res = true;
        for(int k=0; k<2; k++){
            res &= get_hash(k, l1, r1) == get_hash(k, l2, r2);
        }
        return res;
    }
};

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

    t.insert(t.end(),t.rbegin(),t.rend());
    RollingHash h;
    h.build(t);

    for(int k=2;k<=n;k++){
        int len=k, idx=k;
        while(idx < n){
            int r = min(idx-1+len,n), l = idx-(r-idx+1);
            if(h.match(l, r, n*2-r, n*2-l)){
                idx = r;
                len = len*2-1;
            }else{
                break;
            }
        }
        if(idx==n){
            cout << k << endl;
            break;
        }
    }
    return 0;
}


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

max1 = 0
max2 = 0
max1_id = 0
for i, a in enumerate(range(n)):
  a = int(input())
  if a > max1:
    max2 = max1
    max1 = a
    max1_id = i
  elif a > max2:
    max2 = a

for i in range(i+1):
  if i == max1_id:
    print(max2)
  else:
    print(max1)

Measured memory_bytes: 4540
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
MOD = 10 ** 9 + 7

dp = [[0 for _ in range(N+1)] for _ in range(M+1)]
dp[0] = [0 for _ in range(N+1)]

for i in range(1,M+1):
    for j in range(N+1):
        if j == 0:
            dp[i][j] = 0
            continue
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
        if S[j-1] == T[i-1]:
            dp[i][j] += dp[i-1][j-1] + 1
        dp[i][j] %= MOD
        

print((dp[-1][-1] + 1) % MOD)


Measured memory_bytes: 76124
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long e = sc.nextLong();

        long aBottoleNeck = (n + (a-1))/a;
        long bBottoleNeck = (n + (b-1))/b;
        long cBottoleNeck = (n + (c-1))/c;
        long dBottoleNeck = (n + (d-1))/d;
        long eBottoleNeck = (n + (e-1))/e;

        long maxBottoleNeck = Math.max(aBottoleNeck, Math.max(bBottoleNeck, Math.max(cBottoleNeck, Math.max(dBottoleNeck, eBottoleNeck))));
        System.out.println(maxBottoleNeck + 4);
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;

int main(){
	lli n;
	cin >> n;
	vector<lli> pri(1000, 1);
	for(int i=2; i<=n; i++){
		int num=i;
		for(int j=2; j*j<=n; j++){
			while(num%j==0){
				pri[j]++;
				num /= j;
			}
		}
		pri[num]++;
	}
	lli ans=1;
	for(int i=2; i<1000; i++){
		ans = ans*pri[i] %mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IL inline
#define _ 800005
#define ll long long
using namespace std ;

IL int gi(){
    int data = 0 , m = 1; char ch = 0;
    while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
    if(ch == '-'){m = 0 ; ch = getchar() ; }
    while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
    return (m) ? data : -data ; 
}

const int pr = 5 ;
const int mod = 924844033 ;

int Fac[_],IFac[_],inv[_] ; int rev[_],f1[_],f2[_],f3[_],wn[300],n,m,K,W[_] ;
int nn , nl , Ans , ans[_] , cnt[_] , sz[_] ;

struct _Edge{
	int to , next ; 
}Edge[_ << 1] ; int head[_] , CNT ;
IL void AddEdge(int u , int v) {
	Edge[++CNT] = (_Edge){v , head[u]} ; head[u] = CNT ;
	return ;
}

IL int Pow(int ts , int js) {
	int al = 1 ;
	while(js) {
		if(js & 1) al = 1ll * al * ts % mod ;
		ts = 1ll * ts * ts % mod ; js >>= 1 ; 
	}return al ;
}

IL void Numb() {
	int N = max(n , m) ;
	Fac[0] = Fac[1] = IFac[0] = IFac[1] = inv[0] = inv[1] = 1 ;
	for(int i = 2; i <= N; i ++) {
		Fac[i] = 1ll * i * Fac[i - 1] % mod ;
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod ;
		IFac[i] = 1ll * IFac[i - 1] * inv[i] % mod ; 
	}
	return ;
}

IL void NTT(int *P , int op) {
	for(int i = 0; i < nn; i ++) if(rev[i] > i) swap(P[i] , P[rev[i]]) ;
	for(int i = 1,id = 0; i < nn; i <<= 1) {
		++ id ;
		for(int j = 0,p = (i << 1) ; j < nn ; j += p) {
			int w = 1 ;
			for(int k = 0; k < i; k ++, w = 1ll * w * wn[id] % mod) {
				int X = P[j + k] , Y = 1ll * w * P[j + k + i] % mod ;
				P[j + k] = (X + Y) % mod ;
				P[j + k + i] = (X - Y + mod) % mod ; 
			}
		}
	}if(op < 0) {
		for(int i = 1; i < nn / 2; i ++) swap(P[i] , P[nn - i]) ;
		int INV = Pow(nn , mod - 2) ;
		for(int i = 0; i < nn; i ++) P[i] = 1ll * P[i] * INV % mod ; 
	}return ; 
}

void Dfs(int u , int From) {
	sz[u] = 1 ;
	for(int e = head[u] ; e ; e = Edge[e].next) {
		int v = Edge[e].to ; if(v == From) continue ;
		Dfs(v , u) ;
		sz[u] = sz[u] + sz[v] ; cnt[sz[v]] = (cnt[sz[v]] + 1) % mod ; 
	}
	if(From) cnt[n - sz[u]] = (cnt[n - sz[u]] + 1) % mod ; 
	return ; 
}

int main() {
	n = gi() ;
	Numb() ;
	for(int i = 1,u,v; i < n; i ++) u = gi() , v = gi() , AddEdge(u , v) , AddEdge(v , u) ;
	Dfs(1 , 0) ;
	//for(int i = 1; i <= n; i ++) cout << "cnt["<<i<<"] = " << cnt[i] << endl ;
	for(int i = 0; i <= n; i ++) f1[i] = 1ll * Fac[i] * cnt[i] % mod ;
	for(int i = 0; i <= n; i ++) f2[n-i] = IFac[i] % mod ;
	for(int i = 0; i <= 30; i ++) wn[i] = Pow(pr , (mod - 1) / (1 << i)) ;
	for(nn = 1; nn <= 2 * n; nn <<= 1) ++ nl ;
	for(int i = 0; i < nn; i ++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (nl - 1)) ;
	NTT(f1 , 1) ; NTT(f2 , 1) ;
	for(int i = 0; i < nn; i ++) f1[i] = 1ll * f1[i] * f2[i] % mod ;
	NTT(f1 , -1) ;
	for(int i = 1; i <= n; i ++) {
		Ans = 1ll * Fac[n] * IFac[i] % mod * IFac[n - i] % mod * n % mod ;
		Ans = Ans - 1ll * IFac[i] % mod * f1[n + i] % mod + mod ;
		Ans %= mod ;
		printf("%d\n" , Ans) ;
	}
	return 0 ; 
}


Measured memory_bytes: 48384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a[4][4],d[4][4],z,n;
    set<int>s;
    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
            cin>>a[i][j];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>z;
        s.insert(z);
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if(s.count(a[i][j]))
                d[i][j]=1;
            else
                d[i][j]=0;
        }
    }
    if(d[1][1])
    {
        if((d[0][0]&&d[2][2])||
           (d[0][1]&&d[2][1])||
           (d[2][0]&&d[0][2])||
           (d[1][0]&&d[1][2]))
        {
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;
    }
    else
    {
        if((d[0][0]&&d[0][1]&&d[0][2])||
           (d[1][0]&&d[0][0]&&d[2][0])||
           (d[2][0]&&d[2][1]&&d[2][2])||
           (d[0][2]&&d[1][2]&&d[2][2]))
        {
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3652
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M, X = map(int, readline().split())
    A = list(map(int, readline().split()))
    cost = [0] * (N+1)
    for i in range(M):
        cost[A[i]] += 1
    ans = min(sum(cost[:X]), sum(cost[X+1:]))
    print(ans)

if __name__ == '__main__':
    main()

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

/** Problem0049 : Blood Groups **/
int main()
{
	int num[4] = {0, 0, 0, 0};
	int stId[10000], idx=0, inId;
	char camma; string inBlood;
	bool flg;
	
	while (cin >> inId >> camma >> inBlood) {
		flg = true;
		for (int i=0; i<idx; i++) {
			if (stId[i] == inId)
				flg = false;
		}
		
		if (flg) {
			stId[idx++] = inId;
			if (inBlood == "A")
				num[0]++;
			else if (inBlood == "B")
				num[1]++;
			else if (inBlood == "AB")
				num[2]++;
			else if (inBlood == "O")
				num[3]++;
		}
	}
	cout << num[0] << "\n" << num[1] << "\n" << num[2] << "\n" << num[3] << endl;
	return 0;
}

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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint fact[1000005];

int main() {
  long long N, M, K;
  cin >> N >> M >> K;
  fact[0] = fact[1] = 1;
  for (int i = 2; i < 1000005; i++) {
    fact[i] = fact[i - 1] * i;
  }
  // i * (M-i) * N*N * (N*M-2)C(K-2)
  modint x = 0;
  for (int i = 1; i < M; i++) {
    x += i * (M - i);
  }
  x *= N * N;
  modint y = 0;
  for (int i = 1; i < N; i++) {
    y += i * (N - i);
  }
  y *= M * M;
  modint ans = (x + y) * fact[N * M - 2] / fact[K - 2] / fact[N * M - K];
  cout << ans << endl;
  return 0;
}
/* vim:set fdm=marker: */


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

using namespace std;
using ll = long long;


int main()
{
    set<int> st;

    int a, b, k;
    cin >> a >> b >> k;
    for(int i = a; i < a + k; i++)st.insert(i);
    for(int i = b; i > b - k; i--)st.insert(i);
    for(auto i : st){
        if(a <= i && i <= b)cout << i << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include<bits/stdc++.h>
#include<iomanip>
#define inf  (int)1e18
#define EPS   1e-9
#define mod 1000000007
#define all(k) sort(k.begin(),k.end())
#define Pi 3.14159
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define repk(i,a,n) for(int i=a;i<=(n);i++)
#define ll unsigned long long
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vc vector<char>
#define vl vector<ll>
#define mi map<int,int>
#define ml map<ll,ll>
#define umap unordered_map<ll,int>
using namespace std;

ll int togglebit(ll int n)
{
	if (n == 0)
		return 1;


	ll int i = n;

	n |= n >> 1;


	n |= n >> 2;
	n |= n >> 4;
	n |= n >> 8;
	n |= n >> 16;

	return i ^ n;
}

void sol() {
	int n; cin >> n;
	string s;
	cin >> s;
	if (n % 2 != 0) {cout << "No\n"; return;}
	bool ok = 0;
	int i = 0, j = n / 2;
	while (i < j && j < n) {
		if (s[i] != s[j])
			ok = 1;


		i++, j++;
	}
	if (ok)
		cout << "No\n";
	else
		cout << "Yes\n";


}
int main() {


	int t = 1;
	// cin >> t;

	for (int i = 0; i < t; ++i)
		sol();


	return 0;
}

Measured memory_bytes: 3612