akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ACC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mod 1000000007
#define MAXN 10000001
//string alpha="abcdefghijklmnopqrstuvwxyz";
//int dx[]={1,-1,0,0};
//int dy[]={0,0,1,-1};
//int dx8[]={1,-1,0,0,1,1,-1,-1};
//int dy8[]={0,0,1,-1,1,-1,1,-1};
/*int spf[MAXN];
void sieve()
{
	int i,j;
	for(i=0;i<MAXN;i++)
	spf[i]=i;
	for(i=4;i<MAXN;i+=2)
	spf[i]=2;
	for(i=3;i*i<MAXN;i++)
	{
		if(spf[i]==i)
		{
			for(j=i*i;j<MAXN;j+=i)
			{
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}*/
/*bool isvowel(char c)
{
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':return true;
        default : return false;
    }
}*/
/*bool isValid(int x,int y,int n,int m)
{
    if(x<0||x>n-1||y<0||y>m-1)return false;
    return true;
}*/
/*
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(x.first==y.first)
        return x.second<y.second;
    return x.first>y.first;
}*/
int n,m;
int c;

vector<int> vr[200001];
int vis[200001];
void bfs(int node){
	vis[node]=1;
	c++;


	for(int i:vr[node]){
		if(vis[i]==0){


			bfs(i);

		}
	}
}

void solve(){

	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		vr[a].pb(b);
		vr[b].pb(a);

	}
	int cc=INT_MIN;
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			c=0;

			bfs(i);
			cc=max(cc,c);


		}

	}
	cout<<cc+1-1<<endl;
}
int32_t main()
{
    ACC
    int T;
    T=1;
    //cin>>T;
    //sieve();
    while(T--)
    {
        solve();
    }
    return 0;
}


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

ll INF = 1e18;
ll MOD = 1e9+7;
//最大公約数
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;
}


int main(){
    ll N; cin >> N;
    cout << lcm(2, N) << endl;;
}

Measured memory_bytes: 256
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c,d; cin >> a >> b >> c >> d;
    int l = c*d/(__gcd(c,d));
    int ans = b-a+1;
    int num1 = b/c - (a-1)/c;
    int num2 = b/d - (a-1)/d;
    int num3 = b/l - (a-1)/l;
    cout << ans-num1-num2+num3;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    int n;
    
    cin >> n;
    vector <long> l(n,0);
    vector <long> r(n,0);

    long sum =0;
    for(int i=0;i<n;i++){
        cin >> l[i]>> r[i] ;
        sum += r[i] - l[i] +1 ;
    }    
    cout <<sum;
    
    return 0;
}






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

int n,x[N],y[N],r[N],c[N],ans;
bool dp[(1<<N)];
vector<int> v[N];

int main(){
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>r[i]>>c[i];
      for(int j=i-1;j>=0;j--){
	int X=x[i]-x[j];
	int Y=y[i]-y[j];
	int R=r[i]+r[j];
	if(X*X+Y*Y<R*R)v[i].push_back(j);
      }
    }
    for(int i=0;i<(1<<n);i++)dp[i]=false;
    dp[0]=true;
    ans=0;
    for(int i=0;i<(1<<n);i++){
      if(!dp[i])continue;
      ans=max(ans,__builtin_popcount(i));
      for(int j=0;j<n;j++){
	if((i&(1<<j)))continue;
	int f=0;
	for(int k=0;k<v[j].size();k++)
	  if(!(i&(1<<v[j][k])))f=1;
	if(f)continue;
	for(int k=j+1;k<n;k++){
	  if(c[j]!=c[k])continue;
	  if((i&(1<<k)))continue;
	  f=0;
	  for(int l=0;l<v[k].size();l++)
	    if(!(i&(1<<v[k][l])))f=1;
	  if(f)continue;
	  dp[((i|(1<<j))|(1<<k))]=true;
	}
      }
    }
    cout<<ans<<endl;
    for(int i=0;i<n;i++)v[i].clear();
  }
  return 0;
}

Measured memory_bytes: 17608
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
using namespace std;

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

int n;
int M[110][110] = {};
int color[110];
int elapse = 0;
int d[110];
int f[110];

void dfs(int u) {
  color[u] = GRAY;
  d[u] = ++elapse;
  rep(v, n) {
    if (M[u][v] && color[v] == WHITE) dfs(v);
  }
  color[u] = BLACK;
  f[u] = ++elapse;
}

