akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int64_t n;
  cin>>n;
  std::vector<int64_t> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }



  int64_t result=0;
  

  while(true){
    bool found_greater=false;
    for(int i=0;i<n;i++){
      if(a[i]>=n){
        found_greater=true;
        int64_t operation=a[i]/n;
        a[i]%=n;
        result+=operation;
        for(int j=0;j<n;j++){
          if(i!=j){
            a[j]+=operation;
          }
        }
      }
    }
    if(!found_greater){
      break;
    }
  }
  cout<<result<<endl;


  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.reverse()
B.reverse()
ans = 0
t = A[0]
for a, b in zip(A[1:], B):
    t += a
    m = min(t, b)
    ans += m
    t = t - m if t - a <= b else a

print(ans)


Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;
// cout << typeid('変数').name() << endl;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> d(n);
    int x;
    int cnt=0;
    for (int i=0;i<k;i++){
        cin >> x;
        vector<int> a(k);
        for (int j=0;j<x;j++){
            cin >> a.at(i);
            a.at(i)--;
            d[a.at(i)]=1;
        }
    }
    for(int i=0;i<d.size();i++){
        if(d.at(i)==0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  int ans=0;
  for(int i=1;i<=n;i++){
    int cnt=0;
    for(int j=1;j<=i;j+=2){
      if(i%j==0) cnt++;
    }
    if(cnt==8) ans++;
  }
    
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
 
 
using namespace std;
 
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
 
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define left left228
#define right right228
#define prev prev228
#define list list228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

const int N = 100 * 1000 + 228;

int a[N], up[N];
vector<int> g[N];

void dfs(int v, int par = -1) {
    int S = 0;
    vector<int> sons;
    for (int to : g[v]) {
        if (to == par) continue;
        sons.push_back(to);
        dfs(to, v);
        S += up[to];
    }
    if (sons.empty()) {
        up[v] = a[v];
        return;
    }
    sort(sons.begin(), sons.end(), [&] (int i, int j) {
        return up[i] < up[j];
    });
    if ((int)sons.size() == 1) {
        if (up[sons[0]] != a[v]) {
            // ya che-to seychas voobshe ne ponyal
            cout << "NO\n";
            exit(0);
        }
        up[v] = up[sons[0]];
    } else {
        if (a[v] > S || 2 * a[v] - S < 0) {
            cout << "NO\n";
            exit(0);
        }
        up[v] = 2 * a[v] - S;
        int new_S = S - up[v];
        int all = 0;
        for (int son : sons) {
            all += max(0LL, up[son] - new_S / 2);
        }
        if (all > up[v]) {
            cout << "NO\n";
            exit(0);
        }
    }
}

int deg[N];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        ++deg[u], ++deg[v];
        g[u].push_back(v); g[v].push_back(u);
    }
    if (n == 2) {
        if (a[1] == a[2]) {
            cout << "YES\n";
        } else cout << "NO\n";
        return 0;
    }
    int root = 1;
    for (int i = 1; i <= n; ++i) {
        if (deg[i] > deg[root]) {
            root = i;
        }
    }
    dfs(root);

    // cout << "root=" << root << endl;
    // for (int i = 1; i <= n; ++i) {
    //     cout << "up[" << i << "]=" << up[i] << endl;
    // }
    if (up[root] == 0) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 20096
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (N - i >= M && N - j >= M && A[i][j] == B[0][0]) {
        bool succ = true;
        for (int k = 0; k < M; k++) {
          for (int l = 0; l < M; l++) {
            if (A[i + k][j + l] != B[k][l]) {
              succ = false;
              break;
            }
          }
        }
        if (succ) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3616
import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int[]f=new int[n];
        for(int i=0;i<n;++i)
            for(int j=0;j<10;++j)
                f[i]|=sc.nextInt()<<j;
        int[][]p=new int[n][11];
        for(int i=0;i<n;++i)
            for(int j=0;j<11;++j)p[i][j]=sc.nextInt();
        int ans=Integer.MIN_VALUE;
        for(int i=1;i<1024;++i){
            int t=0;
            for(int j=0;j<n;++j)
                t+=p[j][Integer.bitCount(i&f[j])];
            ans=Math.max(ans,t);
        }
        out.println(ans);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22996
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

ans = 0
N,M = map(int,readline().split())
L = []

for i in range(M):
    k,*S = map(int,readline().split())
    L.append(S)

P = list(map(int,readline().split()))

A = list(itertools.product([0,1],repeat=N))

for i in A:
    sw = [False] * M
    for j in range(M):
        count = 0
        for k in L[j]:
            count += i[k-1]

        if count % 2 == P[j]:
            sw[j] = True
            
    if sum(sw) == M:
        ans += 1
print(ans)

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  deque< int > A, Z, O;
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if(a == 0) Z.push_back(0);
    else if(a == 1) O.push_back(1);
    else A.push_back(a);
  }
  sort(A.begin(), A.end());
  if(O.empty() && Z.size() & 1) {
    if(A.empty()) {
      for(auto &s : Z) cout << 0 << endl;
      return (0);
    }
    O.push_back(A.front());
    A.pop_front();
  }
  if(A.size() >= 2 && *-- --A.end() == 2 && *--A.end() == 3) {
    swap(A[A.size() - 2], A[A.size() - 1]);
  }
  while(!A.empty())cout << A.front() << endl, A.pop_front();
  if(Z.size() & 1) {
    Z.pop_front();
    while(!Z.empty())cout << 0 << endl, Z.pop_back();
    cout << O.back() << endl;
    O.pop_back();
    cout << 0 << endl;
    while(!O.empty())cout << 1 << endl, O.pop_back();
  } else {
    while(!Z.empty()) cout << 0 << endl, Z.pop_back();
    while(!O.empty()) cout << 1 << endl, O.pop_back();
  }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int64_t n;
  cin>>n;

  map<int64_t, int64_t> a;
  for(int i=0;i<n;i++){
    int64_t wk;
    cin>>wk;
    if(a.count(wk))
      a.at(wk)++;
    else
      a[wk]=1;
  }


  int64_t k0=0,k1=0,k2=0;
  int64_t wk0=0,wk1=0,wk2=0;
  int64_t max_sum=0;
  for (auto p : a) {
    auto k = p.first;
    auto v = p.second;

    k2 = k1;
    k1 = k0;
    k0 = k;

    wk2=wk1;
    wk1=wk0;
    wk0=v;

  if((abs(k0-k1)<=1) &&abs ((k1-k2)<=1))
      max_sum=max(wk0+wk1+wk2,max_sum);
  else if((abs(k0-k1)<=1))
      max_sum=max(wk0+wk1,max_sum);
  else if(abs ((k1-k2)<=1))
      max_sum=max(wk2+wk1,max_sum);
  }

  if(n==1)
    cout<<1<<endl;
  else
    cout<<max_sum<<endl;

	return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

int main(){
    
    int N,M,Q;cin>>N>>M>>Q;
    vector<vector<int>> S(N+1,vector<int>(N+1,0));//始点-終点[a,b)
    
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[a+1][b+1]++;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(j) S[i+1][j+1]+=S[i+1][j];
        }
    }
    
    for(int j=0;j<N;j++){
        for(int i=0;i<N;i++){
            if(i) S[i+1][j+1]+=S[i][j+1];
        }
    }
    
    /*cout<<"   ";
    for(int i=0;i<N+1;i++){
        if(i) cout<<" ";
        cout<<i;
    }
    cout<<endl;
    
    for(int i=0;i<N+1;i++){
        cout<<i<<"  ";
        for(int j=0;j<N+1;j++){
            if(j) cout<<" ";
            cout<<S[i][j];
        }
        cout<<endl;
    }*/
    
    for(int i=0;i<Q;i++){
        int a,b;cin>>a>>b;
        cout<<S[b][b]-S[a-1][b]<<endl;
    }
}


