akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
#include <valarray>
#include <queue>
#include <utility>
#include <functional>
#include <list>


using namespace std;

struct Point
{
    double x, y;

    Point operator-(const Point & p) const
    {
        Point difference = {x - p.x, y - p.y};
        return difference;
    }

    double operator*(const Point & p) const
    {
        return x*p.x + y*p.y;
    }

    Point operator*(double c) const
    {
        Point p = {c*x, c*y};
        return p;
    }

    friend Point operator*(double c, const Point & p)
    {
        return p*c;
    }

    friend ostream & operator<<(ostream & os, const Point & p) 
    {
        os << setprecision(8) << fixed << p.x << ' ' << p.y << endl;
        return os;
    }

    friend istream & operator>>(istream & is, Point & p)
    {
        is >> p.x >> p.y;
        return is;
    }

    Point operator+(const Point & p) const
    {
        Point sum = {x+p.x, y+p.y};
        return sum;
    }
};


int main()
{
    Point p1, p2, p;

    cin >> p1 >> p2;

    int q;
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> p;
        Point a = p-p1, b = p2-p1;
        cout << (a*b)/(b*b)*b+p1;
    }
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v[i] -= i + 1;
  }

  sort(v.begin(), v.end());
  
  int b = v[n / 2];
  ll res = 0;
  for (int i = 0; i < n; i++) {
    res += abs(v[i] - b);
  }
  cout << res << endl;
}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int n, m;
int vis[200100];

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    
    cin >> n >> m;
    vvi adj(n);
    for (int i = 0; i < m; i++){
        int u, v; cin >> u >> v; u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    queue<pii> q;
    q.emplace(0, 0);
    vis[0] = 1;
    while (!q.empty()){
        pii p = q.front(); q.pop();
        if (p.X == 3) {
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
        if (p.Y == n-1) {
            cout << "POSSIBLE" << endl;
            return 0;
        }

        for (int v : adj[p.Y]){
            if (vis[v]) continue;
            vis[v] = 1;
            q.emplace(p.X + 1, v);
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


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

int main() {
    int k,a,b;
    cin>>k>>a>>b;
    int flag=0;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            flag=1;
        }
    }
    
    if(flag==1){
        cout<<"OK"<<endl;
    }
    else {
        cout<<"NG"<<endl;
    }
	return 0;
}



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

typedef long long ll;

ll N, M, K, A[200005], B[200005];

int main() {
  std::cin >> N >> M >> K;
  A[0] = B[0] = 0;
  for (int i = 1; i <= N; ++i) {
    std::cin >> A[i];
    A[i] += A[i-1];
  }
  for (int i = 1; i <= M; ++i) {
    std::cin >> B[i];
    B[i] += B[i-1];
  }

  int i = N, j = 0;
  while (i >= 0 and A[i] > K)
    i--;

  int ans = 0;

  while (i >= 0) {
    while (j+1 <= M and A[i] + B[j+1] <= K)
      j++;
    ans = std::max(ans, i + j);
    i--;
  }

  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 6748
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = longList()

    val f = a.first()
    var i = f / 2
    val left = i
    a.forEach {
        i = it - i
    }
    if (left != i) {
        i += left
        i /= 2
    }
    buildString {
        a.forEach {
            append("${i * 2} ")
            i = it - i
        }
    }.let {
        println(it.trim())
    }
}


Measured memory_bytes: 59472
N=str(input())
List1=[2,4,5,7,9]
List2=[0,1,6,8]

if int(N) > 99:

    N1=int(N)%100
    N2=N1%10

    if N2 in List1:
        print('hon')
    elif N2 in List2:
        print('pon')
    else:
        print('bon')

elif int(N) >9 and int(N) <100:

    N1=int(N)%10

    if N1 in List1:
        print('hon')
    elif N1 in List2:
        print('pon')
    else:
        print('bon')

else:
    if int(N) in List1:
        print('hon')
    elif int(N) in List2:
        print('pon')
    else:
        print('bon')

Measured memory_bytes: 9224
#include <stdio.h>
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;

int main(){
    int N,W;
    cin >> N >> W;
    vector<long long int> w(N+2),v(N+2);
    rep(i,N) {
        cin >> w[i] >> v[i];
    }
    vector<vector<long long int>> dp(N+2, vector<long long int>(W+2,0));
    rep(i,N+1){
        rep(j,W+1){
            dp[i][j] = 0;
        }
    }

    rep(i,N+1){
        rep(j,W+2){
            if (j >= w[i]) {dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);}
            else {dp[i+1][j] = dp[i][j];}
        }
    }

    cout << dp[N][W];

    return 0;
}


Measured memory_bytes: 81024
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b * 2 == a + c) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