void dfs_init() {
  rep(i, n) color[i] = WHITE;
  rep(i, n) {
    if (color[i] == WHITE) dfs(i);
  }
}

int main() {
  cin >> n;
  rep(i, n) {
    int id, deg;
    cin >> id >> deg;
    --id;    // 0-indexedに直す
    rep(j, deg) {
      int v;
      cin >> v;
      --v;    // 0-indexedに直す
      ++M[id][v];
    }
  }
  dfs_init();
  rep(i, n) {
    cout << i + 1 << " " << d[i] << " " << f[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    ll red=0;
    REP(i, 0, n){
        if(s[i]=='R') red++;
    }

    if(red>(n-red)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;

  vector<int> p(M);
  vector<string> S(M);
  for(int i = 0; i < M; i++) {
    cin >> p.at(i) >> S.at(i);
  }
  
  map<int, int> mp_ac;
  map<int, int> mp_wa;

  int c_ac = 0;
  int c_wa = 0;
  int tmp_c_wa = 0;

  for(int i = 0; i < M; i++) {
    auto iter = mp_ac.find(p.at(i));
    
    if(iter == mp_ac.end()) {
      if(S.at(i) == "AC") {
        mp_ac.insert(make_pair(p.at(i), 0));
      } else {
        auto iter_wa = mp_wa.find(p.at(i));
        if(iter_wa != mp_wa.end()) {
          int c = iter_wa->second;
          c = c + 1;
          mp_wa[p.at(i)] = c;
        } else {
          mp_wa[p.at(i)] = 1;
        }
      }
    }
  }
  
  // mpの中身を計算する
  int count = mp_ac.size();
  int count_wa = 0;
  
  for(auto itr = mp_ac.begin(); itr != mp_ac.end(); ++itr) {
    auto iter = mp_wa.find(itr->first);
    count_wa += iter->second;
  }

  cout << count << " " << count_wa << endl;
}


Measured memory_bytes: 10752
N, X, Y = map(int,input().split())
k_list = [0]*N

for p in range(1, N):
    for q in range(p, N+1):
        p2X = abs(p - X)
        q2Y = abs(q - Y)

        distance = min(q-p, p2X+1+q2Y)
        k_list[distance] += 1

for k in range(1, N):
    print(k_list[k])

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int n,m,d;
	cin >> n >> m >> d;
	int score = 0;
	for(int i=1;i<=n;i++){
		if(i+d <= n) score +=1;
		if(i-d >= 1 && d != 0) score +=1;
	}
	printf("%.7f",double(score)/n * double(m-1) / n);
}


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

int main() {
  int A , B , C , D , L , R ;
  cin >> A >> B >> C >> D ;
 L = A + B ;
 R = C + D ; 
  if ( L > R ) {
      cout << "Left" << endl;
    }
  else if ( L < R ) {
      cout << "Right" << endl;
    }
  else if ( L = R ) {
    cout << "Balanced" << endl;
    }
  }

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n; cin >> n;
	int ue = n / 100, st = n % 100;
	bool uy = false, sy = false;
	if(ue == 0 || ue > 12) uy = true;
	if(st == 0 || st > 12) sy = true;
	if(uy && sy) cout << "NA" << endl;
	else if(uy) cout << "YYMM" << endl;
	else if(sy) cout << "MMYY" << endl;
	else cout << "AMBIGUOUS" << endl;
	return 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())

if K%2 == 1:
    count = 0
    for i in range(1,N+1):
        if i%K == 0:
            count += 1
    ans = count**3
else:
    count = 0
    c = 0
    for j in range(1,N+1):
        if j%K == 0:
            count += 1
        elif j%(K/2) == 0:
            c += 1
    ans = count**3 + c**3

print(ans)

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

int main(){
    unsigned long N;
    cin >> N;
    vector<long> a(N);
    for(auto& i : a)cin >> i;
    long C;
    cin >> C;
    long u{C};
    for(const auto i : a)u = __gcd(u, abs(i));

    vector<long> sieve(31622, 1);
    for(long i = 2; i < 31622; ++i)if(sieve[i]){
        if(u % i == 0 && cout << i << endl)
            while(u % i == 0)u /= i;
        else if(C % i == 0 && i <= N){
            vector<long> v(i);
            for(unsigned long j = 0, k = 0; j < N; ++j, k = k == i - 2 ? 0 : ++k)v[k] += a[j];
            if(none_of(v.begin(), v.end(), [&i](auto x){return x % i;}))cout << i << endl;
        }
        for(auto j = i * i; j < 31622; j += i)sieve[j] = 0;
    }
    if(u ^ 1)cout << u << endl;
}

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

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

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

	int l[n+1],r[n+1];
	l[0]=0,r[n]=0;
	for(int i=1;i<=n;i++) l[i]=gcd(l[i-1],a[i-1]);
	for(int i=n-1;i>=0;i--) r[i]=gcd(r[i+1],a[i]);
	int ans=0;
	for(int i=0;i<n;i++) ans=max(ans,gcd(l[i],r[i+1]));
	cout << ans << endl;
}


