akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

typedef long long ll;

const int N = 500;


int n, k, mod;

inline ll add( ll a, ll b ) { ll ret = a + b; if( ret >= mod ) ret -= mod; return ret; }

ll fac[N], inv_f[N], f[N][N], s[N][N], c[N][N];

inline ll C( ll n, ll m ) { 
    return c[n][m];
}

int main()
{
    memset( f, 0, sizeof( f ) );
    memset( s, 0, sizeof( s ) );

    scanf( "%d%d%d", &n, &k, &mod );
    
    for( int i = 0; i <= n; i ++ )
	{
    	c[i][0] = 1;
    	for( int j = 1; j <= i; j ++ )
    	    c[i][j] = add( c[i-1][j-1], c[i-1][j] );
    }

    for( int i = 0; i <= k; i ++ ) 
        f[1][i] = 1; 
    for( int i = 0; i <= k; i ++ )
        s[1][i] = !i ? f[1][i] : s[1][i-1] + f[1][i];  

    for( int i = 2; i <= n + 1; i ++ )
    // i : 现在的结点个数
        for( int j = 0; j <= k; j ++ )
        {
        // j : 现在根节点的 label 值
            for( int l = 1; l < i; l ++ )
            // l : ID=1 子树含有多少个结点
                f[i][j] = add( f[i][j], C( i-2, l-1 ) * f[i-l][j] % mod * add( s[l][k], mod - s[l][j] ) % mod ),
        
//        	printf( "%lld, %lld, %lld\n", C( i-2, l-1 ), f[i-l][j], add( s[l][k], mod - s[l][j] ) );
        
            s[i][j] = !j ? f[i][j] : add( s[i][j-1], f[i][j] );
//        	printf( "i:%d, j:%d, f:%lld, s:%lld\n", i, j, f[i][j], s[i][j] );
		}
		
    printf( "%lld\n", f[n+1][0] );

    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

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

    int a[200009]; rep(i,N) cin >> a[i];

    int ans[200009]; rep(i,N) ans[i] = 0;

    bool flag = true;
    int cnt;
    for (int i = N-1; i >= 0; i--)
    {
        cnt = 0;
        for (int j = i; j < N; j += i + 1) cnt += ans[j];
        if (cnt % 2 != a[i]) ans[i]++;
    }

    cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (ans[i] == 1) cnt++;
    }

    cout << cnt << endl;
    
    for (int i = 0; i < N; i++)
    {
        if (ans[i] == 1) cout << i + 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2432
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInts() (int,int) {
  var n,k int
  var s []string = strings.Split(NextLine()," ")
  n,_ = strconv.Atoi(s[0])
  k,_ = strconv.Atoi(s[1])
  return n,k
}
func NextIntIntMap() map[int]int {
  var s []string = strings.Split(NextLine()," ")
  var n,a int
  n = len(s)
  m := map[int]int{}
  for i:=0;i<n;i++ {
    a,_ = strconv.Atoi(s[i])
    if v,ok := m[a];ok {
      m[a] = v + 1
    } else {
      m[a] = 1
    }
  }
  return m
}

func main() {
  _,k := NextInts()
  a := NextIntIntMap()
  b := Entries{}
  for key,val := range a {
    e := Entry{key,val}
    b = append(b,e)
  }
  sort.Sort(b)
  var m int = 0
  for i:=0;i<b.Len()-k;i++ {
    m += b[i].val
  }
  fmt.Println(m)
}
type Entry struct {
  key int
  val int
}
type Entries []Entry
func(entries Entries) Len() int {
  return len(entries)
}
func(entries Entries) Swap(i,j int) {
  entries[i],entries[j] = entries[j],entries[i]
}
func(entries Entries) Less(i,j int) bool {
  if entries[i].val == entries[j].val {
    return entries[i].key < entries[j].key
  } else {
    return entries[i].val < entries[j].val
  }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N, K, R, S, P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    ll sum = 0;
    map<char,char> kachi;
    kachi['r'] = 'p'; kachi['s'] = 'r'; kachi['p'] = 's', kachi['*'] = '*';
    map<char,ll> score;
    score['r'] = R; score['s'] = S; score['p'] = P; score['*'] = 0;
    vector<vector<char>> U(N/K+2, vector<char>(K, '*')), V(N/K+2, vector<char>(K, '*'));
    
    REP(i,0,N) U[i/K][i%K] = T[i];
    REP(i,0,K) {
        V[0][i] = kachi[U[0][i]];
        sum += score[V[0][i]];
    }
    
    REP(i,1,N/K+1) {
        REP(j,0,K) {
            if(V[i-1][j] == kachi[U[i][j]]) V[i][j] = U[i+1][j];
            else {
                V[i][j] = kachi[U[i][j]];
                sum += score[V[i][j]];
            }
        }
    }
    PR(sum);
    
    return 0;
}

/*



*/

Measured memory_bytes: 11136
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

typedef long long ll;

int N, M;
ll K;
ll A[200000 + 10], B[200000 + 10];
ll csA[200000 + 10], csB[200000 + 10];

int main() {
	cin >> N >> M >> K;
	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 < N; i++)csA[i + 1] = csA[i] + A[i];
	for (int i = 0; i < M; i++)csB[i + 1] = csB[i] + B[i];

	ll ans = 0;
	for (int i = 0; i <= N; i++) {
		//まずAの本をi冊読む
		ll rest = K - csA[i];
		if (rest < 0)continue;
		if (rest == 0) {
			ans = i;
			continue;
		}

		ll idx = lower_bound(csB, csB + M + 1, rest + 1) - csB;
		
		if (idx == 0)idx++;
		ans = max(ans, i + idx - 1);

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

Measured memory_bytes: 9864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
using Tree = vector<pair<int, int>>;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    double bunbo = 0.0;
    for (int i = 0; i < n; i++)
    {
        bunbo += 1.0 / a[i];
    }
    double ans = 1.0 / bunbo;
    cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 256
//
// Created by kuroneko on 2019-07-06.
//

using namespace std;

#include <iostream>
#include <vector>

typedef long long ll;

int main() {
    int N; cin >> N;
    ll mask = 0;
    vector<pair<int, int> > g(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        g[i] = make_pair(b, a);
    }

    sort(g.begin(), g.end());

    int s_time = 0;
    int f_time = 0;
    for (int i = 0; i < N; i++) {
        f_time = g[i].first;
        s_time += g[i].second;

        if (s_time > f_time) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int g=0;
		if ( s.equals("RRR") )	g = 3 ;
		else if ( s.equals("RRS") || s.equals("SRR") )	g = 2 ;
		else if ( s.equals("SSS") )	g = 0;
		else g = 1 ;

		System.out.println(g);
	}
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
void maxUpdate(int& a, int b) { a = max(a, b); }

int n, m, a[55], b[55], c[55], dp[55][55][55];

int getMaxsatis(int i, int L1, int L2) {
	int res = c[i];
	for_(x,0,L1+1) for_(y,0,L2+1) {
		if (x + y == 0 || x + y > 8) continue;
		maxUpdate(res, a[i] * y + b[i] * x);
	}
	return res;
}

int main() {
	cin >> n >> m;
	for (int i=0; i<n; ++i) cin >> a[i] >> b[i] >> c[i];
	
	for_(i,0,n+1) for_(j,0,m+1) for_(k,0,m+1) dp[i][j][k]= -(1L << 30);
	
	dp[0][0][0] = 0;
	for_(i,0,n) for_(j,0,m+1) for_(k,0,m+1) {
		if (dp[i][j][k] == -(1L << 30)) continue;
		for_(x,0,m-j-k+1) maxUpdate(dp[i+1][j+k][x], dp[i][j][k] + getMaxsatis(i, k, x));
	}
	
	int ans = -(1L << 30);
	for_(j,0,m+1) for_(k,0,m+1) maxUpdate(ans, dp[n][j][k]);
	cout << ans << endl;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] sa = Input();
		int[] b = new int [n-1];
		int[] a = new int[n];
		for(int i = 0; i < n; i++)
			a[i]=-1;
		for(int i = 0; i < n-1; i++)
		{
			b[i] = int.Parse(sa[i]);
		}
		long wa = 0;
		for(int i = 0; i < n; i++)
		{
			if(i==0) {
				a[i] = b[i];
			}
			else if(i<n-1)
			{
				a[i] = Math.Min(b[i-1], b[i]);
			}
			else
			{
				a[i] = b[i-1];
			}
			
			//Console.Write("{0} ",a[i] );
			wa+=a[i];
		
		}
		Console.WriteLine(wa);
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    vvi c(3,vi(3));
    REP(i,3){
        REP(j,3){
            int x;
            cin>>x;
            c[i][j]=x;
        }
    }
    bool flag=true;
    if(c[0][0]-c[0][1]!=c[1][0]-c[1][1])flag=false;
    if(c[1][0]-c[1][1]!=c[2][0]-c[2][1])flag=false;
    if(c[0][1]-c[0][2]!=c[1][1]-c[1][2])flag=false;
    if(c[1][1]-c[1][2]!=c[2][1]-c[2][2])flag=false;

    if(c[0][0]-c[1][0]!=c[0][1]-c[1][1])flag=false;
    if(c[0][1]-c[1][1]!=c[0][2]-c[1][2])flag=false;
    if(c[1][0]-c[2][0]!=c[1][1]-c[2][1])flag=false;
    if(c[1][1]-c[2][1]!=c[1][2]-c[2][2])flag=false;

    Yes(flag);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  vector<int> h(n);
  for(int i=0; i<n; ++i) cin>>h[i];
  vector<int> f(n,0);
  int cnt=0,left=0;
  while(left<n){
    while(f[left]==h[left]) ++left;
    for(int i=left; f[i]<h[i]&&i<n; ++i) ++f[i];
    ++cnt;
  }
  cout<<cnt-1<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void)
{
int a,b,c,d,x,y;
 scanf("%d%d%d%d",&a,&b,&c,&d);
if(a>c)
{x=a;}else{x=c;}
if(b>d){y=d;}else{y=b;}
x=y-x;
if(x>0){printf("%d",x);}
else{printf("0");}
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(void){
    int x=0,N,i,max;
    char S[110]={};
    scanf("%d",&N);
    scanf("%s",S);
    max = x;
    for(i=0;i<N;i++){
        if(S[i]=='I'){x++;}
        if(S[i]=='D'){x--;}
        if(x>max){max = x;}
    }
        printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
typedef long long ll;
const ll mod = 1e9+7;//998244353
int t = 1;
/*
int rooms,psgs;
vector<int> a[(int)1e5 + 3];
vector<int> p((int)1e5 + 3 , 0);
vector<bool> v((int)1e5 + 3, false);

void dfs(int cur) {
  vector<int>
  for(auto &i:a[cur]) {
    if(v[i])  continue;
    p[i] = cur;
    v[i]=true;
  }
}*/

void solve(int BYasD) {
  int n; cin>>n;
  long double p=1;
  rep(i,n) {
    ll x; cin>>x;
    if(p!=-1) p *= x;
    if(p>1e18) {
      p = -1;
    }
    if(x==0)  p=0;
  }
  cout<<(ll)p<<'\n';
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif
  //cin>>t;
  rep(i,t)  {
  //  cout<<"Case #"<<(i+1)<<'\n';
    solve(i);
    //cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	vector<int> v(n);
	vector<int> coor;
	REP(i,n) cin >> v[i];

	int head = v[0];
	coor.PB(0);
	FOR(i,1,n){
	    if(i % 2 == 0){
		if(head != v[i]){
		    coor.PB(i);
		    head = v[i];
		}
	    }else{
		if(head != v[i]){
		    if(coor.size() > 1)
			coor.erase(coor.end()-1);
		    head = v[i];
		}
	    }
	}
	/*
	cout << "==coord==" << endl;
	REP(i,coor.size()) cout << coor[i] << endl;
	cout << "==end==" << endl;
	*/
	int ans = 0;
	int s = n;
	RREP(i,coor.size()){
	    if(head % 2 == 0){
		ans += s - coor[i];
	    }
	    head = (head+1)%2;
	    s = coor[i];
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1532
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(200000)
H,W=map(int,input().split())
S=[input() for i in range(H)]
l=[[0]*(W+2) for i in range(H+2)]
for i in range(1,H+1):
    for j in range(1,W+1):
        l[i][j]=1
a,c=0,1
def nu(h,w):
    global c,b
    if S[h-1][w-1]=="#":
        b+=1
    if l[h-1][w] and S[h-1][w-1]!=S[h-2][w-1]:
        l[h-1][w]=0
        c+=1
        nu(h-1,w)
    if l[h+1][w] and S[h-1][w-1]!=S[h][w-1]:
        l[h+1][w]=0
        c+=1
        nu(h+1,w)
    if l[h][w-1] and S[h-1][w-1]!=S[h-1][w-2]:
        l[h][w-1]=0
        c+=1
        nu(h,w-1)
    if l[h][w+1] and S[h-1][w-1]!=S[h-1][w]:
        l[h][w+1]=0
        c+=1
        nu(h,w+1)
for i in range(1,H+1):
    for j in range(1,W+2):
        if not l[i][j]:
            continue
        b,c=0,1
        l[i][j]=0
        nu(i,j)
        a+=b*(c-b)
print(a)



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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  int N, M;
  scanf("%d%d", &N, &M);

  vector<map<int, vector<pii>>> E(N);
  rep(i, M) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    u--; v--;
    E[u][c].emplace_back(v, c);
    E[v][c].emplace_back(u, c);
    E[u][-1].emplace_back(v, c);
    E[v][-1].emplace_back(u, c);
  }

  rep(i, N) {
    vi cs;
    forr(cv, E[i]) if (cv.fst != -1) cs.push_back(cv.fst);
    forr(c, cs) E[i][c].emplace_back(i, -1);
  }

  vector<map<int, int>> D(N);

  deque<pii> q;
  D[0][-1] = 0;
  q.emplace_back(0, -1);

  while (!q.empty()) {
    int v, c;
    tie(v, c) = q.front(); q.pop_front();

    int cos = D[v][c];
    if (v == N-1) {
      _p("%d\n", cos);
      return;
    }

    for (auto&& edge : E[v][c]) {
      int ev, ec;
      tie(ev, ec) = edge;
      bool eq = c == ec || ec == -1;
      int nc = cos + (eq ? 0 : 1);
      int &nd = D[ev][ec];
      if (nd == 0 || nd > nc) {
        nd = nc;
        if (eq) q.emplace_front(ev, ec);
        else q.emplace_back(ev, ec);
      }
    }
  }
  puts("-1");
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 83456
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   // freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    
    int n;
    cin>>n;
    string a;
    cin>>a;
    int cr =0 ;
    for(int i=0;i<a.length();i++)
    {
        if(a[i]=='R')
            cr++;
    }
    if(cr>(n-cr))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_backa
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<P>p(n);
  rep(i,0,n)cin>>p[i].fi>>p[i].se;
  vector<ll>a(n);
  rep(i,0,n)a[i]=i;
  ld ret=0;
  do{
    ld sumbuf=0;
    rep(i,0,n-1){
      ld d1=p[a[i]].fi-p[a[i+1]].fi;
      ld d2=p[a[i]].se-p[a[i+1]].se;
      sumbuf+=sqrt(d1*d1+d2*d2);
    }
    ret+=sumbuf;
  }while(next_permutation(ALL(a)));
  rep(i,0,n)ret/=i+1;
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int a,b,c,n=0,i,m;
scanf("%d%d%d",&a,&b,&c);
for(i=a;i<=b;i++){
m=c/i;
if(c-m*i==0){
n++;
}
}
printf("%d\n",n);
return 0;
}

Measured memory_bytes: 596
/***********************************************
 *                   _ooOoo_                   *
 *                  o8888888o                  *
 *                  88" . "88                  *
 *                  (| -_- |)                  *
 *                  O\  =  /O                  *
 *               ____/`---'\____               *
 *             .'  \\|     |//  `.             *
 *            /  \\|||  :  |||//  \            *
 *           /  _||||| -:- |||||-  \           *
 *           |   | \\\  -   * |    |           *
 *           | \_|  ''\---/''  |   |           *
 *           \  .-\__  `-`  ___/-. /           *
 *         ___`. .'  /--.--\  `. . __          *
 *      ."" '<  `.___\_<|>_/___.'  >'"".       *
 *     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     *
 *     \  \ `-.   \_ __\ /__ _/   .-` /  /     *
 *======`-.____`-.___\_____/___.-`____.-'======*
 *                   `=---='                   *
 *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

             佛祖保佑       永无BUG

   本程序已经经过开光处理，绝无可能再产生bug
 **********************************************/
#include<algorithm>
#include <iostream>
#include  <cstdlib>
#include  <cstring>
#include   <string>
#include   <vector>
#include   <cstdio>
#include    <queue>
#include    <stack>
#include    <ctime>
#include    <cmath>
#include      <map>
#include      <set>
#define ll long long
#define INF 0x3f3f3f3f
#define db1(x) cout<<#x<<"="<<(x)<<endl
#define db2(x,y) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<endl
#define db3(x,y,z) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<endl
using namespace std;

int main(void)
{
    #ifdef test
    freopen("in.txt","r",stdin);
    //freopen("in.txt","w",stdout);
    clock_t start=clock();
    #endif //test

    char c;
    scanf("%c",&c);
    printf("%c",c+1);

    #ifdef test
    clockid_t end=clock();
    double endtime=(double)(end-start)/CLOCKS_PER_SEC;
    printf("\n\n\n\n\n");
    cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位
    cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位
    #endif //test
    return 0;
}


// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ????━????   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();++i){
        if('A'<=s[i]&&s[i]<='Z'){
            s[i]-='A'-'a';
        }
        else if('a'<=s[i]&&s[i]<='z'){
            s[i]+='A'-'a';
        }
    }
    cout<<s<<endl;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,sum,i=0;
  cin>>a>>b>>c;
  sum=a;
  if(b>=a*c){
    cout<<c<<"\n";
  }
  else{
    while(sum<=b){
      sum+=a;
      i++;
    }
    cout<<i<<"\n";
  }
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> alp(26,0);
    rep(i,n){
        string s;
        cin >> s;
        vector<int> now(26);
        rep(j,s.size()) now[s[j] - 'a']++;
        if(i == 0){
            rep(j,26)alp[j] = now[j];
        }
        else{
            rep(j,26) alp[j] = min(alp[j],now[j]);
        }
    }
    rep(i,26){
        cout << string(alp[i],i+'a');
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int h, m, s;
  int n = 3;
  while (n--) {
    cin >> h >> m >> s;
    int second1 = 60 * 60 * h + 60 * m + s;
    cin >> h >> m >> s;
    int second2 = 60 * 60 * h + 60 * m + s;

    int t = second2 - second1;

    h = t / (60 * 60);
    t %= 60 * 60;
    m = t / 60;
    t %= 60;
    s = t;

    cout << h << " " << m << " " << s << endl;
  }
}

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

from collections import deque

S = deque([])

def getNeighbor(A, i):
    a = len(A)
    for k in range(2, a):
        M[i][A[k]-1] = 1


def dfs(u):
    global t
    t = t + 1
    S.append(u)
    c[u] = 1
    d[u] = t

    for v in range(n):
        if M[u][v] and c[v] == 0:
            dfs(v)
    c[u] = 2
    t += 1
    f[u] = t


n = int(input())
#color
c = [0] * n
d = [0] * n
f = [0] * n

M = [[0] * n for _ in range(n)]
t = 0

for i in range(n):
    A = list(map(int, input().split()))
    getNeighbor(A,i)

for num in range(n):
    if d[num] == 0:
        dfs(num)

for i in range(n):
    print(str(i+1), str(d[i]), str(f[i]))










Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	int E=(C+B-1)/B;
	int F=(A+D-1)/D;
	if(E<=F){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  float ans_conc = 0.0f;
  int ans_total = 0;
  int ans_sugar = 0;

  for (int i = 0; (100 * a * i) <= f; i++) {     // A を i 杯
    if (100 * a * i > f) continue;
    for (int j = 0; (100 * b * j) <= f; j++) {   // B を j 杯
      int water = 100 * a * i + 100 * b * j;
      if (water > f) continue;
      int max_sugar = min(f - water, e * water / 100);
      for (int m = 0; (m * c) <= max_sugar; m++) {    // c を m 杯
        for (int n = 0; (n * d) <= max_sugar; n++) {  // d を n 杯
          int sugar = m * c + n * d;
          if (sugar > max_sugar) continue;
          float conc = float(sugar) / (water + sugar);
          if (conc >= ans_conc) {
            ans_conc = conc;
            ans_total = water + sugar;
            ans_sugar = sugar;
          }
        }
      }
    }
  }

  cout << ans_total << " " << ans_sugar << endl;

  return 0;
}


Measured memory_bytes: 256
R, C, K = map(int, input().split())
items = [[0]*C for _ in range(R)]

for i in range(K):
  r, c, v = map(int, input().split())
  items[r-1][c-1] = v

dp = [[0]*4 for _ in range(C)]

for x in range(1, 4):
  dp[0][x] = items[0][0]
  for j in range(1, C):
    dp[j][x] = max(dp[j-1][x-1] + items[0][j], dp[j-1][x])

#print(items)
#print(dp)

for i in range(1, R):
  for j in range(C):
    for x in range(4):
      dp[j][x] = dp[j][3]
  for x in range(1, 4):
    dp[0][x] += items[i][0]
    for j in range(1, C):
      dp[j][x] = max(dp[j-1][x-1] + items[i][j], dp[j-1][x], dp[j][3] + items[i][j])
  #print(dp)

print(dp[-1][-1])

Measured memory_bytes: 146636
A, B = map(int,input().split())

def euc(a,b):
    euc1 = max(a,b)
    euc2 = min(a,b)
    rem = euc1 % euc2#余り
    if rem == 0:
        return euc2
    else:
        return euc(euc2,rem)

print(int(A * B / euc(A,B)))

Measured memory_bytes: 2940
a,b,c,d = map(int,input().split())
if b <= c or d <= a:
    print(0)
elif a <= c <= b <= d :
    print(b-c)
elif c <= a <= d <= b:
    print(d-a)
elif a <= c <= d <= b:
    print(d-c)
elif c <= a <= b <= d:
    print(b-a)

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

int main(){
	int n ; cin >> n ;
	int cnt = 0 ;
	for(int i=1;i<=n;i+=2){
		int sub = 0 ;
		for(int j=1;j<=i;j++){
			if(i%j==0) sub++ ;
		}
		if(sub==8) cnt++ ;
	}
	cout << cnt << endl ;
}


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

int sw=0;
int bubbleSort(int n, int A[])
{
  bool flag=1;
  for(int i=0;flag;i++)
  {
    flag=0;
    for(int j=n-1;j>i;j--)
    {
      if(A[j]<A[j-1])
      {
        swap(A[j],A[j-1]);
        flag=1;
        sw++;
      }
    }
  }
}

int main()
{
  int n;
  int A[100];
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>A[i];
  }
  bubbleSort(n,A);
  for(int i=0;i<n;i++)
  {
    if(i>0) cout<<" ";
    cout << A[i];
  }
  cout<<endl<<sw<<endl;;
  return 0;
}


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

immutable inf = 10^^9 + 7;

void main() {
    int n;
    int[] t, v;

    scan(n);
    t = readln.split.to!(int[]);
    v = readln.split.to!(int[]);

    t[] *= 2;
    v[] *= 2;
    v ~= 200;

    int T = t.sum();

    auto dp = new int[][](T + 1, 300);
    fillAll(dp, -inf);
    dp[0][0] = 0;

    foreach (i ; 1 .. T + 1) {
        foreach (j ; 0 .. 201) {
            if (j <= (i == t[0] ? min(v[0], v[1]) : v[0])) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j] + 2*j);

                if (j - 1 >= 0) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 2*j - 1);
                }

                if (j + 1 <= 200) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] + 2*j + 1);
                }
            }
            else {
                dp[i][j] = -inf;
            }
        }

        if (i == t[0] && i < T) {
            t[1] += t[0];
            t.popFront();
            v.popFront();
        }

        debug {
            writeln(dp[i][0 .. 10]);
        }
    }

    writefln("%.8s", dp[T][0] / 8.0);
}


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



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

