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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;
	vector<ll> h(n, 0);
	rep(i, n) cin >> h.at(i);

	ll ret = 0;
	ll tmp = 0;
	rep(i, n - 1) {
		if(h.at(i) >= h.at(i+1)) {
			++tmp;
		} else {
			ret = max(ret, tmp);
			tmp = 0;
		}
	}

	ret = max(ret, tmp);

	cout << ret << endl;

	return 0;
}


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

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

  int b[100];
  for(int i=0;i<m;i++) cin>>b[i];

  int c[100];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)c[i]+=a[i][j]*b[j];

  for(int i=0;i<n;i++) cout<<c[i]<<endl;

  return 0;
}


Measured memory_bytes: 3036
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse,sse2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree <T, null_type ,  less<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree <T, null_type ,  less_equal<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;

#define all(x) x.begin(), x.end()
#define all_r(x) x.rbegin(), x.rend()
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, n) for(int i = n; i >= 0; --i)
#define f first
#define s second

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, y = 0;
	cin >> n;
	vi a(n), b(n);
	FOR(i, n) {
		cin >> a[i];
		y ^= a[i];
	}
	FOR(i, n) b[i] = a[i] ^ y;
	FOR(i, n) cout << b[i] << ' ';
	cout << '\n';
 	return 0;
}

Measured memory_bytes: 4744
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define fo(i, n)         for(int i=0; i<n; i++)
#define Fo(i, a, b)      for(int i=a; i<b; i++)
#define rfo(i, n)        for(int i=n-1; i>=0; i--)
#define Rfo(i, a, b)     for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=a.begin(); it!=a.end(); it++)
#define F                first
#define S                second
#define vi               vector<int>
#define vvi              vector<vector<int>>
#define pii              pair<int, int>
#define mii              map<int, int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int, vi, greater<int>>
#define mp               make_pair
#define pb(x)            push_back(x)
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define PI               3.1415926535897932384626
const int mod = 1e9+7;
const int inf = 1e18;
int mpow(int base, int exp);
bool isprime(int num);
void prifact(int num);

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //coderprasukj();
    int  n, k, x, y, flag=1;
    string s, t;
    cin >> s >> t;
    for(int i=0; i<s.length(); i++){
        if(s[i]!=t[i]) {
            flag=0;
            break;
        }
    }
    if(flag) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
  return result;
}

bool isprime(int num) {
    if(num <= 1) return false;
    for(int i=2; i*i <= num; i++)
        if(num%i == 0) return false;
    return true;
}

void prifact(int num){
    for(int i=2; i<=num; i++)
    if(num%i == 0){
        int cnt = 0;
        while(num%i == 0)
        cnt++ , num /= i;
        cout << i << "^" << cnt << " ";
    }
    if(num > 1)
    cout << num << "^" << "1" << " ";
}



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

using namespace std;

bool isPrime(int t){
    for(int i=2;i*i<=t;i++){
        if(t%i==0) return false;
    }
    return true;
}

int main(){
    auto getN = [](int K){ return K*(K-1) + 1; };
    int K = 1, N = getN(1);
    while(!isPrime(K-1) || N < 1000){
        ++K;
        N = getN(K);
    }
    cout << N << " " << K << endl;
    vector<vector<int>> A(N, vector<int>(N, 0));
    for(int i=0;i<K;i++){
        A[i][0] = 1;
        for(int j=0;j<K-1;j++){
            A[i][1+i*(K-1)+j] = 1;
        }
    }
    for(int i=K;i<N;i++){
        A[i][(i-1)/(K-1)] = 1;
    }
    for(int i=0;i<K-1;i++){
        for(int j=0;j<K-1;j++){
            int s = (i*j)%(K-1);
            for(int k=0;k<K-1;k++){
                A[K+i*(K-1)+k][K+j*(K-1)+(k+s)%(K-1)] = 1;
            }
        }
    }
    for(auto& v : A){
        bool first = true;
        for(int i=0;i<N;i++){
            if(!v[i]) continue;
            if(first) first = false;
            else cout << " ";
            cout << i+1;
        }
        cout << endl;
    }
}

Measured memory_bytes: 8192
#include<cstdio>
#include<iostream>
#include<map>
#include<string>

using namespace std;

typedef map<string,string> MSS;

#define MSSVT MSS::value_type

