akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int selectionSort(int A[], int N){
    int i, j, t, minj, sw;
    sw = 0;
    minj =0;
    for (i = 0; i < N; i++){
        minj = i;
        for (j = i + 1; j < N; j++){
            if (A[j] < A[minj]) minj = j;
        }
        t = A[i], A[i] = A[minj], A[minj] = t;
        
        if (i != minj) sw++;
    }
    
    return sw;
}


int main() {
    int A[100], N, i, sw;
    scanf("%d", &N);
    for (i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    
    sw = selectionSort(A, N);
    
    for (i = 0; i < N; i++){
        if (i > 0) printf("%s", " ");
        printf ("%d", A[i]);
    }
    
    printf("\n");
    printf("%d\n", sw);
    
    return 0;
}

Measured memory_bytes: 604
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();

    rep(i,N) {
        S[i] = 'x';
    }

    cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LIM 1+2+4+8+16+32+64+128
using namespace std;
typedef long long int ll;
int main(){
  int n,d;
  cin>>n>>d;
  int zh[n][d];
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>zh[i][j];
    }
  }
  int n2[1000];
  for(int i=1;i<1000;i++){
    n2[i]=i*i;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int nn=0;
      for(int l=0;l<d;l++){
	nn+=abs(zh[i][l]-zh[j][l])*abs(zh[i][l]-zh[j][l]);
      }
      for(int q=1;q<=1000;q++){
	if(n2[q]==nn){
	  ans++;
	  break;
	}else if(n2[q]>nn){
	  break;
	}
      }
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e9 + 5)
#define MAXL ((ll)3e18 + 7)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define NN ((int)3e6 + 7)
#define N ((int)1e5 + 5)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define RIG ((idx<<1)|1)
#define LEF (idx<<1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < int,  null_type,  less < int >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).

int arr[N];