Measured memory_bytes: 86652
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

const int N = 100;
int s[N];

int main() {
  int n; cin >> n;
  int res = 0;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    res += s[i];
  }
  sort(s, s + n);
  if (!(res % 10)) {
    for (int i = 0; i < n; ++i) if (s[i] % 10) {res -= s[i]; break;}
  }
  if (!(res % 10)) res = 0;
  cout << res << endl;
  return 0;
}


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

map<int,ll> ndiv;

int num(int x) {
    int cnt = 0;
    for (auto it = ndiv.begin(); it != ndiv.end(); it++) {
        int val = it->second;
        if (val >= x-1) {
            cnt++;
        }
    }
    return cnt;
}

void solve() {
    ll n;
    cin >> n;

    rep(i,n) {
        int t = i + 1;
        int d = 2;
        while (t != 1) {
            while (t % d == 0) {
                t /= d;
                ndiv[d]++;
            }
            d++;
        }
    }

    cout << num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) / 2<< endl;

}

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


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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N, M;
vector<int> v;

void init()
{
	cin >> N >> M;
	vector<int> t(M);
	v.RS(M-1);
	rep(i, M) {
		int x;
		cin >> x;
		t[i] = x;
	}
	sort(all(t));
	rep(i, M-1) {
		v[i] = t[i+1] - t[i];
	}
	sort(all(v));
}