Measured memory_bytes: 1920
using System;

namespace ABC088_A
{
    class Program
    {
        static string Solve()
        {
            int total = int.Parse(Console.ReadLine());
            int yen1 = int.Parse(Console.ReadLine());
            int i = total % 500;
            if (yen1 >= i)
            {
                return "Yes";
            }
            return "No";            
        }
        static void Main(string[] args)
        {
            Console.WriteLine(Solve());
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
typedef long long ll;
#define NODE_MAX 200000
ll par[NODE_MAX],rk[NODE_MAX];
void init(){
  for(int i=0;i<NODE_MAX;i++){
    par[i]=i;
    rk[i]=0;
  }
}
int root(int x){
  if(x==par[x]) return x;
  return par[x]=root(par[x]);
}
void unite(int x,int y){
  x = root(x);
  y = root(y);
  if(x==y) return;

  if(rk[x]<rk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rk[x]==rk[y]) rk[x]++;
  }
}
bool same(int x,int y){
  return root(x)==root(y);
}
int main(){
  ll n,m,cnt=0,rt;
  cin >> n >> m;
  init();
  ll x[NODE_MAX],y[NODE_MAX],z[NODE_MAX];
  bool know[NODE_MAX];
  for(int i=0;i<m;i++){
    know[i]=false;
    cin >> x[i]>>y[i]>>z[i];
    x[i]--;
    y[i]--;
    unite(x[i],y[i]);
  }
  for(int i=0;i<n;i++){
    rt = root(i);
    if(know[rt]==false){
      know[rt]=true;
      cnt++;
    }
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 8064
import collections

K = int(input())

L = [1,2,3,4,5,6,7,8,9]
Q = collections.deque(L)
count = 0 

while count < K-1:
    V = Q.popleft()
    count+=1
    if V%10 == 0:
        Q.append(10*V)
        Q.append(10*V+1)
    elif V%10 == 9:
        Q.append(10*V+8)
        Q.append(10*V+9)
    else:
        Q.append(10*V+(V%10)-1)
        Q.append(10*V+(V%10))
        Q.append(10*V+(V%10)+1)

print(Q.popleft())

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = a; i < b; i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

int main() {
	fast_io;
	ll n,k; cin>>n>>k;
	n=k+n%k;
	while(abs(n-k)<n){
		n=abs(n-k);
	}
	cout<<n<<"\n";
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))

q = []

for v in a:
    heapq.heappush(q, -v)

for i in range(m):
    v = heapq.heappop(q)
    v = (-v) // 2
    heapq.heappush(q, -v)

ans = 0
for i in range(len(q)):
    ans -= q[i]

print(ans)


Measured memory_bytes: 64920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int i;
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<bool> flag(n,false);
    flag.at(0) = true;
    int temp = 0, ans = 0;
    while(true){
        if(temp == 1){
            cout << ans << endl;
            break;
        }
        temp = a.at(temp)-1;
        if(flag.at(temp)){
            cout << -1 << endl;
            break;
        }else{
            flag.at(temp) = true;
            ++ans;
        }
    }
    return 0;
}

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

int a[200001];

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	int mi = a[0];
	int ans = -1000000001;
	for(int i = 1; i < n; i++){
		mi = min(mi, a[i-1]);
		ans = max(ans, a[i] - mi);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define pi        2*acos(0.0)
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
#define str       string
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	ll x=0,ans=0;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x!=(i+1)){ans+=1;}
	}
	if(ans<=2){cout<<"YES";}
	else{cout<<"NO";}
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}