int main()
{
    fastio;
    int n ;
    cin>>n;
    for(int i = 1 ; i<=n ; i++){
        cin>>arr[i];
    }
    ll ans = 0;
    for(int i = 1 ; i<=n ; i++){
        ans += arr[i]/2;
        if(arr[i+1]>0 && (arr[i]&1)){
            arr[i+1]--;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import kotlin.math.max

fun main(args: Array<String>) {
    val n = readInt()
    val s = readString()

    var ans = 0
    for (i in 1 until n) {
        val l = s.subSequence(0, i).toList()
        val r = s.subSequence(i, n).toList()
        val size = l.intersect(r).size
        ans = max(ans, size)
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()

Measured memory_bytes: 38192
//arc058_c.cpp
//Wed Jul 25 22:16:36 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INF 100000000
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[10];
	fill(a,a+10,1);
	for (int i=0;i<k;i++){
		int temp;
		cin >> temp;
		a[temp] = 0;
	}

	while (true){
		vector<int> digit;
		int tempn = n;
		int nflag = 1;
		while (tempn>=1){
			int temp = tempn%10;
			if (a[temp] == 0){
				nflag = 0;
				break;
			}
			tempn = (tempn-temp)/10;
		}

		if (nflag == 1){
			cout << n << endl;
			break;
		}else{
			n++;
		}
	}
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  char c;cin>>c;

  char t='a';

  while(1){
    if(t==c){
      t++;
      cout<<t<<endl;
      return 0;
    }
    t++;
  }

  
  return 0;
}


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

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

    switch (N%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
             cout << "pon" << endl;
            break;
        default:
            cout << "bon" << endl;

    }
    return 0;

}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;

typedef tuple<string, int, int> TUP;

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

int main()
{
    int x1,x2,x3,x4,x5;
    cin >> x1>> x2>> x3>> x4>> x5;
    if(x1 == 0){
        cout << 1 << endl;
    }
    if (x2 == 0)
    {
        cout << 2 << endl;
    }
    if (x3 == 0)
    {
        cout << 3 << endl;
    }
    if (x4 == 0)
    {
        cout << 4 << endl;
    }
    if (x5 == 0)
    {
        cout << 5 << endl;
    }
}


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

using namespace std;

long long a1, a2, a3, a4, a[15];
string s;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> a1 >> a2 >> a3 >> a4;
    a[a1] = 1;
    a[a2] = 1;
    a[a3] = 1;
    a[a4] = 1;

    if(a[1] && a[9] && a[7] && a[4]) cout << "YES";
    else cout << "NO";
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define reg register
using namespace std;
string s[105];
ll n,l;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>l;
    for(reg int i=1;i<=n;i++)cin>>s[i];
    sort(s+1,s+n+1);
    for(reg int i=1;i<=n;i++)cout<<s[i];
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i)
  {
    cin >> A[i];
  }

  long long res = 0;
  for (int d = 0; d < 60; ++d)
  {
    long long n0 = 0, n1 = 0;
    for (int i = 0; i < N; ++i)
    {
      if ((A[i] >> d) & 1)
        ++n1; // d 桁目が 1
      else
        ++n0; // d 桁目が 0
    }
    long long tmp = (1ll << d) % mod; // 2^d
    // B の要素 (xor 演算を施した数) で d 桁目が 1 である個数
    long long n = n0 * n1 % mod;
    // B の要素 (xor 演算を施した数) の d 桁目の総和 (= 2^d * n0 * n1)
    tmp = tmp * n % mod;
    res = (res + tmp) % mod;
  }
  cout << res << endl;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;


const ll mod = (ll)1e9 + 7;
const ll mxN = 1000003;

ll mm =1e18;
void solve() {
	ll n;cin>>n;
	vll A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	sort(all(A));
	for(int i=0;i<n;i++)
		if(A[i]==0)
		{cout<<0<<"\n";return;}
	ll ans=1;
	bool ok = true;
	for(int i=0;i<n;i++){
		if(ans>mm/A[i]) {
			ok=false;
		}
		else ans*=A[i];
	}
	if(ok) cout<<ans<<"\n";
	else cout<<-1<<"\n";


}





int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


Measured memory_bytes: 3980
N, A, B, C = list(map(int, input().split()))
L = [int(input()) for _ in range(N)]


def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) == 0:  # もし使われない竹があったら,最大のコストを返す
            return float('INF')
        # 最終的に出来上がった三本の竹のコストはどうか
        return sum([abs(_ - __) for _, __ in zip([a, b, c], [A, B, C])])
    sub_cost_A = dfs(cur+1, a+L[cur], b, c) + 10
    sub_cost_B = dfs(cur+1, a, b+L[cur], c)+10
    sub_cost_C = dfs(cur+1, a, b, c+L[cur])+10
    sub_cost_X = dfs(cur + 1, a, b, c)  # どのグループにも使わない
    return min(sub_cost_A, sub_cost_B, sub_cost_C, sub_cost_X)


print(dfs(0, 0, 0, 0)-30)  # a,b,cについて0に連結して＋10のコストをそれぞれ1回受けているので−30して帳尻合わせ


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


	#define int long long 

	const int N = 2e5 + 7, mod = 998244353;


	int f[N], xx[N], yy[N], fact[N], pwr[N], ff[N];


	int pow(int a, int b, int mod, int r = 1) {
		for(int i = b; i; i >>= 1, a = (1LL * a * a) % mod) if(i & 1) r = (1LL * r * a) % mod;
		return r;
	}

	int get(int n, int y) {
		int x = fact[n] * pow(fact[n - 2 * y], mod - 2, mod) % mod;
		x = x * pow(pwr[y], mod - 2, mod) % mod;
		return x * pow(fact[y], mod - 2, mod) % mod;
	}


	vector <int> PWR(int x) {
		vector <int> v(x + 1, 0), res(1, 1);
		v[0] = 1;
		for(int j = 1; j * 2 <= x; j++) {
			v[j * 2] = get(x, j);
		}

		for(int i = ff[x]; i > 0; i >>= 1, v = atcoder ::convolution <mod>(v, v)) if(i & 1) {
			res = atcoder::convolution<mod>(res, v);
		}
		return res;
	}

	int32_t main() {
		ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
		int n; cin >> n;
		fact[0] = pwr[0] = 1;
		for(int i = 1; i <= 2 * n; i++) {
			int x; cin >> x;
			f[x]++;
			fact[i] = (fact[i - 1] * i) % mod;
			pwr[i] = (pwr[i - 1] * 2) % mod;
		}

		for(int i = 1; i < N; i++) ff[f[i]]++;

		vector <int> res(1, 1);

		for(int i = 0; i < N; i++) if(ff[i]) {
			res = atcoder :: convolution<mod>(res, PWR(i));
		}

		int ans = get(2 * n, n); 

		for(int i = 1; i <= n; i++) {
			int lft = 2 * n - 2 * i;
			int kk = res[2 * i] * get(lft, lft / 2) % mod;
			if(i & 1) ans = (ans + mod - kk) % mod;
			else ans = (ans + kk) % mod;
		}

		cout << ans << endl;
	}


Measured memory_bytes: 9868
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b=0;
    cin>>a;
    vector<long long>v;
    set<long long>st;


    for(int i=0;i<a;i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }


    for(int i=0;i<a;i++)
    {
        st.insert(v[i]);
    }



    if(st.size()!=v.size())
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }






    return 0;
}


Measured memory_bytes: 11248
a, b = map(int, input().split())
ans = 0

if a > b:
    ans += a
    a -= 1
    if a > b:
        ans += a
    else: ans += b
    
elif a <= b:
    ans += b
    b -= 1
    if a > b:
        ans += a
    else: ans += b

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > a;
 
int foo(int i, int m,vector<vector<int> > &dp){
 
       
      if(i>=a.size()) return 0;     
     
      int x = INT_MIN;
      if(dp[i][m]!=-1) return dp[i][m];
      for(int j=0;j<3;j++){
          if(j!=m || (i==0 &&m==0)){
              int y = foo(i+1,j,dp);
              // dp[i][j]=y;
            x = max(y+a[i][j],x);  
            // dp[i][m]=x;  
          }
      }
 
      dp[i][m]=x;
            
      return x;
 
}
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int n, k;
    cin>>n;
    
    int x;
    vector<int> v;
    vector< vector<int> > dp(n,vector<int>(3,-1));
    for(int i=0;i<n;i++){
 
        for(int j=0;j<3;j++){
            cin>>x;
            v.push_back(x);
 
        }
        a.push_back(v);
        v.clear();
       
    }
 
    if(n==1){
      cout<<max(a[0][0],max(a[0][1],a[0][2]))<<"\n";
    }
    else
    cout<<foo(0,0,dp)<<"\n";
 
 
    // for(int i=0;i<n;i++)
    // {
    //   for(int j=0;j<3;j++)
    //     cout<<dp[i][j]<<" ";
 
    //   cout<<"\n";
    // }
 
}

