akhauriyash/Code-Regression huggingface dataset:
k,n = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
b = []

for i in range(len(a)-1):
    b.append(a[i+1]-a[i])

b.append(k -( a[-1] - a[0]))
b.sort()
print(k-b[-1])


Measured memory_bytes: 25836
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
//#define endl '\n'
#define ff first
#define ss second
#define LOCAL
const int N = 2e5+7 ;
const int INF = 1e9 ;
const int MOD = INF + 7 ;
string s ;
//#define int long long

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
//debug
#define TRACE

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

int32_t main(){_
	int n,m ;
	cin >> n >> m ;
	vector<vector<int>> g(3*n, vector<int>()) ;
	for(int i = 0; i < m ; i++){
		int x , y ;
		cin >> x >> y ;
		--x ; --y ;
		g[x].pb(y+n) ;
		g[x+n].pb(y+2*n) ;
		g[x+2*n].pb(y) ;
	}
	int S,D ;
	cin >> S >> D ;
	S-- ; D-- ;
	queue<int> Q ;
	Q.push(S) ;
	vector<int> dis(3*n, -1) ;
	dis[S] = 0 ;
	while(!Q.empty()){
		int cur = Q.front() ;
		Q.pop() ;
		for(auto i : g[cur]){
			if(dis[i] == -1){
				dis[i] = dis[cur]+1 ;
				Q.push(i) ;
			}
		}
	}
	//trace(dis) ;
	if(dis[D] == -1){
		cout << -1 << endl ;
	}
	else cout <<dis[D]/3 << endl ;
}


Measured memory_bytes: 17792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	string S;
	int w;
	cin >> S >> w;
	for(int i = 0; i < S.size(); i += w) {
		cout << S[i] ;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main()
{
  int array[N][N];
  int i,j,n,v,w,x,y;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<N;j++)
        {
          array[i][j]=0;
        }
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d",&v,&w);
      v--;
      for(j=0;j<w;j++)
        {
          scanf("%d",&x);
          x--;
          array[v][x]=1;
        }
    }

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
        {
          if(j) printf(" ");
          printf("%d",array[i][j]);
        }
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 2720
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(void){
    char str[200];
    int i,length;
    
    gets(str);
    length=strlen(str);
    
    for(i=0;i<length;i++){
        str[i]=toupper(str[i]);
    }
    
    puts(str);
    return 0;
}

Measured memory_bytes: 524
def swap(a, b):
    tmp = a
    a = b
    b = tmp
    return a, b


def solve(): # 072D- Derangement
    N = int(input())
    p = list(map(int, input().split(" ")))
    p.insert(0, 0)
    cnt = 0

    for i in range(1, N+1):
        if i == p[i]:
            if i != N:
                p[i], p[i+1] = swap(p[i], p[i+1])
                cnt += 1
            else:
                p[i-1], p[i] = swap(p[i-1], p[i])
                cnt += 1
        else:
            pass

    print(cnt)
    
    
solve()

Measured memory_bytes: 13880
def main():
    S = str(input())
    T = str(input())

    if len(S) < len(T):
        print("UNRESTORABLE")
        return 0

    answers = []

    for i in range(0, len(S)-len(T)+1):
        is_ok = True
        for j in range(len(T)):
            # print(S[i+j])
            # print(T[j])
            # print("-----------------")
            if S[i+j] != "?" and S[i+j] != T[j]:
                is_ok = False
        if is_ok:
            answers.append((S[0:i:] + T + S[i+len(T)::]).replace("?","a"))

    if len(answers) == 0:
        print("UNRESTORABLE")
        return 0
    else:
        answer = sorted(answers)[0]
        print(answer)
        return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>