Measured memory_bytes: 3612
using System;

namespace AtCoderContest
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            if (x >= 30)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27448
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#define int long long
using namespace std;

long double a[101];
int32_t main(){

    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(7);
    int n;
    cin>>n;
    long double s = 0;
    long double in;
    for(int i=0;i<n;i++) {
        cin>>in;
        s+=1/in;
    }
    
    cout<<1/s<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
using namespace std;
 
int main(){
	int a, b;
	cin >> a >> b;
	
	if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
		printf("Possible\n");
	}else printf("Impossible\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if ((c<b && c>a) || (c>b && c<a)) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string c[100001];
bool yyy (string a , string b)
{
	return a<b;
}
int main()
{
	int n,l;
    cin >> n >> l;
    for(int i = 1;i <= n;++i)
        cin >> c[i];
    sort(c+1,c+1+n,yyy); 
    for(int i=1;i<=n;i++)
    {
    	cout<<c[i];
	}
}

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

int main()
{
    lint x;
    cin >> x;

    lint ans = 0;
    ans += x / 11;

    if (x % 11 == 0)
    {
        cout << 2*ans << endl;
    }
    else if (x % 11 <= 6)
    {
        cout << 2*ans + 1 << endl;
    }
    else 
    {
        cout << 2*ans + 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
  using namespace std;
  int a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0) {
    cout << "Zero" << endl;
  } else if (a > 0 || (b >= 0 && (-a & 1) == 0) ||
             (b < 0 && ((-a - b + 1) & 1) == 0)) {
    cout << "Positive" << endl;
  } else {
    cout << "Negative" << endl;
  }

  return 0;
}


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

int main() {
  ll n, h;
  cin >> n >> h;
  vector<ll> a(n);
  vector<ll> b(n);

  rep(i,n) {
    cin >> a[i] >> b[i];
  }

  sort(a.begin(), a.end(), greater<ll>());
  sort(b.begin(), b.end(), greater<ll>());

  ll a_attack = a[0];
  bool is_a = false;

  int cnt = 0;
  int cur_h = 0;
  int cur_b = 0;
  while(cur_h < h) {
    if(!is_a && a_attack < b[cur_b]) {
      cur_h += b[cur_b];
      cur_b++;
      cnt++;
      if(cur_b > n) {
        is_a = true;
      }
    } else {
      is_a = true;
    }

    if(is_a) {
      // 残り
      ll res = h - cur_h;
      ll res_cnt = res / a_attack;
      if(res % a_attack != 0) {
        res_cnt++;
      }
      cnt += res_cnt;
      break;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4820
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int a[100010];
signed main() {
	int n;
	cin >> n;
	rep(i, n)cin >> a[i];
	int sum = 0;
	int ans = 0;
	loop(i, 1, n) {
		if (a[i] <= a[i - 1])sum++;
		if (a[i] > a[i - 1])sum = 0;
		if (sum > ans)ans = sum;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    if(a[0] != 0)
    {
        cout << -1 << endl;
        return 0;
    }
    for(int i = 1; i < n; i++)
    {
        int t = a[i] - a[i-1];
        if(t == 1)
        {
            ans++;
        }
        else if(t >= 2)
        {
            cout << -1 << endl;
            return 0;
        }
        else
        {
            ans += a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
qt = int(input())
sl = [input() for i in range(qt)]
d = {}
count = 0

for s in sl:
    s = "".join(sorted(s))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

for e in d.values():
    if e > 1:
        count += e * (e - 1) // 2

print(count)


Measured memory_bytes: 25036
import heapq
x,y,z,k=map(int,input().split())
#heapqは小さい順にしか並べられないので、-をつければ大きい順になる
a=sorted([-int(i) for i in input().split()])
b=sorted([-int(i) for i in input().split()])
c=sorted([-int(i) for i in input().split()])
check=set()
ans=[]
heapq.heappush(ans,(a[0]+b[0]+c[0],0,0,0))
check.add((0,0,0))
for i in range(k):
    h=heapq.heappop(ans)
    print(-h[0])
    if h[1]+1<x:
        if (h[1]+1,h[2],h[3]) not in check:
            heapq.heappush(ans,(a[h[1]+1]+b[h[2]]+c[h[3]],h[1]+1,h[2],h[3]))
            check.add((h[1]+1,h[2],h[3]))
    if h[2]+1<y:
        if (h[1],h[2]+1,h[3]) not in check:
            heapq.heappush(ans,(a[h[1]]+b[h[2]+1]+c[h[3]],h[1],h[2]+1,h[3]))
            check.add((h[1],h[2]+1,h[3]))
    if h[3]+1<z:
        if (h[1],h[2],h[3]+1) not in check:
            heapq.heappush(ans,(a[h[1]]+b[h[2]]+c[h[3]+1],h[1],h[2],h[3]+1))
            check.add((h[1],h[2],h[3]+1))
'''
while len(ans)!=0:
    print(heapq.heappop(ans)[0])
'''


Measured memory_bytes: 4976
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

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

  map<int,int> e,o;

  for(int i=0;i<(n/2);i++){
    int temp;
    cin >> temp;
    e[temp]++;
    cin>>temp;
    o[temp]++;
  }
  int e1=0,e2=0,e_max;
  int o1=0,o2=0,o_max;
  for(auto it=e.begin();it!=e.end();it++){
    if(it->second >= e1){
      e2=e1;
      e1=it->second;
      e_max=it->first;
    }
    else if(it->second > e2){
      e2=it->second;
    }
  }
  for(auto it=o.begin();it!=o.end();it++){
    if(it->second >= o1){
      o2=o1;
      o1=it->second;
      o_max=it->first;
    }
    else if(it->second >= o2){
      o2=it->second;
    }
  }
  int ans=0;
  if(e_max!=o_max){
    ans+=(n/2)-e1;
    ans+=(n/2)-o1;
  }
  else{
    ans=min((n-e1-o2),(n-e2-o1));
  }

  cout << ans<<endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
using namespace std;
int a,b;
int main(){
	scanf("%d %d",&a,&b);
	if(a<=0 && b>=0){
		printf("Zero\n");
		return 0;
	}
	if(a>0){
		printf("Positive\n");
		return 0;
	}
	else{
		if((b-a+1)%2==1){
			printf("Negative\n");
		}
		else printf("Positive\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 dp[101][10001]={};

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

    int n,W; cin>>n>>W; int v[n],w[n];
    for (int i = 0; i < n; i++)cin>>v[i]>>w[i];
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= W; j++){
            if(j<w[i])chmax(dp[i+1][j],dp[i][j]);
            else chmax(dp[i+1][j],max(dp[i][j],max(dp[i][j-w[i]]+v[i],dp[i+1][j-w[i]]+v[i])));
        }
    }
    cout<<dp[n][W]<<'\n';
}


Measured memory_bytes: 7064
#include<stdio.h>
#define N 2000000
int a[N],b[N],c[N];
int main(void){

  int i,j,k=0,n;
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    c[a[i]]=c[a[i]]+1;
    if(k<a[i])k=a[i];
  }

  for(i=1;i<=k;i++){
    c[i]=c[i]+c[i-1];
  }
 
  for(i=0;i<n;i++){
    b[c[a[i]]-1]=a[i];
    c[a[i]]--;
  }

  for(i=0;i<n;i++){
    if(i!=n-1){
      printf("%d ",b[i]);
  }
    else printf("%d\n",b[i]);
     
  }
  return 0;
}

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

int main(){

  string s;
  cin >> s;

  for( int i =0; i<s.size()-1; i++){
    if (s.at(i) == s.at(i+1)){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  
  
  return 0;
}


Measured memory_bytes: 764
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = set([])
for i in range(n):
    s.add(ins())
print(len(s))


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

#define f(i,x,y)			for(int i=x; i<y; i++)
#define ll 					long long 
#define pb 					push_back
#define mp 					make_pair
#define F 					first
#define S 					second
#define N 					100005
#define inf 				1e9+1

int dp[100005];
//memset(dp,-1,sizeof(dp));
vector <vector <int> > graph(100005);

int func(int src)
{
	if(dp[src] != -1)
		return dp[src];

	bool leaf = 1;
	int best = 0;
	for(auto child : graph[src])
	{
		leaf = 0;
		best = max(best,func(child));
	}
	return dp[src] = leaf ? 0 : 1+best;
}

int main()
{
	int n,m;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));

	f(i,0,m)
	{
		int a,b;
		cin>>a>>b;
		graph[a].pb(b);
	}

	int ans = 0;
	f(i,1,n+1)
		ans = max(ans,func(i));

	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 8192
import java.util.*;
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();
        }
        Arrays.sort(a);
        int n = a[N-1];
        int m = Arrays.binarySearch(a, n / 2);
        if(m < 0){
            if(m == -N) m = N-1;
            else{
                int x = a[-m - 2];
                int y = x, i = 1;
                while(y == x && -m - 2 + i < N){
                    y = a[-m - 2 + i];
                    i++;
                }
                m = ((double)(y -  n / 2) > (double)(n / 2 - x))? x : y;
            }
        }
        else m = a[m];
        if(N == 2) m = 0;
        System.out.println(n + " " + m);
    }
}

Measured memory_bytes: 51484
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define fst	first
#define scn second

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;

int main() {
	int n;	cin >> n;
	vint sum(100010, 0);
	rep(i, n) {
		int a, b;	cin >> a >> b;
		sum[a]++;	sum[b + 1]--;
	}
	srep(i, 1, 100010)	sum[i] += sum[i - 1];
	int ret = 1;
	REP(i, n + 1) {
		if (sum[i] + 1 >= i)	ret = max(ret, i);
	}
	cout << ret - 1 << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int x;
	cin>>x;
	if(x<1200){
		ce("ABC")
	}else{
		ce("ARC")
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    float A,B,T;
    cin>>A>>B>>T;
    int ans=0;
    int p=A;
    for(;;){
        if(p<=(T+0.5)){
            ans+=B;
            p+=A;
        }else{
            cout<<ans<<endl;
            return 0;
        }
    }
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n,k;
	cin >> n>>k;
    int i=0;
    while(n!=0){
        n/=k;
        ++i;
    }
    cout<<i;
	return 0;
}

Measured memory_bytes: 256
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

    long long N;
    cin >> N;

    if(N % 2 == 1) {
        cout << "0\n";
        return 0;
    }

    N /= 2;
    long long ans = 0;
    while(N > 0) {
        ans += N / 5;
        N /= 5;
    }
    cout << ans << '\n';
    return 0;

}


Measured memory_bytes: 256
num = int(input())
sort_list = list(map(int,input().split()))
print(*sort_list)
v = 0
for i in range(1,num):
	v = sort_list[i]
	j = i - 1
	while j >= 0 and sort_list[j] > v:
		sort_list[j+1] = sort_list[j]
		j -= 1
		sort_list[j+1] = v
	print(*sort_list)

Measured memory_bytes: 7988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);

		int card = sc.nextInt();
		int gate = sc.nextInt();
		int min = 100000;
		int max = 0;

		int[] L = new int[gate];
		int[] R = new int[gate];
		for(int i = 0; i<gate; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		for(int i=0; i<gate; i++) {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		}
			int anser = Math.max((min-max)+1, 0);
			System.out.println(anser);
		}

	}

Measured memory_bytes: 64440
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;

int main() {
    int R;
    int C;

    cin >> R >> C;

    long long tot = (long long)R*C;

    if (min(R, C) > 1) {
        cout << (tot+1)/2 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: usize,
        As: [usize; N],
    }

    let mut ans = vec![0; N];

    for (ind, a) in As.iter().enumerate() {
        let a_ind = *a - 1;
        ans[a_ind] = ind + 1;
    }

    for a in &ans {
        print!("{} ", *a);
    }
    println!("");
}


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

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

int N;
int cel[114514];

int Solve() {
  int app = 0;
  int cnt = 0;
  int ans = 0;
  int pend = 0;
  int check = 0;
  rep(i, N) {
    if (cel[i] == 1) {
      app = 1;
      cnt = 0;
    } else if (cel[i] == 2) {
      if (check) {
        check = 0;
        pend = 0;
      }
      if (app) {
        cnt++;
      }
    } else if (!cel[i]) {
      if (check) {
        ans = max(ans, pend);
        check = 0;
        pend = 0;
      }
      if (app) {
        pend = cnt;
        check = 1;
        cnt = 0;
      }
      app = 0;
    } else assert(0);
  }
      if (check) {
        ans = max(ans, pend);
        check = 0;
        pend = 0;
      }
  return ans;
}

int main() {
  scanf("%d", &N);
  rep(i, N) {
    char c;
    scanf(" %c", &c);
    if (c == 'W') cel[i] = 1;
    else if (c == 'B') cel[i] = 2;
    else assert(c == '.');
  }

  int ans = Solve();
  reverse(cel, cel+N);
  ans = max(ans, Solve());

  cout << ans << endl;
}



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

int main(){
  int n;
  cin >> n;
  cout << n*(n+1)/2 << endl;
  return 0;
}


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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
typedef long long lint;

// solv
int main(){

    int M; 
    cin >> M;
    lint sum = 0, ans = -1;
    while(M--){
        int d; lint c;
        cin >> d >> c;
        ans += c;
        sum += c * d;
    }
    cout << ans + (sum - 1) / 9 << '\n';
    return 0;

}


Measured memory_bytes: 256
#######################################
import numpy as np

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
#######################################
n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
tmp = list(range(n+1))
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
ret2 = sorted(ret2)
cout(ret2)

Measured memory_bytes: 38528
#include<iostream>
#include<vector>
#include<set>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<double> t(n+2, 0.0), v(n+2, 0.0);
    vector<double> l(n+2, 0.0), r(n+2, 0.0);
    for(int i = 1; i <= n; i++) cin >> t[i];
    for(int i = 1; i <= n; i++) cin >> v[i];
 
    for(int i = 2; i < n+2; i++) l[i] = l[i-1] + t[i-1];
    for(int i = 1; i < n+2; i++) r[i] = r[i-1] + t[i];
 
    vector<double> sv;
    for(double x = 0; x <= r[n+1]; x += 0.5) {
        double mn = 1e9+1;
        for(int i = 0; i < n+2; i++) {
            if(x < l[i]) mn = min(mn, v[i] + (l[i] - x));
            if(l[i] <= x && x <= r[i]) mn = min(mn, v[i]);
            if(r[i] < x) mn = min(mn, v[i] + (x - r[i]));
        }
        sv.push_back(mn);
    }
 
    double ans = 0;
    for(int i = 1; i < sv.size(); i++) {
        ans += 0.25 * (sv[i] + sv[i-1]);
    }
 
    printf("%lf", ans);
 
    return 0;
}

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

using namespace std;


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

    long long ans = 0;
    for (int bits = 0; bits < 1 << (s.length() - 1); bits++) {
        long long acc = 0;
        int bt = bits | (1 << (s.length() - 1));
        int b = 0;
        for (int j = 0; j < s.length(); j++) {
            if ((bt >> j) & 1) {
                // cout << b << " ~ " << j + 1 << endl;
                string t = s.substr(b, j + 1 - b);
                acc += stoll(t);
                b = j + 1;
                // cout << t << endl;
            }
        }
        // cout << endl;
        ans += acc;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
  int64_t n,k;
  cin >> n >> k;
  
  int64_t h[n];
  rep(i,n) cin >> h[i];
  
  sort(h,h+n,greater<int>());
  int64_t ans = 0;
  for(int64_t i = k; i < n; i++){
    ans += h[i];
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 5072
const main = input => {
  const grid = input.trim().split('\n')
  for (let i = 0; i < 3; i++) {
    if (grid[0].charAt(i) !== grid[1].charAt(3 - 1 - i)) {
      console.log('NO')
      return
    }
  }
  console.log('YES')
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, q;
    string s;
    cin >> n >> s >> q;
    string g(n, '*');
    s = s + g;
    n *= 2;
    vector<ll> prefM(n), prefC(n);
    for (int i = 0; i < n; ++i)
    {
        prefM[i] = 0;
        if (s[i] == 'M')
            ++prefM[i];
        if (i - 1 >= 0)
            prefM[i] += prefM[i - 1];
    }
    for (int i = 0; i < n; ++i)
    {
        prefC[i]= 0;
        if (s[i] == 'C')
            ++prefC[i];
        if (i - 1 >= 0)
            prefC[i] += prefC[i - 1];
    }
    for (int i = 0; i < q; ++i)
    {
        int k;
        cin >> k;
        --k;
        ll odp = 0;
        vector<ll> ilMC(n);
        ilMC[0] = 0;
        for (int j = 0; j < k - 1; ++j)
            if (s[j] == 'M')
                ilMC[0] += prefC[k - 1] - prefC[j];
        for (int j = 1; j + k - 1 < n; ++j)
        {
            if (s[j] == '*')
                break;
            ilMC[j] = ilMC[j - 1];
            if (s[j - 1] == 'M')
                ilMC[j] -= prefC[j + k - 2] - prefC[j - 1];
            if (s[j + k - 1] == 'C')
                ilMC[j] += prefM[j + k - 2] - prefM[j - 1];
        }
        ++k;
        for (int j = 0; j + k - 1 < n; ++j)
        {
            if (s[j] =='*')
                break;
            if (s[j] == 'D')
                odp += ilMC[j + 1];
        }
        cout << odp << endl;
    }
    return 0;
}


Measured memory_bytes: 51144
#include <iostream>
#include <string>
using namespace std;
const int INF = 1<<30;
template<typename T1, typename T2> T1 gcd(T1 a, T2 b) { return (b ? gcd(b, a % b) : a); }
template<class Type> class List 
{
    struct Node { Type val; Node *next, *pre; };
    Node *origin;
    public:
        List() { origin = new Node; origin->next = origin; origin->pre = origin; }
        Node *find(Type num)
        {
            Node *n = origin->next; while(n != origin && n->val != num) n = n->next;
            return n;
        }
        void push_front(Type num)
        {
            Node *n = new Node;
            n->val = num; n->next = origin->next;
            origin->next->pre = n; origin->next = n;
            n->pre = origin;
        }
        void _erase(Node *n)
        {
            if(n == origin) return;
            n->pre->next = n->next; n->next->pre = n->pre;
            delete n;
        }
        void erase(Type num){ _erase(find(num)); }
        void pop_front() { _erase(origin->next); }
        void pop_back() { _erase(origin->pre); }
        void print()
        {
            Node *n = origin->next;
            bool flag = false;
            while(n != origin)
            {
                if(flag) cout << " " << n->val;
                else cout << n->val, flag = true;
                n = n->next;
            }
            cout << "\n";
        }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    List<int> ls;
    for(int i = 0; i < n; i++)
    {
        string s; cin >> s;
        if(s == "insert")
        {
            int x; cin >> x;
            ls.push_front(x);
        }
        else if(s == "deleteFirst") ls.pop_front();
        else if(s == "deleteLast") ls.pop_back();
        else 
        {
            int x; cin >> x;
            ls.erase(x);
        }
    }
    ls.print();
    return 0;
}


Measured memory_bytes: 34492
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max1 = 11;
const intt max2 = 102;
const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
const intt lg2 = 7;
const intt lg3 = 10;
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
const intt lg7 = 24;
const intt lg8 = 27;
const intt lg9 = 30;
const intt lg18 = 60;
const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a, intt b) { while(b) b ^= a ^= b ^= a %= b; return a;}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
/**************************/

intt n, m, a, b;

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    cin >> n >> m;
    if ((n + m) % 3 != 0 && n % 3 != 0 && m % 3 != 0)
        cout << "Impossible";
    else
        cout << "Possible" << endl;
    return 0;
}


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

int main(void){
    
    ll n, ans=0;
    ll a[200009]={};
    ll b[200009]={};
    ll c[200009]={};
    map<ll, ll> m;
    
    cin >> n;
    
    for(ll i=1; i<=n; i++){
        
        cin >> a[i];
        b[i] = a[i] - i;
        
        if(m.count(b[i])==1){
            
            ans += m.at(b[i]);
            
        }
        
        c[i] = 0 - b[i] - 2 * i;
        m[c[i]] += 1;
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 17660
using System;
using System.Linq;
 
class P{
  static void Main(){
    
    int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int N = n[0];
    int K = n[1];
    long ans = K;
    for(int i = 0; i < N - 1; i++){
      ans *= K - 1;
    }
    Console.WriteLine(ans);
       
  }
}

Measured memory_bytes: 11348
def main():
    N = list(map(int,input()))
    K = int(input())
    if len(N) < K :
        print(0)
    else:
        print(dfs(N, 0, K))
def test(N,K):
    return dfs(list(map(int,str(N))),0,K)

def comb(N, K):
    if N < K:
        return 0
    if K == 0:
        return 1
    elif K == 1:
        return N
    elif K == 2:
        return N * (N - 1) // 2
    elif K == 3:
        return N * (N - 1) * (N - 2) // 6


def dfs(N, pos, rest):
    if rest == 0:
        return 1
    if pos >= len(N):
        return 0
    ans = 0
    for i in range(10):
        if N[pos] > i:
            if i == 0:
                ans += comb(len(N) - pos - 1, rest) * (9**rest)
            else:
                ans += comb(len(N) - pos - 1, rest - 1) * (9 ** (rest-1))
        elif N[pos] == i :
            if i == 0 :
                ans += dfs(N, pos+1, rest)
            else :
                ans += dfs(N, pos+1, rest - 1)
        else:
            break
    return ans
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064