Measured memory_bytes: 19504
import * as fs from 'fs'
function main(input: string) {
  const lines = input.split('\n')

  const [a, b, c] = lines[0].split(' ').map(Number)
  // console.log({ a, b, c })

  console.log(Math.max(0, c - (a - b)))
}

const path = process.argv[2]
if (!path) {
  main(fs.readFileSync('/dev/stdin', 'utf8'))
} else {
  const testPath = `${path}/tests`
  const files = fs.readdirSync(`${path}/tests`)
  const qn = files.length / 2
  for (let i = 1; i <= qn; i++) {
    console.log(`${testPath}/sample-${i}.in`)
    console.log('-- res')
    main(fs.readFileSync(`${testPath}/sample-${i}.in`, 'utf8'))
    console.log('-- expected')
    console.log(fs.readFileSync(`${testPath}/sample-${i}.out`, 'utf8'))
  }
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
const int mod = 1'000'000'007;
int mul(long long a, long long b){
	return a * b % mod;
}
int f(int x){
	int r = 0;
	while(x) x /= 10, r++;
	return r;
}
int pw(int a, int b){
	int r = 1;
	for(; b; b >>= 1, a = mul(a, a)) if(b&1) r = mul(r, a);
	return r;
}
const int maxn = 30'000'000;
char ff[maxn];
int main(){
	int s; cin >> s;
	int ans = 0;
	ff[0] = 0;
	for(int i = 1; i < maxn; i++) ff[i] = ff[i / 10] + 1;
	for(int i = 1, j = 1, sum = 0; ff[i] <= 7; i++){
		while(sum < s) sum += ff[j++];
		if(sum == s){
			ans++;
			if(ans >= mod) ans -= mod;
		}
		sum -= ff[i];
	}
	for(int i = 1; i <= s/8; i++){
		ans++;
		if(ans >= mod) ans -= mod;
		if(s % i == 0){
			ans += pw(10, s / i); if(ans >= mod) ans -= mod;
			ans += mod - pw(10, s / i - 1); if(ans >= mod) ans -= mod;
			ans += mod - i; if(ans >= mod) ans -= mod;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 29696
n, x, y = map(int, input().split())
x -= 1
y -= 1
ans_l = [0]*n
for i in range(n):
    for j in range(i, n):
        k = min(abs(j-i), abs(x-i)+1+abs(y-j), abs(x-j)+1+abs(y-i))
        ans_l[k] += 1
for ans in ans_l[1:]:
    print(ans)

Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m;
int a[100010],b[100010],cnt[100010];
int main(){
	scanf("%d%d",&n,&m);
	int i,j;
	for(i=1;i<=m;++i){
		scanf("%d%d",&a[i],&b[i]);cnt[a[i]]++;cnt[b[i]]++;
	}
	for(i=1;i<=n;++i){
		if(cnt[i]%2!=0){
			printf("NO\n");return 0;
		}
	}
	printf("YES\n");return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
struct Point
{
	ll x,y;
}p[1005];
int n,m,d[105];
void solve(Point p,ll d)
{
	if(abs(p.x-d)+abs(p.y)<=d-1)p.x-=d,putchar('R');
	else if(abs(p.x+d)+abs(p.y)<=d-1)p.x+=d,putchar('L');
	else if(abs(p.x)+abs(p.y-d)<=d-1)p.y-=d,putchar('U');
	else if(abs(p.x)+abs(p.y+d)<=d-1)p.y+=d,putchar('D');
	if(d>1)solve(p,d/2);
}
int main()
{
	scanf("%d",&n);
	ll x=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&p[i].x,&p[i].y);
		if(((p[i].x+p[i].y)&1)!=((p[1].x+p[1].y)&1))return puts("-1"),0;
		x=max(x,abs(p[i].x)+abs(p[i].y));
	}
	bool flag=((p[1].x+p[1].y)%2==0);
	while((1ll<<m)<=x)m++;
	m++;
	if(flag)printf("%d\n1 ",m+1);
	else printf("%d\n",m);
	for(int i=m-1;i>=0;i--)printf("%lld ",1ll<<i);
	printf("\n");
	for(int i=1;i<=n;i++)
	{
		if(flag)putchar('R'),p[i].x--;
		solve(p[i],1ll<<(m-1));
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "5 2", "5 3 1 4 2", "1 3", "5 4" ].solve == 2 );
	assert( [ "3 2", "3 2 1", "1 2", "2 3" ].solve == 3 );
	assert( [ "10 8", "5 3 6 8 7 10 9 1 2 4", "3 1", "4 1", "5 9", "2 5", "6 5", "3 5", "8 9", "7 9" ].solve == 8 );
	assert( [ "5 1", "1 2 3 4 5", "1 5" ].solve == 5 );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	ps[] -= 1;
	auto xys = new long[ 2 ][ m ];
	foreach( ref xy; xys )
	{
		input.popFront;
		xy = input.front.split.to!( long[] );
		xy[] -= 1;
	}
	
	auto uft = UnionFindTree( n );
	foreach( xy; xys )
	{
		uft.unite( xy[ 0 ], xy[ 1 ] );
	}
	
	auto ans = 0L;
	foreach( i, p; ps )
	{
		if( uft.same( i, p ) ) ans++;
	}
	return ans;
}

// UnionFind木
struct UnionFindTree
{
	long[] ps;
	long[] rs;
	
	this( long n )
	{
		ps.length = n;
		ps[] = -1;
		rs.length = n;
	}
	
	long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	auto same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	void unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( rs[ i ] < rs[ j ] )
		{
			ps[ j ] += ps[ i ];
			ps[ i ] = j;
		}
		else
		{
			ps[ i ] += ps[ j ];
			ps[ j ] = i;
			if( rs[ i ] == rs[ j ] ) rs[ i ]++;
		}
	}
	
	auto toString()
	{
		return ps.to!( string );
	}
}


Measured memory_bytes: 12640
N, M = gets.split(' ').map(&:to_i)
x_list = gets.split(' ').take(M).map(&:to_i).sort
diff_list = Array.new(M + 10, 0)
(0...(M - 1)).each do |i|
  diff_list[i] = (x_list[i] - x_list[i + 1]).abs
end
diff_list.sort_by! { |n| -n }
puts diff_list.drop(N - 1).reduce(0) { |acc, n| acc + n }


Measured memory_bytes: 12656
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static long[] a,b,c;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		a = new long[n];
		b = new long[n];
		c = new long[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i++) {
			b[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i++) {
			c[i] = sc.nextLong();
		}
		Arrays.sort(a);

		Arrays.sort(c);
		long count = 0;
		for(int i = 0 ; i < n ; i++) {
			long b2 = b[i];
			int right = n; //使用値 + 1
			int left = -1;
			while(right - left > 1) {
	            // mid
	            int mid = (left + right) / 2;
	            if(a[mid] >= b2) { //判定
	            	right = mid;
	            }
	            else {
	            	left = mid;
	            }
	        }
			long count_a = left + 1;  //必ずLeft
			right = n;
			left = -1;
			while (right - left > 1) {
	            // mid
	            int mid = (right + left) / 2;
	            if(c[mid] <= b2) {
	            	left = mid;
	            }
	            else {
	            	right = mid;
	            	}
	        }
			long count_c = n - (left + 1);
			count += count_a * count_c;
		}

		sc.close();
		System.out.println(count);

	}
}