int main(){
	
	string gc;
	string inp;
	string sea;
	string hen;
	string ans;
	MSS data1,data2;

	data1.insert(MSSVT("101"," "));
	data1.insert(MSSVT("010001","."));
	data1.insert(MSSVT("000011",","));
	data1.insert(MSSVT("10010001","-"));
	data1.insert(MSSVT("000000","'"));
	data1.insert(MSSVT("000001","?"));
	data1.insert(MSSVT("100101","A"));
	data1.insert(MSSVT("10011010","B"));
	data1.insert(MSSVT("0101","C"));
	data1.insert(MSSVT("0001","D"));
	data1.insert(MSSVT("110","E"));
	data1.insert(MSSVT("01001","F"));
	data1.insert(MSSVT("10011011","G"));
	data1.insert(MSSVT("010000","H"));
	data1.insert(MSSVT("0111","I"));
	data1.insert(MSSVT("10011000","J"));
	data1.insert(MSSVT("0110","K"));
	data1.insert(MSSVT("00100","L"));
	data1.insert(MSSVT("10011001","M"));
	data1.insert(MSSVT("10011110","N"));
	data1.insert(MSSVT("00101","O"));
	data1.insert(MSSVT("111","P"));
	data1.insert(MSSVT("10011111","Q"));
	data1.insert(MSSVT("1000","R"));
	data1.insert(MSSVT("00110","S"));
	data1.insert(MSSVT("00111","T"));
	data1.insert(MSSVT("10011100","U"));
	data1.insert(MSSVT("10011101","V"));
	data1.insert(MSSVT("000010","W"));
	data1.insert(MSSVT("10010010","X"));
	data1.insert(MSSVT("10010011","Y"));
	data1.insert(MSSVT("10010000","Z"));
	data2.insert(MSSVT(" ","11010"));
	data2.insert(MSSVT(".","11011"));
	data2.insert(MSSVT(",","11100"));
	data2.insert(MSSVT("-","11101"));
	data2.insert(MSSVT("'","11110"));
	data2.insert(MSSVT("?","11111"));
	data2.insert(MSSVT("A","00000"));
	data2.insert(MSSVT("B","00001"));
	data2.insert(MSSVT("C","00010"));
	data2.insert(MSSVT("D","00011"));
	data2.insert(MSSVT("E","00100"));
	data2.insert(MSSVT("F","00101"));
	data2.insert(MSSVT("G","00110"));
	data2.insert(MSSVT("H","00111"));
	data2.insert(MSSVT("I","01000"));
	data2.insert(MSSVT("J","01001"));
	data2.insert(MSSVT("K","01010"));
	data2.insert(MSSVT("L","01011"));
	data2.insert(MSSVT("M","01100"));
	data2.insert(MSSVT("N","01101"));
	data2.insert(MSSVT("O","01110"));
	data2.insert(MSSVT("P","01111"));
	data2.insert(MSSVT("Q","10000"));
	data2.insert(MSSVT("R","10001"));
	data2.insert(MSSVT("S","10010"));
	data2.insert(MSSVT("T","10011"));
	data2.insert(MSSVT("U","10100"));
	data2.insert(MSSVT("V","10101"));
	data2.insert(MSSVT("W","10110"));
	data2.insert(MSSVT("X","10111"));
	data2.insert(MSSVT("Y","11000"));
	data2.insert(MSSVT("Z","11001"));

	
	while(getline(cin,inp)){
		hen=("");
		for(int i=0;i<inp.size();i++){
			sea=inp[i];
			//cout<<inp[i]<<"||"<<endl;
			hen+=data2[sea];
		}
		ans=("");
		sea=("");
		for(int i=0;i<hen.size();i++){
			sea+=hen[i];
			if(data1.find(sea)!=data1.end()){
				ans+=data1[sea];
				//cout<<data1[sea]<<","<<sea<<endl;
				sea=("");
			}
		}
		cout<<ans<<endl;
	}

}

Measured memory_bytes: 1220
#include<stdio.h>
#include<math.h>
int main(void){
double a, b, C, S, L, h, l;
    double s;
    double c;
     
    scanf("%lf %lf %lf", &a, &b, &C);
 
    s = sin(C*3.1415926535/180);
    c = cos(C*3.1415926535/180);
     
    S = 0.5*a*b*s;
     
    l = (a*a)+(b*b)-(2*a*b*c);
    L = sqrt(l)+a+b;
     
    h = (2*S)/a;
     
    printf("%lf\n%lf\n%lf\n", S, L, h);
     
return 0;
}


Measured memory_bytes: 2112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {

            int str = int.Parse(Console.ReadLine());
            int h = str / 3600;
            int m = (str - (h * 3600)) / 60;
            int s = str - (h * 3600 + m * 60);
            Console.WriteLine(h +":"+m+":"+s);
        }
    }
}



