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

int main(void){
  int n; cin >> n;
  while(n--){
    string order, message;
    cin >> order >> message;
    reverse(order.begin(), order.end());
    for(int pos = 0; pos < order.length(); pos++){
      int len = message.length();
      if(order[pos]  == 'C'){
        char c = message[0];
        for(int i=0; i < len-1; i++){
          message[i] = message[i+1];
        }
        message[len-1] = c;
      }
      if(order[pos]  == 'J'){
        char c = message[len-1];
        for(int i=len-1; i >= 1; i--){
          message[i] = message[i-1];
        }
        message[0] = c;
      }
      if(order[pos]  == 'E'){
        if(len % 2 == 0){
          message = message.substr(len/2, len/2) + message.substr(0, len/2);
        }else{
          message = message.substr(len/2 + 1, len/2) + message.substr(len/2, 1) + message.substr(0, len/2);
        }
      }
      if(order[pos]  == 'A'){
        reverse(message.begin(), message.end());
      }
      if(order[pos]  == 'M'){
        for(int i = 0; i < len; i++){
          if(isdigit(message[i])){
            if(message[i] - '0' == 9) message[i] = '0';
            else{
              message[i] = message[i] - '0' + 1 + '0';
            }
          }
        }
      }
      if(order[pos]  == 'P'){
        for(int i = 0; i < len; i++){
          if(isdigit(message[i])){
            if(message[i] - '0' == 0) message[i] = '9';
            else{
              message[i] = message[i] - '0' - 1 + '0';
            }
          }
        }
      }
    }
    cout << message << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<cstdio>

int main(void){
  int x=-1,y=-1,z=-1;
  int n,m;

  scanf("%d %d",&n,&m);

  for(int i=0;i<=n;i++){
    for(int j=0;i+j<=n;j++){
      int k = n-i-j;
      if(i*10000+j*5000+k*1000==m){
        x=i; y=j; z=k;
        goto ABC;
      }
    }
  }
  ABC:
  printf("%d %d %d\n",x,y,z);


  return 0;
}


Measured memory_bytes: 128
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

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

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int a, b;
	int ans = 0;
	int outlet = 1;

	cin >> a >> b;
	while (outlet < b) {
		outlet += (a - 1);
		++ans;
	}
	OUT(ans) BR;
	RET;
}


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


def f(b):
    l=[]
    n=0
    while not 2**n<=b<2**(n+1):
        n+=1

    for i in range(n):
        if (b-2**n)>(2**i-1):
            if ((b-2**n-(2**i-1))//2**i)//2==((b-2**n-(2**i-1))//2**i)/2:
                l.append((((b-2**n-(2**i-1))//2**i)//2)*(2**i)+((b-2**n-(2**i-1))%(2**i)))

            else:
                l.append(((((b-2**n-(2**i-1))//2**i)//2)+1)*(2**i))

        else:
            l.append(0)
            
    l.append((b-2**n)+1)
    for i in range(n):
        l[i]=l[i]+2**(n-1)

    return (l)

l=[]
m=0
if a>0 and b>0:
    c=f(a-1)
    d=f(b)
    for i in range(len(d)-len(c)):
        c.append(0)

    for i in range(len(d)):
        l.append(d[i]-c[i])
elif a==0 and b>0:
    l=f(b)
else:
    l=[]
    m=0


    
for i in range(len(l)):
    if not l[i]//2==l[i]/2:
        m+=2**i
print(m)
        


    




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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int IINF = 2002002002;
constexpr ll LINF = 9009009009009009009LL;

//===




int main()
{
	int N, M;
	cin >> N >> M;
	vector<Pii> yp(M);
	map<Pii, int> midx;
	for (int i = 0; i < M; ++i) {
		cin >> yp[i].second >> yp[i].first;
		--yp[i].second;
		midx[yp[i]] = i;
	}
	sort(yp.begin(), yp.end());

	Vi pnum(N);
	Vi ord(M);
	for (int i = 0; i < M; ++i) {
		ord[i] = ++pnum[yp[i].second];
	}

	vector<string> ans(M);
	for (int i = 0; i < M; ++i) {
		int idx = midx[yp[i]];
		stringstream ss1, ss2;
		ss1.fill('0');
		ss2.fill('0');
		ss1 << setw(6) << yp[i].second + 1;
		ss2 << setw(6) << ord[i];
		ans[idx] = ss1.str() + ss2.str();
	}

	for (int i = 0; i < M; ++i) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  for(int i = N/2-1; i >= 1; i--){
    bool flag = true;
    for(int j = 0; j < i; j++){
      if(S[j] != S[i+j]){
        flag = false;
      }
    }
    if(flag){
      cout << i * 2 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, a, r int
	fmt.Scan(&N)
	m := map[int]int{}
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		m[a]++
	}
	for _, v := range m {
		if v%2 != 0 {
			r++
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 8064
import numpy as np
from itertools import product

N, M = map(int, input().split())
switch = []

for i in range(M):
    switch.append(list(map(int, input().split()))[1:])

p = list(map(int, input().split()))

st = list(product([0,1],repeat=N))

ans = 0

for i, s in enumerate(st):
    tmp = []
    for j, sw in enumerate(switch):
        on = 0
        for x in sw:
            on += s[x-1]
        if (on%2)==p[j]:
            tmp.append(True)
        else:
            tmp.append(False)
    if all(tmp)==True:
        ans += 1

print(ans)

Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

// 素因数を index で表現。N の数が大きいとダメ
template <class T> vector<T> factring_vector(T N) {
    vector<T> ans(N + 1);
    T now = N;
    while (now != 0) {
        long long i = 2;
        while (i * i <= N) {
            if (N % i == 0) {
                ans[i]++;
                N /= i;
            } else {
                i++;
            }
        }
        ans[N]++;
        now--;
        N = now;
    }
    ans[1] = 0;
    return ans;
}

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

    int N;
    cin >> N;

    auto fac = factring_vector(N);

    int ans = 0, cnt = 0;
    REP(i, N + 1) {
        if (74 <= fac[i])
            ans++;
        REP(j, N + 1) {
            if (i == j)
                continue;
            if (14 <= fac[i] && 4 <= fac[j])
                ans++;
            if (24 <= fac[i] && 2 <= fac[j])
                ans++;
            REP(k, N + 1) {
                if (i == k || j == k)
                    continue;
                if (4 <= fac[i] && 4 <= fac[j] && 2 <= fac[k]) {
                    ans++;
                    cnt++;
                }
            }
        }
    }

    std::cout << ans - cnt / 2 << '\n';

    return 0;
}

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

using namespace std;

const int N = 3005;
const int MOD = 1e9 + 7;

char s[N];
int n, f[N][N], sum[N][N];

int main() {
  scanf("%d %s", &n, s + 2);
  f[1][1] = sum[1][1] = 1;
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= i; ++j) {
      if (s[i] == '>') {
        f[i][j] = sum[i - 1][i - 1] - sum[i - 1][j - 1];
        if (f[i][j] < 0) f[i][j] += MOD;
      } else {
        f[i][j] = sum[i - 1][j - 1];
      }
      sum[i][j] = sum[i][j - 1] + f[i][j];
      if (sum[i][j] >= MOD) sum[i][j] -= MOD;
    }
  }
  cout << sum[n][n] << endl;
  return 0;
}



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

bool is_prime[10000000] = {};
vector<int> get_prime() {
    for (int i = 2; i < 10000000; i++)
        is_prime[i] = true;

    for (int i = 2; i * i < 10000000; i++) {
        if (!is_prime[i]) continue;
        for(int j = i * 2; j < 10000000; j += i)
            is_prime[j] = false;
    }

    vector<int> prime_list;
    for (int i = 0; i < 10000000; i++)
        if (is_prime[i]) prime_list.push_back(i);
    return prime_list;
}

int main() {
    auto prime_list = get_prime();

    int n, p;
    while (cin >> n >> p, p > 0) {
        vector<int> x;
        for (int i = 0; i < prime_list.size() && x.size() <= p; i++) {
            if (prime_list[i] > n) {
                x.push_back(prime_list[i]);
            }
        }

        vector<int> cand;
        for (int i = 0; i < x.size(); i++)
            for (int j = i; j < x.size(); j++) {
            cand.push_back(x[i] + x[j]);
        }
        sort(cand.begin(), cand.end());
        cout << cand[p - 1] << endl;
    }
}



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

const int MAXN = 51;

int64_t height[MAXN], patties[MAXN]; // spondge bob can go fuck himself with his shitty crabby patties

void precalc () {
    height[0] = patties[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        height[i] = 2 * height[i - 1] + 3;
        patties[i] = 2 * patties[i - 1] + 1;
    }
}

signed main () {
    precalc();
    
    int64_t n, x;
    cin >> n >> x;
    int64_t ans = 0;
    for (int64_t j = n; j >= 0 && (x > 0); --j) {
        if (height[j] <= x) {
            ans += patties[j];
            x -= height[j];
            if (x) {
                ++ans;
                --x;
            }
            if (x >= height[j] - j) {
                ans += patties[j];
                x = 0;
            }
        }
        --x;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <algorithm>
#include <sstream>
#include <set>
#include <math.h>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>
 
using namespace std;
 
typedef unsigned long long ll;
 
int N,NP;
 
ll S[100000];
ll prime[100000];
bool is_prime[100001];
 
map <ll, ll> mp;
map <ll,ll>::iterator it;
set <ll> st;
 
int sieve(int n){
  int p=0;
  for(int i=0; i<=n; i++) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2; i<=n; i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i; j<=n; j+=i) is_prime[j]=false;
    }
  }
  return p;
}
 
ll dv(ll x){
 
  for(int i=0; i<NP; i++){
 
    ll q=prime[i]; if(q>1000) break;
    ll t=q*q*q;
    if(t>x) break;
    while(x%t==0) x/=t;
 
  }
 
  return x;
 
}
 
ll tp(ll x){
 
  ll y=x*x; //cout<<y<<endl;
 
  for(int i=0; i<NP; i++){
 
    ll q=prime[i]; if(q>1000) break;
    ll t=q*q*q;
 
    if(t>y) break;
 
    while(y%t==0) y/=t;
 
  }
 
  return y;
 
}
 
int main(){
 
 scanf("%d",&N);
 
 NP=sieve(100000);
 
 for(int i=0; i<N; i++){
 
  scanf("%lld",&S[i]);
  ll x=dv(S[i]);
  mp[x]++;
  
 }
 
 int ans=0;
  
 for(it=mp.begin();it!=mp.end();it++){
 
  ll x=it->first; //cout<<x<<endl;
  ll y=tp(x);
 
  if(st.count(x)) continue;
 
  if(x!=1) ans+=max(mp[x],mp[y]);
  else ans++;
 
  st.insert(y);
 
 }
  
  cout<<ans<<endl;
 
 return 0;
 
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i(0);i<n;i++)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(), v.end()

int maxi(int a, int b, int c){
	return max(a, max(b,c));
}
/*int dp(int a[][],int n){
	dp[n][3];
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];

	rep(i,n){
		rep(j,3){
			int ans=-1;
			rep(k,3){
				if(j!=k){
					ans = max(ans, dp[i-1][k]);
				}
			}
			dp[i][j] = ans + a[i][j];
		}
	}
	return maxi(dp[n-1][0], dp[n-1][1], dp[n-1][2]);

}*/

int32_t main() {
    fast;
    
    
	int n;
	cin>>n;
	int a[n+5][3];
	rep(i,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
	int dp[n+5][3];
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];

	/*rep(i,n){
		rep(j,3){
			int ans=-1;
			rep(k,3){
				if(j!=k){
					ans = max(ans, dp[i-1][k]);
				}
			}
			dp[i][j] = ans + a[i][j];
		}
	}*/
	for(int i = 1;i<n;i++){
        for(int j = 0;j<3;j++){
            long long ans = -1;
            for(int k = 0;k<3;k++){
                if(j!=k){
                    ans = max(ans, dp[i-1][k]);
                }
            }
            dp[i][j] = ans + a[i][j];
        }
    }
	cout<<maxi(dp[n-1][0], dp[n-1][1], dp[n-1][2]);
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <set>

using namespace std;

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

    set<string> st;
    for(int i=0; i<s.size(); i++) {
        for(int j=1; j<min((int)s.size()-i+1, K+1); j++) {
            st.insert(s.substr(i, j));
        }
    }

    for(int i=0; i<K-1; i++) {
        st.erase(st.begin());
    }

    cout << *st.begin() << endl;
    return 0;
}


Measured memory_bytes: 1664
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.ByteString.Char8 as B
import Data.Char
import Control.Monad

put :: Int -> IO ()
put s = Prelude.putStr $ show s ++ " "

solve vec n 
    | even n = do
        VU.forM_ (VU.reverse $ VU.fromList [1,3..n-1]) $ \i -> VUM.read vec i >>= put
        VU.forM_ (VU.fromList [0,2..n-2]) $ \i -> VUM.read vec i >>= put
        Prelude.putStrLn ""
    | otherwise = do
        VU.forM_ (VU.reverse $ VU.fromList [0,2..n-1]) $ \i -> VUM.read vec i >>= put
        VU.forM_ (VU.fromList [1,3..n-2]) $ \i -> VUM.read vec i >>= put
        Prelude.putStrLn ""

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    xs' <- VU.unsafeThaw xs
    solve xs' n

Measured memory_bytes: 11516
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;

int N;

int main(){
	int res = 0;
	int cnt1 = 0, cnt2 = 0, cnt3 = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		string s;
		cin >> s;
		if(s[0] == 'B' && s[s.length() - 1] == 'A') cnt3++;
		else if(s[0] == 'B') cnt2++;
		else if(s[s.length() - 1] == 'A') cnt1++;
		for(int j = 0; j < s.length(); j++){
			if(s.substr(j, 2) == "AB") res++;
		}
	}
	res += max(cnt3 - 1, 0);
	if(cnt3 != 0){
		if(cnt1 >= 1){
			cnt1--;
			res++;
		}
		if(cnt2 >= 1){
			cnt2--;
			res++;
		}
	}
	cout << res + min(cnt1, cnt2) << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<char> s(4);
  for(int i=0;i<4;i++){
    cin>>s[i];
  }
  int x=0;
  for(int i=0;i<4;i++){
    if(s[i]=='+'){
      x++;
    }
    else{
      x--;
    }
  }
  cout<<x;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A=[]
for i in range(N):
    A.append(list(map(int,input().split())))


cnt =0
for a in A:
    c = 0
    for j in range(len(a)):
        c += a[j]*B[j]
    if c+C > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
// Aizu 1194: Vampire
// 2017.9.14 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define EPS 1e-7
#define INF 4096
#define BASE 30
int hi[60];
int r;

double tim(int x, int h)
{
	x -= BASE; if (x < 0) x++;
	if (x > r || x < -r) return INF;  
	return h+r-sqrt((double)(r*r-x*x));
}

int main()
{
	int n, x, x1, x2, h;
	double min, t;

	while (scanf("%d%d", &r, &n) && r) {
		memset(hi, 0, sizeof(hi));
		while (n-- > 0) {
			scanf("%d%d%d", &x1, &x2, &h); x1 += BASE, x2 += BASE;
			for (x = x1; x < x2; x++) if (hi[x] < h) hi[x] = h;
		}
		min = INF;
		for (x = BASE-r; x < BASE+r; x++) {
			t = tim(x, hi[x]);
			if (fabs(t) <= EPS) { min = 0; break; }
			if (min-t > EPS || t <= min) min = t;
		}
		printf("%.4lf\n", min);
	}
	return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>
#define PI  2*acos(0.0)
#define pb push_back

       
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;

//long long a[99999999];
//long long b[99999999];

int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);

ll n;
cin>>n;
ll k,ans=0;
for(int i=1;i<=n;i++)
{
	k=n/i;
	ans+=i*k*(k+1) / 2;
}

cout<<ans<<"\n";











	
	
	return 0;
	
	
	       /***Israil Hosen
	            Computer Science & Engineering
	         University Of Rajshahi.
	         ***/
	
	
	
}

Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <vector>

int main() {
  std::string S;
  std::cin >> S;

  std::vector<long long> key_pos_array;
  const std::string key = "RL";
  std::string::size_type pos = S.find(key);
  while (pos != std::string::npos) {
    key_pos_array.push_back(pos);
    pos = S.find(key, pos + key.length());
  }

  std::vector<long long> key_2_pos_array;
  key_2_pos_array.push_back(-1);
  const std::string key_2 = "LR";
  std::string::size_type pos_2 = S.find(key_2);
  while (pos_2 != std::string::npos) {
    key_2_pos_array.push_back(pos_2);
    pos_2 = S.find(key_2, pos_2 + key_2.length());
  }

  for (unsigned int i = 0; i < key_pos_array.size(); ++i) {
    const unsigned int num_R = key_pos_array.at(i) - key_2_pos_array.at(i);
    unsigned int num_L;
    if (i + 1 != key_pos_array.size()) {
      num_L = key_2_pos_array.at(i + 1) - key_pos_array.at(i);
    } else {
      num_L = (S.length() - 1) - key_pos_array.at(i);
    }

    const unsigned int count_R_pos = num_R / 2 + num_R % 2 + num_L / 2;
    const unsigned int count_L_pos = num_R / 2 + num_L / 2 + num_L % 2;
    for (unsigned int j = 1; j < num_R; ++j) {
      std::cout << "0 ";
    }
    std::cout << count_R_pos << " " << count_L_pos << " ";
    for (unsigned int j = 1; j < num_L; ++j) {
      if ((i + 1 != key_pos_array.size()) || (j + 1 != num_L)) {
        std::cout << "0 ";
      } else {
        std::cout << "0";
      }
    }
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 1592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob
int n,a[maxn],ans=0;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep(n) cin >> a[i];
    sort(a,a+n);
    reverse(a,a+n);
    rep(n-1) ans+=a[i+1>>1];
    print1(ans);
    return 0;
}


Measured memory_bytes: 5116
#include <bits/stdc++.h>   
using namespace std;
#define N 3005   
#define REP(i, n) for(int i=0; i<n; i++)
int n,y;
int ans[3];
int exist=0;
int main(){
 scanf("%d%d",&n,&y);
 
 for(int i=0;i<=n;i++){
     for(int j=0;j<=n-i;j++){
         int k=n-i-j;
         int money=i*10000+j*5000+k*1000;
         if(money==y){
             ans[0]=i;
             ans[1]=j;
             ans[2]=k;
             exist=1;
         }
     }
 }
 if(exist==1){
 printf("%d %d %d",ans[0],ans[1],ans[2]);
 }else{
 printf("-1 -1 -1");
 }
}





Measured memory_bytes: 256
var i,j,f:Longint;s:String;
begin
	readln(s);
	for i:=1 to length(s) do begin
		for j:=i+1 to length(s) do begin
			if s[i]=s[j] then f:=1;
		end;
	end;
	if f>0 then writeln('no')else writeln('yes')
end.


Measured memory_bytes: 128
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m=MI()
print((1800*m+100*n)*(2**m))

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int[] p = new int[sc.nextInt()];

    for(int pIdx=0;pIdx<p.length;pIdx++){
      p[pIdx]=sc.nextInt();
    }

    int count=0;
    for(int pIdx = 1;pIdx<p.length-1;pIdx++){
      if(isMatch(p[pIdx-1],p[pIdx],p[pIdx+1]))count++;
    }
    System.out.println(count);
  }

  static boolean isMatch(int pm1, int p0, int pp1) {
    if(p0 < pm1 && p0 < pp1) return false;
    return !(p0 > pm1 && p0 > pp1);
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
using namespace std;



int main()
{
    //int m,n,o=0,i,j,k;
    int sum=0,range=0;
    long long int m,n,o,i,j,k=0;
    long long int q,h,s,d,a1,a2,a3;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    //string a;
    cin>>q>>h>>s>>d>>n;
    if(q*2<=h&&q*4<=s)
    {
        m=q;
        i=1;
        a1=m*4*n;
    }
    else if(q*2>=h&&h*2<=s)
    {
        m=h;
        i=2;
        a1=m*2*n;
    }
    else if(q*4>=s&&h*2>=s)
    {
        m=s;
        i=3;
        a1=m*n;
    }
    a3=n/2*d;
    if(n%2!=0)
    {
        if(i==1) a3+=4*m;
        else if(i==2) a3+=2*m;
        else a3+=m;
    }
    cout<<min(a1,a3);
    return 0;
}





Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a[100],sum,b[100],mn,mi,x,i;
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&a[i]);
		sum+=a[i];
		b[i]=a[i]*n;
	}
	mn=sum;
	for(i=0;i<n;i++)	{
		x=sum-b[i];
		if(x<0)	x=-x;
		if(mn>x)	{
			mn=x;
			mi=i;
		}
	}
	printf("%d\n",mi);
	return 0;
}

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

int main() {
  int a,b,cnt=0;
  int i0,i1,i3,i4,tmp;
  cin >> a >>b;
  for (int i = a; i <= b; i++)
  { tmp=i;
      i0=tmp%10;
      tmp/=10;
      i1=tmp%10;
      tmp/=100;
      i3=tmp%10;
      tmp/=10;
      i4=tmp;
      if(i0==i4 && i1==i3){
          cnt++;
      }
  }
  cout<<cnt<<endl; 
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

int main() {
  int x, y;
  cin >> x >> y;
  if (4 * x == y) {
    cout << "Yes" << endl;
    return 0;
  } else if (4 * x > y) {
    int diff = (4 * x - y) / 2;
    x -= diff;
    if (x < 0 || diff < 0) {
    } else if (4 * x + 2 * diff == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

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

    S[0] = '2';
    S[1] = '0';
    S[2] = '1';
    S[3] = '8';

    cout <<S << endl;

    return 0;
}


Measured memory_bytes: 256
// you should probably see at the bottom ..
#include<bits/stdc++.h>

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(1e3 + 10)
#define ff first
#define ss second

using namespace std;

vector<vector<int>> dir{{1,  0},
	{0,  1},
	{0,  -1},
	{ -1, 0}};
int n, m;
vector<string> grid(N);
vector<vector<int>> dist(N, vector<int>(N, inf));
deque<pair<int, int>> q;

bool isOk(int ni, int nj) {
	return (ni >= 0 and nj >= 0 and ni < n and nj < m and grid[ni][nj] == '.');
}

void solve() {
	int si, sj, ei, ej;
	cin >> n >> m;
	cin >> si >> sj >> ei >> ej;
	si--, sj--, ei--, ej--;
	for (int i = 0; i < n; i++)
		cin >> grid[i];

	dist[ei][ej] = 0;
	q.push_back({ei, ej});

	while (!q.empty()) {
		int i = q.front().ff, j = q.front().ss;
		q.pop_front();
		// dbg(i, j);

		// moves without using magic spell
		for (vector<int> &d : dir) {
			int ni = i + d[0], nj = j + d[1];
			if (isOk(ni, nj) and dist[ni][nj] > dist[i][j]) {
				dist[ni][nj] = dist[i][j];
				q.push_front({ni, nj});
			}
		}

		// moves with using magic spell
		for (int ni = i - 2; ni <= i + 2; ni++) {
			for (int nj = j - 2; nj <= j + 2; nj++) {
				if (isOk(ni, nj) and dist[ni][nj] > dist[i][j] + 1) {
					// dbg(ni, nj, dist[i][j] + 1);
					dist[ni][nj] = dist[i][j] + 1;
					q.push_back({ni, nj});
				}
			}
		}
	}

	int ans = dist[si][sj] == inf ? -1 : dist[si][sj];
	cout << ans << endl;

}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

/*
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


Measured memory_bytes: 12896
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  string S;
  string amari ="2018";
  cin >> S;
  rep_s(i, 4, S.length()) amari += S[i];
  cout << amari << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define mp make_pair
using namespace std;
typedef map<pair<int,int>,int> S;
int main(){
	int n,t1,t2; char c;
	while(cin>>n,n){
		S s;
		rep(i,n){
			cin>>c;
			if(c=='W'){
				cin>>t1>>t2;
				int p=0,q;
				if(s.empty())s.insert(mp(mp(0,t2),t1)),t2=0;
				else{
					foreach(j,s){
						if(j->first.first>p){
							q=min(p+t2,j->first.first);
							s.insert(mp(mp(p,q),t1));
							t2-=q-p; p=q;
							j--;
						}else p=j->first.second;
						if(t2==0)break;
					}
					if(t2>0)s.insert(mp(mp(p,p+t2),t1));
				}
			}else if(c=='D'){
				cin>>t1;
				foreach(j,s)if(j->second==t1)s.erase(j);
			}else{
				cin>>t1;
				foreach(j,s)if(j->first.first<=t1&&t1<j->first.second){
					cout<<j->second<<endl; goto END;
				}
				cout<<-1<<endl; END:;
			}
		}
		cout<<endl;
	}
	return 0;
}

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


int solve() {
		
}

int main() {
	int n,command, comnum;
	vector<int> vec;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> command;
		switch (command) {
			case 0:
				cin >> comnum;
				vec.push_back(comnum);
				break;
			case 1:
				cin >> comnum;
				cout << vec.at(comnum) << endl;
				break;
			case 2:
				vec.pop_back();
				break;
		}
	}
}



Measured memory_bytes: 3904
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(M,0);
    vector<ll> B(M,0);
    for(ll i=0;i<M;i++)cin>>A[i]>>B[i];
    priority_queue<P, vector<P>, greater<P>> pq;
    for(ll i=0;i<M;i++)pq.emplace(P(B[i],A[i]));
    vector<ll> check(N,0);//check[i]はiとi+1間について
    ll ans=0;
    ll last=-INF;
    while(!pq.empty()){
        P y=pq.top();
        pq.pop();
        if(last<y.second){
            ans++;
            last=y.first-1;
        }
    }
    print(ans)

    return 0;
}

Measured memory_bytes: 4208
class Book < Array
  def initialize
    super
  end

  def sort_by_city!
    self.sort! { |a, b| (a.city <=> b.city).nonzero? || b.rate <=> a.rate }
  end
end

class Restaurant
  attr_reader :city, :rate, :original_number

  def initialize(city, rate, original_number)
    @city = city
    @rate = rate
    @original_number = original_number
  end
end

n = gets.chomp.to_i
book = Book.new
n.times do |i|
  city, rate = gets.chomp.split(" ")
  book.push(Restaurant.new(city, rate.to_i, i + 1))
end

book.sort_by_city!

book.each { |restaurant| puts restaurant.original_number }


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define tam 120004
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define ptr tre*
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;

int main()
{
    ll n;
    cin>>n;
    cout<<(n-2)*180<<endl;
}

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

int main() {
  long a, b, x;
  cin >> a >> b >> x;
  if(a % x == 0) cout << (b / x) - (a / x) + 1 << endl;
  else cout << (b / x) - (a / x) << endl;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**8)

def dfs(x, last=-1, ban_color=-1):
    """
    x: 今いる頂点
    last: 既に探索済の頂点(無限ループにならないように初期値-1)
    ban_color: 既に探索済の頂点(last)と今いる頂点(x)との辺に塗られている色(→使っちゃいけない色)
    """
    color = 1
    for to in vertex[x]:  #今いる頂点に隣接する頂点(つまり今いる頂点から出てる辺をすべて舐める),(rootから隣接する頂点に対してのroopとも捉えられる)
        if to == last: continue  # 既に探索済の辺はもう色が塗られているからスキップ
        if color == ban_color: color += 1
        color_dic[(x, to)] = color  # 辺の色をぬる
        dfs(to, x, color)
        color += 1
        
        

n = int(input())
vertex = {i: [] for i in range(n)} # 隣接頂点を保持
a = [0] * (n - 1)  #i番目の辺を保持
b = [0] * (n - 1)  #i番目の辺を保持
color_dic = {} # 辺の色を保持


for i in range(n-1): # 隣接頂点の辞書を作成
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    vertex[a[i]].append(b[i])
    vertex[b[i]].append(a[i])

max_v = 0

for _, v in vertex.items():
    if len(v) > max_v:
        max_v = len(v)
print(max_v)
    


dfs(0)

for i in range(n - 1):
    if (a[i], b[i]) in color_dic:
        print(color_dic[(a[i], b[i])])
    else:
        print(color_dic[(b[i], a[i])])
        



    


Measured memory_bytes: 98528
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> PII;


int main(){
  ll R,D,X;
  cin>>R>>D>>X;
  rep(i,10){
    X=X*R-D;
    cout<<X<<endl;
  }
}


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

bool atgc(char s) {
  string c = "ACGT";
  for (int i = 0; i < c.size(); i++) {
    if (s == c[i]) {
      // cout << "true" << endl;
      return true;
    }
  }
  // cout << "f" << endl;
  return false;
}

int counter(string s, int index) {
  int count = 0;
  for (int i = index; i < s.size(); i++) {
    if (atgc(s[i])) {
      count++;
    } else {
      ans = max(ans, count);
      counter(s, i + 1);
      break;
    }
  }
  ans = max(ans, count);
  return 0;
}

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

  counter(s, 0);
  cout << ans << endl;
}

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

namespace ABC133
{
	class Program
	{
		static void Main(string[] args)
		{
			int a,b,c;
			var word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);
			if ((a * b) < c)
			{
				Console.WriteLine(a * b);
			}
			else if ((a * b) > c)
			{
				Console.WriteLine(c);
			}
			else if ((a * b) == c)
			{
				Console.WriteLine(c);
			} 
			Console.ReadLine();
		}
	}
}


Measured memory_bytes: 11092
from collections import defaultdict,deque
import itertools

N, M = map(int, input().split())
d = defaultdict(list)
for i in range(M):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

p=list(itertools.permutations([i for i in range(2,N+1)]))
now=1
ans=0
for i in p:
    now=1
    frag=True
    for g in range(N-1):
        if i[g] in d[now]:
            now = i[g]
        else:
            frag=False
            break
    if frag:
        ans+=1
print(ans)

Measured memory_bytes: 41584
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
  int n;
  int ans=0;
  cin>>n;
  vector<int> v(n);
  vector<int> c(n);
  rep(i,0,n)cin>>v[i];
  rep(i,0,n)cin>>c[i];
  rep(i,0,n){
    if((v[i]-c[i])>0)ans+=v[i]-c[i];
  }
  cout<<ans<<endl;
}

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

int main()
{
    char s[201];
    scanf("%s",s);

    int len = strlen(s);
    int i,j;
    for (i = 2; i < len; i += 2)
    {
        for (j = 0; j < (len - i) / 2; j++)
        {
            if(s[j] != s[j + (len - i) / 2])break;
        }
        if(j == (len - i) / 2)break;
    }
    printf("%d",j * 2);
}

Measured memory_bytes: 128
#include<stdio.h>

int sum(int); /*プロトタイプ宣言*/

int main(void){
    int a,b;
    int diff;
    int snow;
    
    scanf("%d %d",&a,&b);
    
    diff=b-a; /*二本の石柱の差=n本目*/
    
    snow=sum(diff)-b; /*本来の高さー現在の高さ＝雪の高さ*/
    
    printf("%d\n",snow);
    
    return 0;
}

int sum(int max){
    int s;
    s=(1+max)*max/2;  /*1~nまでの和*/
    
    return s;
}

Measured memory_bytes: 128
n,m = gets.chomp.split.map(&:to_i)
ab = []
m.times do |i|
  a,b = gets.chomp.split.map(&:to_i)
  if a > b
    a,b=b,a
  end
  ab.push([a,b])
end
ab.uniq!

class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end
end

union = UnionFind.new(n)
ab.each do |t|
  a,b=t
  a-=1
  b-=1
  union.unite(a,b)
end
group = []
n.times do |i|
  group.push(union.get_parent(i))
end
t =group.tally
cou = t.map{|k,v|v}
p cou.max


Measured memory_bytes: 40352
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const uint64_t MOD = 1'000'000'007L;

int64_t dp[51][51][2 * 50 * 51 + 1];

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

    irep(i, n) irep(j, n) irep(k, 2 * n * (n + 1))
    {
        if (i == 0) {
            dp[i][j][k] = (j == 0 && k == n * (n + 1)) ? 1 : 0;
        } else {
            dp[i][j][k] = dp[i - 1][j][k] * (2 * j + 1) % MOD;
            if (j - 1 >= 0 && k + 2 * i <= 2 * n * (n + 1)) {
                dp[i][j][k] = (dp[i][j][k] + dp[i - 1][j - 1][k + 2 * i]) % MOD;
            }
            if (j + 1 <= n && k - 2 * i >= 0) {
                dp[i][j][k] = (dp[i][j][k] + dp[i - 1][j + 1][k - 2 * i] * (j + 1) * (j + 1) % MOD) % MOD;
            }
        }
    }

    cout << dp[n][0][k + n * (n + 1)] << endl;

    /*irep(i, n) irep(j, n)
    {
        cout << i << ", " << j << ": ";
        irep(k, 2 * n * (n + 1))
        {
            cout << dp[i][j][k] << " ";
        }
        cout << endl;
    }*/
    return 0;
}

Measured memory_bytes: 103936
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();
		
		int result = ((h2 * 60) + m2) - ((h1 * 60) + m1) - k;
		
		System.out.println(result);
	}
}

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


int main(){
    string s;cin>>s;
    int N=s.size();
    int ite=N-1;
    int ok=1;
    while(1){
        if(ite-5>=0&&s.at(ite-0)=='r'&&s.at(ite-1)=='e'&&s.at(ite-2)=='s'&&s.at(ite-3)=='a'&&s.at(ite-4)=='r'&&s.at(ite-5)=='e')ite=ite-6;
        else if(ite-4>=0&&s.at(ite-0)=='e'&&s.at(ite-1)=='s'&&s.at(ite-2)=='a'&&s.at(ite-3)=='r'&&s.at(ite-4)=='e')ite=ite-5;
        else if(ite-6>=0&&s.at(ite-0)=='r'&&s.at(ite-1)=='e'&&s.at(ite-2)=='m'&&s.at(ite-3)=='a'&&s.at(ite-4)=='e'&&s.at(ite-5)=='r'&&s.at(ite-6)=='d')ite=ite-7;
        else if(ite-4>=0&&s.at(ite-0)=='m'&&s.at(ite-1)=='a'&&s.at(ite-2)=='e'&&s.at(ite-3)=='r'&&s.at(ite-4)=='d')ite=ite-5;
        else if(ite<0)break;
        else {
            ok=0;
            break;
        }
    }
    if(ok==1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}







Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}

int main() {
    Int N,M;
    cin >>N>>M;
    vi P = vi(M);
    vi Y = vi(M);
    rep(i,M){
        cin >> P[i];
        cin >> Y[i];
    }

    map<Int,vi> mp;
    rep(i,M){
        mp[P[i]].push_back(Y[i]);
    }

    rep(i,N+1){
        sort(mp[i].begin(),mp[i].end());
    }

    rep(i,M){
        stringstream ans;
        Int yi = binary_search_index(Y[i],mp[P[i]])+1;
        ans << std::setw(6) << std::setfill('0') << P[i];
        ans << std::setw(6) << std::setfill('0') << yi;
        cout << ans.str() << endl;
    }


    return 0;
}

Measured memory_bytes: 13952
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
//#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
int find(int i,int a[]){
	if(a[i]==i)return i;
	return a[i]=find(a[i],a);
}
void uni(int i,int j,int a[],int sz[]){
	int x=find(i,a);
	int y=find(j,a);
	if(sz[x]>sz[y])a[y]=x;
	else a[x]=y;
	sz[x]+=sz[y];
	sz[y]=sz[x];
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n;i++){
    	for(int j=i+1;j<n;j++){
    		for(int k=j+1;k<n;k++){
    			if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]+a[j]>a[k])ans++;
    		}
    	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

int main()
{
    int n;
    set<int> st;
    cin >> n;

    REP(i, n)
    {
        int d;
        cin >> d;
        st.insert(d);
    }

    cout << st.size() << endl;

    return 0;
}

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

using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)

typedef long long ll;

int main(){
 long n,k,q;
  cin >> n >> k >> q;
  vector<long> a(n,0);
  rep(i,0,q){
    long b;
    cin >> b;
    b--;
    a[b]++;
  }
  
  rep(i,0,n){
   if(q-a[i]>=k) cout << "No" << endl;
   else cout << "Yes" << endl;
  
  }
  
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define maxn 1005
using namespace std;
const int mod=1e9+7;
int n,m,k,s[maxn],t[maxn];
ll ans=1;
int main(){
	scanf("%d%d",&n,&m);
	int ss=n,tt=m;
	for(int i=0;i<n;i++) scanf("%d",&s[i]);
	for(int i=0;i<m;i++) scanf("%d",&t[i]);
	sort(s,s+n),sort(t,t+m);
	for(int i=n*m;i>0;i--){
		if(s[ss-1]==i&&t[tt-1]==i&&ss*tt) ss--,tt--;
    	else if(s[ss-1]==i&&ss){
			ans*=m-tt;
			ss--;
		}
    	else if(t[tt-1]==i&&tt){
			ans*=n-ss;
			tt--;
		}
    	else ans*=(n-ss)*(m-tt)-(n*m-i);
    	ans%=mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main() 
{ 
    long len, start,end;
    char inp[200002];
    scanf("%s", inp);
    len = strlen(inp);
    int n;
    for(n=0;n<len;n++){
        if(inp[n] == 'A'){
            start = n;
            break;
        }
    }
    for(n=len-1;n>=0;n--){
        if(inp[n] == 'Z'){
            end = n;
            break;
        }
    }
    long sum = end-start;
    printf("%ld\n", sum+1);
    return 0; 
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////
vector<LL> yaku(LL a) {
	vector<LL> ans;
	for (LL i = 1; i * i <= a; ++i) {
		if (a % i == 0) {
			ans.push_back(i);
			if (i != a / i) {
				ans.push_back(a / i);
			}
		}
	}
	return ans;
}
void solve() {
	LL N;
	cin >> N;
	LL ans = 0;
	vector<LL> res = yaku(N - 1);
	ans += res.size()-1;//1

	res = yaku(N);
	int len = res.size();
	for (int i = 0; i < len; ++i) {
		LL ter = N;
		if (res[i] == 1) {
			continue;
		}
		while (ter % res[i] == 0) {
			ter /= res[i];
		}
		
		ter %= res[i];
		if (ter == 1) {
			++ans;
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>





    int main()
    {
        int a;
        scanf("%d",&a);
        
        if((a>=105) && (a<135))
        {
            printf("1\n");
            return 0;
        }
        
        if((a>=135) && (a<165))
        {
            printf("2\n");
            return 0;
        }

        
        if((a>=165) && (a<189))
        {
            printf("3\n");
            return 0;
        }
        
        if((a>=189) && (a<195))
        {
            printf("4\n");
            return 0;
        }

        
        if((a>=195) && (a<201))
        {
            printf("5\n");
            return 0;
        }
        
        else
        {
  
          printf("0\n");
        }
        
                
        return 0;
        
    }


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if(a<b){
                if(c<d)printf("%d\n",a+c);
                else printf("%d\n",a+d);
        }
        else{
                if(c<d)printf("%d\n",b+c);
                else printf("%d\n",b+d);
        }
        return 0;
}


Measured memory_bytes: 1728