void solve()
{
	int a = max(0LL, M - N);
	int res = 0;
	rep(i, a) {
		res += v[i];
	}
	cout << res << endl;
}




Measured memory_bytes: 1792
K = int(input())
N = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(N[K-1])

Measured memory_bytes: 9188
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,M=MAP()
nodes=[[] for i in range(N)]
for i in range(M):
    a,b=MAP()
    nodes[a-1].append(b-1)
    nodes[b-1].append(a-1)

visited=[False]*N
team=['']*N

def rec(u):
    if visited[u]:
        return True
    visited[u]=True
    for v in nodes[u]:
        if team[u]==team[v]:
            return False
        if team[u]=='a':
            team[v]='b'
        elif team[u]=='b':
            team[v]='a'
        if not rec(v):
            return False
    return True

# 1からnまでの等差数列の和
def get_sum(n):
    return (1+n)*n//2

team[0]='a'
if rec(0):
    C=Counter(team)
    ans=C['a']*C['b']-M
else:
    ans=get_sum(N-1)-M
print(ans)


Measured memory_bytes: 31876
#coding:utf-8

n, m = map(int, input().split(' '))
pro = [0 for _ in range(n + 1)]

ac_cnt = 0
wa_cnt = 0
for i in range(m):
    idx, res = input().split(' ')
    idx = int(idx)
    if pro[idx] == 'AC':
        continue
    if res == 'AC':
        wa_cnt += pro[idx]
        pro[idx] = 'AC'
        ac_cnt += 1
    else:
        pro[idx] += 1
