akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) cout << "+" << endl;
    else if (a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

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

	int N; cin >> N;
	queue<int> A;
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp;
		A.push(tmp);
	}

	int ans = 0;
	while (!A.empty()) {
		int num = A.front();
		A.pop();
		ans++;

		while (!A.empty() && num == A.front()) A.pop();

		if (!A.empty()) {
			if (num < A.front()) {
				while (!A.empty() && num <= A.front()) {
					num = A.front();
					A.pop();
				}
			}
			else { // num > A.front()
				while (!A.empty() && num >= A.front()) {
					num = A.front();
					A.pop();
				}
			}
		}
	}

	cout << ans << endl;


	return 0;
}

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

int main(){
   int n; cin>>n;
   vector<int> p(n);
   vector<int> q(n);
   rep(i,n) cin>>p[i];
   rep(i,n) cin>>q[i];
   vector<int> a(n);
   rep(i,n) a[i]=i+1;
   map<vector<int>,int> mp;
   do{
      mp[a]=mp.size();
   } while(next_permutation(a.begin(),a.end()));

   int ans=abs(mp[p]-mp[q]);
   cout<<ans<<endl;
   return 0;

}

   


Measured memory_bytes: 5248
N, M = map(int, input().split())
paths = []

for i in range(M) :
    paths.append(list(map(int, input().split())))
    
INF = -10**20
cost = [INF for x in range(N)]
cost[0] = 0
break_flg, inf_flg = True, False
cnt = 0

for i in range(N) :
    break_flg = True 
    
    for p in paths :
        f, t, c = p[0] - 1, p[1] - 1, p[2]
        
        if cost[t] < cost[f] + c :
            cost[t] = cost[f] + c
            break_flg = False
            
            if i == N - 1 and t == N - 1 :
                inf_flg = True 
            
    # break flg
    if break_flg == True :
        break
        
if inf_flg == True :
    print("inf")
else :
    print(cost[N - 1])

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

int main(){
  int N,a,b;
  cin >> N;
  int k=0, x=0;
  for (int i=0; i<N; i++){
    cin >> a >> b;
    if (a == b)
      k++;
    else
      k=0;
    if (k == 3)
      x =1;
  }
  if (x == 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 20;
const int INF = int(1e9);

int n, m, x;
int c[N], a[N][N];


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m >> x;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (int j = 0; j < m; ++j) cin >> a[i][j];
    }

    int ALL = (1 << n);
    int ans = INF;
    for (int mask = 0; mask < ALL; ++mask) {
        vector<int> level(m);
        int cur = 0;

        for (int i = 0; i < n; ++i) {
            if ((1 << i) & mask) {
                cur += c[i];
                for (int j = 0; j < m; ++j) level[j] += a[i][j];
            }
        }

        bool ok = true;
        for (int i = 0; i < m; ++i) {
            if (level[i] < x) {
                ok = false;
                break;
            }
        }

        if (ok) ans = min(ans, cur);
    }

    if (ans == INF) cout << -1 << '\n';
    else cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3652
N, X = map(int, input().split(' '))

level2p = [1] * (N + 1)
level2pb = [1] * (N + 1)

for i in range(N):
    level2p[i + 1] = level2p[i] * 2 + 1
    level2pb[i + 1] = level2pb[i] * 2 + 3


def dfs(n, x):
    if n == 0:
        return 1

    if x <= 1:
        return 0
    elif x <= 1 + level2pb[n - 1]:
        return dfs(n - 1, x - 1)
    elif x <= 1 + level2pb[n - 1] + 1:
        return level2p[n - 1] + 1
    elif x <= 1 + level2pb[n - 1] + 1 + level2pb[n - 1]:
        return level2p[n - 1] + 1 + dfs(n - 1, x - 1 - level2pb[n - 1] - 1)
    else:
        return level2p[n]


print(dfs(N, X))


Measured memory_bytes: 9124
import java.util.Scanner;

//time:: 16:44~16:56

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int m=sc.nextInt();
			int nmin=sc.nextInt();
			int nmax=sc.nextInt();
			if((m==0&&nmin==0)&&nmax==0) break;
			Integer[] point = new Integer[m];
			for(int i=0;i<m;++i){
				point[i]=sc.nextInt();
			}
			int gap=-1,res=-1;
			for(int i=nmin-1;i<nmax;++i){
				if(gap<point[i]-point[i+1]){
					gap=point[i]-point[i+1];
					res=i;
				} else if(gap==point[i]-point[i+1]&&res<i){
					res=i;
				}
			}
			System.out.println(res+1);
		}
	}

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_printf(x...) cerr << "line " << __LINE__ << " : "; debug_printf_in(x);