Measured memory_bytes: 15952
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  cin>>n;
  rep(i,n){
    string s;
    string ans;
    bool han=false;
    if(i==0)getline(cin,s);
    getline(cin,s);
    rep(a,27){
      rep(b,27){
	string tmp=s;
	rep(j,tmp.size())if(isalpha(tmp[j]))tmp[j]=(a*(tmp[j]-'a')+b)%26+'a';
	rep(j,tmp.size()-3){
	  if(tmp.substr(j,4)=="this"){ans=tmp;han=true;}
	  if(tmp.substr(j,4)=="that"){ans=tmp;han=true;}
	}
	if(han==true)break;
      }
      if(han==true)break;
    }
    cout<<ans<<endl;
  }


}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    ll s;
    cin >> s;
    
    const int max_n = 1000000000;
    if (s < max_n) {
        out("0 0 0 " << s << " " << 1 << " " << 0);
        return 0;
    } else if (s == 1e18) {
        int a = 0, b = 1e9, c = 1e9, d = 0;
        // out(1LL * c * b - a * d);
        out("0 0 0 1000000000 1000000000 0");
        return 0;
    }
    
    ll a, b, c, d;
    c = max_n;
    
    b = s / c;
    b++;
    
    d = 1;
    a = s % max_n;
    a = -a;
    // out(a);
    a += max_n;
    
    out(0 << " " << 0 << " " << a << " " << b << " " << c << " " << d);
    
    // out(1LL * c * b - a);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

	int main(){
		char s[200];
		scanf("%s",s);
		int n = strlen(s);
		for(int i = n-2; i; i-=2){
			if(strncmp(s, s+i/2, i/2) ==0){
				printf("%d\n" ,i);
				return 0;
			}
		}
	}

Measured memory_bytes: 128
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  string s;
  cin>>s;
  ll a = (int)s.sz;
  rep(i,0,a){
    cout << "x";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<endl
#define f first
#define s second
#define endl '\n'
#define sq(x) (x)*(x)*1ll
typedef long long ll;
typedef pair<int,int> pii;

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do something instead of nothing and stay organized
*/


int main () {
      int mat[3][3];
      for (int i = 0; i<3; i++)
            for (int j=0; j<3; j++)
                  cin>>mat[i][j];

      int n;
      cin >> n;
      set<int>sim;
      for (int i=0; i<n; i++) {
            int x; cin>>x;
            sim.insert(x);
      }

      for (int i=0; i<3; i++)
            for (int j=0; j<3; j++)
                  if (sim.count(mat[i][j]))
                        mat[i][j] = INT_MIN;

      bool ok =false;

      for (int i = 0; i<3; i++) {
            if (mat[i][0] == INT_MIN && mat[i][1] == INT_MIN &&
            mat[i][2] == INT_MIN) ok=true;
            if (mat[0][i] ==INT_MIN && mat[1][i] ==INT_MIN &&
            mat[2][i] ==INT_MIN) ok=true;
      }

      if (mat[0][0] ==INT_MIN&& mat[1][1] ==INT_MIN && mat[2][2] ==INT_MIN) {
            ok=true;
      }

      if (mat[2][0] == INT_MIN&& mat[1][1] ==INT_MIN && mat[2][0] ==INT_MIN)
            ok=true;


      cout << (ok ? "Yes" : "No") << 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;
 
int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n){
    int tmp;
    cin >> tmp;
    vec.at(i) = tmp;
  }
//  rep(i,n) cout << vec.at(i) << endl;
  int ans=0;
  rep(i,n-1){
    rep(j,n-i-1){
      ans += vec.at(i) * vec.at(j+i+1);
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,cnt=0;
  cin >> n;
  vector<ll> p(n);
  rep(i,n) cin >> p[i];
  rep(i,n){
    if(p[i]!=i+1) cnt++;
  }
  if(cnt<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 600+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
vector<int> g[N];
double ans = 1e9;

void block(int v){
	vector<double> dp(n+2);
	dp[n] = 0.0;
	for(int i=n-1; i>=1; i--){
		int sz = g[i].size();
		double sum = 0.0;
		double mx = 0.0;
		for(auto u:g[i]){
			sum += dp[u];
			mx = max(mx, dp[u]);
		}
		if (i == v && sz > 1){
			sum -= mx;
			sz -= 1;
		}
		dp[i] = sum / sz + 1; //1 for all edges
	}
	ans = min(ans, dp[1]);
}

int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int u, v; cin >> u >> v;
		g[u].push_back(v);
	}
	for(int i=0; i<n; i++){ //i=0 means no block any passage
		block(i);
	}
	cout << fixed << setprecision(9);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    int n,m,x;
    cin >> n>>m>>x;
    vi bb(n,0);
    rep(i,m) {
        int ai;
        cin >> ai;
        bb[ai]++;
    }
    int ans=0;
    rep(i,x) ans+=bb[i];
    int res=0;
    for(int i=x;i<n;++i) res+=bb[i];
    out(min(ans,res));
}

Measured memory_bytes: 256
n = int(input())
s = input()
t = input()
i = 0
if s[0]==t[0]:
    h = True
    r = 3
    i += 1
else:
    r = 6
    i += 2
    h = False
mod = 10**9 +7
while i < n:
    if s[i]==t[i]:
        if h:
            i += 1
            r = (r*2)%mod
        else:
            i += 1
            h = True
    else:
        if h:
            r = (r*2)%mod
            h = False
        else:
            r = (r*3)%mod
        i += 2
print(r)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Factorial II
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line);
			if (n == 0) {
				break;
			}

			int two = 0;
			int five = 0;

			for (int i = n; i > 1; i--) {
				if (i % 2 == 0) {
					int j = i;
					while (j % 2 == 0) {
						two++;
						j /= 2;
					}
				}
				if (i % 5 == 0) {
					int j = i;
					while (j % 5 == 0) {
						five++;
						j /= 5;
					}
				}
			}
			System.out.println(two < five ? two : five);
		}
	}
}