print(ac_cnt, wa_cnt)

Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
   int n,m;
  int a[10000];
  double s=0;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a[i];
    s+=a[i];
  }
  sort(a,a+n,greater<int>());
  for(int i=0;i<m;i++){
    
    if((double)(s/(4*m))>a[i]){
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
    string s;
    cin >> s;
    vector<int> a(26);
    int n = s.length();
    rep(i,n) a[(int)(s[i]-'a')]++;
    int id = -1;
    rep(i,26) {
        if(a[i]==0) {
            id=i;
            break;
        }
    }
    if(id!=-1) {
        cout << s+(char)('a'+id) << endl;
        return 0;
    }
    id = (int)(s[n-1]-'a');
    rrep(i,n-1) {
        if(s[i]>s[i+1]) {
            continue;
        }
        char cc = 'z';
        rrep(j,n) {
            if(i==j) break;
            if(s[i]>s[j]) continue;
            else cc = min(cc, s[j]);
        }
        cout << s.substr(0,i)+cc << endl;
        return 0;
    }
    cout << -1 << endl;

    return 0;
}



Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.*;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		StringBuilder sb = new StringBuilder(sc.next());	//入力された文字列を用意
		String ans="Yes";	//strの初期設定

		for(int i=0;i<sb.length();i++){
			int num=0;
			for(int j=0;j<sb.length();j++){
				//文字が一致した回数numをカウント
				if(sb.charAt(i)==sb.charAt(j)) num++;
			}
			//numが奇数になったらansをNoに変更
			if(num%2==1) ans="No";
			//ansがNoになったらfor文を抜ける
			if(ans.equals("No")) break;
		}

		//結果を出力
		System.out.println(ans);
	}
} 

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