Measured memory_bytes: 66544
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct xyz {
    int x;
    int y;
    int z;
};

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<xyz> v(m);
    for(int i = 0; i < m; i++) {
        cin >> v[i].x >> v[i].y >> v[i].z;
    }
    
    vector<vector<int>> list(n);
    for(int i = 0; i < m; i++) {
        list[v[i].x - 1].push_back(v[i].y);
        list[v[i].y - 1].push_back(v[i].x);
    }
    
    bool flag[n];
    for(int i = 0; i < n; i++) {
        flag[i] = false;
    }
    
    queue<int> que;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(!flag[i - 1]) {
            que.push(i);
            flag[i - 1] = true;
            ans++;
        }
        
        while(!que.empty()) {
            int now = que.front();
            que.pop();
            
            for(int j = 0; j < list[now - 1].size(); j++) {
                if(!flag[list[now - 1][j] - 1]) {
                    flag[list[now - 1][j] - 1] = true;
                    que.push(list[now - 1][j]);
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7800
#include <iostream>
#include <queue>

using namespace std;

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

struct dat {
	int x, y, t;
	dat(int x, int y, int t) :x(x), y(y), t(t) {}
};

int main() {
	int t, n;
	while (cin >> t >> n, t) {
		bool G[120][120] = {};
		int x, y;
		while (n--) {
			cin >> x >> y;
			G[x + 60][y + 60] = true;
		}
		int ans = 0;
		queue<dat> q;
		cin >> x >> y;
		G[x + 60][y + 60] = true;
		q.push(dat(x + 60, y + 60, 0));
		while (!q.empty()) {
			auto now = q.front(); q.pop();
			if (now.t > t) break;
			ans++;
			for (int i = 0; i < 6; ++i) {
				int nx = now.x + dx[i], ny = now.y + dy[i];
				if (G[nx][ny]) continue;
				G[nx][ny] = true;
				q.push(dat(nx, ny, now.t + 1));
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3152
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

int sort(const void *a, const void *b){
  ll x = *(ll *)a, y = *(ll *)b;
  if(x > y) return -1;
  if(x < y) return  1;
  return 0;
}

ll comb(ll n, ll a){
  if(a == 0) return 1;
  return (n * comb(n - 1, a - 1)) / a;
}

int
main(int argc, char *argv[])
{
  int n, a, b; ll v[50];
  scanf("%d %d %d", &n, &a, &b);
  rep(i, n) scanf("%lld", &v[i]);

  qsort(v, n, sizeof(ll), sort);

  int k = 0, l = 0;
  while(v[a - 1 - k] == v[a - 1] && a - 1 - k >= 0) k++;
  while(v[a - 1 + l] == v[a - 1] && a - 1 + l < n) l++;

  // printf("%d %d", k, l);
  k--; l--;
  ll ans = 0;
  for(int i = 0; i < a; i++) ans += v[i];
  printf("%f\n", (double)ans / (double)a);
  
  if(a - 1 - k == 0){
    ll cnt = 0;
    b = Min(b, a + l);
    for(int i = a; i <= b; i++) cnt += comb((ll)(a + l), (ll)i);
    printf("%lld\n", cnt);
  } else {
    printf("%lld\n", comb((ll)(k + l + 1), (ll)(k + 1)));
  }

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
int w[1<<15];
double dp[1<<15][15];
vector<int> path[1<<15][15];
int main() {
	int n,id[15],dist[15],value[15];
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d %d %d",&id[i],&dist[i],&value[i]);
	}
	for(int i=0;i<(1<<n);i++) {
		int sum=0,cnt=0;
		for(int j=1;j<(1<<n);j<<=1,cnt++) {
			if(i&j) sum+=value[cnt];
		}
		w[i]=sum*20;
	}
	fill((double*)dp,(double*)(dp+(1<<15)),1e100);
	for(int i=0;i<n;i++) {
		dp[1<<i][i]=0;
		path[1<<i][i].push_back(i);
	}
	for(int i=0;i<(1<<n);i++) {
		double v=2000/(70.0+w[i]);
		for(int j=0;j<n;j++) {
			if((i&(1<<j))==0) continue;
			for(int k=0;k<n;k++) {
				if(i&(1<<k)) continue;
				double cost=abs(dist[j]-dist[k])/v;
				if(dp[i|(1<<k)][k]>dp[i][j]+cost) {
					dp[i|(1<<k)][k]=dp[i][j]+cost;
					path[i|(1<<k)][k]=path[i][j];
					path[i|(1<<k)][k].push_back(k);
				}
			}
		}
	}
	double min_t=1e100;
	vector<int> ans;
	for(int i=0;i<n;i++) {
		if(min_t>dp[(1<<n)-1][i]) {
			min_t=dp[(1<<n)-1][i];
			ans=path[(1<<n)-1][i];
		}
	}
	for(int i=0;i<ans.size()-1;i++) {
		printf("%d ",id[ans[i]]);
	}
	printf("%d\n",id[ans[ans.size()-1]]);
}

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

void solve1()
{
	ll n, mx = 0;
	cin >> n;
	ll ar[n];
	for(int i; i < n; i++)
		cin >> ar[i], mx = max(mx, ar[i]);
	ll s = 0, t = INT_MAX;
	for(int k = 1; k <= 100; k++){
		s = 0;
		for(int i = 0; i < n; i++){
			s += pow(ar[i] - k, 2);
		}
		t = min(t, s);
	}
	cout << t;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
 
int cnt[26];
char s[1000][1000];
 
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 0 ; i < n; i++)
        scanf("%s", s[i]);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cnt[s[i][j] - 'a']++;
    bool flag = true;
    if((n % 2 == 0) && (m % 2 == 0)) {
        for(int i = 0; i < 26; i++) {
            if(cnt[i] % 4 != 0) {
                flag = false;
                break;
            }
        }
        puts(flag ? "Yes" : "No");
    }
 
    else if((n % 2 == 0) && (m % 2 != 0)) {
        int cur = 0;
        bool flag = true;
        for(int i = 0; i < 26; i++) {
            if(cnt[i] % 2 != 0) {
                flag = false;
                break;
            }
            if(cnt[i] % 4 != 0 && cnt[i] % 2 == 0)
                cur ++;
        }
        if(flag && cur <= n / 2)
            puts("Yes");
        else
            puts("No");
    }
    else if((n % 2 != 0) && (m % 2 == 0)) {
        int cur = 0;
        bool flag = true;
        for(int i = 0; i < 26; i++) {
            if(cnt[i] % 2 != 0) {
                flag = false;
                break;
            }
            if(cnt[i] % 4 != 0 && cnt[i] % 2 == 0)
                cur ++;
        }
        if(flag && cur <= m / 2)
            puts("Yes");
        else
            puts("No");
    }
    else {
        int center = 0;
        int cur = 0;
        for(int i = 0; i < 26; i++) {
            if(cnt[i] % 2 == 1) {
                center++;
            }
            else if (cnt[i]%4==2||cnt[i]%4==3)
                cur++;
        }
        if(cur<=n/2+m/2&&center<=1)
                printf("Yes");
            else
                printf("No");
    }
    return 0;
}


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

int main(){
    long long int N, other, min_num;
    cin >> N;
    min_num = LLONG_MAX; 

    for(long long int i=1;i*i<=N;i++){
        if(N%i == 0){
            other = N/i;
            if(min_num > i+other-2){
                min_num = i+other-2;
            }
        }
    }
    cout << min_num;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {

	for (int i = 0; i < 3000; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) break;
		if (a < b) {
			printf("%d %d\n", a, b);
		}
		else {
			printf("%d %d\n", b, a);
		}
	}

	return 0;
}


Measured memory_bytes: 2040
n=int(input())
s=str(input())
list1=[0]*(n+2)
list2=[0]*(n+2)
count1=0
count2=0
min=n
for i in range(1,n+1):
  if s[i-1]=='E':
    count1 += 1
  if s[i-1]=='W':
    count2 += 1
  list1[i] = count1
  list2[i] = count2
for i in range(1,n+1):
  sum=list2[i-1]+(list1[n]-list1[i])
  if sum < min:
    min=sum
print(min)

Measured memory_bytes: 17636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int main() {
    int n, m;
    cin >> n >> m;
    Graph g (n);
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        g[a].push_back (b);
        g[b].push_back (a);
    }
    //BFSを行う
    int color[n];
    rep (i, n) color[i] = -1;
    int now = 0;
    rep (i, n) {
        if (color[i] == -1) {
            queue<int> q;
            q.push (i);
            color[i] = now;
            while (!q.empty()) {
                int v = q.front();
                q.pop();
                for (auto p : g[v]) {
                    if (color[p] != -1) continue;
                    color[p] = now;
                    q.push (p);
                }
            }
            now++;
        }
    }
    int q;
    cin >> q;
    rep (i, q) {
        int s, t;
        cin >> s >> t;
        if (color[s] == color[t]) cout << "yes"
                                       << "\n";
        else
            cout << "no"
                 << "\n";
    }
}



Measured memory_bytes: 8612
import sys
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) < sum(B):
    print(-1)
    sys.exit()
V = []
Vp = V.append
_V = []
_Vp = _V.append
for i in range(N):
    d = A[i] - B[i]
    if d > 0:
        Vp(d)
    elif d < 0:
        _Vp(-d)
if len(_V) == 0:
    print(0)
    sys.exit()
V.sort()
_V.sort()
i = len(V) - 1
_i = len(_V) - 1
t = 0
res = 0
while _i >= 0:
    if t < 0:
        t += V[i]
        i -= 1
        res += 1
    else:
        t -= _V[_i]
        _i -= 1
        res += 1
print(res + int(t < 0))


Measured memory_bytes: 24156
def main():
    a , b ,k= map(int,input().split())
    temp = a - k
    if temp <= 0:
        b = b + temp
        if b <= 0:
            print(0,0)
        else:
            print(0, b)
    else:
        print(temp,b)


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
while(1):
    [n,m]=[int(x) for x in raw_input().split()]
    if n==0:
        break
    else:
        familymatrix=[[-100000 for x in range(n)] for y in range(n)]
        for i in range(n):
            familymatrix[i][i]=0
        namedic={}
        returned=[0 for x in range(n)]
        spacenum=0
        spacenumold=0
        for i in range(n):
            indata=raw_input()
            name=indata.strip()
            spacenum=len(indata)-len(name)
            namedic[name]=i
            for j in range(i):
                familymatrix[j][i]=familymatrix[j][i-1]+(spacenum-spacenumold)
                #if familymatrix[j][i]<0:
                #    familymatrix[j][i]=-1000000
                #if familymatrix[j][i]>0 and returned[j]:
                #    familymatrix[j][i]=-1000000
            spacenumold=spacenum
        for i in range(n):
            for j in range(i):
                if familymatrix[j][i]==0 and returned[j]==0:
                    returned[j]=1
                elif familymatrix[j][i]<0:
                    returned[j]=2
                if familymatrix[j][i]>0 and returned[j]==1:
                    familymatrix[j][i]=-1
                elif returned[j]==2:
                    familymatrix[j][i]=-1
        #for i in range(n):
        #    print familymatrix[i]
        for i in range(m):
            query=raw_input().split()
            X=namedic[query[0]]
            Y=namedic[query[-1][:-1]]
            question=' '.join(query[1:-1])
            if question == 'is a child of':
                print familymatrix[Y][X]==1
            elif question == 'is the parent of':
                print familymatrix[X][Y]==1
            elif question == 'is a sibling of':
                print (familymatrix[X][Y]==0) or (familymatrix[Y][X]==0)
            elif question == 'is a descendant of':
                print familymatrix[Y][X]>0
            elif question == 'is an ancestor of':
                print familymatrix[X][Y]>0
        print ''
        

Measured memory_bytes: 16716
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container;
import core.bitop, std.datetime;

void main(){
    auto N = readln.chomp.to!int;
    int ans = N * (N + 1) / 2;
    ans.writeln;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	string S;
	string S1;
	string S2;
	cin >> S;
	S1 = S;
	S2 = S;
	int answer1 = 0;
	int answer2 = 0;

		for(int j = 0; j < S1.size() - 1; j++)
		{
			if(S1.at(j) == S1.at(j + 1))
			{
				if(S1.at(j + 1) == '0')
				{
					S1.at(j + 1) = '1';
				}
				else
				{
					S1.at(j + 1) = '0';
				}
				answer1++;
			}
		}
	
	cout << answer1<< endl;

	return 0;
}

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

int main() {
  string str;
  int N;
  cin >> N >> str;
  
  int i,j;
  for(j=0;j<str.size();j++){
    for(i=0;i<N;i++){
      if(str.at(j)=='A')
        str.at(j)='B';
     else if(str.at(j)=='B')
        str.at(j)='C';
       else if(str.at(j)=='C')
        str.at(j)='D';        
       else if(str.at(j)=='D')
        str.at(j)='E';  
       else if(str.at(j)=='E')
        str.at(j)='F';  
       else if(str.at(j)=='F')
        str.at(j)='G';
      else  if(str.at(j)=='G')
        str.at(j)='H';
      else  if(str.at(j)=='H')
        str.at(j)='I';
      else  if(str.at(j)=='I')
        str.at(j)='J';
      else  if(str.at(j)=='J')
        str.at(j)='K';
      else  if(str.at(j)=='K')
        str.at(j)='L';
       else if(str.at(j)=='L')
        str.at(j)='M';
       else if(str.at(j)=='M')
        str.at(j)='N';
      else  if(str.at(j)=='N')
        str.at(j)='O';
      else  if(str.at(j)=='O')
        str.at(j)='P';
      else  if(str.at(j)=='P')
        str.at(j)='Q';
       else if(str.at(j)=='Q')
        str.at(j)='R';
      else  if(str.at(j)=='R')
        str.at(j)='S';
       else if(str.at(j)=='S')
        str.at(j)='T';
       else if(str.at(j)=='T')
        str.at(j)='U';
       else if(str.at(j)=='U')
        str.at(j)='V';
       else if(str.at(j)=='V')
        str.at(j)='W';
       else if(str.at(j)=='W')
        str.at(j)='X';
       else if(str.at(j)=='X')
        str.at(j)='Y';
       else if(str.at(j)=='Y')
        str.at(j)='Z';
       else if(str.at(j)=='Z')
        str.at(j)='A';
      
}
  }
  cout<<str<<endl;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

import fractions
import math

e = c*d//fractions.gcd(c,d)
x = b - b//c - b//d + b//e
y = (a-1) - (a-1)//c - (a-1)//d + (a-1)//e

print(x-y)


Measured memory_bytes: 5048
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static PrintWriter out;
static InputReader ir;
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
static void solve(){
 while(true){
  int n=ir.nextInt();
  if(n==0) return;
  int[] a=ir.nextIntArray(n);
  Arrays.sort(a);
  int total=0;
  for(int i=1;i<n-1;i++) total+=a[i];
  out.println((int)(total/(n-2)));
 }
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
 
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public BigDecimal nextBigDecimal(){return new BigDecimal(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 
 public long[] nextLongArray(int n){
  long[] a=new long[n];
  for(int i=0;i<n;i++) a[i]=nextLong();
  return a;
 }

 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 24056
h,w = (int(i) for i in input().split())
a = []
ans = []
ct = 0
for i in range(h):
  tmp = list(int(i) for i in input().split())
  a.append(tmp)
for i in range(h):
  if i%2 == 0: #右向き
   for j in range(w):
    if a[i][j]%2 == 1:
      if j != w-1:
       a[i][j+1] += 1
       ans.append([i+1,j+1,i+1,j+2])
      elif i+1 != h:
       a[i+1][j] += 1
       ans.append([i+1,j+1,i+2,j+1])
      else:
       break
  else:#左向き
    for j in range(w-1,-1,-1):
     if a[i][j]%2 == 1:
      if j != 0:
        a[i][j-1] += 1
        ans.append([i+1,j+1,i+1,j])
      elif i+1 != h:
       a[i+1][j] += 1
       ans.append([i+1,j+1,i+2,j+1])
      else:
        break
ct = len(ans)
print(ct)
for i in range(ct):
 print(*ans[i])

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,s;

void nhap()
{
    scanf("%d %d",&s,&n);
    for (int i=1;i<=n;++i)
    {
        int x;
        scanf("%d",&x);
        s-=x;
    }
    if (s<=0) cout<<"Yes";
    else cout<<"No";
}

int main()
{
    nhap();
    return 0;
}


Measured memory_bytes: 384
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
import static java.math.BigInteger.ONE;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	static final int MOD = 998244353;
	static final BigInteger BMOD = BigInteger.valueOf(MOD);

	static int add(int a, int b) {
		int res = a + b;
		return res >= MOD ? res - MOD : res;
	}

	static int sub(int a, int b) {
		int res = a - b;
		return res < 0 ? res + MOD : res;
	}

	static int mul(int a, int b) {
		int res = (int) ((long) a * b % MOD);
		return res < 0 ? res + MOD : res;
	}

	static void solve() throws Exception {
		int n = scanInt();
		BigInteger bigMod = ONE.shiftLeft(n).add(ONE), lim = new BigInteger(scanString(), 2).add(ONE);
		int ans = 0;
		List<Integer> divs = new ArrayList<>(), divCnts = new ArrayList<>();
		for (int i = 1; i <= 2 * n; i++) {
			if (2 * n % i != 0) {
				continue;
			}
			int cnt = lim.divide(bigMod.divide(ONE.shiftLeft(n % i).add(ONE).gcd(ONE.shiftLeft(i).subtract(ONE)))).mod(BMOD).intValue();
			for (int j = 0; j < divs.size(); j++) {
				if (i % divs.get(j) == 0) {
					cnt = sub(cnt, divCnts.get(j));
				}
			}
			divs.add(i);
			divCnts.add(cnt);
			ans = add(ans, mul(i, cnt));
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 53464
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	string s;
	cin >> s;
	if (s.back() == 's') s += "es";
	else s += 's';
	cout << s << endl;
	return 0;
}

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

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

  int n = s.size();

  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      if (s[i] == s[j]) {
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" << endl;
}





Measured memory_bytes: 256
#include <stdio.h>

#define WIDTH 6
#define HEIGHT 12

enum { YET, ALREADY };

int del( void );
int search( int, int );
int search_body( int, int, char );
void fall( void );

typedef struct {
	char color;
	int state;
} FIELD;

FIELD field[ WIDTH + 2 ][ HEIGHT + 2 ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int stack[ WIDTH * HEIGHT ], sp;

int main( void ) {
	int n, x, y, chain;

	for ( scanf( "%d", &n ); n--; printf( "%d\n", chain ) ) {
		for ( y = 1; y <= HEIGHT; y++ )
			for ( x = 1; x <= WIDTH; x++ ) {
				scanf( " %c", &field[ x ][ y ].color );
				field[ x ][ y ].state = YET;
			}

		for ( chain = 0; del(); fall(), chain++ ) ;
	}

	return 0;
}

int del( void ) {
	int x, y, del = 0;

	for ( y = 1; y <= HEIGHT; y++ )
		for ( x = 1; x <= WIDTH; x++ )
			if ( field[ x ][ y ].color != '.' && field[ x ][ y ].color != 'O' && field[ x ][ y ].state == YET ) {
				sp = 0;
				if ( search( x, y ) >= 4 ) {
					while ( sp-- )
						field[ stack[ sp ] / ( HEIGHT + 2 ) ][ stack[ sp ] % ( HEIGHT + 2 ) ].color = '.';

					del = 1;
				}
			}

	return del;
}

int search( int x, int y ) {
	return search_body( x, y, field[ x ][ y ].color );
}

int search_body( int x, int y, char color ) {
	int i, sum;

	stack[ sp++ ] = x * ( HEIGHT + 2 ) + y;
	field[ x ][ y ].state = ALREADY;

	sum = 0;
	for ( i = 4; i--;  ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( field[ nx ][ ny ].state == YET && ( field[ nx ][ ny ].color == color || field[ nx ][ ny ].color == 'O' ) )
			if ( field[ nx ][ ny ].color == 'O' )
				stack[ sp++ ] = nx * ( HEIGHT + 2 ) + ny;
			else
				sum += search_body( nx, ny, color );
	}

	return sum + 1;
}

void fall( void ) {
	int x, y;

	for ( x = 1; x <= WIDTH; x++ ) {
		int cnt = 0;

		for ( y = HEIGHT; y; y-- )
			if ( field[ x ][ y ].color == '.' )
				cnt++;
			else {
				field[ x ][ y + cnt ].color = field[ x ][ y ].color;
				field[ x ][ y + cnt ].state = YET;
			}

		for ( y = cnt; y; y-- )
			field[ x ][ y ].color = '.';
	}
}

Measured memory_bytes: 592
#include <iostream>
#include <cstring>

using namespace std;

int w, h, xs, ys, xg, yg, n;
int field[1024][1024];
bool vis[1024][1024];

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

void rec(int x, int y, int c){
	
	if( vis[y][x] || x <= 0 || w < x || y <= 0 || h < y || field[y][x] != c )
		return;
	
	vis[y][x] = true;
	
	rec(x+1, y, c);
	rec(x-1, y, c);
	rec(x, y+1, c);
	rec(x, y-1, c);
	
	return;
}

int main()
{
	while(cin >> w >> h, (w||h)){
	
		memset(field,0,sizeof(field));
		memset(vis,0,sizeof(vis));
		
		cin >> xs >> ys;
		cin >> xg >> yg;
		
		cin >> n;
		
		for(int k = 0; k < n; ++k){
			
			int c, d, x, y;
			
			cin >> c >> d >> x >> y;
			
			for(int i = 0; i < 8; ++i){
				
				field[y+dy[d][i]][x+dx[d][i]] = c;
			}
		}
		
		
		rec(xs,ys,field[ys][xs]);
		
		cout << (vis[yg][xg]?"OK":"NG") << endl;
	
	}
	
	return 0;
}

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

int main(){
    int n,cnt=0;string s;cin>>n>>s;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = input().split()

ans = 'No'
for i in range(n - 2):
    if (a[i] == b[i]) and (a[i + 1] == b[i + 1]) and (a[i + 2] == b[i + 2]):
        ans = 'Yes'

print(ans)


Measured memory_bytes: 62208
#ABC079C
ABCD=str(input())
op='+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans_str=ABCD[0]+op[i]+ABCD[1]+op[j]+ABCD[2]+op[k]+ABCD[3]
            ans=eval(ans_str)
            if ans==7:
                print(ans_str+'=7')
                exit()

Measured memory_bytes: 3060
m = 10**9+7
n,a,b = map(int,input().split())
def c(k):
  v = 1
  w = 1
  for i in range(k):
    v = v*(n-i)%m
    w = w*(i+1)%m
  return (v*pow(w,m-2,m)%m)
print((pow(2,n,m)-1-c(a)-c(b))%m)

Measured memory_bytes: 9052
#include <stdio.h>
#define INFTY 1000000001

typedef long long ll;

ll mergesort(int *,int,int);
ll merge(int *,int,int,int);
int main (){
  int n,i,A[500000];
  ll cnt;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  cnt=mergesort(A,0,i);
  printf("%lld\n",cnt);
  return 0;
}

ll mergesort(int *A,int left,int right){
  int mid;
  ll cnt=0;
  if(left+1<right){
    mid=(left+right)/2;
    cnt+=mergesort(A,left,mid);
    cnt+=mergesort(A,mid,right);
    cnt+=merge(A,left,mid,right);
  }
  return cnt;
}
ll merge(int *A,int left,int mid,int right){
  int n1,n2,i,j,k;
  ll cnt=0;
  n1=mid-left;
  n2=right-mid;
  int L[n1+1],R[n2+1];
  for(i=0;i<n1;i++)
    L[i]=A[left+i];
  for(i=0;i<n2;i++)
    R[i]=A[mid+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
      cnt+=(right-left)/2-i;
    }
  }
  return cnt;
}

    
  
  
   
  
    
  



Measured memory_bytes: 3352