Measured memory_bytes: 18504
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
typedef long long int lli;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define JUGAD freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
using namespace std;

const lli M=1000000007;
const int n=200001;
lli ar[n],dar[n];

lli modpow(lli a,lli b){
    lli res=1;
    while(b){
        if(b&1){
            res=(res*a)%M;
        }
        a=(a*a)%M;
        b>>=1;
    }
    return res;
}

lli ncr(lli n,lli r){
    if(r==0||r==n){return 1;}
    return (dar[r]*((ar[n]*dar[n-r])%M))%M;
}

int main(){
    FAST;
    ar[0]=1;
    int h,w,a,b;cin>>h>>w>>a>>b;
    for(lli i=1;i<n;i++){
        ar[i]=(ar[i-1]*i)%M;
        dar[i]=modpow(ar[i],M-2);
    }
    lli ans=0;
    for(int i=b;i<w;i++){
        int y1=h-a-1,x1=i;
        int y2=a-1,x2=w-i-1;
        lli xx=(ncr(x1+y1,x1)*ncr(x2+y2,x2))%M;
        ans=(ans+xx)%M;
    }
    cout<<ans<<endl;
}




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

const int MAX_N = (int)1e5 + 5;
int N, M, parent[MAX_N], r[MAX_N];
multiset<lint> S[MAX_N];

void merge(int x, int y){
    for(auto e : S[y]) S[x].emplace(e);
    S[y].clear();
}

void init(int n){
    for(int i=0;i<n;i++){
        parent[i] = i;
        r[i] = 0;
    }
}

int find(int x){
    if(parent[x] == x) return x;
    else return parent[x] = find(parent[x]);
}

void unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return;
    if(r[x]<r[y]) parent[x] = y, merge(y, x);
    else{
        parent[y] = x, merge(x, y);
        if(r[x] == r[y]) r[x]++;
    }
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> N >> M;
    for(int i=0;i<N;i++){
        int a; cin >> a;
        S[i].emplace(a);
    }
    init(N);
    for(int i=0;i<M;i++){
        int a, b; cin >> a >> b;
        unite(a, b);
    }

    int cnt = 0;
    lint ans = 0;
    vector<lint> v;
    for(int i=0;i<N;i++){
        if(!S[i].empty()) ans += *S[i].begin(), S[i].erase(S[i].begin()), cnt++;
        for(auto e : S[i]) v.push_back(e);
    }

    if((int)v.size()<cnt-2) {cout << "Impossible" << endl; return 0;}
    if(cnt==1) {cout << 0 << endl; return 0;}
    sort(v.begin(), v.end());
    for(int i=0;i<cnt-2;i++) ans += v[i];

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

Measured memory_bytes: 11896
#include "bits/stdc++.h"
using namespace std;
#define ri(a,b,c) for(int a=(b);a<(c);++a)
#define ll long long
#define rll(a,b,c) for(ll a=(b);a<(c);++a)

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

    int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
    cin>>a>>b;
  c=(a?(a-1?10000:100):1);
  n=(b-100)?b:101;
  







    cout<<n*c<<endl;

    return 0;
}



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

int main(){
  int a,b,c,k;
  std::cin >> a>>b>>c>>k;

  bool flag=false;
  rep(i,k){
    if(b<=a)b*=2;
    else if(c<=b)c*=2;
  }

  if(b>a && c>b)flag=true;

  if(flag)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 3628
N = int( input() )
p = list( map( lambda x: int(x), input().split(" ") ) )

c = 0
for i, v in zip(range(N), p):
    if i+1 != v:
        c+=1

if c == 0 or c == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;





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

    if(n<b){
        cout<<a*n/b<<endl;
    }else{
        cout<<a*(b-1)/b<<endl;
    }
    return 0;
}

Measured memory_bytes: 3172
#include<stdio.h>