Measured memory_bytes: 1408
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int MAIN()
{
	int n, A, B;
	int s = 0;
	cin >> n >> A >> B;
	for(int i = 1; i <= n; i++)
	{
		int t;
		cin >> t;
		if(t < A || t >= B) s ++;
	}
	cout << s << endl;
	return 0;
}

int main()
{
	int start = clock();
	#ifdef LOCAL_TEST
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios :: sync_with_stdio(false);
	cout << fixed << setprecision(16);
	int ret = MAIN();
	#ifdef LOCAL_TEST
		cout << "[Finished in " << clock() - start << " ms]" << endl;
	#endif
	return ret;
}


Measured memory_bytes: 256
using System;

namespace ALDS1_5B
{
    class Program
    {
        static int count = 0;
        static void Merge(int[] array, int left, int mid, int right)
        {
            var n1 = mid - left;
            var n2 = right - mid;

            var l = new int[n1 + 1];
            var r = new int[n2 + 1];

            for (var n = 0; n < n1; n++)
                l[n] = array[left + n];
           
            for (var n = 0; n < n2; n++)
                r[n] = array[mid + n];
            
            l[n1] = 2147483647;
            r[n2] = 2147483647;

            var i = 0;
            var j = 0;

            for (var k = left; k < right; k++)
            {
                count++;
                if (l[i] <= r[j])
                {
                    array[k] = l[i];
                    i++;
                }
                else
                {
                    array[k] = r[j];
                    j++;
                }
            }
        }

        static void MergeSort(int[] array, int left, int right)
        {
            if (left + 1 < right)
            {
                var mid = (left + right) / 2;
                MergeSort(array, left, mid);
                MergeSort(array, mid, right);
                Merge(array, left, mid, right);
            }
        }

        static void Main()
        {
            var len = int.Parse(Console.ReadLine());
            var array = Array.ConvertAll(
                Console.ReadLine().Split(' '),
                e => int.Parse(e)
            );
            MergeSort(array, 0, len);
            Console.WriteLine(string.Join(" ",
                Array.ConvertAll(array, e => e.ToString())
            ) + "\n" + count.ToString());
        }
    }
}


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

const int mod = 1e9 + 7;

void add(int &x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int mul(int x,int y) {
	return 1LL * x * y % mod;
}

int n;
int f[1000005];

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	f[0] = 1; f[1] = n; f[2] = mul(n, n);
	int sum = f[0] + f[1] + f[2];
	while (sum >= mod) sum -= mod;
	for (int i = 3; i <= n; ++i) {
		add(f[i], mul(n - 1, n - 1));
		add(f[i], sum);
		add(f[i], mod - f[i - 2]);
		add(f[i], n - i + 1);
		add(sum, f[i]);
	}
	cout << f[n] << '\n';
}