int main(){
    
    int x;
    cin >> x;
    
    cout << abs(1 - x) << "\n";
    
    return 0;
}



Measured memory_bytes: 3176
k=int(input())
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[k-1])

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_N = 212345;
int a[MAX_N];
vector<int> g[MAX_N];

int ans[MAX_N];
int dp[MAX_N]; // dp[i] = 長さ i で終わる増加列の末尾の最小値
const int INF = 1001001001;


void dfs(int cur, int prev) {

  int pos = distance(dp, lower_bound(dp, dp + MAX_N, a[cur]));
  int org = dp[pos];
  dp[pos] = a[cur];
  ans[cur] = distance(dp, lower_bound(dp, dp+MAX_N, INF));

  for (int nxt : g[cur]) if (nxt != prev) {
    dfs(nxt, cur);
  }
  dp[pos] = org;
}

int main2() {
  REP(i, MAX_N) g[i].clear();
  int N = nextInt();
  REP(i, N) a[i] = nextInt();
  REP(i, N-1) {
    int v = nextInt() - 1;
    int u = nextInt() - 1;
    g[v].push_back(u);
    g[u].push_back(v);
  }

  REP(i, MAX_N) dp[i] = INF;
  dfs(0, -1);

  REP(i, N) printf("%d\n", ans[i]);
  return 0;
}

int main() {

#ifdef LOCAL
  // for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 31608
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        long a=sc.nextLong();
        long c=a-1;
        String m="";
            while (a != 0&&c>=0) {
                char n=(char)(c % 26 + 'a');
                m = n + "" + m;
                c/=26;
                c--;
                a /= 26;
            }
            System.out.print(m);
    }
}


Measured memory_bytes: 39368
N = int(input())
C = []
S = []
F = []
for _ in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N):
    if i == N-1:
        print(0)
        break
    t = C[i] + S[i]
    for j in range(i+1, N-1):
        k = t % F[j]
        arrive = t + F[j] - k if k != 0 else t
        t = max(S[j], arrive) + C[j]
    print(t)

Measured memory_bytes: 3064
ai = lambda: list(map(int, input().split()))

n,m = ai()
from collections import defaultdict
dd = defaultdict(list)

for _ in range(m):
    l,r,d = ai()
    dd[l].append((r,d))
    dd[r].append((l,-d))

pos = [None] * (n+1)

for i in range(1, n+1):
    if pos[i] is not None:
        continue
    pos[i] = 0
    stack = [i]
    while stack:
        s = stack.pop()
        for p,d in dd[s]:
            if pos[p] is None:
                pos[p] = pos[s] + d
                stack.append(p)
            elif pos[p] != pos[s] + d:
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 75108
using System;
using System.Numerics;

namespace ABC176.Problems
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int n = int.Parse(Console.ReadLine());
            string[] ss = Console.ReadLine().Split(" ");
            int[] a = new int[n+1];
            for (int i = 0; i < n; i++) {
                a[i] = int.Parse(ss[i]);
            }

            long sum = 0;
            for (int i = 1; i < n; i++) {
                if (a[i-1] > a[i]) {
                    sum += a[i-1] - a[i];
                    a[i] = a[i-1];
                }
            }
            Console.WriteLine(sum);

            Console.Out.Flush();
        }
    }
}


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

using namespace std;


int main(){
	int n;
	int h[100100][3];
	int dp[100100][3];

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> h[i][0] >> h[i][1] >> h[i][2];
	}
	memset(dp, INT_MIN, sizeof(dp));
	dp[0][0] = h[0][0]; dp[0][1] = h[0][1]; dp[0][2] = h[0][2];	

	for(int day = 1; day < n; day++){
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				if(i != j){
					dp[day][j] = max(dp[day - 1][i] + h[day][j], dp[day][j]);  	
				}
			}
		}
	}
	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

//ユークリッドの互除法
ll gcd(ll x,ll y){
    if(x > y) swap(x,y);
    if(x == 0) return y;
    return gcd(x,y%x);
};
//最小公倍数
ll lcm(ll x,ll y){
    return x*y/gcd(x,y);
};