int main(){
  int W,H,N;
  cin >> W >> H >> N;
  vector<vector<int>> Z(N,vector<int>(3));
  for(int i=0;i<N;i=i+1){
    for(int j=0;j<3;j=j+1){
      cin >> Z.at(i).at(j);
    }
  }
  int S=0;
  int x1=0;
  int x2=W;
  int y1=0;
  int y2=H;
  for(int i=0;i<N;i=i+1){
    if(Z.at(i).at(2) == 1){
      if(Z.at(i).at(0) > x1){
        x1 = Z.at(i).at(0);
      }
    }
    else if(Z.at(i).at(2) == 2){
      if(Z.at(i).at(0) < x2){
        x2 = Z.at(i).at(0);
      }
    }
    else if(Z.at(i).at(2) == 3){
      if(Z.at(i).at(1) > y1){
        y1 = Z.at(i).at(1);
      }
    }
    else if(Z.at(i).at(2) == 4){
      if(Z.at(i).at(1) < y2){
        y2 = Z.at(i).at(1);
      }
    }
  }
  if((x1>=x2) || (y1>=y2))cout << "0" << endl;
  else{
    S = y1*H + (W-y2)*H + (y2-y1)*x1 + (y2-y1)*(H-x2);
    int s = W*H - S;
    if(s > 0)cout << s << endl;
  }
}



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