int main(void){
    int r, c, tmp;
    scanf("%d%d", &r, &c);
    int sheet[r+1][c+1];
    for(int i=0; i<r; i++) for(int j=0; j<c; j++) scanf("%d", &sheet[i][j]);
    for(int i=0; i<r; i++){
        tmp = 0;
        for(int j=0; j<c; j++) tmp += sheet[i][j];
        sheet[i][c] = tmp;
    }
    for(int j=0; j<c+1; j++){
        tmp = 0;
        for(int i=0; i<r; i++) tmp += sheet[i][j];
        sheet[r][j] = tmp;
    }
    for(int i=0; i<r+1; i++){
        for(int j=0; j<c+1; j++){
            printf("%d", sheet[i][j]);
            if(j<c) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int A,B,C,D;
  int f=0;
  cin >> A >> B >>C >> D;
  while (1)
  {
    C=C-B;
    if (C <= 0)
    {
      f = 1 ;
      break;
    }
    A=A-D;
    if (A <= 0 )
    {
      break;
    }
  }
  if (f == 1)
  {
    cout << "Yes" << endl;
  }
  else
  { 
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
int n;
ll ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		if(n%i==0) ans+=n/i-1;
		else ans+=n/i;
	}
	cout<<ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  N=S.size();
  for(auto v:S){
    if(!num&&v=='T')continue;
    if(v=='S')num++;
    else{
      num--;
      sum++;
    }
  }
  Out(N-2*sum);
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N; cin>>N;
  ll a[N]; CINA(a,N);
  sort(a,a+N);
  ll n = -1;
  ll c = 1;
  ll r = 0;
  REP(i,N){
    if(a[i]!=n){
      r += c%n;
      c = 1;
      n = a[i];
    }else{
      if(c<a[i]){ c++; }
      else{ r++; }
    }
  }
  r += c%n;
  cout << r;
  
}

Measured memory_bytes: 1024
; ABC091-B
; Lisp study
(defun find_item(l k)
  (let ((elem (car l)))
	(if (null elem) (return-from find_item nil))

	(if (equal k (car elem))
	  (return-from find_item elem)
	  (find_item (cdr l) k)
	  )
	)
  )

(defun remove_item_x(l k pl)
  (let ((elem (car l)))
	(if (null elem) (return-from remove_item_x pl))

	(if (equal k (car elem))
	  (return-from remove_item_x (append pl (cdr l)))
	  (remove_item_x (cdr l) k (cons elem pl))
	  )
	)
  )

(defun remove_item(l k)
  (remove_item_x l k '())
  )

(defun update_item(l k v)
  (let ((nl (remove_item l k)))
	(cons (list k v) nl)
	)
  )

(defun make_list(l n)
  (if (<= n 0) (return-from make_list l))
  (let ((k (read-line)))
	(let ((elem (find_item l k)))
	  (setq nl (update_item l k (if (null elem) 1 (+ (car (cdr elem)) 1))))
	  (make_list nl (- n 1))
	  )
	)
  )

(defun compute_list(l n)
  (if (<= n 0) (return-from compute_list l))
  (let ((k (read-line)))
	(let ((elem (find_item l k)))
	  (setq nl
			(if (null elem)
			  l
			  (update_item l k (- (car (cdr elem)) 1))
			  )
			)
	  (compute_list nl (- n 1))
	  )
	)
  )

(defun get_result(l n)
  (let ((elem (car l)))
	(if (null elem) (return-from get_result n))

	(let ((n2 (car (cdr elem))))
	  (if (< n n2) (setq n n2))
	  (get_result (cdr l) n)
	  )
	)
  )

(defun abc091b()
  (setq n (read))
  (setq sl (make_list '() n))
  (setq m (read))
  (setq dl (compute_list sl m))
  (format t "~d~%" (get_result dl 0))
  )

(abc091b)



Measured memory_bytes: 6504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();

		boolean ans = true;

		for (int i = 0; i < a; i++) {
			if(!Character.isDigit(s.charAt(i))) {
				ans = false;
			}
		}
		if(Character.isDigit(s.charAt(a))) {
			ans = false;
		}
		for (int i = a + 1; i < s.length(); i++) {
			if(!Character.isDigit(s.charAt(i))) {
				ans = false;
			}
		}

		if (ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	string s;
	long long n,a,b,ans=0;
	cin >> n;

	cout << (n/2)+(n%2) << endl;

	
}

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

int main() {
  int h,w;
  cin>>h>>w;
  for(int i=0;i<w+2;i++)
  cout<<"#";
  cout<<endl;
  for(int j=0;j<h;j++){
    cout<<"#";
    string a;
    cin>>a;
    cout<<a;
    
    cout<<"#"<<endl;
  }
  for(int i=0;i<w+2;i++)
  cout<<"#";
  cout<<endl;
}


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

int main()
{
    vector<vector<int>> a(3, vector<int> (3));
    rep(i, 3){
        rep(j, 3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n){
        cin >> b[i];
    }
    rep(i, n){
        rep(j, 3){
            rep(k, 3){
                if(a[j][k] == b[i]){
                    a[j][k] = 0;
                }
            }
        }
    }
    int i = 0;
    if(a[i][0] == 0 && a[i+1][0] == 0 && a[i+2][0] == 0){
        cout << "Yes" << endl;
    }
    else if(a[i][1] == 0 && a[i+1][1] == 0 && a[i+2][1] == 0){
        cout << "Yes" << endl;
    }
    else if(a[i][2] == 0 && a[i+1][2] == 0 && a[i+2][2] == 0){
        cout << "Yes" << endl;
    }
    else if(a[0][i] == 0 && a[0][i+1] == 0 && a[0][i+2] == 0){
        cout << "Yes" << endl;
    }
    else if(a[1][i] == 0 &&a[1][i+1] == 0 && a[1][i+2] == 0){
        cout << "Yes" << endl;
    }
    else if(a[2][i] == 0 && a[2][i+1] == 0 && a[2][i+2] == 0){
        cout << "Yes" << endl;
    }
    else if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0){
        cout << "Yes" << endl;
    }
    else if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
object Main{
  def main(args: Array[String]){
    if (sys.env.getOrElse("TEST", "")=="1"){

    }else{
      val input=io.Source.stdin.getLines().mkString("\n");
      println(solve(input).trim());
    }
  }


  def solve(input:String):String={
    input.filter(_ == '1').length.toString
  }
}

Measured memory_bytes: 27328
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int R = int.Parse(Console.ReadLine());
            int G = int.Parse(Console.ReadLine());
            Console.WriteLine(2*G-R);
        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}

Measured memory_bytes: 11092
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N, kazu, K;
int A[18], B[18], onaji[18], MAB[18];
unsigned char dp[36][1 << 18];
int keisan(int b, bool n, int k) {
	if (dp[k][b] != 255) return dp[k][b];
	if (b == (1 << N) - 1) return 0;

	int saishou = 254;
	int num2 = 0;
	int used = 0;
	auto a = n ? B : A;

	rep(i, N) {
		if (!(b >> i & 1)) {
			//if (MAB[i] < k) return dp[k][b] = 254;
			if (A[i] < k && B[i] < k) return dp[k][b] = 254;
			if (a[i] >= k && !(used >> onaji[i] & 1)) {
				chmin(saishou, keisan(b ^ (1 << i), !n, a[i]) + num2);
				used ^= 1 << onaji[i];
			}
			num2++;
		}
	}
	return dp[k][b] = saishou;
}

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


	scanf("%d", &N);
	rep(i, N) {
		if (i & 1) scanf("%d", B + i);
		else scanf("%d", A + i);
	}
	rep(i, N) {
		if (i & 1) scanf("%d", A + i);
		else scanf("%d", B + i);
	}
	rep(i, N) MAB[i] = max(A[i], B[i]);

	rep(i, N) {
		int atta = -1;
		rep(j, i) {
			if (A[i] == A[j] && B[i] == B[j]) {
				atta = j;
				break;
			}
		}
		if (atta != -1) onaji[i] = onaji[atta];
		else onaji[i] = kazu++;
	}

	pair<int, int> kari[36];
	rep(i, N) kari[i] = mp(A[i], i);
	rep(i, N) kari[i + N] = mp(B[i], i + N);
	sort(kari, kari + N * 2);
	int mae = kari[0].first;
	rep(i, N * 2) {
		if (mae != kari[i].first) K++;
		mae = kari[i].first;
		if (kari[i].second < N) A[kari[i].second] = K;
		else B[kari[i].second - N] = K;
	}
	memset(dp[0], 255, (K + 1) * (1 << 18));

	int kotae = keisan(0, 0, 0);
	if (kotae == 254) printf("-1\n");
	else printf("%d\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int b[n],f[n],r[n],v[n];
    int number[120];
    for (int i=0; i<120; i++) {
        number[i]=0;
    }
    
    for (int i=0; i<n; i++) {
        cin >> b[i] >> f[i] >> r[i] >> v[i];
        number[(b[i]-1)*30+(f[i]-1)*10+(r[i]-1)]=number[(b[i]-1)*30+(f[i]-1)*10+(r[i]-1)]+v[i];
    }
    for (int i=0; i<120; i++) {
        cout << ' ' <<number[i];
        if((i+1)%10 ==0)cout << endl;
        if((i+1)%30 == 0 && i<119){
            for (int j=0; j<20; j++) {
                cout << '#';
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
    char S[20],W[10],s[10],X,Y;
   scanf("%c",&X);
   if((X=='a')||(X=='i')||(X=='u')||(X=='e')||(X=='o')){
       printf("vowel");
   }else{
       printf("consonant");
   }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
        int out = 1;
        int answer = 0;

        while(out < b){
            out--;
            out += a;
            answer++;
        }

        System.out.println(answer);

    }

}


Measured memory_bytes: 21076
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int D = int.Parse(input[1]);
        int d = D * 2 + 1;
        if(N % d == 0)
        {
            Console.WriteLine(N / d);
        }
        else
        {
            Console.WriteLine(N / d + 1);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,l,a,j,i,b,s,p;
	while(~scanf("%d",&n))
	{   int a[n];
	     int b[n];
	      p=0;
	      s=0;
		 for(i=0;i<n;i++)
		 {
		 scanf("%d",&a[i]);
		 b[i]=a[i];}
		 sort(a,a+n);
		 for(i=0;i<n;i++)
		 {
		
		 {   
		 	if(b[i]!=a[n-1])
		 	{
			 printf("%d ",a[n-1]);}
		 	else
		 	{	
			 printf("%d ",a[n-2]);}
		 }
	
	 
}}}

Measured memory_bytes: 3200
n,m = map(int, input().split())
a = sorted(list(map(int,input().split())))
d = [list(map(int, input().split())) for _ in range(m)]
d.sort(key=lambda x:(-x[1]))
e = []
for b,c in d:
    e += [c]*b
    if len(e) >= n:
        break
e = sorted(e)[::-1]
ans = 0
j = 0
for i in range(n):
    if j < len(e):
        if a[i] >= e[j]:
            ans += a[i]
        else:
            ans += e[j]
            j += 1
    else:
        ans += a[i]
print(ans)


Measured memory_bytes: 36060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    cout << max(a1,max(a2,a3))-min(a1,min(a2,a3)) << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define LL long long
#define mp make_pair
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair < int , int >

int n;
long double X[1005], Y[1005];
vector < int > Z;

long double dist( long double x, long double y ){
	x *= x;
	y *= y;
	return sqrt(x+y);
}

bool cmpx( int a, int b ){
	if ( X[a] == X[b] ) return Y[a] > Y[b];
	return X[a] > X[b];
}

bool cmpx1( int a, int b ){
	if ( X[a] == X[b] ) return Y[a] > Y[b];
	return X[a] < X[b];
}

bool cmpx2( int a, int b ){
	if ( X[a] == X[b] ) return Y[a] < Y[b];
	return X[a] > X[b];
}

bool cmpx3( int a, int b ){
	if ( X[a] == X[b] ) return Y[a] < Y[b];
	return X[a] < X[b];
}

bool cmpy( int a, int b ){
	if ( Y[a] == Y[b] ) return X[a] > X[b];
	return Y[a] > Y[b];
}

bool cmpy1( int a, int b ){
	if ( Y[a] == Y[b] ) return X[a] > X[b];
	return Y[a] < Y[b];
}

bool cmpy2( int a, int b ){
	if ( Y[a] == Y[b] ) return X[a] < X[b];
	return Y[a] > Y[b];
}

bool cmpy3( int a, int b ){
	if ( Y[a] == Y[b] ) return X[a] < X[b];
	return Y[a] < Y[b];
}

long double solve(){
	long double ans = 0;
	long double x = 0, y = 0;
	for ( int i = 0; i < n; i++ ){
		int id = Z[i];
		if ( dist(x,y) < dist(x+X[id],y+Y[id]) ){
			x += X[id];
			y += Y[id];
		}
	}
	return dist(x,y);
}

int main(){

	scanf("%d",&n);
	for ( int i = 0; i < n; i++ ) scanf("%Lf%Lf",&X[i],&Y[i]);
	for ( int i = 0; i < n; i++ ) Z.push_back(i);
	long double ans = 0;

	sort(Z.begin(),Z.end(),cmpx);
	ans = max( ans, solve() );

	sort(Z.begin(),Z.end(),cmpx1);
	ans = max( ans, solve() );

	sort(Z.begin(),Z.end(),cmpx2);
	ans = max( ans, solve() );

	sort(Z.begin(),Z.end(),cmpx3);
	ans = max( ans, solve() );

	sort(Z.begin(),Z.end(),cmpy);
	ans = max( ans, solve() );

	sort(Z.begin(),Z.end(),cmpy1);
	ans = max( ans, solve() );

	sort(Z.begin(),Z.end(),cmpy2);
	ans = max( ans, solve() );

	sort(Z.begin(),Z.end(),cmpy3);
	ans = max( ans, solve() );

	for ( int i = 0; i < 100000; i++ ){
		random_shuffle(Z.begin(),Z.end());
		ans = max( ans, solve() );
	}

	printf("%.15Lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    rep(i, n) {
        if ( i == 0 ) {
            ans = k;
        }
        else {
            ans *= ( k - 1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def get_par(x):
  if x == par_list[x]:
    return x
  else:
    par_list[x] = get_par(par_list[x])
    return par_list[x]

def merge(x,y):
  par_x = get_par(x)
  par_y = get_par(y)
  if par_x != par_y:
    par_list[par_y] = par_x

def is_same(x,y):
  return get_par(x) == get_par(y)

N=int(input())
if N<=2:
  print(1)
  sys.exit(0)

xylist=[]
for i in range(N):
  x,y=map(int,input().split())
  xylist.append((x,y))
xylist.sort()
#print(xylist)

pqset=set()
for i in range(N):
  x1,y1=xylist[i]
  for j in range(i+1,N):
    x2,y2=xylist[j]
    p=x2-x1
    q=y2-y1
    pqset.add((p,q))
#print(len(pqset))
    
answer=50
for p,q in pqset:
  par_list=list(range(N))
  for i in range(N):
    x1,y1=xylist[i]
    for j in range(i+1,N):
      x2,y2=xylist[j]
      if p==x2-x1 and q==y2-y1:
        merge(i,j)
        
  comp_set=set()
  for i in range(N):
    comp_set.add(get_par(i))
  answer=min(answer,len(comp_set))
    
print(answer)

Measured memory_bytes: 3188
def heapify(A, i):
    right_i = (i+1)*2-1
    left_i = (i+1)*2
    if right_i  > len(A)-1:
        return
    if left_i > len(A)-1:
        if A[right_i] > A[i] :
            A[right_i], A[i] = A[i], A[right_i ]
        return
    if A[i] < A[right_i] and A[left_i] < A[right_i ]:
        A[right_i ], A[i] = A[i], A[right_i ]     
        heapify(A, right_i )
    if A[i] < A[left_i] and A[right_i] < A[left_i]:
        A[left_i ], A[i] = A[i], A[left_i ]     
        heapify(A, left_i)

def build_heap(A):
    for i in reversed(range(len(A)//2)):
        heapify(A, i)

input()    
input_list = list(map(int, input().split()))
build_heap(input_list)

output = ""
for i in input_list:
    output += " " + str(i)
print(output)


Measured memory_bytes: 63668
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int popcount(int n){
    n = (n & 0x55555555) + (n >> 1 & 0x55555555);
    n = (n & 0x33333333) + (n >> 2 & 0x33333333);
    n = (n & 0x0f0f0f0f) + (n >> 4 & 0x0f0f0f0f);
    n = (n & 0x00ff00ff) + (n >> 8 & 0x00ff00ff);
    return (n & 0x0000ffff) + (n >>16 & 0x0000ffff);
}

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

	// dp[i][j]: iの組み合わせで選んで、最後がjのときの最小コスト
	vector<vector<int>> dp(1<<n, vector<int>(n, inf));
	for(int i=0; i<n; i++){
		dp[1<<i][i] = i;
	}
	for(int i=1; i<(1<<n); i++){
		int count = popcount(i);
		for(int j=0; j<n; j++){
			if(!(i>>j&1)) continue;
			if(dp[i][j] == inf) continue;
			//cout << i << " " << j << endl;
			int last = ((count-1-j)%2==0)? a[j]: b[j];
			for(int k=0; k<n; k++){
				if(i>>k&1) continue;
				//cout << i << " " << j << " " << k << endl;
				int newlast = ((count-k)%2==0)? a[k]: b[k];
				//cout << "last " << last << " " << newlast << endl;
				if(newlast < last) continue;
				int smallcount = 0;
				for(int l=0; l<k; l++){
					if(i>>l&1) smallcount++;
				}
				int cost = max(k-smallcount, 0);
				int newset = i|(1<<k);
				dp[newset][k] = min(dp[newset][k], dp[i][j]+cost);
			}
		}
	}
	/*
	for(int i=0; i<(1<<n); i++){
		cout << "i= " << i << endl;
		for(int j=0; j<n; j++){
			cout << dp[i][j] << endl;
		}
	}
	*/
	int ans = *min_element(dp[(1<<n)-1].begin(), dp[(1<<n)-1].end());
	if(ans == inf) ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  double v[n];
  for(i=0;i<n;i++)cin>>v[i];
  sort(v,v+n);
  double sum=(v[0]+v[1])/2;
  for(i=2;i<n;i++){
    sum=(sum+v[i])/2;
  }
  printf("%.7lf",sum);
}

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

const int MAX = 10000000;
//何で割るのか
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  // 前処理
  COMinit();
  int n,m;cin >> n >> m;
  if(n-m==1 or n-m==-1){
    cout << ((fac[n]%MOD)*fac[m])%MOD << endl;
  }else if(n==m){
    cout << (((fac[n]%MOD)*fac[m])%MOD*2)%MOD << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 234624
N, X, Y = map(int, input().split())

anss = [0] * N
for a in range(1, N+1):
    for b in range(a+1, N+1):
        d1 = b-a
        d2 = abs(X-a) + 1 + abs(Y-b)
        d = d1 if d1 <= d2 else d2
        anss[d] += 1

print('\n'.join(map(str, anss[1:])))


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

bool Check(int N, int A, int B, int C, int D, string S){
  A = A - 1;
  B = B - 1;
  C = C - 1;
  D = D - 1;
  
  if(C < D){
    for(int i = B; i < D - 1; i++){
      if(S.at(i) == '#' && S.at(i + 1) == '#') return false;
    }
    for(int i = A; i < C - 1; i++){
      if(S.at(i) == '#' && S.at(i + 1) == '#') return false;
    }
    return true;
  }
  else{
    while(true){
      if(S.at(B - 1) == '.' && S.at(B + 1) == '.'){
    	for(int i = A; i < C - 1; i++){
      	  if(S.at(i) == '#' && S.at(i + 1) == '#') return false;
    	}
        return true;
      }else if(B == D) return false;
      
      int temp_B = B;
      if(S.at(B + 1) == '.') temp_B = B + 1;
      else if(B + 2 < N && S.at(B + 2) == '.') temp_B = B + 2;
      
      if(temp_B == B) return false;
      if(temp_B > D) return false;
      B = temp_B;
    }
  }
}

int main(){
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D;
  cin >> S;
  if(Check(N, A, B, C, D, S)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 772