Measured memory_bytes: 4224
/*
    WRITER:kakitamasziru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const int INF = 1001001000;
const int MOD = 1000000007;
typedef pair<long,long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    long long N,M;cin >> N >> M;
    if(abs(N-M) > 1){
        cout << 0 << endl;
        return 0;
    }
    if(N == M) cout << ((nCr(N,1)*nCr(M,1))%MOD*2)%MOD << endl;
    else cout << (nCr(N,1)*nCr(M,1))%MOD << endl;
    

    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define pb push_back
# define FOR(i,a,n) for(int i=a;i<n;i++)
# define mp make_pair
# define RFOR(i,a,n) for(int i=n;i>a;i--)
# define pii pair<long long int,long long int>
#define ub upper_bound
#define lb lower_bound
#define MOD 1000000007
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
	char ch;
	cin>>ch;
	if(ch>=65&&ch<=90)
	cout<<"A"<<endl;
	else
	cout<<"a"<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<string>
#include<algorithm>
#include<cmath>
#define rg register
#define il inline
using namespace std;
typedef long long ll;
ll read(){
    ll ans=0,flag=1;char ch;
    while((ch=getchar())<'0'||ch>'9') if(ch=='-') flag=-1;ans=ch^48;
    while((ch=getchar())>='0'&&ch<='9') ans=(ans<<3)+(ans<<1)+(ch^48);
    return flag*ans;
}
int main(){
    int n=read();
    char buff[1005];
    scanf("%s",buff);
    int t=read();
    for(rg int i=0;i<n;i++){
        if(buff[i]!=buff[t-1]) putchar('*');
        else putchar(buff[i]);
    }
    return 0;
}

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

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

ans = 0
for i,b in enumerate(B):
    x = min(A[i], b)
    b -= x
    ans += x
    if b > 0:
        x = min(A[i+1], b)
        A[i+1] -= x
        ans += x
print(ans)


Measured memory_bytes: 18624
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

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

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < n / 2; ++i) {
			if (s[i] != s[i + n / 2]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
} 

Measured memory_bytes: 256
import java.util.Scanner;


class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int i;
		int y = 0;
		for(int x = a; x <= b; x++){
			i = c / x;
			if(c == i * x){
				y = y + 1;
			}
		}
		System.out.println(y);
	}
}


Measured memory_bytes: 26320
#include <bits/stdc++.h>
#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 repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;
  vll A(N);

  ll sum = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    A[i] = a;
    if (i == 0) {
      sum += abs(a);
    } else {
      sum += abs(a - A[i - 1]);
    }
  }
  sum += abs(A[N - 1]);

  rep(i, N) {
    if (i == 0) {
      ll ans = sum - abs(A[0]) - abs(A[0] - A[1]) + abs(A[1]);
      COUT(ans);
      continue;
    }
    if (i == N - 1) {
      ll ans = sum - abs(A[N - 1]) - abs(A[N - 2] - A[N - 1]) + abs(A[N - 2]);
      COUT(ans);
      continue;
    }
    ll a = abs(A[i - 1] - A[i]);
    ll b = abs(A[i] - A[i + 1]);
    ll c = abs(A[i - 1] - A[i + 1]);
    ll ans = sum - a - b + c;
    COUT(ans);
  }

  return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

ld calc(vector<ld> &v) {
    ld result = 1;

    sort(v.begin(), v.end());
    
    for(const auto &it : v) {
        result *= it;

        if(result > 1e18L)
            return -1;
    }

    return result;
}

int main() {
    int n;
    cin >> n;
    vector<ld> v(n);
    cout << fixed << setprecision(0);

    for(auto &ent : v)
        cin >> ent;

    cout << calc(v) << endl;

    return 0;
}

Measured memory_bytes: 4840
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CManagement solver = new CManagement();
        solver.solve(1, in, out);
        out.close();
    }

    static class CManagement {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt();
            int[] d = new int[n];
            for (int i = 1; i < n; i++)
                d[s.nextInt() - 1]++;
            for (int i = 0; i < n; i++)
                w.println(d[i]);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

using namespace std;

int N;
char sir[6009];

string takeString (vector < int > p)
{
    string curr;
    for (auto i : p)
        curr.push_back (sir[i]);
    return curr;
}

vector < int > operator + (vector < int > a, vector < int > b)
{
    for (auto i : b)
        a.push_back (i);
    return a;
}

void updateAns (vector < int > &ans, vector < int > potentialAns)
{
    if (takeString (potentialAns) > takeString (ans))
        ans = potentialAns;
}

vector < int > solve (int l, int r)
{
    vector < int > pa, pb;
    for (int i=l; i<=r; i++)
        if (sir[i] == 'a') pa.push_back (i);
        else pb.push_back (i);
    if (pa[0] < pb[0])
    {
        vector < int > ans;
        ans.push_back (pa[0]), ans.push_back (pb[0]);
        int lastB = pb[0];
        for (int i=1; i<pa.size (); i++)
            if (pa[i] > lastB)
                ans.push_back (pa[i]),
                ans.push_back (pb[i]),
                lastB = pb[i];
        return ans;
    }
    vector < int > ans, curr;
    for (int i=pa.size () - 1; i>=0; i--)
    {
        curr.push_back (pa[i]);
        curr.push_back (pb[i]);
        sort (curr.begin (), curr.end ());
        updateAns (ans, curr);
    }
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d\n", &N);
scanf ("%s", sir + 1);
int balance = 0, lst = 0;
vector < string > ans;
for (int i=1; i<=2 * N; i++)
{
    if (sir[i] == 'a') balance ++;
    else balance --;
    if (balance == 0)
    {
        ans.push_back (takeString (solve (lst + 1, i)));
        lst = i;
    }
}
reverse (ans.begin (), ans.end ());
string finalAns;
for (auto s : ans)
    if (s + finalAns > finalAns)
        finalAns = s + finalAns;
printf ("%s\n", finalAns.c_str ());
return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int DP[]=new int[45];
		DP[0]=1; DP[1]=1;
		
		for(int i=2;i<=44;i++)DP[i]=DP[i-1]+DP[i-2];
		
		System.out.println(DP[in.nextInt()]);
		in.close();
	}

}


Measured memory_bytes: 26040
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  ll n;
  cin>>n;
  ll a[n],b[n];
  rep(i,n) cin>>a[i]>>b[i];
  P pa[n];
  rep(i,n) {
    pa[i].first = a[i] + b[i];
    pa[i].second = i;
  }
  sort(pa, pa + n, greater<>());
  ll ta = 0, ao = 0;
  rep(i,n) {
    if(i % 2 == 0) {
      ta += a[pa[i].second];
    } else {
      ao += b[pa[i].second];
    }
  }
  cout << ta - ao << endl;


  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  string result = S.substr(0,3);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, X := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()

	A = append(A, X)

	sort.Ints(A)

	tmp := A[1] - A[0]
	for i := 1; i < N; i++ {
		tmp = gcd(tmp, A[i+1]-A[i])

	}
	fmt.Println(tmp)
}
func gcd(a, b int) int {
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

vector<int> v(303030);
int n,k,m,a;
string s,t;

int main() {
  cin >> n;
  int ans=0;
  rep(i,n){
   cin >> a; ans+=a-1;
  }
  cout << ans << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int t = 1900 * M + 100 * (N - M);
  int ans = t * pow(2, M);
  cout << ans << "\n";
  return 0;
}


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

def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

d=divisore(n)

ans=0
for i in d[1:]:
  cand=i-1
  if n//cand==n%cand:
    ans+=cand

print(ans)

Measured memory_bytes: 9536
#include<iostream>

int main(){
	int a,b,c,n,i;
	std::cin>>n;
	for(i=0;i<n;i++){
	std::cin>>a>>b>>c;
	if(a*a+b*b==c*c){
		std::cout<<"YES"<<std::endl;
	}else if(a*a+c*c==b*b){
		std::cout<<"YES"<<std::endl;
	}else if(b*b+c*c==a*a){
		std::cout<<"YES"<<std::endl;
	}else{
		std::cout<<"NO"<<std::endl;
	}
}
	return 0;
}

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

void include3(int x, int i){
  if(x % 10 == 3) {
    cout  << " " << i;
  }else{
    x /= 10;
    if(x) include3(x, i);
  }
}

void call(int n){
  int i, x;

  for(i = 1; i < n+1; ++i){
    x = i;
    if(x % 3 == 0) {
      cout << " " << i;
    }else{
      include3(x, i);
    }
  }
  
}

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

  call(n);
  cout << endl;
}

Measured memory_bytes: 1160
#include <cstdio>
int main(){
	int n;
	scanf("%d", &n);
	for (int i = 1; i < 10; i++){
		if (n % i == 0){
			if (n / i >= 1 && n / i < 10){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

void ppp(vector<ll> dp, ll n) {
	return ;
	cout << "DBG ";
	for(int i=0;i<n;i++) {
		cout << dp[i] << ' ';
	}
	cout << endl;
}
int main() {
	ll		c,i,j,k,n,m,x,y,ans = 0;

	cin >> n >> m;
	vector<ll> a(n),dp(n),b(n);

	for(i=0;i<n;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	vector<pair<ll,ll>> cb(m);
	
	for(i=0;i<m;i++) {
		cin >> cb[i].second >> cb[i].first;
	}
	sort(cb.begin(), cb.end());
	x = m-1;
	y = cb[x].second;
	for(i=0;i<n;i++) {
		dp[i] = cb[x].first;
		if (--y == 0) {
			y = cb[--x].second;
		}
	}
	ppp(a, n);
	ppp(dp , n);

	i = x = 0;
	for(j=0;j<n;j++) {
		if (dp[x] > a[i]) {
			b[j] = dp[x++];
		} else {
			b[j] = a[i++];
		}
	}
	for(i=0;i<n;i++) {	
		ans += b[i];
	}

	ppp(a, n);


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


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

int main(){
    int A,B,C;
    cin >> A >> B >> C;

    if(A < C && B > C){
        cout << "Yes" << endl;
        return 0;
    }
    if(A > C && B < C){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	ll n, i, mi = LLONG_MAX, ma = LLONG_MIN, a, b;
	
	cin >> n;
	vl x(n), y(n);
	rep(i, 0, n)
	{
		cin >> a >> b;
		x[i] = a + b;
		y[i] = a - b;
	}
	sort(all(x));
	sort(all(y));
	cout << max(x[n - 1] - x[0], y[n - 1] - y[0]);
}

Measured memory_bytes: 6364
import numpy as np

def main():

    N,L = (int(i) for i in input().split())
    L_list = [int(L+i) for i in range(N)]

    if L_list[0] < 0:
        if L_list[0]+N-1 >= 0 :
            print(sum(L_list[:]))
        else:
            print(sum(L_list[:-1]))
    else:
        print(sum(L_list[1:]))


if __name__ == '__main__':
    main()

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

int main() {
    string s;  cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])   cout << "Bad" << endl;
    else  cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;

    ll ans = 0;
    vector<vector<int>> dp(2,vector<int>(s.size(),0));


    reverse(s.begin(),s.end());
    dp[0][0] = s[0] - '0';
    dp[1][0] = 11 - (s[0] - '0');
    for(int i = 0;i < s.size() - 1;i++){
        dp[0][i+1] = min(dp[0][i]+(int)(s[i+1]-'0'),dp[1][i]+(int)(s[i+1]-'0'));
        dp[1][i+1] = min(dp[0][i]+11-(int)(s[i+1]-'0'),dp[1][i]+9-(int)(s[i+1]-'0'));
    }

    cout << min(dp[0][s.size()-1],dp[1][s.size()-1]) << endl;
} 


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m; cin >> n >> m;
	vll x(m), y(m);
	rep(i, m) cin >> x[i];
	sort(all(x));

	if (n >= m){
		cout << 0 << "\n";
		return 0;
	}

	rep(i, m-1) y[i] = x[i+1]-x[i];
	sort(rall(y));

	ll ans = x[m-1]-x[0];

	rep(i, n-1) ans -= y[i];

	cout << ans << "\n";

	return 0;
}

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

struct edge {int to, cost; };

const int MAX_V=100000;
const int INF=1000000001;

int V,E;
vector<edge> G[MAX_V+1];
int d[MAX_V+1];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(d, d+V, INF);
  d[s]=0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p=que.top(); que.pop();
    int v=p.second;
    if (d[v]<p.first) continue;
    for (int i=0; i<G[v].size(); i++) {
      edge e=G[v][i];
      if (d[e.to]>d[v]+e.cost) {
        d[e.to]=d[v]+e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  cin>>V>>E;
  int s; cin>>s;
  rep(i, E) {
    int a,b,c; cin>>a>>b>>c;
    G[a].push_back(edge{b, c});
  }
  dijkstra(s);
  rep(i, V) {
    if (d[i]==INF) cout<<"INF"<<endl;
    else cout<<d[i]<<endl;
  }
}



Measured memory_bytes: 13064
#include<iostream>
#include<string>
#define P 1000000007
using namespace std;
 
int main(){
  string s;
  long long a[4] = {1, 0, 0, 0};
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '?'){
      a[3] = (a[2] + a[3] * 3) % P;
      a[2] = (a[1] + a[2] * 3) % P;
      a[1] = (a[0] + a[1] * 3) % P;
      a[0] = a[0] * 3 % P; 
    }else if(s[i] == 'A'){
      a[1] = (a[1] + a[0]) % P;
    }else if(s[i] == 'B'){
      a[2] = (a[2] + a[1]) % P;
    }else if(s[i] == 'C'){
      a[3] = (a[3] + a[2]) % P;
    }
  }
  cout << a[3] << endl;
}

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

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

    for(int i=0; i<a; i++)
    {
        if(s[i] == s[b-1])
        cout << s[i] ;
        else 
        cout << "*" ;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;

    if((s[2]==s[3]) && (s[4]==s[5])) {cout<<"Yes"<<endl;}

    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
import math
n = int(input())
b = 0
c = math.ceil(n/2)
e = math.factorial(n)
s = []
for i in range(n):
    a = list(map(int,input().split()))
    s.append(a)
ans = 0
for l in range(n):
    for m in range(l+1,n):
        ans += ((s[l][0]-s[m][0])**2 + (s[l][1] - s[m][1])**2)**0.5
    b += 1
print(ans*2 / n)

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

int S[1000000], cnt = 0;

int sor(int n, int g){
	do{
		g = (g - 1) / 3;
		for(int i = g;i < n;i++){
			int j = i - g, v = S[i];
			while(j >= 0 && v < S[j]){
				S[j + g] = S[j];
				j -= g, cnt++;
			}
			S[j + g] = v;
		}
	}while(g != 1);
	return 0;
}

int main(){
	int g = 1, n, num = 0;
	scanf("%d", &n);
	for(int i= 0;i < n;i++)scanf("%d", &S[i]);
	while(g <= n)g = g * 3 + 1, num++;
	printf("%d\n", num);
	for(int i= g;i != 1;){
		if(i != g)printf(" ");
		i = (i - 1) / 3;
		printf("%d", i);
	}
	puts("");sor(n, g);
	printf("%d\n", cnt);
	for(int i= 0;i < n;i++)printf("%d\n", S[i]);
	
	return 0;
}

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

int main(){
    int a[4];
    for(int i=0;i<4;i++){
        cin>>a[i];
    }
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)cout << "YES" <<endl;
    else cout << "NO" <<endl;
    return 0;
}

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    string A[50], B[50];
    for (int i = 0; i < N; i++)
        cin >> A[i];

    for (int i = 0; i < M; i++)
        cin >> B[i];

    for (int i = 0; i + M <= N; i++) {
        for (int j = 0; j + M <= N; j++) {
            bool flag = true;
            for (int k = 0; k < M; k++) {
                if (A[i + k].substr(j, M) != B[k]) {
                    flag = false;
                }
            }
            if (flag) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  for(int i = 0; i < n; i = i + 2){
    cout << s[i];
  }
  cout << "\n";
}

Measured memory_bytes: 3720
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := IOInitialize()
	A := Int(s)
	B := Int(s)
	C := Int(s)
	if A+B >= C {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

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

int main(void){
  bool flag = true;
  string s, t;
  int table[26], cnt[26] = {};
  cin >> s >> t;
  for (int i = 0; i < 26; i++)
    table[i] = -1;
  table[t[0] - 'a'] = s[0] - 'a';
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == s[i - 1] && t[i] == t[i - 1])
      continue;
    else if (s[i] != s[i - 1] && t[i] != t[i - 1]) {
      if (table[t[i] - 'a'] == s[i] - 'a')
        continue;
      else if (table[t[i] - 'a'] == -1) {
        table[t[i] - 'a'] = s[i] - 'a';
        cnt[s[i] - 'a']++;
      }
      else flag = false;
    }
    else
      flag = false;
  }
  for (int i = 0; i < 26; i++)
    if (cnt[i] > 1)
      flag = false;
  
  cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int A,B,M;
    cin >> A >> B >> M;
    //
    vector<int> a(A);
    for(int i=0;i<A;i++){
        cin >> a[i];
    }
    //
    vector<int> b(B);
    for(int i=0;i<B;i++){
        cin >> b[i];
    }
    //
    vector<int> x(M);
    vector<int> y(M);
    vector<int> c(M);
    for(int i=0;i<M;i++){
        cin >> x[i] >> y[i] >> c[i] ;
    }
    //
    ll price;
    ll min_price;
    for(int i=0;i<M;i++){
        price = a[x[i]-1] + b[y[i]-1] - c[i];
        if(i==0){
            min_price = price;
        }
        else if(min_price > price){
            min_price = price;
        }
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    price = a[0] + b[0];
    if(min_price > price){
        min_price = price;
    }
    cout << min_price << endl;
}

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

int main()
{
    int total, min;
    cin >> total;
    min = total;
    for (int i = 1; i < total; i++)
    {
        int sub = total - i;
        string a = to_string(i);
        string b = to_string(sub);

        int a1 = 0, b1 = 0;
        for (int i = 0; i < a.size(); i++)
            a1 += a[i] - '0';
        for (int i = 0; i < b.size(); i++)
            b1 += b[i] - '0';
        
        min = std::min(min, a1+b1);
    }
    
    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256