int main() {
  string S, T;
  cin >> S >>T;
  
  int t=T.size();
  int s=S.size();
  int count = 0;
  int ans =100000; 
  for(int i=0; i<s-t+1; i++){
    count =0;
    for(int j=0; j<t; j++){
      if(S.at(i+j)!=T.at(j))count++;
    }
    ans = min(ans, count);
    if(ans ==0)break;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3584
N=int(input())
numlist=[1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]
timeslis2=[0,]*(100001)
timeslis2[1]=1
numlist2=numlist[::-1]
def times2(N):
    if N!=0:
        if timeslis2[N]==0:
            mini2=[]
            i=0
            while i<=11 and len(mini2)<=2:
                if N-numlist2[i]>=0:
                    mini2.append(times2(N-numlist2[i]))
                #print(mini2,numlist2[i],i)
                i+=1
            mini2.sort()
            timeslis2[N]=mini2[0]+1
            return mini2[0]+1
        else:
            return timeslis2[N]
    return 0
print(times2(N))

Measured memory_bytes: 3956
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 数値の読み込み
x,y = [int(i) for i in input().split()]

res = 0


if abs(y) > abs(x):
    # |x| < |y|
    if x < 0:
        res = res + 1
    if y < 0:
        res = res + 1
    res = res + abs(abs(y)-abs(x))
else :
    # x > y
    if x > 0:
        res = res + 1
    if y > 0:
        res = res + 1
    res = res + abs(abs(y)-abs(x))


print(res)

Measured memory_bytes: 3064
def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

N, X = map(int, input().split())
a = [abs(int(i)-X) for i in input().split()]


if N == 1:
    print(a[0])
else:
    ans = gcd(a[0], a[1])
    for i in range(N):
        ans = gcd(ans, a[i])
    print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const double pi=acos(-1);

int num[4][3][10];
int main(){
  int n;
  cin >> n;
  rep(i,n){
    int b,f,r,v;
    cin >> b >> f >> r  >> v;
    b--;
    f--;
    r--;
    num[b][f][r]+=v;
  }
  rep(i,4){
    rep(j,3){
      rep(k,10){
        cout << " " << num[i][j][k];
      }
      cout << endl;
    }
    if(i!=3){
      rep(j,20){
        cout << '#';
      }
      cout << endl;
    }
  }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500001
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	if (a >= k) {
		cout << a - k << " " << b << endl;
	}
	else if (b >= (k - a)) {
		cout << 0 << " " << b - (k - a) << endl;
	}
	else{
		cout << 0 << " " << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        int ans=0;
        for(int i=0;i<n;i++){
            int minj=i;
            for(int j=i;j<n;j++){
                if(a[j]<a[minj]){
                    minj=j;
                }
            }
            if(i!=minj){
                ans++;
                int tmp=a[i];
                a[i]=a[minj];
                a[minj]=tmp;
            }
            
        }
        for(int i=0;i<n;i++){
            System.out.printf("%d",a[i]);
            if(i!=n-1) System.out.printf(" ");
        } 
        System.out.printf("\n");
        System.out.println(ans);
    }
}


Measured memory_bytes: 26544
use std::io::*;
fn main() {
    let mut rdx = String::new();
    stdin().read_line(&mut rdx).unwrap();

    let r: i32 = rdx.trim().split_whitespace().collect::<Vec<&str>>()[0].parse().unwrap();
    let d: i32 = rdx.trim().split_whitespace().collect::<Vec<&str>>()[1].parse().unwrap();
    let mut x: i32 = rdx.trim().split_whitespace().collect::<Vec<&str>>()[2].parse().unwrap();
    

    for _ in 0..10 {
        x = r * x - d;
        println!("{}", x);
        
    }




}


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

int main(){
    string s;
    cin >> s;
    vector<int> res(s.length());
    int cnt_1, cnt_2;

    cnt_1 = 0;
    cnt_2 = 0;
    for(int i=0; i<s.length()-1; i++){
        if(s[i] == 'R'){
            if(i%2 == 0){
                cnt_1++;
            }else{
                cnt_2++;
            }
        }
        if(s[i+1] == 'L'){
            if(i%2 == 0){
                res[i] += cnt_1;
                res[i+1] += cnt_2;
                cnt_1 = 0;
                cnt_2 = 0;
            }else{
                res[i] += cnt_2;
                res[i+1] += cnt_1;
                cnt_1 = 0;
                cnt_2 = 0;
            }
        }
    }

    cnt_1 = 0;
    cnt_2 = 0;
    for(int i=s.length()-1; i>0; i--){
        if(s[i] == 'L'){
            if(i%2 == 0){
                cnt_1++;
            }else{
                cnt_2++;
            }
        }
        if(s[i-1] == 'R'){
            if(i%2 == 0){
                res[i] += cnt_1;
                res[i-1] += cnt_2;
                cnt_1 = 0;
                cnt_2 = 0;
            }else{
                res[i] += cnt_2;
                res[i-1] += cnt_1;
                cnt_1 = 0;
                cnt_2 = 0;
            }
        }
    }
    for(int i=0; i<s.length(); i++){
        cout << res[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), x = in.ni(), y = in.ni();
        int max = Math.min(x,y), min = Math.max(0, x+y-n);
        out.printf("%d %d\n",max,min);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22612
A, B, C, K = map(int, input().split())
if((K-A)>0):
    Y = K-A
else:
    print(K)
    exit()
if((Y-B)>0):
    Z = Y-B
else:
    Z = 0

X = A + 0 * Y + (-1) * Z
print(X)











	



Measured memory_bytes: 9076
#include<stdio.h>

int A[1000000], n;

//二分探索
int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;

	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;// keyを発見
		if (key > A[mid]) left = mid + 1;// 後半を探索
		else if (key < A[mid]) right = mid;// 前半を探索
	}

	return 0;
}

int main(void) {
	int i, q, k, sum = 0;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &k);
		if (binarySearch(k)) sum++;
	}

	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 2104
n = gets.to_i
xys = n.times.map do
  a = gets.to_i
  a.times.map { gets.split.map(&:to_i) }
end

ans = 0

(1 << n).times do |bit|
  count = 0

  xys.each_with_index do |xy, i|
    next if bit[i] == 0

    valid = true
    xy.each do |x, y|
      next if bit[x - 1] == y

      valid = false
    end

    if valid == true
      count += 1
    else
      count = 0
      break
    end
  end

  ans = count if count >= ans
end

puts ans


Measured memory_bytes: 3836