akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n, m;
	cin >> n >> m;
	deque<P> ab(n);
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		ab.at(i).first = x;
		ab.at(i).second = y;
	}
	sort(all(ab));
	ll ans = ab.front().first * ab.front().second;
	ll cnt = ab.front().second;
	while (cnt < m) {	
		ab.pop_front();
		cnt += ab.front().second;
		ans += ab.front().first * ab.front().second;
	}
	ans -= ab.front().first * ab.front().second;
	cnt -= ab.front().second;
	ans += ab.front().first * (m - cnt);
	cout << ans;
	return 0;
}

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

int main() {
  ll a,b,c; cin >> a >> b >> c;
  rep(i,10){
    c = a*c - b;
    cout << c << endl;
  }
}

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

typedef long long ll;
int main(){
  ll n,k,ans=0;
  cin>>n>>k;
  if(k==0){
    cout<<n*n<<"\n";
    return 0;
  }

  for(int b=k+1;b<=n;b++){
    ans+=(n/b)*(b-k)+ max(n%b-k+1,(ll)0);
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int q,w,e,r;
  cin >>q>>w>>e>>r;
  q=q+w;
  e=e+r;
  if(q<e){
  cout << "Right" << endl;
  }
  else if(q>e){
  cout << "Left" << endl;
  }
  else if(q=e){
  cout << "Balanced" << endl;
  }
 
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n, k;
  cin >> n >> k;
  if(ceil(n, 2LL) >= k) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
import sys, os.path
from collections import*
from copy import*
import math
mod=10**9+7
if(os.path.exists('input.txt')):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")

n=int(input())
d=[]
flag=0
for i in range(n):
    a=list(map(int,input().split()))
    d.append(a)
count=0
for i in range(n):
    if(d[i][0]==d[i][1]):
        count+=1
    else:
        count=0
    if(count==3):
        flag=1
        break
if(flag==1):
    print("Yes")
else:
    print("No")




Measured memory_bytes: 68024
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()

print(N*(N-1)//2)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

const ll INF = 1000000007;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0, now = 1;
    for(int i = 0; i < n; i++){
        if(a[i] == now){
            now++;
        }
        else{
            ans++;
        }
    }
    if(ans == n) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


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

#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;

int main(){
  ll n,a,b;
  cin>>n;
  bool p=false;
  rep(i,1,10){
    rep(j,1,10){
      if(n==i*j)p=true;
    }
  }
  if(p)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int n,k,i,c=1;
 scanf("%d%d",&n,&k);
 for(i=0;i<n;i++){
  if(c<=k) c*=2;
  else c+=k;
 }
 printf("%d",c);
 return 0;
}

Measured memory_bytes: 128
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		int mado = sc.nextInt();
            int car = sc.nextInt();
            int result = mado - 2 * car;
            if(result < 0){
            	result = 0;
            }
    		// 出力
    		System.out.println(result);
    	}
    }

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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

constexpr int mxn = 1e6 + 5;
int idx = 1, ch[mxn][26], cnt[mxn][26];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> all(n);
    for (auto& s : all)
        cin >> s;
    sort(all.begin(), all.end(), [](const auto& a, const auto& b){
        return a.size() > b.size();
    });
    ll ans = 0;
    for (const auto& s : all) {
        int ptr = 0;
        bool ok = true;
        auto it = rbegin(s);
        for (; it != rend(s) - 1; it++) {
            if (!ch[ptr][*it - 'a']) {
                ok = false;
                break;
            }
            ptr = ch[ptr][*it - 'a'];
        }
        if (ok && cnt[ptr][*it - 'a']) {
            ans += cnt[ptr][*it - 'a'];
        }
        int count[26] = {};
        for (char x : s)
            count[x - 'a']++;
        ptr = 0;
        it = rbegin(s);
        for (; it != rend(s); it++) {
            int c = *it - 'a';
            if (!ch[ptr][c])
                ch[ptr][c] = idx++;
            for (int j = 0; j < 26; j++)
                cnt[ptr][j] += !!count[j];
            ptr = ch[ptr][c];
            count[c]--;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 207384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A[200000], B[200000];
    cin >> N;
    map<int, int> mii;
    REP(i, N) {
        cin >> A[i];
        mii[A[i]]++;
    }
    REP(i, N) {
        cin >> B[i];
        mii[B[i]]++;
    }
    for (auto p : mii) {
        if (p.second > N) {
            cout << "No" << endl;
            return 0;
        }
    }

    int C[200001] = {}, D[200001] = {};
    REP(i, N) {
        C[A[i]]++;
        D[B[i]]++;
    }
    REP(i, N) {
        C[i + 1] += C[i];
        D[i + 1] += D[i];
    }

    int offset = 0;
    REP(i, N) {
        offset = max(C[i + 1] - D[i], offset);
    }
    cout << "Yes" << endl;
    REP(i, N) {
        cout << B[(i + N - offset) % N] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 15992
N = int(input())

def searchPrimeNum(N):
    max = int(N**0.5)
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

plis = searchPrimeNum(100)

def pfact(N,dic):
    for p in plis:
        if N%p == 0:
            dic[p] += 1
            N = N//p
        while N%p == 0:
            dic[p] += 1
            N = N//p
        if N == 1:
            break
    return dic

dict = {}
for p in plis:
    dict[p] = 0

for i in range(1,N+1):
    dict = pfact(i,dict)

nlis = [0,0,0,0,0]
r = [75,25,15,5,3]
for i in dict.values():
    for j in range(len(r)):
        if i >= r[j]-1:
            nlis[j] += 1
ans = 0
ans += nlis[0]
ans += nlis[1]*(nlis[-1]-1)
ans += nlis[2]*(nlis[-2]-1)
ans += nlis[-2]*(nlis[-2]-1)*(nlis[-1]-2)//2
print(ans)


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

int main(){
        int N,Q,l,r;
        string S;
        cin >> N >> Q;
        cin >> S;
        vector<int> cnt(N);
        vector<int> ans(Q);
        for(int i=1;i<N;++i){
                if(S[i]=='C' && S[i-1]=='A') cnt[i] = cnt[i-1] + 1;
                else cnt[i] = cnt[i-1];
        }
        for(int i=0;i<Q;++i){
                cin >> l >> r;
                ans[i] = cnt[r-1] - cnt[l-1];
        }
        for(int i=0;i<Q;++i) cout << ans[i] << endl;
        return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var aho = Console.ReadLine().Split();
    long a = long.Parse(aho[0]);
    long b = long.Parse(aho[1]);
    for(long i = 1;;i++){
      var c = a*i;
      if(c%b == 0){
        Console.WriteLine(c);
        return;
      }
    }
  }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;

void solve()
{
   ll h;
   cin>>h;
   ll ans=0,p=1;
   while(h>0)
   {
       ans+=p;
       h/=2;
       p*=2;
   }
   cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s;
  cin >> s;
  rep(i,4) cout << s[i];
  cout << " ";
  rep(i,8) cout << s[i+4];
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define readvec(vec)    \
  for (auto& e : vec) { \
    cin >> e;           \
  }
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n;
  cin >> n;
  vecll a(n);

  for (auto& e : a) cin >> e;
  ll sum = 0;
  REP(i, n - 1) {
    if (i % 2 == 0) {
      sum += a[i];
    } else {
      sum -= a[i];
    }
  }
  vecll ans(n);
  ans[0] = (sum + a.back()) / 2;
  for (int i = 1; i < n; i++) {
    ans[i] = a[i - 1] - ans[i - 1];
  }
  for (const auto& e : ans) cout << 2 * e << endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define trarr(a,n) rep(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) rep(i,0,n)rep(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 2e5+10;
void solve(int _t){
	string s;
	cin >> s;
	int n = s.length();
	ll ans = 0;
	rep(i, 0, n){
		ans = (ans+(s[i]-'0'))%9;
	}
	if(ans == 0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}  

Measured memory_bytes: 3784
#include <stdio.h>

int main(void)
{
	int n, k;
	scanf("%d %d", &n, &k);

	int* a = (int*)malloc(sizeof(int) * n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	
	int cnt = 0;
	while (1)
	{
		if (n <= k) {
			cnt++;
			break;
		}
		else {
			n -= (k-1);
			cnt++;
		}
	}
	printf("%d\n", cnt);
}


Measured memory_bytes: 512
local N = io.read("n")
local P = {}
local sort_count = {}
sort_count[0] = 0
for i=1,N do
    P[i] = io.read("n")
    sort_count[i] = 0
end

for i=1,N do
    local n = P[i]
    sort_count[n] = sort_count[n-1] + 1
end

local max = 0
for i=1,N do
    if sort_count[i] > max then
        max = sort_count[i]
    end
end

print(N-max)


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

int main() {

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

    long long l = 1, r = 1000000000;
    while(l < r) {
        long long mid = (l + r) / 2;
        long long remain = mid;
        for(int i = 0; i < n; i++) {
            if(mid * b < h[i]) {
                remain -= (h[i] - mid * b) / (a - b);
                if((h[i] - mid * b) % (a - b)) remain--;
            }
        }
        if(remain < 0){
            l = mid + 1;
        } else {
            r = mid;
        }
    }
    cout << l << endl;
}


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

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double area = 0.5 * w * h;
    bool center = 2 * x == w && 2 * y == h;
    printf("%.20f %d\n", area, center);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

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

	int A, B;
	std::cin >> A >> B;
	
	int N = abs(A-B);
	if (0 != N % 2) {
		std::cout << "IMPOSSIBLE";
		return 0;
	}
	std::cout << (N / 2 + std::min(A, B));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	if(n%2==0)
	{
		cout<<n/2-1<<"\n";
	}
	else
	{
		cout<<(n-1)/2<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N; cin.ignore();
  vector<string> v(N);
  rep(i, N) {
    getline(cin, v[i]);
    if(v[i].back() == ';') v[i] = v[i].substr(0, v[i].size()-1);
    if(v[i].back() == ':') v[i] = v[i].substr(0, v[i].size()-1);
  }

  vector<pair<int, int>> g[101];

  rep(i, N) {
    if(v[i].size() < 4 || v[i].substr(0, 4) != "goto") {
      g[i].emplace_back(0, i+1);
    } else {
      string label = v[i].substr(5);
      int to = find(all(v), label) - v.begin();
      g[i].emplace_back(0, to);
      g[i].emplace_back(1, i+1);
    }
  }

  deque<pair<int, int>> q;
  q.emplace_back(0, 0);

  int dist[101]; rep(i, 101) dist[i] = inf;
  dist[0] = 0;

  while(!q.empty()) {
    int cost, pos; tie(cost, pos) = q.front(); q.pop_front();
    if(pos == N) {
      cout << cost << endl;
      return 0;
    }
    for(auto e: g[pos]) {
      int pc = e.first;
      int to = e.second;
      if(dist[to] > cost + pc) {
        dist[to] = cost + pc;
        if(pc == 1) {
          q.emplace_back(dist[to], to);
        } else {
          q.emplace_front(dist[to], to);
        }
      }
    }
  }

  cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 3180
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]

MOD = 10 ** 9 + 7
dp = [[0] * w for _ in range(h)]

i = 0
while i < w and grid[0][i] != '#':
	dp[0][i] = 1
	i += 1

j = 0
while j < h and grid[j][0] != '#':
	dp[j][0] = 1
	j += 1

for i in range(1, h):
	for j in range(1, w):
		if grid[i][j] == '#':
			dp[i][j] == 0
		else:
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
			dp[i][j] %= MOD

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


Measured memory_bytes: 87408
// C - Traveling
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	while(N--){
		int t,x,y; cin>>t>>x>>y;
		if(t<x+y || (t-x-y)&1){ puts("No"); return 0; }
	}
	puts("Yes");
}

Measured memory_bytes: 256
// BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

typedef long long ll;

int main()
{
    int a, b;

    scanf("%d %d", &a, &b);

    if(a + b == 15){
        printf("+\n");
    }
    else if(a * b == 15)
        printf("*\n");
    else
        printf("x\n");

    return 0;
}


Measured memory_bytes: 256
/************************************************************
	> File Name: a.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Fri 20 Dec 2019 02:08:44 AM CST
************************************************************/

#pragma GCC optimize(2)
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
int main(void){
	int a, b, c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b+c>=22)
		printf("bust\n");
	else
		printf("win\n");
	return 0;
}

Measured memory_bytes: 256
from operator import itemgetter


n,m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for i in range(m)]

a.sort()

bc = sorted(bc,key=itemgetter(1))
bc.reverse()

j = 0
k = 0
for i in range(n):
    if bc[j][1]>a[i]:
        a[i]=bc[j][1]
        k+=1
        if k >=bc[j][0]:
            k=0
            j+=1
    if j==len(bc):
        break

print(sum(a))

Measured memory_bytes: 82840
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=A.at(i);
  }
  double x=(double)sum/(4*M);
  int cnt=0;
  for(int i=0;i<N;i++){
    if(A.at(i)>=x){
      cnt++;
    }
  }
  if(cnt>=M){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int c[n];
    int a[n][m];
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int ans = INF;
    for(int bit=0;bit<(1<<n);bit++){
        int sum = 0;
        int u[m];
        rep(i,m)u[i]=0;
        rep(i,n){
            if((bit>>i)&1){
                sum+=c[i];
                rep(j,m){
                    u[j]+=a[i][j];
                }
            }
        }
        bool ok = 1;
        rep(i,m){
            if(u[i]<x)ok=0;
        }
        if(ok)chmin(ans,sum);
    }
    if(ans!=INF)cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N=3e3+5,Mod=1e9+7,inv2=(Mod+1)/2;
int a[N],f[N][N],g[N][N];
int main (){
	int n,q;scanf ("%d%d",&n,&q);
	for (int i=1;i<=n;i++) scanf ("%d",&a[i]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			f[i][j]=a[i]<a[j];
	int pw=1;
	while (q--){
		pw=2ll*pw%Mod;
		int x,y;scanf ("%d%d",&x,&y);
		for (int i=1;i<=n;i++)
			if (i!=x&&i!=y){
				g[i][x]=1ll*inv2*(f[i][x]+f[i][y])%Mod;
				g[x][i]=1ll*inv2*(f[x][i]+f[y][i])%Mod;
				g[i][y]=1ll*inv2*(f[i][y]+f[i][x])%Mod;
				g[y][i]=1ll*inv2*(f[y][i]+f[x][i])%Mod;
			}
		for (int i=1;i<=n;i++)
			if (i!=x&&i!=y)
				f[i][x]=g[i][x],f[x][i]=g[x][i],f[i][y]=g[i][y],f[y][i]=g[y][i];
		f[x][y]=f[y][x]=1ll*(f[x][y]+f[y][x])*inv2%Mod;
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<i;j++)
			ans=(ans+1ll*pw*f[i][j])%Mod;
	printf ("%d",ans);
	return 0;
}


Measured memory_bytes: 70784
import java.util.*;

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

		while(n-- > 0){
			p = sc.next().toCharArray();
			Parsed ans = expr(0);
			System.out.println(ans.val);
		}
	}

	static char[] p;

	static Parsed expr(int idx){
		Parsed r = term(idx);
		while(p[r.idx] == '+' || p[r.idx] == '-'){
			char op = p[r.idx];
			int tmp = r.val;
			r = term(r.idx + 1);
			if(op == '+') r.val = tmp + r.val;
			else r.val = tmp - r.val;
		}
		return r;
	}

	static Parsed term(int idx){
		Parsed r = fact(idx);
		while(p[r.idx] == '*' || p[r.idx] == '/'){
			char op = p[r.idx];
			int tmp = r.val;
			r = fact(r.idx + 1);
			if(op == '*') r.val = tmp * r.val;
			else r.val = tmp / r.val;
		}
		return r;
	}

	static Parsed fact(int idx){
		if(Character.isDigit(p[idx])){
			int t = p[idx++] - '0';
			while(Character.isDigit(p[idx]))t = t*10 + p[idx++] - '0';
			return new Parsed(t,idx);
		}
		else if(p[idx] == '('){
			Parsed r = expr(idx + 1);
			if(p[r.idx] != ')') return null;
			return new Parsed(r.val, r.idx + 1);
		}
		else return null;
	}
}

class Parsed{
	int val;
	int idx;
	Parsed(int val,int idx){
		this.val = val;
		this.idx = idx;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  while (N) {
    ans++;
    N /= K;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;

  set<int> num;
  num.insert(A);
  num.insert(B);
  num.insert(C);

  if (num.size() == 2) cout << "Yes" << endl;
  else cout << "No" << endl;

}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



int main() {
  int n;
  cin >> n;
  int a = 0, b = 0, c = 0;
  int ans = 0;
  rep (i, n) {
    string s;
    cin >> s;
    if (s[0] == 'B' && s.back() == 'A') {
      c++;
    }
    else if (s[0] == 'B') b++;
    else if (s.back() == 'A') a++;

    rep (j, s.size() - 1) {
      if (s.substr(j, 2) == "AB") ans++;
    }
  }
  if (c > 0) {
    if (a > 0) {
      ans += min({n - 1, c + min(a, b)});
    }
    else {
      if (b == 0) {
        ans += c - 1;
      }
      else {
        ans += c;
      }
    }
  }
  else {
    ans += min(a, b);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        
    	int minj;
    	int n = 0;
        for(int i = 0; i < N; i++){
        	minj = i;
            for(int j = i; j < N; j++){
                if(a[j] < a[minj]){
                    minj = j;
                }
            	if(j == N-1 && minj != i){
            		n += 1;
            	}
            }
        	int a0;
            a0 = a[i];
            a[i] = a[minj];
            a[minj] = a0;
        }
    	
    	for(int j = 0; j < N; j++){
    		if(j == N-1){
            	System.out.println(a[j]+"");
    		}else{
    			System.out.print(a[j]+" ");
    		}
    	}
    	System.out.println(n);
    }
}


Measured memory_bytes: 26268
#include <iostream>

using namespace std;

int a[100][100], b[100][100];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, l;
	cin>>n>>m>>l;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<m; ++j) {
			cin>>a[i][j];
		}
	}
	for(int i=0; i<m; ++i) {
		for(int j=0; j<l; ++j) {
			cin>>b[i][j];
		}
	}
	long long s;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<l; ++j) {
			s=0;
			for(int k=0; k<m; ++k) {
				s+=a[i][k]*b[k][j];
			}
			if(j) cout<<' ';
			cout<<s;
		}
		cout<<'\n';
	}
	return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
 
const ll mod = 1e9+7;
const double pi = acos(-1);

ll n,t,j,i,k;
ll m;

int main(){
	scanf("%lld %lld", &n, &m);
	if(n>m){
		swap(n,m);
	}
	if(n==1&&m==1)
		puts("1");
	else if(n==1){
		printf("%lld\n", m-2);
	}
	else
		printf("%lld\n", n*m-(2*n+2*m-4));
	return 0;
}

Measured memory_bytes: 256
n=gets.to_i
l=[]
n.times do
  a,b=gets.split.map(&:to_i)
  l << [a+b,a,b]
end
c=0
l.sort.reverse.each.with_index do |ll,i|
  if i.even?
    c+=ll[1]
  else
    c-=ll[2]
  end
end
puts c


Measured memory_bytes: 22300
import java.util.*;

public class Main {
    static int n;
    static int k;
    static int[] a;
    static int[] dp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        a = new int[n];
        for (int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }

        dp = new int[n+1];
        dp[0] = 0;
        for (int i=1; i<n+1; i++) {
            //最小問題は最大値を代入
            dp[i] = Integer.MAX_VALUE;
        }
        for (int i=1; i<n; i++) {
            int min = Integer.MAX_VALUE;
            for (int j=1; j<=k; j++) {
                if (i<j) {
                    continue;
                }
                min = Math.min(min, Math.abs(a[i] - a[i-j]) + dp[i-j]);
            }
            dp[i] = min;
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 51584
N = int(input())
H = list(map(int, input().split()))

check = [True]*(N-1)
for i in range(N-1):
    if check[i] and H[i] > H[i+1]:
        check[i] = False
        H[i] -= 1
for i in range(N-2, -1, -1):
    if check[i] and H[i] > H[i+1]:
        check[i] = False
        H[i] -= 1
for i in range(N-1):
    if H[i] > H[i+1]:
        break
else:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 14704
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[200005];
long long s[200005];
long long cal(long long s[], int nn) {
    if (nn == 1) return 0;
    long long s1[nn/2+2], s2[nn/2+2];
    for(int i = 1; i <= nn/2; ++i) s1[i] = s[i];
    for(int i = nn/2+1; i <= nn; ++i) s2[i-nn/2] = s[i];
    long long ans1 = cal(s1, nn/2);
    long long ans2 = cal(s2, nn-nn/2);
    sort(s1+1, s1+1+nn/2);
    long long ans3 = 0;
    for(int i = 1; i <= nn-nn/2; ++i) {
        int inf = 1, sup = nn/2, mid, tt = 0;
        while (inf <= sup) {
            mid = inf + sup >> 1;
            if (s1[mid] <= s2[i]) {
                tt = mid;
                inf = mid + 1;
            } else sup = mid - 1;
        }
        ans3 += tt;
    }
    return ans1 + ans2 + ans3;
}
int main() {
    cin >> n >> k;
    long long sum =0;
    long long ans = 0;
    s[1] = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum = sum + a[i];
        long long t = sum - 1LL*k*i;
        s[i+1] = t;
    }
    ans = cal(s, n+1);
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include<stdio.h>
int main(void){
    int a,b,c,min;
    scanf("%d%d%d",&a,&b,&c);
    min=a+b>a+c?a+c:a+b;
    min=min>b+c?b+c:min;
    printf("%d",min);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <cstdio>
#define EPS (1e-10)
using namespace std;
typedef pair<int,int> pii;

struct P{
  double X, Y, Z;
};

namespace std{
  P operator- (const P& a, const P& b){
    P ret = {a.X-b.X, a.Y-b.Y,a.Z-b.Z};
    return ret;
  }
}

double norm_3d(P a){
  return a.X*a.X + a.Y*a.Y + a.Z*a.Z;
}

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y + a.Z*b.Z;
}

int n;

vector<double> solve(vector<P> &p, vector<P> &v, vector<double> &r, vector<double> &vr){
  vector<double> vanish;
  vector< pair<double, pii> > collision;
  for(int i = 0; i < n; ++i)
    vanish.push_back(r[i]/vr[i]);
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < i; ++j){
      P d_p = p[i]-p[j], d_v = v[i]-v[j];
      double A = norm_3d(d_v) - (vr[i]+vr[j])*(vr[i]+vr[j]),
	B = dot(d_p,d_v) + (r[i]+r[j])*(vr[i]+vr[j]),
	C = norm_3d(d_p) - (r[i]+r[j])*(r[i]+r[j]),
	m  = min(vanish[i],vanish[j]);
      if(abs(A) > EPS && B*B - A*C > 0){
	double
	  t1 = (-B+sqrt(B*B - A*C))/A,
	  t2 = (-B-sqrt(B*B - A*C))/A;
	if(t1 > 0 && t1 < m) collision.push_back(make_pair(t1,pii(i,j)));
	if(t2 > 0 && t2 < m) collision.push_back(make_pair(t2,pii(i,j)));
      }else if(abs(A) < EPS){
	double t1 = -C/2.0/B;
	if(t1 > 0 && t1 < m) collision.push_back(make_pair(t1,pii(i,j)));
      }
    }
  }
  sort(collision.begin(), collision.end());
  int k = (int)collision.size();
  for(int i = 0; i < k; ++i){
    double t = collision[i].first;
    int p = collision[i].second.first, q = collision[i].second.second;
    if(t < vanish[p] && t < vanish[q]){
      vanish[p] = t;
      vanish[q] = t;
    }
  }
  return vanish;
}

int main(){
  while(cin >> n, n){
    vector<P> p, v;
    vector<double> r(n), vr(n);
    double px, py, pz, vx, vy, vz;
    for(int i = 0; i < n; ++i){
      cin >> px >> py >> pz >> vx >> vy >> vz >> r[i] >> vr[i];
      P pi = {px,py,pz}, vi = {vx,vy,vz};
      p.push_back(pi);
      v.push_back(vi);
    }
    vector<double> ans = solve(p,v,r,vr);
    for(int i = 0; i < n; ++i)
      printf("%.10f\n",ans[i]); 
  }
  return 0;
}

Measured memory_bytes: 3324
N,M,C=map(int, raw_input().split())
B=map(int, raw_input().split())
A=[ map(int, raw_input().split()) for _ in range(N)]

ans=0

for x in A:
	t=0
	for a,b in zip(x,B):
		t+=a*b
	t+=C
	if t>0: ans+=1

print ans

Measured memory_bytes: 28140
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

void solve();

const int N = 2e5 + 10;

int main() {
    fast_cin();

    int t=1;
    // cin >> t;
    while(t--) {
        solve();
    }
}

void solve() {
    int n, k;
    cin >> n >> k;
    int a[N];
    for (int i=1; i <= n; i++) { 
        cin >> a[i];
    }

    sort(a+1, a+1+n, greater<int>());
    
    ll sum = 0;
    for (int i=k+1; i <= n; i++) {
        sum += a[i];
    }
    
    cout << sum << '\n';
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    char in[500];
    int ans_max=0,ans_long=0;
    string s_max,s_long;
    map<string,int> mm;
    
    while(EOF!=scanf("%s",in)){
        
        string S = in;
        
        if((int)S.size() > ans_long){
            s_long = S;
            ans_long = (int)S.size();
        }
        
        mm[S]++;
    }
    
    for(map<string,int>::iterator it = mm.begin();it!=mm.end();it++){
        if( (it->second) > ans_max ){
            ans_max = it->second;
            s_max = it->first;
        }
    }
    
    cout << s_max <<  " " << s_long << endl;
    
    return 0;
}

Measured memory_bytes: 1208
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    vector<ll> A(n); rep(i, n) cin >> A[i];
    int res = 0;
    rep(i, n){
        rept(j,i+1, n){
            rept(k,j+1, n){
                int a = A[i], b = A[j], c = A[k];
                if(a == b || a == c || b == c)continue;
                if(a < b+c && b < a+c && c < a+b)res++;
            }
        }
    }
    cout << res << ln;
}
    


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int k, x;
int main(){
    cin >> k >> x;
    int have = k*500;
    if(have >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], right[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
		add_BIT(W, BIT, i, 1);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, A - 1);
		if (sum_BIT(BIT, B) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		L = A;
		R = B++;
		while (L < R) {
			M = (L + R) / 2;
			if (sum_BIT(BIT, M) > tmp) R = M;
			else L = M + 1;
		}
		
		left[B] = left[L];
		right[left[L]] = B;
		if (s[B] < 0) add_BIT(W, BIT, B, 1);
		for (j = L; j < B; j = right[j]) {
			s[B] = (s[j] > s[B])? s[j]: s[B];
			s[j] = -1;
			add_BIT(W, BIT, j, -1);
		}
		if (j != B) {
			left[j] = B;
			right[B] = j;
		}
		if (B <= W) {
			d.key = B - s[B];
			d.id = B;
			push(d, &h);
		}
		
		while (h.size > 0 && s[h.obj[1].id] < h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

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

int main(){
    int N;
    string s, t;
    cin >> N >> s >> t;
    for(int i=0; i<N; i++){
      bool flag =true;
      for(int j=i; j<N; j++){
        if(s[j]!=t[j-i]){
          flag =false;
          break;
        }
      }
      if(flag){
        cout << N+i << endl;
        return 0;
      }
    }
    cout << 2*N << endl;
    return 0;
}

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

int main(){
  int a;
  int b;
  int c;
  int seged;
  cin >> a;
  cin >> b;
  cin >> c;
  seged=a;
  a=b;
  b=seged;
  seged=c;
  c=a;
  a=seged;
  cout << a<<" "<<b <<" "<<c;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

int main(int argc, const char* argv[]) {
  u64 ret = 0;
  
  i64 n, m, c;
  cin >> n >> m >> c;
  
  i64 a[n][m] = {0};
  i64 b[m] = {0};
  for(u64 i = 0; i < m; ++i) {
    cin >> b[i];
  }
  for(u64 i = 0; i < n; ++i) {
    i64 score = 0;
    for(u64 j = 0; j < m; ++j) {
      cin >> a[i][j];
      score += a[i][j] * b[j];
    }
    
    if(score + c > 0) ++ret;
  }
  
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

vector<int> g[128000];

int dfs(int v) {
  vector<int> vec;
  for (int i: g[v]) {
    vec.emplace_back(dfs(i));
  }
  if (vec.empty()) return 0;
  sort(ALL(vec));
  reverse(ALL(vec));
  REP(i,vec.size()) vec[i] += i + 1;
  return *max_element(ALL(vec));
}

void solve(ll N, vector<ll> a) {
  REP(i,N-1) {
    g[a[i] - 1].push_back(i + 1);
  }
  cout << dfs(0) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> a(N-2+1);
	for (int i = 0 ; i <= N-2 ; i++) {
	  scanf("%lld", &a[i]);
	}
	solve(N, a);
	return 0;
}


Measured memory_bytes: 15744