int main(){
    int a,b;
    cin >> a >> b;  
    cout << lcm(a,b) << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007  
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 100002

int32_t main()
{   
    io
    int n;
    cin>>n;

    int a[n];
    int order[n];

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        order[a[i]-1] = i+1;
    }

    for(auto x:order)
        cout<<x<<" ";

return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
int main(void)
{
    int A,B;
    scanf("%d %d",&A,&B);
    if(A >= 13){
        printf("%d",B);
    }else if(A >= 6){
        printf("%d",B/2);
    }else{
        printf("%d",0);
    }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll X;
    cin >> X;
    rep2(i, 1, 1000) {
        if(i * X % 360 == 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
const int N=2e5+5,mo=1e9+7;
int n,i,z,ans=1,f=0;
char c[N];
int main(){
	scanf("%d%s",&n,c+1);
	for(i=1;i<=n;++i)ans=1ll*ans*i%mo;
	for(i=1;i<=n*2;++i)if((c[i]=='B')==f){
		if(!z)ans=0;
		ans=1ll*ans*z--%mo;f^=1;
	}else ++z,f^=1;
	if(z)ans=0;
	printf("%d\n",ans);
}

Measured memory_bytes: 384
def partition(hoge, p, r):
    x = int(hoge[r][1])
    i = p-1
    for j in range(p, r):
        if int(hoge[j][1]) <= x:
            i += 1
            tmp = hoge[i]
            hoge[i] = hoge[j]
            hoge[j] = tmp
    tmp = hoge[i+1]
    hoge[i+1] = hoge[r]
    hoge[r] = tmp
    return i+1
    
def qSort(hoge, p, r):
    if p < r:
        q = partition(hoge, p, r)
        qSort(hoge, p, q-1)
        qSort(hoge, q+1, r)
    
def isStable(input_array, output_array):
    same_nums = list()
    now_num = 0
    for elem in output_array:
        if now_num != int(elem[1]):
            now_num = int(elem[1])
            same_nums = list()
        else:
            for c in same_nums:
                if input_array.index(c) > input_array.index(elem):
                    return 'Not stable'
        same_nums.append(elem)
    return 'Stable'
    
if __name__ == '__main__':
    num = int(input())
    hoge = list()
    for _ in range(num):
        c, s = input().split()
        hoge.append((c,s))
    origin = hoge[:]
    qSort(hoge, 0, len(hoge)-1)
    print(isStable(origin, hoge))
    print('\n'.join(['{0[0]} {0[1]}'.format(x) for x in hoge]))


Measured memory_bytes: 26228
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "NO\n"; return;}
#define yes {cout << "YES\n"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    string s;
    cin >> s;
    loop(i, s.size())
        cout << 'x';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	int l = a * 100 / 8, r = (a + 1) * 100 / 8;
	for(int i = l; i <= r; i++) {
		if((int)(i * 0.08) == a && (int)(i * 0.1) == b) { printf("%d\n", i); return 0; }
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = []
for i in range(N):
    ai = int(input())
    A.append(ai)
n = A[0]
if n==2:
    print(1)
    exit()
cnt=1
while True:
    N-=1
    n = A[n-1]
    cnt+=1
    if n==2:
        print(cnt)
        exit()
    elif N==0:
        break
    else:
        continue
print(-1)

Measured memory_bytes: 7084
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define fir first
#define sec second
#define pb push_back
#define lowbit(x) ((x)&(-(x))) 

const int maxn = 106; 

int n, o; 
int x[maxn], y[maxn], h[maxn];

int Abs(int x) {
	return x>0?x:-x; 
}

int D(int x1, int y1, int x2, int y2) {
	return Abs(x1-x2)+Abs(y1-y2); 
}

bool check(int X, int Y) {
	int H = D(X,Y,x[o],y[o])+h[o];
	for (int i = 1; i <= n; ++i) 
		if (max(0,H-D(X,Y,x[i],y[i])) != h[i]) return false; 
	return true; 
} 

int main() {
	cin>>n; 
	for (int i = 1; i <= n; ++i) 
		cin>>x[i]>>y[i]>>h[i]; 
	for (int i = 1; i <= n; ++i)
		if (h[i] != 0) o = i; 
	for (int X = 0; X <= 100; ++X) 
		for (int Y = 0; Y <= 100; ++Y) 
			if (check(X, Y)) {
				cout<<X<<' '<<Y<<' '<<D(X,Y,x[o],y[o])+h[o]<<endl; 
				return 0; 
			}
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
static long n = long.Parse(input[0]);
static long k = long.Parse(input[1]);
static long p = 1000000007;
static long answer = 0;
static long[] factorials = new long[n+1];//i!(mod p)を先にメモ
static long[] factorialRs = new long[n+1];//i!^-1(mod p), pは素数

	static void Main()
	{
    factorials[0] = 1;
    factorialRs[n] = DivideModFactorial(n,p);
    for(long i = 1; i <= n; i++)
    {
      factorials[i] = (factorials[i-1]*i)%p;//i!(mod p)
      factorialRs[n-i] = (factorialRs[n+1-i]*(n+1-i))%p;//逆元も先にメモ
    }
  
    if(k > n) answer = 0;
    else
    {
      for(long i = 0; i <= k-1; i++)
      {
        long memo = Comb(k, i, p) * DivideMod(k-i, n, p);
        if(i % 2 == 0)
        {
          answer += memo;
          answer %= p;
        }else
        {
          answer -= memo;
          answer %= p;
          if(answer < 0) answer += p;
        }
      }
    }

		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

  static long Comb(long a, long b, long p)//戻り値は組み合わせC(a,b)のmod p
  {
    long answer = 1;
    answer *= factorials[a];
    answer %= p;
    answer *= factorialRs[a-b];//引数a-bは負にならないようにする
    answer %= p;
    answer *= factorialRs[b];
    answer %= p;
    return answer;
  }

  
}


Measured memory_bytes: 18096
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, p[100000];
string s[100000];
bool bl[100010];
int cnt[100010];
int ans1, ans2;

signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> s[i];
		if (!bl[p[i]]) {
			if (s[i] == "WA")cnt[p[i]]++;
			else bl[p[i]]++;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (bl[i]) {
			ans1++;
			ans2 += cnt[i];
		}
	}
	cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 7296
#include <stdio.h>
  
int main(void){
  int a,b;
  char op;
  
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?')  break;
    if(op=='+')  printf("%d\n",a+b);
    else if(op=='-')  printf("%d\n",a-b);
    else if(op=='*')  printf("%d\n",a*b);
    else if(op=='/')  printf("%d\n",a/b);
  }
  
  return 0;
}

Measured memory_bytes: 600
import bisect

def prime_num(num):
    if num == 1:
        return False
    else:
        i = 2
        while i*i <= num:
            if num%i == 0:
                return False
            i += 1
        return True

def prime_list(max_num):
    prime_list = [2]

    lens = 1
    n = 3
    while prime_list[-1] <= 10**5:
        if prime_num(n):
            prime_list.append(n)
            lens += 1
        n += 2

    count_list = [0 for i in range(max_num+1)]
    cnt = 0

    for n in range(3,max_num+1,2):

        tar1 = n
        tar2 = (n+1)//2

        ind2 = bisect.bisect_left(prime_list, tar2, 0, len(prime_list))
        if tar2 == prime_list[ind2]:

            ind1 = bisect.bisect_left(prime_list, tar1, 0, len(prime_list))
            if tar1 == prime_list[ind1]:
                cnt += 1

        count_list[n] = cnt
        count_list[n+1] = cnt

    return count_list

count_list = prime_list(10**5)
# print(count_list[91] - count_list[13-1])
# exit()

Q = int(input())

for i in range(Q):
    l,r = map(int, input().split())

    ans = count_list[r] - count_list[l - 1]
    print(ans)


Measured memory_bytes: 4540
# -*- coding: utf-8 -*-
n = int(raw_input())
p = map(int,raw_input().split())

err_cnt = 0

for i in range(n):
    if p[i]!=i+1:
        err_cnt+=1

if err_cnt ==0 or err_cnt==2:
    print "YES"
else :
    print "NO"

Measured memory_bytes: 2568
#include<cstdio>
char s[1<<17];
int l=-1,r=-1,i;
int main(){
	scanf("%s",s);
	for(i=1;s[i];i++)if(s[i-1]==s[i])l=i,r=i+1;
	for(i=2;s[i];i++)if(s[i-2]==s[i])l=i-1,r=i+1;
	printf("%d %d\n",l,r);
}


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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

int main(){
    ll n; cin >> n;
    if (n >= 1800) cout << 1 << endl;
    else if (n >= 1600) cout << 2 << endl;
    else if (n >= 1400) cout << 3 << endl;
    else if (n >= 1200) cout << 4 << endl;
    else if (n >= 1000) cout << 5 << endl;
    else if (n >= 800) cout << 6 << endl;
    else if (n >= 600) cout << 7 << endl;
    else if (n >= 400) cout << 8 << endl;

    return 0;
}

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

using namespace std;

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

using ll = long long;

int x, y, z, k;

ll a[1000] = {};
ll b[1000] = {};
ll c[1000] = {};
bool used[1000][1000][100] = {false};

int main(){
    cin >> x >> y >> z >> k;

    rep(i, x)cin >> a[i];
    rep(i, y)cin >> b[i];
    rep(i, z)cin >> c[i];

    sort(a, a+x, greater<ll>());
    sort(b, b+y, greater<ll>());
    sort(c, c+z, greater<ll>());

    vector<ll> sum;
    rep(i, x)rep(j, y)rep(l, z){
        if((i+1)*(j+1)*(l+1) <= k)sum.push_back(a[i]+b[j]+c[l]);
        else break;
    }
    
    sort(sum.begin(), sum.end(), greater<ll>());

    rep(i, k)cout << sum[i] << endl;

}

Measured memory_bytes: 1400
// Anve$hi $hukla
#include <bits/stdc++.h>
using namespace std;
struct ${$(){ios_base::sync_with_stdio(false);cin.tie(NULL);}}$;

typedef long long LL;
const int Maxn = 200005;

int main() {
    string s;
    cin >> s;
    map <char, int> m;
    for(int i = 0; i < s.length(); i++) {
        m[s[i]]++;
    }   
    bool ok = false;

    if(m['N']) {
        if(!m['S'])
            ok = 1;
    }
    if(m['S']) {
        if(!m['N'])
            ok = 1;
    }

    if(m['E']) {
        if(!m['W'])
            ok = 1;
    }

    if(m['W']) {
        if(!m['E'])
            ok = 1;
    }
    if(ok)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (int i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (int i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

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

    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll wcnt = count(s.begin(), s.end(), 'W'), rcnt = count(s.begin(), s.end(), 'R');
    ll ans_w = 0, ans_r = 0;
    REP(i, 0, rcnt)
    if (s[i] == 'W')
        ++ans_r;
    REPR(i, n - 1, n - 1 - wcnt)
    if (s[i] == 'R')
        ans_w++;
    cout << min(ans_w, ans_r) << endl;
}

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

using namespace std;

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

	int plugs;
	if ((b-1) % (a-1) == 0)
		plugs = ((b-1) / (a-1));
	else
		plugs = ((b-1) / (a-1)) + 1;

	cout << plugs;
	return 0;
}

Measured memory_bytes: 256
// Bismillah .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e6+5;
bool flag[mx];
int a[200005];
 map<int,int>mp;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b;
    cin>>a>>b;
    a = a*b;
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 3508
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    def dfs(node):
        for adjnode in edges[node]:
            if colors[adjnode[0]] == -1:
                if adjnode[1] % 2 == 0:
                    colors[adjnode[0]] = colors[node]
                else:
                    colors[adjnode[0]] = colors[node] ^ 1
                dfs(adjnode[0])
    # input
    n = int(input())
    edges = {e: [] for e in range(n)}
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        edges[u].append((v, w))
        edges[v].append((u, w))
    # process
    colors = [-1] * n
    colors[0] = 0
    dfs(0)
    # output
    print(*colors, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 103876
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<stack>
#include<random>
#include<iterator>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

template <typename T>
void printvec(vector<T> v)
{
    for(auto it=v.begin();it != v.end();it++)
    {
        cout << (*it) << endl;
    }
    cout << endl;
}


struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};


void printl(ListNode* l){
    ListNode *h;h=l;
    while(h!= NULL){
        cout << h->val<< endl;
        h = h->next;
    }
}

template <typename T>
void chmax(T& a,const T& b){if(b > a)a = b;}
template<typename T>
void chmin(T& a ,const T& b){if(a > b)a = b;}

int lower_bound(vector<int> v,int k){//vの中でk以下の値をみっけるないときは一番いひだりが帰ってくる
    int l(0),r(v.size());
    long long int mid;
    while(l<r){
        mid = (l+r)/2;
        if(mid == v.size() -1 ){
            return v.size()-1;
        }
        if(v[mid] <= k && v[mid+1] >k ){
            return mid;
        }else if(v[mid] > k){
            r = mid-1;
        }else{
            l = mid + 1;
        }
    }
    return l;
}
template <typename T>
void print2dvec(vector<vector<T>> v){
    for(int j=0;j<v[0].size();j++)
    {
        for(int i=0;i<v.size();i++){
            cout << v[i][j];
        }
        cout << endl;
    }
    
}


int lcs(string s1,string s2){
    int dp[50][50] = {0};
    cout << dp[2][2] << endl;
    //i,jは何文字目か
    for(int i=1;i<=s1.size();i++){
        for(int j = 1;j<=s2.size();j++){
            if(s1[i-1] ==s2[j-1] ){
                chmax(dp[i][j] , dp[i-1][j-1] + 1);
            }
            chmax(dp[i][j],dp[i-1][j]);
            chmax(dp[i][j] , dp[i][j-1]);
        }
    }
    return dp[s1.size()][s2.size()];
}


struct veccomp{
    bool operator()(const vector<int>& a,const vector<int>& b)const{
        return a[0] < b[0];
    }
};    

int main(){

    long double a,b,h,m;
    cin >> a >> b >> h >> m;
    long double arg1,arg2;
    arg1 = (((h * 60 + m)*2)/(12 * 60));
    arg2 = (m*2 )/60;
    long double arg = abs(arg1 - arg2);
    arg *= M_PI;
    cout << fixed << setprecision(15) << sqrt(a*a + b*b - 2*a*b*cos(arg)) << endl;//a*a + b*b - 2*a*b*
}


Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
const int sz = 200005;

int main() {
  int n;
  cin >> n;
  vector<long long> wa(sz), sa(sz);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a + i < sz) wa[a + i]++;
    if (a - i < 0) sa[i - a]++;
  }
  long long ans = 0;
  for (int i = 0; i < sz; i++) ans += wa[i] * sa[i];
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  int c = 0;
  
  for(int i = 0; i < N; i++){
    if(i % 2 == 0 && A.at(i) % 2 == 1){
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3624
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;

string next(string s) {
	int nc = -1, v = 1; int n = s.size();
	do {
		nc += v;
		if (0 <= nc&&nc < n) {
			if (s[nc] == 'A') {
				v *=-1;
				s[nc] = 'B';
			}
			else {
				s[nc] = 'A';
			}
		}
	} while (0<=nc&&nc<n);
	return s;
}
string next2(string s) {
	if (s[0] == 'A') {
		s[0] = 'B';
		return s;
	}
	else {
		rep(i, s.size() - 1) {
			if (s[i] == 'B'&&s[i + 1] == 'B')s[i] = 'A';
			else if (s[i] == 'A'&&s[i + 1]=='A')s[i] = 'B';
		}
		s[s.size() - 1] = 'A';
		return s;
	}
}

void disp(char now, deque<int>Q) {
	while (Q.size()) {
		int f = Q.front(); Q.pop_front();
		rep(i, f)cout << now;
		if (now == 'A')now = 'B'; else now = 'A';
	}cout << endl;
}
void debug() {
	string t; cin >> t;
	rep(i, 60) {
		t = next(t);
		cout << t << endl;
	}
}

signed main() {
//	debug(); return 0;


	int n, k; cin >> n >> k;
	string s; cin >> s;
	deque<int>D;
	char now = s[0];
	int cnt = 0;

	rep(i, n) {
		if (now == s[i])cnt++;
		else {
			D.push_back(cnt);
			cnt = 1;
			now = s[i];
		}
	}
	D.push_back(cnt);
	now = s[0];

	if (n == 1) {
		if (k & 1) {
			if (now == 'A')cout << 'B' << endl;
			else cout << 'A' << endl;
		}
		else cout << 'A' << endl;

		return 0;
	}

	while (k) {
		if (now == 'A') {
			int u = D.front();
			D.pop_front();
			if (u == 1) {
				int t = D.front();
				D.pop_front();
				t++;
				D.push_front(t);
			}
			else {
				u--;
				D.push_front(u);
				D.push_front(1);
			}
			now = 'B';
		}
		else {
			if (D.size() == 1) {
				now = 'A';
			}
			else {
				int a = D.front();
				D.pop_front();
				if (a == 1) {
					D.push_back(a);
				}
				else {
					a--;
					D.push_back(1);
					D.push_front(a);
					now = 'A';
				}

				if ((now == 'A'&&D.size() % 2==0)||(now=='B'&&D.size()%2)) {
					int t = D.back();
					D.pop_back();
					if (t == 1) {
						int u = D.back();
						D.pop_back();
						u++;
						D.push_back(u);
					}
					else {
						t--; D.push_back(t);
						D.push_back(1);
					}
				}
		
			}
		}
		k--;
		if (D.size() == n) {
			if(((n&1)&&now=='A')||(!(n&1)&&now=='B'))
			break;
		}
//		disp(now, D);
	}
	if ((1&n)&&(1&k)) {
		D.pop_front();
		D.pop_front();
		D.push_front(2);
		now = 'B';
	}
	disp(now, D);
}

Measured memory_bytes: 3972
import math
def koch(d, p1, p2):
    if d == 0:
        return

    sx = (2*p1[0]+1*p2[0])/3
    sy = (2*p1[1]+1*p2[1])/3
    s = (sx, sy)
    tx = (1*p1[0]+2*p2[0])/3
    ty = (1*p1[1]+2*p2[1])/3
    t = (tx, ty)
    rad = math.radians(60)
    ux = (t[0]-s[0])*math.cos(rad)-(t[1]-s[1])*math.sin(rad)+s[0]
    uy = (t[0]-s[0])*math.sin(rad)+(t[1]-s[1])*math.cos(rad)+s[1]
    u = (ux, uy)

    koch(d-1, p1, s)
    print(s[0], s[1])
    koch(d-1, s, u)
    print(u[0], u[1])
    koch(d-1, u, t)
    print(t[0], t[1])
    koch(d-1, t, p2)

d = int(input())
p1 = (0, 0)
p2 = (100, 0)
print(p1[0], p1[1])
koch(d, p1, p2)
print(p2[0], p2[1])


Measured memory_bytes: 5780
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d)cout<<"Left\n";
    if(a+b==c+d)cout<<"Balanced\n";
    if(a+b<c+d)cout<<"Right\n";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
int a,i=0,m=0,n=0,d=1,c=0,S=0;
scanf("%d",&a);
if(a<105)
{printf("0\n");
return 0;}


for(m=105;m<=a;)
{d=1;
c=0;
for(d;d<=m;d++)
{
if(m%d==0)
{
c++;
}

}

if(c==8)
{
S++;
}
m=m+2;
}
printf("%d\n",S);
return 0;
}

Measured memory_bytes: 128
"""
author : halo2halo
date : 12, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b = map(int,read().split())
print((b+a*3)//2)



Measured memory_bytes: 2940
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	string s;
	cin >> s;
	vector<int>v(N);
	for (int i = 1; i < N; i++) {
		if (s[i] != s[i - 1])v[i]++;
		v[i] += v[i - 1];
	}
	//	for (auto i : v)cout << i << endl;
	L = 0, R = 0;
	M = 1;
	while (L < N) {
		if (v[R + 1] - v[L] <= K * 2-1+(s[L]=='1') && R + 1 < N)R++;
		else L++;
		M = max(M, R - L + 1);
	}
	cout << M << endl;
	return 0;
}

Measured memory_bytes: 848
using System;
using System.Linq;
class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int p = int.Parse(input[0]);
    int q = int.Parse(input[1]);
    int r = int.Parse(input[2]);
    int[] array = new int[] { p+q, q+r, r+p };
    Console.WriteLine(array.Min());
  }
}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<vector<int>>v(50),neat(50);
vector<int>ch;
map<int, int>m;

int main() {
	int n,c;
	cin >> n >> c;
	REP(i, 0, n) {
		int s, t, a;
		cin >> s >> t >> a;
		v[a-1].push_back(2*s-1);
		v[a-1].push_back(2*t);
	}
	REP(i, 0, c) {
		if (v[i].size() != 0) {
			sort(all(v[i]));
			neat[i].push_back(v[i][0]);
			REP(j, 1, v[i].size()) {
				if (v[i][j] == v[i][j - 1] + 1) {
					neat[i].pop_back();
					j++;
					neat[i].push_back(v[i][j]);
				}
				else {
					neat[i].push_back(v[i][j]);
				}
			}
		}
	}
	REP(i, 0, c) {
		REP(j, 0, neat[i].size()) {
			if (j % 2 == 0) {
				m[neat[i][j]]++;
			}
			else {
				m[neat[i][j]]--;
			}
			ch.push_back(neat[i][j]);
		}
	}
	sort(all(ch));
	int hoge = m[ch[0]], ans = m[ch[0]];
	REP(i, 1, ch.size()) {
		if (ch[i] != ch[i - 1]) {
			hoge += m[ch[i]];
			ans = max(ans, hoge);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi a(N);
  rep(i,N) {
    cin >> a[i];
  }
  int ans = 0;
  rep(i,N) {
    if(i&1) continue;
    if(a[i]&1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

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

  vector<int> H(N);
  rep(i, N) {
    cin >> H[i];
  }

  sort(all(H));
  reverse(all(H));

  ll ans = 0LL;
  for (int i = K; i < N; i++) {
    ans += H[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)


int32_t main() {

	boost;
 	cout<<setprecision(10)<<fixed;	
	double n;
	cin>>n;
	n/=(3.0);
	double ans =n*n*n;
	cout<<ans<<endl;    
}

Measured memory_bytes: 256
n,k,*a=map(int,open(i:=0).read().split())
a.sort()
s=b=~k%2or a.pop()
j=1
for _ in k//2*'_':
 if(x:=a[i]*a[i+1])*b>(y:=a[-j]*a[~j])*b:s*=x;i+=2
 else:s*=y;j+=2
 s%=10**9+7
print(s)

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    vi price(3);
    REP(i, 3) cin >> price[i];
    sort(ALL(price));
    cout << price[0] + price[1] << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;

int main() {
	cin >> N;
	vector<ll>A(N + 1);
	for (int i = 1; i <= N; i++) {
		int a;
		scanf("%d", &a);
		A[i] = a - i;
	}
	sort(A.begin() + 1, A.end());
	int b = A[N / 2 + 1];
	for (int i = 1; i <= N; i++) {
		ans += abs(A[i] - b);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
n = int(input())
lst1 = [list(input().split()) for i in range(n)]
x = input()

for i in range(n):
    if x == lst1[i][0]:
        theindex = i
        break
ans = 0
for i in range(theindex+1,n):
    ans += int(lst1[i][1])

print(ans)

Measured memory_bytes: 38256
import math
import sys
from collections import defaultdict
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
    
n = inp()
A = invr()

map = defaultdict(int)
for i, boss in enumerate(A, 2):
	map[boss] += 1 
	
for i in range(n):
	print map[i+1]


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define pb push_back
#define f first
#define s second
#define INF 1000000000000
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 3100, MAXK = 25;
const ll MOD = 1e9+7;

ld dp[MAXN][MAXN];
ld p[MAXN];

int main()
{
    FAST_IO;

    int n; cin >> n;
    FOR(i, 1, n) cin >> p[i];
    //FOR(i, 1, n) p[i] *= 100;

    dp[0][0] = 1.0;

    FOR(i, 1, n) {
        dp[i][0] = dp[i-1][0] * p[i];
        dp[0][i] = dp[0][i-1] * (1.0 - p[i]);
    }

    FOR(i, 1, n) FOR(a, 1, i-1)
        dp[a][i-a] = dp[a-1][i-a]*p[i] + dp[a][i-a-1]*(1.0-p[i]);

    ld ans = 0.0;
    FOR(i, n/2+1, n)  ans += dp[i][n-i];
    cout << fixed << setprecision(12) << ans << endl;
    //cout << fixed << "  " << dp[3][0] << "  " << dp[2][1] << endl;

    return 0;
}


Measured memory_bytes: 145664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m, x, a[110];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m >> x;
    erep(i, 1, m) {
        int p; cin >> p;
        a[p]++;
    }
    int ans1 = 0, ans2 = 0;
    erep(i, x, n) ans1 += a[i];
    eper(i, x, 0) ans2 += a[i];
    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 a, b;
  std::cin >> a >> b;
  std::cout << (b - a) * (b - a + 1) / 2 - b << std::endl;
  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	int i = 0, j = n-1;
	
	while (i < n / 2) {
		if (s[i] != s[j]) {
			ans++;
			//cout << i << endl;
		}
		i++;
		j--;
	}
	
	cout << ans << endl;
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 998244353

int mpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = (int64_t) res * a % MOD;
		a = (int64_t) a * a % MOD;
	}
	return res;
}
int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	std::vector<int64_t> cnt(1000001);
	for (int i = 0; i < n; i++) cnt[a[i]] += a[i];
	for (int i = 0; i <= 1000000; i++) cnt[i] %= MOD;
	
	auto converted = cnt;
	for (int x = 1; x <= 1000000; x++) {
		for (int y = 2 * x; y <= 1000000; y += x) converted[x] += converted[y];
		converted[x] %= MOD;
	}
	for (auto &i : converted) i %= MOD, i *= i, i %= MOD;
	for (int x = 1000000; x >= 1; x--) {
		for (int y = 2 * x; y <= 1000000; y += x) converted[x] -= converted[y];
		converted[x] %= MOD;
	}
	for (int i = 0; i < n; i++) converted[a[i]] -= (int64_t) a[i] * a[i];
	int64_t ans = 0;
	for (int i = 1; i <= 1000000; i++) {
		converted[i] = converted[i] % MOD + MOD;
		if (converted[i] >= MOD) converted[i] -= MOD;
		ans += (int64_t) converted[i] * 499122177 % MOD * mpow(i, MOD - 2) % MOD;
	}
	std::cout << ans % MOD << std::endl;
	
	return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=2e5+5;
const ll inf=1e17;


int par[ms];
int sz[ms];


int findpar(int i)
{
    if(i==par[i])return i;
    return par[i]=findpar(par[i]);
}

void unionn(int u,int v)
{
    u=findpar(u);
    v=findpar(v);
    if(u!=v)
    {
        if(sz[v]>sz[u])swap(u,v);
        sz[u]+=sz[v];
        par[v]=u;
    }
}

int main()
{
    idfc;

    int n;
    cin>>n;
    int i;

    for(i=1;i<=n;i++)
    {
        par[i]=i;
        sz[i]=1;
    }


    int m;
    cin>>m;
    int u,v;

    for(i=1;i<=m;i++)
    {
        cin>>u>>v;
        unionn(u,v);
    }


    int ans=1;
    for(i=1;i<=n;i++)
    {
        ans=max(ans,sz[findpar(i)]);
    }
    cout<<ans;
    return 0;
}

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


int main() {
int N;
cin>>N;
vector<long> a(N);
for(int i=0;i<N;i++) cin>>a[i];
long ans=0;
long mod=1e9+7;
long base=1;
vector<long> b(N);
for(int i=0;i<N;i++)  ans= ans^a[i];

for(int i=0;i<=60;i++){
  for(int i=0;i<N;i++){
    long tmp=ans^a[i];
    b[i]=tmp;
  }
  ans>>1;
}
for(int i=0;i<N;i++) cout<<b[i]<<endl;
}


Measured memory_bytes: 6264