template <typename First>
void debug_printf_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_printf_in(First first, Rest... rest){
  cerr << first << " ";
  debug_printf_in(rest...);
  return;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  string S;
  IN(S);
  ll L = S.size();

  REP(i,L) S[i] -= 'A';
  REP(i,L) S[i] += N;
  REP(i,L) S[i] %= ('Z'-'A'+1);
  REP(i,L) S[i] += 'A';

  OUT(S);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		if(s.substring(s.length() - 1).equals("s")) {
			s += "es";
		} else {
			s += "s";
		}
 		prtln(s);
	}

	public static <T> void prtln(T t) { System.out.println(t); }
}


Measured memory_bytes: 27008
n = int(input())
a = list(map(int,input().split()))
q = int(input())
u = []
for i in range(q):
    u.append(tuple(map(int,input().split())))

from collections import Counter
z = Counter(a)

sum = sum(a)
for i in range(q):
    try:
        rev = z.pop(u[i][0])
        sum+=(u[i][1]-u[i][0])*rev
        print(sum)
        if u[i][1] in z:
            z[u[i][1]]+=rev
        else:
            z[u[i][1]]=rev
    except KeyError:
        print(sum)

Measured memory_bytes: 32712
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC148C - Snack

        Scanner sc = new Scanner(System.in);

        long a = (long)sc.nextInt();
        long b = (long)sc.nextInt();

        long x = 0;
        
        for (int i = 1; i <= b; i++) {
            x = a * i;
            if (x % b == 0) {
                break;
            }
        }
        
        System.out.println(x);
    }
}