using namespace std;
static const int INF = 1000000000;
static int dp[2][2501][2501];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	const int m = accumulate(a.begin(), a.end(), 0);
	for(int i = 0; i <= m; ++i){
		for(int j = 0; j <= m; ++j){ dp[0][i][j] = 0; }
	}
	dp[0][0][0] = 1;
	for(int i = 0, sum = 0; i < n; ++i){
		const int cur = i & 1, next = 1 - cur, ai = a[i];
		sum += ai;
		for(int j = 0; j <= sum; ++j){
			for(int k = 0; k <= sum; ++k){ dp[next][j][k] = 0; }
		}
		for(int j = 0; j <= sum; ++j){
			for(int k = j; k <= sum; ++k){
				if(dp[cur][j][k] == 0){ continue; }
				const int x = 0, y = j, z = k;
				{	// (x, y, z + ai)
					array<int, 3> w = { x, y, z + ai };
					sort(w.begin(), w.end());
					w[1] -= w[0]; w[2] -= w[0]; w[0] = 0;
					dp[next][w[1]][w[2]] = 1;
				}
				{	// (x, y + ai, z)
					array<int, 3> w = { x, y + ai, z };
					sort(w.begin(), w.end());
					w[1] -= w[0]; w[2] -= w[0]; w[0] = 0;
					dp[next][w[1]][w[2]] = 1;
				}
				{	// (x + ai, y, z)
					array<int, 3> w = { x + ai, y, z };
					sort(w.begin(), w.end());
					w[1] -= w[0]; w[2] -= w[0]; w[0] = 0;
					dp[next][w[1]][w[2]] = 1;
				}
			}
		}
	}
	int answer = INF;
	for(int i = 0; i <= m; ++i){
		for(int j = 0; j <= m; ++j){
			if(dp[n & 1][i][j]){
				const int y = i, z = j;
				answer = min(answer, (m - y - z) / 3 + z);
			}
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 48256
#include<stdio.h>

int main(void){

    int N,i;

    scanf("%d",&N);

    for(i = 1;i <= 9;i++){
        if((N/i)/10 == 0 && (N/i)*i == N){
            printf("Yes\n");
            return 0;
        }
    }

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


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



int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  long long int sum=0;
  if(k>=a){
    sum+=a;
    k=k-a;
  }else{
    sum+=k;
    k=0;
  }
  if(k>=b){
    sum+=0;
    k=k-b;
  }else{
    sum+=0;
    k=0;
  }
  if(k>=c){
    sum+=-c;
    k=k-c;
  }else{
    sum+=-k;
    k=0;
  }
  cout<<sum<<endl;
}





    

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

bool A[110];

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

	A[0] = true;
	for (int i = 0; i < 100; i++)
	{
		if (A[i])
		{
			A[i + 4] = true;
			A[i + 7] = true;
		}
	}

	int N;
	cin >> N;
	cout << (A[N] == 1 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int res, S0C, S1C;
    string S; 
    cin >> S;
    S0C = S1C = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == '0') {
            S0C++;
        } else {
            S1C++;
        }
    }
    res = min(S0C, S1C) * 2;
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<vector<int>> l(h, vector<int>(w, -MOD)),
                        r(h, vector<int>(w, MOD));
    while (n--) {
        int y, x, p;
        cin >> y >> x >> p;
        y--; x--;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                int dist = abs(i-y)+abs(j-x);
                l[i][j] = max(l[i][j], p-dist);
                r[i][j] = min(r[i][j], p+dist);
                if(l[i][j] > r[i][j]){
                    puts("No");
                    return 0;
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ans += l[i][j];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    ans[1]++;
    ans[x]++;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,p;
    cin>>n>>p;
    if(n==1){
      cout<<p<<endl;
      return 0;
    }
    map<ll,ll> ret=prime_factor(p);
    ll ans=1;
    for(auto itr:ret){
      ans*=pow(itr.first,((itr.second)/n));
      //cout<<itr.first<<' '<<(itr.second)/n<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
ll a[12345],b[1234],three[1234567];
int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin>>s;
    three[0]=1;
    ll i;
    f(i,1,123456){
    	three[i]=three[i-1]*3;
    	three[i]%=mod;
    }
    rep(i,s.length()){
    	b[s[i]]++;
    }
    ll cnt=b['?'],flag,ans=0;
    rep(i,s.length()){
    	b[s[i]]--;
    	if(s[i]=='?')
    		flag=1;
    	else
    		flag=0;
    	if(s[i]=='B' || s[i]=='?'){
    		ans+=(a['A']*b['C']%mod)*three[cnt-flag];
    		if(b['?']){
    			ans+=(a['A']*b['?']%mod)*three[cnt-1-flag];
    		}
    		ans%=mod;
    		if(a['?']){
    			ans+=(a['?']*b['C']%mod)*three[cnt-1-flag];
    		}
    		ans%=mod;
    		if(a['?'] && b['?']){
    			ans+=(a['?']*b['?']%mod)*three[cnt-2-flag];
    		}
    		ans%=mod;

    	}
    	a[s[i]]++;
    }
    cout<<ans<<endl;

    return 0;     
}



Measured memory_bytes: 1488
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;

int main()
{
  int N,V[50],C[50],sum = 0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }
  for(int i=0;i<N;i++){
    if(V[i] > C[i])sum += V[i] - C[i];
  }
  cout << sum;
}


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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int a, b, c;
	int ans = 0;

	cin >> a >> b >> c;
	repc(i, a, b) {
		if (c % i == 0) ans++;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3100
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        ArrayList<String> array = new ArrayList<String>();
        String w = sc.next();
        while (sc.hasNext()) {
            array.add(sc.next());
        }
        sc.close();
        int count =0; 
        for (String string : array) {
            if(string.equalsIgnoreCase(w)){
                count++;
            }
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 18288
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 61;

int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);

    int n,k; cin >> n;
    string s; cin >> s;
    cin >> k;
    char x = s[k-1];
    string ans = "";
    rep(i, s.size()){
        if(s[i]!=x){
            ans+='*';
        } else {
            ans+=s[i];
        }
    }

    cout << ans << endl;

    
    return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,k;

int main(){
  cin >> n >> k;
  if(k*2 <= n+1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 250

int main(){
  int n,i,a[N+1];
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d",&a[i]);
  }
  for(i=1; i<=n; i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(i>=2){
      printf("parent key = %d, ",a[i/2]);
    }
    if(i*2<=n){
      printf("left key = %d, ",a[i*2]);
    }
    if(i*2+1<=n){
      printf("right key = %d, ",a[i*2+1]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int x = fs.nextInt();
        int y = fs.nextInt();
        int z = fs.nextInt();
        x -= z;
        int per = y + z;
        System.out.println(x / per);

    }

}


Measured memory_bytes: 81492
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long ans;
    foreach (i; 0 .. S.length / 2)
        if (S[i] != S[$ - i - 1])
        {
            ans++;
        }
    writeln(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int y, m , d;
   char c1, c2;
   cin >> y >> c1 >> m >> c2 >> d;
   if(m <= 4){
       cout << "Heisei" << endl;
   }
   else{
       cout << "TBD" << endl;
   }
}

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

import numpy

def main():
  n, w = map(int, input().strip().split())
  Ws, Vs = numpy.array([[int(x) for x in input().strip().split()] for _ in range(n)]).T
  dp = numpy.zeros((n, w+1), dtype=numpy.int)
  dp[0, Ws[0]:] = Vs[0]
  for i in range(1, n):
    dp[i] = dp[i-1,:]
    if w - Ws[i] + 1 > 0:
      dp[i, Ws[i]:w+1] = numpy.maximum(dp[i-1, Ws[i]:w+1], dp[i-1,:w-Ws[i]+1]+Vs[i])
  print(dp[n-1, w])


if __name__=='__main__':
  main()

Measured memory_bytes: 92140
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

using namespace std;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
const int mod = (int)1e9 + 7;
const int N = int(1e5) + 123;

int a[N];
deque <pair <int, int> > d;
vector <int> ans;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	int n, l;
	cin >> n >> l;
	for(int i = 1; i <= n; i++) cin >> a[i], d.pb(mp(a[i], i));
	bool ok = 0;
	for(int i = 1; i < n; i++) if(a[i] + a[i + 1] >= l) ok = 1;
	if(!ok) cout << "Impossible", exit(0);
	cout << "Possible" << endl;
	for(int i = 1; i < n; i++)
	{
		if(a[i] + a[i + 1] >= l)
		{
			for(int j = n - 1; j >= i + 1; j--) cout << j << endl;
			for(int j = 1; j <= i; j++) cout << j << endl;
			return 0; 
		}
	}
}


Measured memory_bytes: 2048
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X,Y,kosu;
		double keisan;
		
		X=0;
		Y=0;
		keisan=0;
		kosu=0;
		
		for(int i=1;i<=N;i++) {
			X = sc.nextInt();
			Y = sc.nextInt();
			
			keisan = Math.sqrt(Math.pow(X,2)+Math.pow(Y,2));
			
			if(keisan<=D) {
				kosu++;
			}
		}
		
		System.out.println(kosu);
		sc.close();
	}

}

Measured memory_bytes: 59476
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize, k: usize,
        mut p_vec: [usize; n],
    }

    p_vec.sort();
    let mut ans = 0;

    for i in 0..k {
        ans += p_vec[i]
    }

    println!("{}", ans);
}


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

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

int n,k;
char s[252521];
bool yo[252521];

int main(){
  scanf("%d%d",&n,&k);
  scanf("%s",s);
  REP(i,n)yo[i]=s[i]=='B';

  int head = 0;
  int tail = n-1;
  bool flip = false;
  while(k--){
    if(yo[head]^flip){
      // head is b
      flip ^= true;
      head++;
      if(head==n)head=0;
      tail++;
      if(tail==n)tail=0;
    }else{
      yo[head]^=true;
    }
  }
  REP(i,n)putchar(yo[(head+i)%n]^flip?'B':'A');
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
struct Card{char suit,value;};
void bubble(struct Card A[], int N){
  int i,j,sw=0,minj;
  for(i = 0; i < N;i++){
    for(j = N-1; j >=i + 1;j--){
      if(A[j].value < A[j - 1].value){
          Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N){
    for(int i = 0;i < N; i++){
        int minj = i;
        for(int j = i;j < N; j++){
            if(A[j].value < A[minj].value)minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[],int N){
    for(int i = 0; i < N; i++){
        if(i > 0)cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}
bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i = 0; i < N; i++){
        if(C1[i].suit != C2[i].suit)return false;
    }
    return true;
    }
int main(){
  int A[100],N,i,sw;
  Card C1[100],C2[100];
  char ch;

  cin >> N;
  for(i = 0;i < N;i++){
      cin >> C1[i].suit >> C1[i].value;
  }
  for(int i = 0; i < N;i++)C2[i] = C1[i];
  bubble(C1, N);
  selection(C2,N);
  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1, C2, N)){
      cout << "Stable" <<endl;
  }else{
      cout << "Not stable" << endl;
  }


  return 0;
}




Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int a,b,c; 
    cin >> a >> b >> c;
    if ((a==b && b!=c) || (b==c && a!=b) || (c==a && b!=c)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;


ll N, C;


int main() {
	cin >> N >> C;
	vector< vector<int> >d(C, vector<int>(C, 0));
	rep(i, 0, C) {
		rep(j, 0, C) {
			cin >> d[i][j];
		}
	}

	vector< vector<int> >c(N, vector<int>(N, 0));
	rep(i, 0, N) {
		rep(j, 0, N) {
			int x;
			cin >> x;
			x--;
			c[i][j] = x;
		}
	}



	vector< vector<int> >modcol(3, vector<int>(C,0));
	rep(i, 0, C) {
		rep(j, 0,N) {
			rep(k, 0, N) {
				modcol[(j+1+k+1)%3][i]+=d[c[j][k]][i];
			}
		}
	}

	ll ans = inf;
	rep(i, 0, C) {
		rep(j, 0, C) {
			rep(k, 0, C) {
				if (i != j && j != k && k != i) {
					ll temp = 0;
					temp += modcol[0][i] + modcol[1][j] + modcol[2][k];
					ans = min(temp, ans);
				}
			}
		}

	}

	cout << ans << endl;




	return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include<chrono>
using namespace std;
using namespace std::chrono;
//using namespace __gnu_pbds;
#define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi         first
#define se         second
#define int         long long
#define pb         push_back
#define emp        emplace_back
#define vv(x)      vector<x>
#define mp(x,y)    map<x,y>
#define dq(x)      deque<x>
#define pql(x)     priority_queue<x>
#define pqs(x)     priority_queue<x,vv(x),greater<x> >
#define mod         1000000007
#define forf(i,a,b) for(int i=a;i<b;i++)
#define it(x)      x::iterator
#define ll         long long
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#define vii        vector<int>
#define big        3e18
#define sm         -2e9
#define mkr        make_pair
#define vpi        vector<pair<int,int> >
#define pii        pair<int,int>
#define rng        500005
#define sz(x)      (int)x.size()
#define rv(x)      reverse(x.begin(),x.end())
#define out(x)     cout<<x.fi<<" "<<x.se<<endl;
 
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
 
void pr_init()
{
 
#ifndef ONLINE_JUDGE
  freopen("gin.txt", "r", stdin);
  freopen("gout.txt", "w", stdout);
 
#endif
}
int Mxn = 4e6;

int rs(int m,int k)
{
    int an = 1,a=10;
    while(m>0)
    {
        if(m%2!=0) an = ((an%k) * a%k)%k;
        m/=2;
        a = ((a%k) * a%k)%k;
    }
    return an;
}

void solve()
{
  // int k,an=-1;
  // cin >> k;
  
  // k/=__gcd(k,(int)7);
  // forf(i,1,Mxn)
  // {
   
  //   if(rs(i,k)==1)
  //   {
  //       an = i;
  //       break;
  //   }
  // }

  // cout<<an;
  
  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int>wh(n+1,0);

  forf(i,0,n+1)
  {
    if(i!=0) wh[i] = wh[i-1];
    if(i<n && s[i]=='W')wh[i]++;
  }
  
  int an = min(wh[n-1],n-wh[n-1]);
   
  forf(i,0,n)
  {
    int lf = wh[i] , rg = n-i-1-(wh[n]-wh[i]);
    int cur = max(lf,rg);
    an = min(an,cur);
    
  }

  
  cout<<an;
}
 
 
int32_t main()
{
  pr_init();
  fastio;
 
  auto start = high_resolution_clock::now();
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);
  // cout << "Time taken by function: "
  //       << duration.count() << " microseconds" << endl;
 
}
 

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

int main(){
  int N;
  cin >> N;
  bool a=false;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      if(i*4+j*7==N){
        a=true;
        break;
      }
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout<< "No" << endl;
  }
}

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

int main(){
  ull a, b, k;
  cin >> a >> b >> k;
  ull tk, ao;
  tk = a;
  ao = b;
  
  if (a > k) tk = a - k;
  else if ( a <= k && b > (k - a)) {
    tk = 0;
    ao = b - (k - a);
  } else {
    tk = 0;
    ao = 0;
  }
  
  cout << tk << " " << ao;
  
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
int N;
vector<int> D;
vector<ll> Num;
ll mod=998244353;
int main() {
    cin >> N;
    D.resize(N);
    Num.resize(N+1,0);
    REP(i,N)
        cin >> D[i];
    REP(i,N)
        Num[D[i]]+=1;
    ll ans=1;
    if (D[0]!=0)ans=0;
    if (Num[0]>1)ans=0;
    int rest=N-1-Num[1];
    for(int i=2;Num[i]>0&&rest>0;++i) {
        for(int j=0;j<Num[i];++j) {
            ans *= Num[i - 1];
            ans=AS_MOD(ans,mod);
        }
        rest-=Num[i];
    }
    if (rest>0)ans=0;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 110;

int n;

int main()
{
    cin >> n;
    while(n--)
    {
        int x;
        cin >> x;
        if(x % 2 == 0)
        {
            if(x % 3 && x % 5)
            {
                puts("DENIED");
                return 0;
            }
        }
    }
    puts("APPROVED");
    return 0;
}


Measured memory_bytes: 256
c=0
a=input()
if a=='SUN':
  c+=7
elif a=='MON':
  c+=6
elif a=='TUE':
  c+=5
elif a=='WED':
  c+=4
elif a=='THU':
  c+=3
elif a=='FRI':
  c+=2
else:
  c+=1
print(c)  
  


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

int main ()
{
    string s;
    cin >> s;
    if (
        (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
        ||
        (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
        ||
        (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])
    )
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
 
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
 
    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]
 
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False
 
    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a
 
def main():
    N = I()
    a = []
    b = []
    for i in range(N):
        x,y = LI()
        a.append((x,i))
        b.append((y,i))
    a.sort()
    b.sort()
    t = []
    for i in range(1,N):
        t.append((a[i][0]-a[i-1][0], a[i][1], a[i-1][1]))
        t.append((b[i][0]-b[i-1][0], b[i][1], b[i-1][1]))
    t.sort()
    r = 0
    uf = UnionFind(N)
    for c,d,e in t:
        if uf.union(d,e):
            r += c
 
    return r
 
print(main())

Measured memory_bytes: 52852
//
//  main.cpp
//  Curry Making
//
//  Created by x15071xx on 2017/06/13.
//  Copyright ?? 2017??´ AIT. All rights reserved.
//

#include <iostream>


using namespace std;
int main(int argc, const char * argv[]) {
    
    
    
    while (1) {
        int r0,w0,c,r,count = 0;
        
        
        cin >> r0 >> w0 >> c >> r;
        
        if (r0 == 0 && w0 == 0 && c == 0 && r == 0) {
            break;
        }
        
        while (r0 < c*w0) {
            r0 += r;
            count++;
        }
        
        cout << count << endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> V(N);
	for (int i = 0; i < N; i++)
		cin >> V[i];

	sort(V.begin(), V.end()); // , greater<int>() をつけると降順

	double X = V[0];
	for (int i = 1; i < N; i++) {
		X = (X + V[i]) / 2;
	}

	cout << setprecision(10) << X << endl;

	return 0;
}

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

#define nil -1
int p[200];
int c[200][200];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    if(n==1||n==2){
      if(m==1||m==2)cout<<3<<endl;
    }
    if(n==3||n==2){
      if(m==3||m==2)cout<<1<<endl;
    }
    if(n==1||n==3){
      if(m==1||m==3)cout<<2<<endl;
    }

   return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(void){
	int n, m, a[1000], b[1000], c[1000]={0}, i, j;
	scanf("%d%d", &n, &m);
	for(i=0; i<n; ++i){ scanf("%d", a+i); }
	for(i=0; i<m; ++i){ scanf("%d", b+i); }
	for(i=0; i<m; ++i){ 
		for(j=0; (j<n)&&(a[j]>b[i]); ++j);
		++c[j];
	}
	for(i=1, j=0; i<n; j=(c[j]<c[i])?i:j, ++i);
	printf("%d\n", j+1);
	return(0);
}


Measured memory_bytes: 2624
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
pair<llong, llong> Reduction(pair<llong, llong> A) {
	llong tmp = gcd(A.first, A.second);
	auto p = make_pair(A.first / tmp, A.second / tmp);
	return p;
}
//ここまで共通
int main() {
	int D, T, S;
	cin >> D >> T >> S;
	if (D <= T * S) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
using namespace std;
#define int long long
int ans[110000];
int mas[110000];
int fac[110000];
int cnt[110000];
int mod = 1e9 + 7;
int binpow(int a, int n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return binpow(a, n - 1) * a % mod;
	else {
		int b = binpow(a, n / 2);
		return b * b % mod;
	}
}
int cc(int n, int k) {
	if (k > n) return 0;
	return fac[n] * binpow(fac[k] * fac[n - k] % mod, mod - 2) % mod;
}
signed main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	for (int i = 1; i <= n + 1; ++i) {
		cin >> mas[i];
	}
	int l = 0, r = 0;
	int x = 0;
	for (int i = 1; i <= n + 1; ++i) {
		cnt[mas[i]]++;
		if (cnt[mas[i]] == 2) x = mas[i];
	}
	for (int i = 1; i <= n + 1; ++i) {
		if (mas[i] == x) {
			l = i;
			break;
		}
	}
	for (int i = n + 1; i >= 1; --i) {
		if (mas[i] == x) {
			r = i;
			break;
		}
	}
	fac[0] = 1;
	for (int i = 1; i <= n + 1; ++i) {
		fac[i] = fac[i - 1] * i;
		fac[i] %= mod;
	}
	for (int i = 1; i <= n + 1; ++i) {
		ans[i] = cc(n + 1, i);
		ans[i] -= cc(l - 1 + n + 1 - r, i - 1);
		ans[i] += mod * mod;
		ans[i] %= mod;
	}
	for (int i = 1; i <= n + 1; ++i) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 4480
import sys

n,a=map(int, input().split())
cards=list(map(int, input().split()))

integers=[x-a for x in cards]
cards.append(a)
f=max(cards)*n


dp=[[0 for i in range(n+1)] for j in range(2*f+1) ]

for y in range(n+1):
    for x in range(2*f+1):
        if y==0 and x==f:
            dp[x][y]=1
        elif y>0 and (x-integers[y-1]<0 or x-integers[y-1]>2*f):
            dp[x][y]=dp[x][y-1]
        elif y>0 and x-integers[y-1]>=0 and x-integers[y-1]<=2*f:
            dp[x][y]=dp[x-integers[y-1]][y-1]+dp[x][y-1]
        else:
            dp[x][y]=0
print(dp[f][n]-1)



Measured memory_bytes: 12140
#include<bits/stdc++.h>
#define oo 0x7ffffff
using namespace std;
int n;
int x[100030],X;
int d[100030]={1},ans;
int ls;
int gcd(int a,int b)
{
	if(a<b)
		swap(a,b);
	if(b==0)
         return a;
    else
        return gcd(b,a%b);
}
int main()
{
	cin>>n>>X;
	for(int i=1;i<=n;++i)
		{
			scanf("%d",&x[i]);
			ls=i==1?abs(X-x[i]):gcd(ls,abs(X-x[i]));
		}
	cout<<ls;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

template <typename T, int b = 8, int bit = sizeof(T) * 8>
void radix_sort(T* a, int n) {
  vector<T> temp(n);
  T *dist = temp.data(), *src = a;
  constexpr int mask = (1 << b) - 1;
  constexpr int kn = (bit + b - 1) / b;
  for (int k = 0; k < kn; ++k) {
    int bucket[1 << b] = {};
    int index[1 << b];
    for (int i = 0; i < n; ++i) bucket[mask & (src[i] >> (b * k))] += 1;
    index[0] = 0;
    for (int i = 0; i < (1 << b) - 1; ++i) index[i + 1] = index[i] + bucket[i];
    for (int i = 0; i < n; ++i)
      dist[index[mask & (src[i] >> (b * k))]++] = src[i];
    swap(dist, src);
  }
  if (kn % 2 == 1) { memcpy(a, src, sizeof(T) * n); }
}

int a[200020];
int main() {

  int n;
  cin >> n;
  rep(i, 0, n) cin >> a[i];
  radix_sort<int>(a, n);
  ll ans = 0;
  rep(i, 1, n) ans += a[n - 1 - i / 2];
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll n, k;
cin>>n>>k;
vector<ll> a(n+1);
for(ll i = 1; i < n+1; i++){
    cin>>a[i];
}
ll count=1;
map<ll, ll> m;
ll present = 1;
ll loopsize = 0;
ll temp, start;
while (count < n+1)
{
    if(m[present]){
        loopsize = count - m[present];
        start = m[present] - 1;
        break;
    }
    temp = present;
    m[present] = count;
    present = a[present];
    count++;
}
//cout<<loopsize<<" "<<temp<<" "<<start<<" "<<present<<endl;
if(loopsize == 0){
    cout<<temp;
}else
{
    if(k <= start){
        ll p = 1;
        for(ll i = 0; i < k; i++){
            p = a[p];
        }
        cout<<p;
    }else
    {
        k -= start;
        k %= loopsize;
        ll p = present;
 //       cout<<k<<endl;
        for(ll i = 0; i < k; i++){
            p = a[p];
        }
        cout<<p;
    }
    
}
return 0;    
}

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

#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    int n,m;
    cin>>n>>m;
    int ans[n];
    REP(i,n)ans[i]=0;
    REP(i,m){
        int s,c;cin>>s>>c;s--;
        if(ans[s]>0&&ans[s]!=c){cout<<-1<<endl;return;}
        else ans[s]=c;
        if(n>1&&s==0&&c==0){cout<<-1<<endl;return;}

    }
    if(n>1&&ans[0]==0)ans[0]=1;
    REP(i,n)cout<<ans[i];cout<<endl;
}

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

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

#define ll   	long long
#define pb	    push_back
#define F   	first
#define S	    second
#define B   	begin()
#define E	    end()
#define FASTIO   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


using namespace std ;

int main()
{
    FASTIO ;
    int n , l ;
    cin >> n >> l ;
    vector < string > v(n) ;
    for ( int i = 0 ; i < n ; i++ )
        cin >> v[i] ;
    sort ( v.B , v.E ) ;
    for ( int i = 0 ; i < n ; i++ )
        cout << v[i] ;
    return 0;
}



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

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")

typedef long long ll;
typedef long double ld;

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define fast() {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
#define eb emplace_back
#define pb push_back
#define deb(a) cerr << #a << " = " << a << '\n';

int main()
{
    fast();
    ll a, b, n, x;
    cin >> a >> b >> n;
    x = min(n, b - 1);
    cout << a * x / b - a * (x / b);
    return 0;
}


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

public class Main 
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext())
		{
			int n = sc.nextInt();
			int ans =0;
			boolean a[] = new boolean [n+1];
			Arrays.fill(a, true);
			a[0]=a[1]=false;

			for (int p=2; p<=n; p++) 
			{
				if (!a[p]) 
					continue;
				for (int j = p+p; j<= n; j += p)   //合成数jを消す
				{ 
					a[j] = false;
				}
			}
			for(int i =0; i<=n; i++)
			{
				if(a[i])
					ans++;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 16000
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
int main()
{
    lint a = 0;
    lint b = 0;
    int n;
    cin >> n;
    vi v(n);
    vi s(n);
    //vector<lint> s(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    s[0] = v[0];
    rep(i, n) //0番目を正と仮定
    {
        if (i > 0)
        {
            s[i] = s[i - 1] + v[i];
        }
        if (i % 2 == 0)
        {
            if (s[i] <= 0)
            {
                a += 1 - s[i];
                s[i] = 1;
            }
        }
        else
        {
            if (s[i] >= 0)
            {
                a += s[i] + 1;
                s[i] = -1;
            }
        }
        
    }
    s[0] = v[0];
    rep(i, n) //0番目を負と仮定
    {
        if (i > 0)
        {
            s[i] = s[i - 1] + v[i];
        }
        if (i % 2 == 0)
        {
            if (s[i] >= 0)
            {
                b += s[i] + 1;
                s[i] = -1;
            }
        }
        else
        {
            if (s[i] <= 0)
            {
                b += 1 - s[i];
                s[i] = 1;
            }
        }
    }
    cout << min(a, b) << endl;
    return 0;
}

Measured memory_bytes: 1024