Measured memory_bytes: 21972
function Main(input) {
  var tmp = input.split(' ');
  var a = parseInt(tmp[0], 10);
  var b = parseInt(tmp[1], 10);

  //出力
  console.log('%d', Math.max(a + b, a - b, a * b));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <set>

using namespace std;

struct ArticularPoint {
    int n;
    vector<vector<int>> g;
    set<int> points;
    vector<int> parent;
    vector<int> discTime;
    vector<int> lowTime;
    vector<bool> visited;
    vector<bool> isAp;
    int time = 0;
    
    ArticularPoint(int n): n(n) {
        g.assign(n, vector<int>());
        parent.assign(n, -1);
        discTime.assign(n, 0);
        lowTime.assign(n, n + 1);
        visited.assign(n, false);
        isAp.assign(n, false);
    }
    
    void addEdge(int from, int to) {
        g[from].push_back(to);
        g[to].push_back(from);
    }
    
    int solve() {
        dfs(0, -1);
        return points.size();
    } 
    
    void dfs(int u, int p) {
        discTime[u] = time++;
        lowTime[u] = discTime[u];
        visited[u] = true;
        int child = 0;
        for (int v : g[u]) {
            if (!visited[v]) {
                child++;
                parent[v] = u;
                dfs(v, u);
                lowTime[u] = min(lowTime[u], lowTime[v]);
                if (lowTime[v] >= discTime[u]) {
                    isAp[u] = true;;
                }
            }
            else if (v != p) {
                lowTime[u] = min(lowTime[u], discTime[v]);
            }
        }
        //Remove root is it has only one child
        if (p < 0 && child == 1) {
           isAp[u] = false;
        }
    }   
};

int main() {
    int n, m;
    cin >> n >> m;
    ArticularPoint ap(n);
    
    for (int i = 0; i < m; i++) {
        int from, to;
        cin >> from >> to;
        ap.addEdge(from, to);
    }
    
    int ans = ap.solve();
    for (int i = 0; i < n; i++) {
        if (ap.isAp[i]) {
            cout << i << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4552
class ModOperator:
    def __init__(self, MOD: int = 10 ** 9 + 7):
        self.MOD = MOD

    # x^n % MOD
    def mod_pow(self, x: int, n: int):
        bi = str(format(n, "b"))
        res = 1
        a = x
        for i in range(len(bi)):
            if n >> i & 1:
                res = (res * a) % self.MOD
            a = (a * a) % self.MOD
        return res
    
    # x! % MOD
    def mod_fact(self, x: int):
        res = 1
        for i in range(1, x + 1):
            res = res * i % self.MOD
        return res % self.MOD

    # x * (x - 1) * ... * (x - y + 1) % MOD
    def mod_partial_fact(self, x: int, y: int):
        res = 1
        for i in range(x - y + 1, x + 1):
            res = res * i % self.MOD
        return res % self.MOD

    # inverse of a number
    def mod_inv(self, x: int):
        return self.mod_pow(x, self.MOD - 2)
    
    # conmination nCk
    def mod_comb(self, n: int, k: int):
        numerator = self.mod_partial_fact(n, k)
        denomintator = self.mod_fact(k)
        return numerator * self.mod_inv(denomintator) % self.MOD


def main():
    X, Y = map(int, input().split())

    p = (X + Y) // 3
    q = (X + Y) % 3
    if q == 0 and p <= X <= 2 * p and p <= Y <= 2 * p:
        op = ModOperator()
        res = op.mod_comb(p, X - p)
    else:
        res = 0
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N * 3);
  for (int i = 0; i < N * 3; i++){
    cin >> A[i];
  }
  long long sum = 0;
  vector<long long> L(N * 3, 0);
  priority_queue<long long, vector<long long>, greater<long long>> pq1;
  for (int i = 0; i < N; i++){
    sum += A[i];
    pq1.push(A[i]);
  }
  L[N] = sum;
  for (int i = N; i < N * 2; i++){
    if (pq1.top() < A[i]){
      sum -= pq1.top();
      pq1.pop();
      sum += A[i];
      pq1.push(A[i]);
    }
    L[i + 1] = sum;
  }
  sum = 0;
  vector<long long> R(N * 3, 0);
  priority_queue<long long> pq2;
  for (int i = N * 3 - 1; i >= N * 2; i--){
    sum += A[i];
    pq2.push(A[i]);
  }
  R[N * 2] = sum;
  for (int i = N * 2 - 1; i >= N; i--){
    if (pq2.top() > A[i]){
      sum -= pq2.top();
      pq2.pop();
      sum += A[i];
      pq2.push(A[i]);
    }
    R[i] = sum;
  }
  long long ans = -INF;
  for (int i = N; i <= N * 2; i++){
    ans = max(ans, L[i] - R[i]);
  }
  cout << ans << endl;
}

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

int main(){
	int N;
	cin >> N;
  	if(N%2==0){
  		cout << N/2 << endl;
  	}
    else cout << N/2+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()
 
int main(){
  ll X,K,D;
  cin >> X >> K >> D;
  X=abs(X);
  if(X/D>K){
    cout << X-K*D << endl;
  }else if(X==0){
    if(K%2==0) cout << 0 << endl;
    else cout << D << endl;
  }else{
    ll k=X/D;
    if(K%2==k%2){
      cout << X-k*D << endl;
    }else{
      cout << abs(X-(k+1)*D) << endl;
    }
  }
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
int color[100050];
int cnt;
vector<int> G[100050];
#define WHITE 0
#define GRAY 1
#define BLACK 2

class Union_find{
 public :
 vector<int> Parent;
  
 int root(int n){
  if(Parent[n]<0)return n;
  else return Parent[n]=root(Parent[n]);
 }

 int size(int n){
  return - Parent[root(n)];
 }
  
 Union_find(int n){
  Parent=vector<int>(n+1,-1);
 }
 
 bool connect(int a, int b){
  a=root(a);
  b=root(b);
  if(a==b)return false;

  if(size(a)<size(b))swap(a,b);
  Parent[a]+=Parent[b];
  Parent[b]=a;
  return true;
 }
};

int main(void){
 int N,M,a,b;
 cin>>N>>M;
 vector<long long int> A;
 vector<long long int> B;
 vector<long long int> ans(M,0); 

 for(int i=0;i<M; i++){
  cin>>a>>b;
  A.push_back(a);
  B.push_back(b);
 }
 Union_find Uni(N);
 
 ans[M-1]=(long long int)N*(N-1)/2;
 for(int i=M-1; i>=1; i--){
  ans[i-1]=ans[i];
  if(Uni.root(A[i])!=Uni.root(B[i])){
   ans[i-1]-=(long long int)Uni.size(A[i])*Uni.size(B[i]);
   Uni.connect(A[i],B[i]);
  }
 }
 for(int i=0; i<M; i++)cout<<ans[i]<<endl;
 return 0;
}

Measured memory_bytes: 6380
#include<bits/stdc++.h>
using namespace std;
const int N=55;
int n,a[N];
bool check()
{
    for(int i=2;i<=n;i++)
        if(a[i]<a[i-1]) return false;
    return true;
}
int main()
{
    bool flag=false;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    if(check()) flag=true;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
    {
        swap(a[i],a[j]);
        if(check()) flag=true;
        swap(a[i],a[j]);
    }
    printf(flag?"YES":"NO");
}


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

using ull = unsigned long long;

const ull mod = 1000000007;

int main() {

    int n;

    cin >> n;

    const int maxV = 1000 + 10;
    vector<ull> count(maxV, 0);

    for(int i = 2; i <= n; ++i) {

        ull num = i;

        for(int j = 2; j * j <= num; ++j) {

            while(num % j == 0) {
                num /= j;
                count[j]++;
            }

        }

        if(num != 1)
            count[num]++;

    }

    ull ans = 1;

    for(int i = 2; i <= n; ++i) {
        if(count[i] == 0)
            continue;

        ans = ans * (count[i] + 1);
        ans %= mod;

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

const ll INF=1LL<<29;

signed main() {
  int n; cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  rep(i,n) rep(j,n) cin >> a[i][j];

  ll ans = 0;
  rep(i,n) for(int j=i+1; j<n; j++) ans += a[i][j];
  rep(i,n) for(int j=i+1; j<n; j++) rep(k,n) {
    if(a[i][j] > a[i][k] + a[k][j]) {
      puts("-1");
      return 0;
    }
    if(i!=k && j!=k && a[i][j] == a[i][k] + a[k][j]) {
      ans -= a[i][j];
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
int d,t,s;
int ok() {
    if(s*t>=d)return 1;
    return 0;
}
int main() {
    cin>>d>>t>>s;
    if(ok()) cout<<"Yes";
    else cout<<"No";
	return 0;
}

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

int main(){
	int H,W;
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0)break;
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    string s; cin >> s;
    int n = s.size();
    int h = (n-1)/2;
    bool flag = true;
    rep(i, h) {
        char a = s[i];
        char b = s[n-i-1];
        if (a!=b) flag = false;
    }
    int a = h/2;
    rep(i, a) {
        char a = s[i];
        char b = s[h-i-1];
        if (a!=b) flag = false;
    }
    if (flag) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 201001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
ll H[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．


ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//ll lcm(ll a, ll b) {
//    return a / (gcd(a, b) % MOD) * (b % MOD);
//}

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program
void solve() {
    ll  N,K;
    cin >> N;
    cin >> K;
    ll sum = 0;
    //ll MOD = 1000000007;

    for (ll i = 0; i < N; i++) {
        cin >> H[i];
    }

    sort(H, H + N, std::greater<long>());
    
    //if (K == 0) K = +1;
    for (ll i = K; i < N; i++) {
        sum+=H[i];
    }

    cout << sum;
    return;
    //ll  N;
    //cin >> N;
    //ll sum = 0;

    //ll Top = 0;
    //ll Bottom = 0;
    //ll Len = 0;

    //for (ll i = 1; i < N; i++) {
    //    Len = digit_length(i);
    //    Top = i / Len;
    //    Bottom = i %10;

    //    if (i < 10) {
    //        sum++;
    //        for (ll j = 1; j < 6; j++) {
    //            if (i >= Bottom * pow(10,j) + Top) {
    //                sum++;
    //            }
    //        }
    //    }
    //    else if (i < 100) {
    //        //sum++;
    //        for (ll j = 1; j < 6; j++) {
    //            if (i >= Bottom * pow(10, j) + Top) {
    //                sum++;
    //            }
    //        }
    //    }
    //    else if (i < 1000) {
    //        //sum+=10;
    //        for (ll j = 1; j < 6; j++) {
    //            if (i >= Bottom * pow(10, j) + Top) {
    //                sum++;
    //            }
    //        }
    //    }
    //    else if (i < 10000) {
    //        sum += 100;
    //    }
    //    else if (i < 100000) {
    //        sum += 1000;
    //    }
    //    else if (i < 1000000) {
    //        sum += 10000;
    //    }
    //}
    //cout << sum;
    //   
    //return;

}



int main() {
    solve();
    return 0;
}







Measured memory_bytes: 1792
n, m = gets.split.map(&:to_i)
brokens = []
m.times do
  brokens << gets.to_i
end

options = [1]

(1..n).each do |i|
  if brokens.bsearch { |broken| broken >= i } == i
    options[i] = 0
  else
    case i
    when 1
      options[i] = options[i - 1]
    else
      options[i] = options[i - 1] + options[i - 2]
    end
  end
end

puts options.last % 1_000_000_007


Measured memory_bytes: 433020
def solve():
  s = input()
  n = len(s)-1
  ans = 0
  for i in range(2**n):
    nsum = 0
    for j in range(n):
      if 1&(i>>j) == 1:
        ans += int(s[nsum:j+1])
        nsum = j+1
    ans += int(s[nsum:])
  print(ans)
solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    ll int n;
   char a[101],b[101];
   cin>>n>>a>>b;
   for(int i=0;i<n;i++)
   {
     cout<<a[i]<<b[i];
   }


return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll INF = 1e18;

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

	int n;
	cin >> n;
	vector<pair<int, int>> itvs(n);
	for (auto& pr : itvs) {
		ll x, l;
		cin >> x >> l;
		pr = {x + l, x - l};
	}
	sort(itvs.begin(), itvs.end());

	int res = 0;
	ll mx = -INF;
	for (auto pr : itvs) {
		if (pr.second >= mx) {
			++res;
			mx = pr.first;
		}
	}
	cout << res << '\n';
}


Measured memory_bytes: 1024
// B.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

typedef pair<int, int> II;

void update_r(int h, int w, int x, int y, int &r) {
	r = min(r, x);
	r = min(r, y);
	r = min(r, w - 1 - x);
	r = min(r, h - 1 - y);
}

int main(int argc, char *argv[])
{
	int h, w, k, sx, sy, r = 1 << 30;
	cin >> h >> w >> k;
	string b[1000];
	for (int i = 0; i < h; ++i) {
		cin >> b[i];
		int pos = b[i].find('S');
		if (pos >= 0) {
			sx = pos, sy = i;
		}
	}
	update_r(h, w, sx, sy, r);
	vector<II> v;
	v.push_back(II(sx, sy));
	for (int i = 0; i < k; ++i) {
		vector<II> next;
		for (auto &xy : v) {
			int dx[] = {-1,1,0,0};
			int dy[] = {0,0,-1,1};
			for (int d = 0; d < 4; ++d) {
				int x = xy.first + dx[d], y = xy.second + dy[d];
				if (x >= 0 && x < w && y >= 0 && y < h && b[y][x] == '.') {
					b[y][x] = '?';
					next.push_back(II(x, y));
					update_r(h, w, x, y, r);
				}
			}
		}
		v = next;
	}
	int ans = 1 + (r + k - 1) / k;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000007;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
  ll n;
  cin >> n;

  vector<ll> v(n);
	scan(v);
  vector<ll> counter(n);
  ll pattern = 1;

  for (const auto &val : v) {
    counter[val]++;
  }

  for (int i = (n % 2 == 0) ? 1 : 2; i < n; i += 2) {
    if (counter[i] != 2) {
      pattern = 0;
      break;
    }
  }
  if (counter[0] != 1 && n % 2 != 0) {
    pattern *= 0;
  }

	REP(i, 0, (n / 2)) {
		pattern *= 2;
		pattern %= LL_MOD;
	}
	
	cout << pattern << "\n";
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int sx,sy,tx,ty,x,y;
    cin>>sx>>sy>>tx>>ty;
    x=tx-sx;
    y=ty-sy;
    for(int i=0;i<y;i++)
    {
    	printf("%c",'U');
	}
	for(int i=0;i<x;i++)
    {
    	printf("%c",'R');
	}
	for(int i=0;i<y;i++)
    {
    	printf("%c",'D');
	}
	for(int i=0;i<x;i++)
    {
    	printf("%c",'L');
	}
	printf("%c",'L');
	for(int i=0;i<y+1;i++)
    {
    	printf("%c",'U');
	}
	for(int i=0;i<x+1;i++)
    {
    	printf("%c",'R');
	}
	printf("%c",'D');
	printf("%c",'R');
	for(int i=0;i<y+1;i++)
    {
    	printf("%c",'D');
	}
	for(int i=0;i<x+1;i++)
    {
    	printf("%c",'L');
	}
	printf("%c\n",'U');
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>

using namespace std;

int main(void){

  int n;
  cin >> n;
  int cnt=0;

  while(n--){
    string s;
    cin >> s;
    if(s=="A")cnt++;
    else if(s=="Un" && cnt==0){
      cout << "NO" << endl;
      return 0;
    }
    else cnt--;
  }

  if(cnt==0)cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 3164
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll myp(ll a, ll n) {
	if (n <= 0)return 1;
	ll d = myp(a, n / 2);
	if (n & 1)return d * d%MOD*a%MOD;
	return d * d%MOD;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ll ans = 0;
	int n = s.size();
	vl a(n + 1, 0), c(n + 1, 0), q(n + 1, 0), rq(n + 1, 0);
	int cnt = 0;
	REP(i, n)cnt += s[i] == '?';
	REP(i, n) {
		a[i + 1] = a[i] + (s[i] == 'A');
		q[i + 1] = q[i] + (s[i] == '?');
	}
	RREP(i, n) {
		
		c[i] = c[i+1] + (s[i] == 'C');
		rq[i] = rq[i+1] + (s[i] == '?');
	}
	REP(i, n) {
		if (s[i] == 'B') {
			ans += a[i] * c[i+1] % MOD*myp(3, cnt);
			ans += q[i] * c[i+1] % MOD*myp(3, cnt - 1);
			ans += a[i] * rq[i+1] % MOD*myp(3, cnt - 1);
			ans += q[i] * rq[i+1] % MOD*myp(3, cnt - 2);
		
		}
		else if (s[i] == '?') {
			ans += a[i] * c[i+1] % MOD*myp(3, cnt - 1);
			ans += q[i] * c[i+1] % MOD*myp(3, cnt - 2);
			ans += a[i] * rq[i + 1] % MOD*myp(3, cnt - 2);
			ans += q[i] * rq[i + 1] % MOD*myp(3, cnt - 3);
		}
		ans %= MOD;
	}
	cout << ans << endl;

}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool U[100005];

int main()
{
    ll N;
    cin >> N;
    ll n = N;
    vector<ll> prime;
    FOR(i, 100000, 2)
    {
        if (U[i])
            continue;
        prime.push_back(i);
        for (int j = i; j < 100000; j += i)
            U[j] = true;
    }

    vector<ll> ans;
    int index = 0;
    while (index < prime.size())
    {
        if (N % prime[index] == 0)
        {
            ans.push_back(prime[index]);
            N /= prime[index];
        }
        else
            ++index;
    }
    if (N > 1)
        ans.push_back(N);

    cout << n << ":";
    REP(i, ans.size())
    {
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3384
s = input() + 'R'
a = [0] * (len(s) - 1);

prechar = 'R'
prepos = 0
odd = 0
even = 0
for i in range(len(s)):
    if prechar == 'R':
        if s[i] == 'L':
            prechar = 'L'
            prepos = i-1
    else:
        if s[i] == 'R':
            if (i - prepos) % 2 == 1:
                odd, even = even, odd
            a[prepos] = odd
            a[prepos+1] = even
            prechar = 'R'
            odd = 0
            even = 0
    odd, even = even, odd + 1
    #print(odd+even)

#print(a)
for i in range(len(s) - 1):
    if i != len(s) - 2:
        print(a[i], end=" ")
    else:
        print(a[i])



Measured memory_bytes: 10012
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  string S;
  cin >> N >> S;
  bool result;
  if (N & 1) result = false;
  else {
    int hn = N / 2;
    result = true;
    F0R(i, hn) {
      if (S[i] != S[hn + i]) {
        result = false;
        break;
      }
    }
  }
  cout << (result ? "Yes" : "No");
}
#endif


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int l, r, d;

int solve() {
    int cnt = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0)
            cnt++;
    }
    return cnt;
}

void input() {
    cin >> l >> r >> d;
}

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

    input();
    cout << solve() << endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
	ll x; cin >> x;
    ll ans=0;
    ans = (x/500)*1000 + ((x%500)/5)*5;

    cout << ans << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;

int main() {
    long long n;
    cin >> n;
    if(n <= 6)cout << 1;
    else if(n <= 11)cout << 2;
    else{
        if(n % 11 == 0)cout << n / 11 * 2;
        else if(n % 11 <= 6)cout << n / 11 * 2 + 1;
        else cout << n / 11 * 2 + 2;
    }

	return 0;

}


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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int count = 0;

    for(int i = 1;i <= N;++i){
        int num_1 = i % 10;
        int num_2 = (i / 10) % 10;
        int num_3 = (i / 100) % 10;
        int num_4 = (i / 1000) % 10;
        int num_5 = i / 10000;
        int sum = num_1 + num_2 + num_3 + num_4 + num_5;
        if(A <= sum && sum <= B)count += i;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/

/+---test
4 5
1 2
1 3
3 2
2 4
3 4
---+/
/+---test
6 3
2 3
4 5
5 6
---+/
/+---test
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
---+/

void main(string[] args) {
  long N, M;
  readf(" %d %d ", &N, &M);

  auto paths = new long[][](N);
  foreach (i; 0..M) {
    long x, y;
    readf(" %d %d ", &x, &y);
    --x; --y;
    paths[x] ~= y;
  }

  auto dp = new long[](N);
  dp[] = -1;

  long f(size_t v) {
    if (dp[v] != -1) return dp[v];
    dp[v] = 0;
    foreach (p; paths[v]) {
      dp[v].amax(f(p)+1);
    }
    return dp[v];
  }

  iota(N).each!f;
  dp.maxE.writeln;
}


Measured memory_bytes: 9852
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void calc(int n){
  if(n==0) return;
  calc(-((n-ABS(n)%2)/2));
  printf("%d",n%2==0?0:1);
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  if(n==0){
    printf("0\n");
    return;
  }
  calc(n);
  printf("\n");
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
g = [input() for _ in range(n)]

def bfs(r, c):
    t = [[-1] * m for v in g]
    q = []
    t[r][c] = 0
    q += (r, c),
    h = 0
    dirs = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    while h < len(q):
        r, c = q[h]
        h += 1
        for d in range(4):
            r1, c1 = r + dirs[d][0], c + dirs[d][1]
            if 0 <= r1 < n and 0 <= c1 < m and '.' == g[r1][c1] and t[r1][c1] < 0:
                t[r1][c1] = t[r][c] + 1
                q += (r1, c1),
    ret = -1
    for v in t:
        ret = max(ret, max(v))
    return ret

ans = 0
for i in range(n):
    for j in range(m):
        if g[i][j] == '.':
            ans = max(ans, bfs(i, j))
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main() {
	int a, b, n, m, x[101010], ans, add;
	string S;
	cin >> a >> b >> n >> m;
		cout << std::min(a,b)+std::min(n,m) << endl;
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>

int main() {
   int a, b, c;
   scanf("%d%d%d", &a, &b, &c);
    if((a != b && a != c && b!= c) || (a == b && b == c))
        printf("No\n");
    else
        printf("Yes\n");

    

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int n,m,l,i,j,k,a[100][100],b[100][100];
	long int c[100][100];
	
	cin >> n >> m >> l;
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			a[i][j]=0;
			cin >> a[i][j];
		}
	}
	
	for(j=0;j<m;j++){
		for(k=0;k<l;k++){
			b[j][k]=0;
			cin >> b[j][k];
		}
	}
	
	for(i=0;i<n;i++){
		for(k=0;k<l;k++){
			c[i][k]=0;
		}
	}
	
	for(i=0;i<n;i++){
		for(k=0;k<l;k++){
			for(j=0;j<m;j++){
				c[i][k]=c[i][k]+a[i][j]*b[j][k];
			}
		}
	}

	for(i=0;i<n;i++){
		for(k=0;k<l-1;k++){
			cout << c[i][k] << " ";
		}
		cout << c[i][l-1] << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1312
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] a = new int[n];
        int t = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            t += a[i];
        }
        Arrays.sort(a);
        a[n-1] = a[n-1] / 2;
        out.println(t - a[n-1]);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    inline int RANDAM(){
        return rand()%26+1;
    }

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl c(26);
        rep(i,26)cin>>c[i];
        vvl s(n,vl(26));
        rep(i,n)rep(j,26)cin>>s[i][j];
        rep(i,n){
            cout<<RANDAM()<<endl;
        }
    }


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

bool p[10001];

void seive(int s){
	for(int i=0;i<=s;i++)p[i]=true;
	p[0]=p[1]=false;
	for(int i=2;i<=s;i++){
		if(p[i]==true){
			for(int j=i*2;j<=s;j+=i)p[j]=false;
		}
	}
}

int main(void){
	seive(10000);
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		while(1){
			if(p[n]==true && p[n-2]==true){
				printf("%d %d\n",n-2,n);
				break;
			}
			n--;
		}
	}
    return 0;
}

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

using namespace std;
typedef long long lint;

int main() {
    int N, M;
    cin >> N >> M;
    map<int, int> mp;
    int sum = 0;
    mp[sum]++;
    lint ans = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        (sum += a) %= M;
        ans += mp[sum];
        mp[sum]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3200