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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,M; cin >> N >> M;
	V<int> cnt(M+1,0);
	for(int i = 0; i < N; ++i){
		int K; cin >> K;
		for(int j = 0; j < K; ++j){
			int A; cin >> A;
			cnt[A]++;
		}
	}
	int ans = 0;
	for(int i = 0; i <= M; ++i){
		if(cnt[i]==N) ans++;
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    int s=to_string(n).size();
    if(s==1){
        cout<<n<<endl;
        return 0;
    }
    vvll num(10,vll(10));//num[i][j]:iで始まってjで終わるn以下の数の数
    ll res;
    rep2(i,1,10)rep2(j,1,10){
        res=1;
        rep2(k,2,s){
            num[i][j]+=res;
            res*=10;
        }
        if(i<n/(10*res))num[i][j]+=res;
        else if(i==n/(10*res)){
            num[i][j]+=(n%(10*res))/10;
            if(j<=n%10)num[i][j]++;
        }
        if(i==j)num[i][j]++;
    }
    ll ans=0;
    rep2(i,1,10)rep2(j,1,10)ans+=num[i][j]*num[j][i];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N, C = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(N)]

cum_col = [0 for _ in range(N+1)]
for i in range(N):
    cum_col[i+1] = cum_col[i] + sushi[i][1]

clockwise_dp = [None for _ in range(N)]
clockwise_best = [0, 0]
anti_clockwise_dp = [None for _ in range(N)]
anti_clockwise_best = [0, 0]
for i in range(N):
    if clockwise_best[0] < cum_col[i+1] - sushi[i][0]:
        clockwise_best = [cum_col[i+1]-sushi[i][0], sushi[i][0]]
    clockwise_dp[i] = clockwise_best

for i in range(N-1, -1, -1):
    if anti_clockwise_best[0] < cum_col[N] - cum_col[i] - C + sushi[i][0]:
        anti_clockwise_best = [
            cum_col[N]-cum_col[i]-C+sushi[i][0],
            C-sushi[i][0]
        ]
    anti_clockwise_dp[i] = anti_clockwise_best

ans = max(clockwise_dp[N-1][0], anti_clockwise_dp[0][0])
for i in range(N-1):
    ans = max(ans,
              clockwise_dp[i][0],
              anti_clockwise_dp[i+1][0],
              clockwise_dp[i][0]+anti_clockwise_dp[i+1][0]-min(clockwise_dp[i][1], anti_clockwise_dp[i+1][1])
              )

print(ans)


Measured memory_bytes: 56044
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
wv.sort(key=lambda x:-x[1])#reverse
wv.sort(key=lambda x:x[0])
#print(wv)
w0=wv[0][0]
x=[[0],[0],[0],[0]]
for i in range(n):
    z=wv[i][0]-w0
    k=wv[i][1]+x[z][-1]
    l=len(x[z])
    if l*wv[i][0]<=w:
        x[z].append(k)
ma=0
l3=len(x[3])
l2=len(x[2])
l1=len(x[1])
l0=len(x[0])
for i in range(l3):
    for j in range(l2):
        d=w-i*(w0+3)-j*(w0+2)
        if d>=0:
            for k in range(l1):
                d=w-i*(w0+3)-j*(w0+2)-k*(w0+1)
                if d>=0:
                    ma_sub=x[3][i]+x[2][j]+x[1][k]+x[0][min(d//w0,l0-1)]
                    ma=max(ma,ma_sub)
                else:
                    break
        else:
            break

print(ma)


Measured memory_bytes: 3188
// Gaurav Nuti
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define ar array
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define INF 1e9 

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

ll power_without_mod(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

bool comparep(pair<ll, ll> i1, pair<ll, ll> i2){
	return (i1.S < i2.S);
} 

ll modInverse(ll a)
{
    return power(a , mod - 2);
}

vector<vector<ll>> graph;
vector<bool> visited;
vector<ll> dist;
map<ll,ll> mymap;
ll max_dist = 1;

void bfs(int u1){
    visited[u1] = 1;
    dist[u1] = 1;
    mymap[1] = u1;
    queue<ll> q;
    q.push({u1});
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(auto i=graph[u].begin();i!=graph[u].end();i++){
            if(!visited[*i]){
                dist[*i] = dist[u] + 1;
                visited[*i] = 1;
                max_dist = max(dist[*i],max_dist);
                mymap[dist[*i]] = *i;
                q.push({*i});
            }
        }
    }
}

// int next_lunlun(ll n){
//     vector<int> digits;
//     while(n){
//         digits.pb(n%10);
//         n /= 10;
//     }
//     // reverse(digits.begin(),digits.end());
//     ll num_digits = digits.size(); 
//     int count_9 = 0;
//     for(int i: digits)
//         if(i == 9)
//             count_9++;
//     if(count_9 == num_digits)
//         return ;
//     for(int i=0;i<(num_digits-1);i++){
//         if(digits)
//     }
// }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
	
    ll t;
    // cin>>t;
    t = 1;
    for(ll z=0;z<t;z++){
        ll n;
        cin>>n;
        ll inp[n][3];
        ll dp[n][3];
        for(ll i=0;i<n;i++){
            cin>>inp[i][0]>>inp[i][1]>>inp[i][2];
            for(ll j = 0;j<3;j++){
                dp[i][j] = inp[i][j];
                ll max1 = 0;
                for(ll k = 0;k<3;k++){
                    if(k!=j && i > 0)
                        max1 = max(dp[i-1][k],max1);
                }
                dp[i][j] += max1;
            }
        }
        ll i = n-1;
        cout<<max({dp[i][0],dp[i][1],dp[i][2]});
    }
}

Measured memory_bytes: 8256
from sys import stdin

N = int(stdin.readline().rstrip())
T, A = [int(a) for a in stdin.readline().rstrip().split()]
H = [int(a) for a in stdin.readline().rstrip().split()]

ans = 0
min_sub = 100000
for i in range(len(H)):
    tmp = T - 0.006 * H[i]
    sub = abs(A - tmp)
    if (sub < min_sub):
        ans = i
        min_sub = sub

print(ans + 1)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int a,b,c,d=0;
  scanf("%d %d %d",&a,&b,&c);
  for(int i=1; i<=a; i++){
    int e=0,f=i;
    while(f>0){e+=f%10;f/=10;}
    if(b<=e&&e<=c){d+=i;}
  }
  printf("%d",d);
  return 0;}


Measured memory_bytes: 128
inf = 10**15
mod = 10**9+7
s = input()
n = len(s)-1
ans = 0
for i in range(2**n):
    acc = int(s[0])
    for j in range(n):
        if ((i >> j) & 1):  # 1だったら(オンだったら)
            ans+=acc
            acc=int(s[j+1])
        else:
            acc *= 10
            acc += int(s[j+1])
    ans+=acc
print(ans)

Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
    int N; cin >> N;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    map<ll, ll> mp;
    ll ans = 0;
    rep(i, N) {
        ans += mp[i - A[i]];
        mp[i + A[i]]++;
    }
    cout << ans << endl;
}

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



int main() 
{
  ll N; cin>>N;
  string S; cin>>S;
  ll hitomi=0;
  ll max_hitomi=0;
  rep(i,N)
  {
    if(i==0) {continue;}
    if(S.at(i)=='W') {hitomi++;}
  }
  rep(i,N)
  {
    if(i==0) {max_hitomi=hitomi; /*cout<<hitomi<<" "<<max_hitomi<<endl;*/ continue;}
    if(S.at(i-1)=='E') {hitomi++;}
    if(S.at(i)=='W') {hitomi--;}
    max_hitomi=max(max_hitomi,hitomi);
    //cout<<hitomi<<" "<<max_hitomi<<endl;
  }
  cout<<N-1-max_hitomi<<endl;
  return 0;
}

Measured memory_bytes: 900
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    map<char,int>mp;
    string s; cin>>s;
    rep(i,s.size())mp[s[i]]++;
    bool flag=true;
    rep(i,s.size())if(mp[s[i]]>1)flag=false;
    if(flag)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

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

struct Info{
    int damage;
    int mp;
};

int main(void){
    using namespace  std;
    int H, N;
    cin >> H >> N;
    vector<Info> X(N);
    rep(i, N){
        cin >> X[i].damage >> X[i].mp;
    }

    vector<int> DP(H);
    rep(i, H){
        int hp = i + 1;
        int mp = 1000000000;
        rep(j, N){
            int remained = hp - X[j].damage;
            if(remained>0){
                int new_mp = DP[remained - 1] + X[j].mp;
                if(mp > new_mp)
                    mp = new_mp;
            }
            else if(mp > X[j].mp)
                mp = X[j].mp;

        }
        DP[i] = mp;
    }

    cout << DP[H - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var A, B int
	fmt.Scan(&A, &B)
	for cost := 1; cost <= 20000; cost++ {
		if cost*8/100 == A && cost*10/100 == B {
			fmt.Println(cost)
			return
		}
	}
	fmt.Println(-1)
}


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

int main() {
	int N , K ;
    cin >> N >> K;
    int denko_keiji_ban = 1;
    for(int i = 0; i < N ; i++){
    	if(denko_keiji_ban * 2 < denko_keiji_ban + K){
        	denko_keiji_ban *= 2;
        }else{
        	denko_keiji_ban += K;
        }
    }
    cout << denko_keiji_ban << endl;
}


Measured memory_bytes: 3640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <array>
#include <functional>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <stack>

int main()
{
	//std::cout << std::fixed << std::setprecision(15);

	int h, w;
	std::cin >> h >> w;

	std::vector<std::vector<char>> s(h, std::vector<char>(w, 0));
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			std::cin >> s.at(i).at(j);
		}
	}

	std::vector<std::vector<int>> d(h * w, std::vector<int>(h * w, 1000));
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			d.at(i * w + j).at(i * w + j) = 0;

			if (s.at(i).at(j) == '.')
			{
				if (i + 1 < h && s.at(i + 1).at(j) == '.')
				{
					d.at(i * w + j).at((i + 1) * w + j) = 1;
				}
				if (i - 1 >= 0 && s.at(i - 1).at(j) == '.')
				{
					d.at(i * w + j).at((i - 1) * w + j) = 1;
				}
				if (j + 1 < w && s.at(i).at(j + 1) == '.')
				{
					d.at(i * w + j).at(i * w + j + 1) = 1;
				}
				if (j -1 >= 0 && s.at(i).at(j - 1) == '.')
				{
					d.at(i * w + j).at(i * w + j - 1) = 1;
				}
			}
		}
	}

	for (int i = 0; i < h * w; i++)
	{
		for (int j = 0; j < h * w; j++)
		{
			for (int k = 0; k < h * w; k++)
			{
				d[j][k] = std::min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}

	int max = 0;
	for (int i = 0; i < h * w; ++i)
	{
		for (int j = 0; j < h * w; ++j)
		{
			if (d[i][j] < 1000 && d[i][j] > max)
			{
				max = d[i][j];
			}
		}
	}

	std::cout << max << std::endl;

	return 0;
}

Measured memory_bytes: 896
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b,c; cin >> a >> b >> c;
    cout << (b-a==c-b ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  int a[12],i;
int main(){
  for(;i<12;i++)cin>>a[i];
  sort(a,a+12);
  if(a[0]==a[3]&&a[4]==a[7]&&a[8]==a[11])cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 3140
def solve():
    N = int(input())
    s = 0
    n = [0 for _ in range(100000+1)]
    for a in map(int, input().split()):
        s += a
        n[a] += 1
    q = int(input())
    for _ in range(q):
        b, c = map(int, input().split())
        s += (c - b) * n[b]
        print(s)
        n[c] += n[b]
        n[b] = 0


if __name__ == '__main__':
    solve()


Measured memory_bytes: 18060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			int r1 = 0, r2 = 0;
			string line = "";
			while ((line = Console.ReadLine()) != null)
			{
				int[] a = line.Split(',').Select(i => int.Parse(i)).ToArray();
				if ((a[0] * a[0] + a[1] * a[1]) == a[2] * a[2])
					r1++;
				else if (a[0] == a[1])
					r2++;
			}
			Console.WriteLine(r1);
			Console.WriteLine(r2);
		}
	}
}

Measured memory_bytes: 5904
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()
	for i := 1; i <= n; i++ {
		if i%3 == 0 {
			fmt.Fprintf(out, " %d", i)
			continue
		} else {
			checkNum(i, i)
		}
	}
	fmt.Fprintf(out, "\n")
}

func checkNum(i int, x int) {
	if x%10 == 3 {
		fmt.Fprintf(out, " %d", i)
	} else if x != 0 {
		x /= 10
		checkNum(i, x)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1220
import java.util.ArrayList;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

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

    int n = sc.nextInt();
    ArrayList<Integer> as = new ArrayList<>();
    ArrayList<Integer> bs = new ArrayList<>();

    for (int i = 0; i < n-1; i++) {
      bs.add(sc.nextInt());
    }

    int ans = bs.get(0) + bs.get(n-2);

    for (int i = 0; i < n-2; i++) {
      ans += Math.min(bs.get(i), bs.get(i+1));
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

signed main() {
    cin >> S;
    vi a(26);
    REP(i, S.size())
    a[S[i] - 'a'] = 1;
    REP(i, 26)
    if (a[i] == 0) {
        cout << char('a' + i) << endl;
        return 0;
    }
    cout << "None" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define nl '\n'
typedef long long ll;
typedef long double ld;
//////////////////////////////////////////////////////////////////////

const int N = 331;
int a[N][N],n;
bool done[N][N];

int main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  cin>>n;
  ll tot = 0;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++){
      cin>>a[i][j];
      if(i<j)
	tot += a[i][j];
    }
  cerr << tot << endl;

  memset(done,0,sizeof done);
  for(int mid=1;mid<=n;mid++)
    for(int lx=1;lx<=n;lx++)
      for(int rx=lx+1;rx<=n;rx++){
	if(lx==mid or rx==mid)continue;
	if(a[lx][mid] + a[mid][rx] < a[lx][rx]){
	  cout << -1 << endl;
	  return 0;//
	}
	if(!done[lx][rx] and a[lx][mid] + a[mid][rx] == a[lx][rx]){
	  //cerr << "~" << lx << ',' << mid << ',' << rx << endl;
	  tot -= a[lx][rx];
	  done[lx][rx] = 1;
	}
      }
  cout << tot << endl;
  
  return 0;
};


Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        boolean winT = false;
        for (int i = 0; i < 100; i++) {
            c -= b;
            if (c <= 0) {
                winT = true;
                break;
            }
            a -= d;
            if (a <= 0) {
                winT = false;
                break;
            }

        }
        System.out.println(winT?"Yes":"No");
    }
}


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

int N,a,b,c;

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a >> b >> c;
    if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n;
  cin>>n;
  vi p(n),a(n),b(n);
  rep(i,n)cin>>p[i];

  rep(i,n)a[i]=25000*(i+1),b[i]=25000*(n-i);

  rep(i,n)b[p[i]-1]+=i+1;

  rep(i,n){
    cout<<a[i];
    if(i<n-1)cout<<" ";
    else cout<<endl;
  }
  rep(i,n){
    cout<<b[i];
    if(i<n-1)cout<<" ";
    else cout<<endl;
  }
}


Measured memory_bytes: 1152
#include<iostream>
#define endl "\n"
using namespace std;
#include<map>
#include<string>

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	map<string, int>m;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		m[s] = i;
	}
	cout << m.size();
	return 0;
}

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


int main(){
    int N;
    cin>>N;
    
    vector<int> p(200001);
    int count=0;
    int min=300001;
    rep(i,N){
        cin>>p[i];
        if(min>p[i]){
            count++;
            min=p[i];
        }
    }
    cout<<count<<endl;

    
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

const int MAXN = 2e3 + 5;
char s[MAXN + 5][MAXN + 5];
int sum[MAXN + 5][MAXN + 5];
int L[MAXN + 5][MAXN + 5], U[MAXN + 5][MAXN + 5];
int sumL[MAXN + 5][MAXN + 5], sumU[MAXN + 5][MAXN + 5];

int N, M, Q;

void Init()
{
	scanf("%d%d%d", &N, &M, &Q);
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++) scanf(" %c", &s[i][j]);

	int t = 0;
	for(int i = 1; i <= N; i++)
	{
		t = 0;
		for(int j = 1; j <= M; j++)
		{
			if(s[i][j] == '1') t++;
			sum[i][j] = sum[i - 1][j] + t;
		}
	}
}

int getNum1(int x1, int y1, int x2, int y2)
{
	return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
}

int getConnect(int x1, int y1, int x2, int y2)
{
	int sumConnect = 0;
	if(x2 - x1 >= 1)
	{
		sumConnect += sumU[x2][y2] - sumU[x2][y1 - 1] - sumU[x1][y2] + sumU[x1][y1 - 1];
	}
	if(y2 - y1 >= 1)
	{
		sumConnect += sumL[x2][y2] - sumL[x2][y1] - sumL[x1 - 1][y2] + sumL[x1 - 1][y1];
	}
	return sumConnect;
}

void Solve()
{
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
		if(s[i][j] == '1')
		{
			if(i > 1 && s[i - 1][j] == '1') U[i][j]++;
			if(j > 1 && s[i][j - 1] == '1') L[i][j]++;
		}

	int l = 0, u = 0;
	for(int i = 1; i <= N; i++)
	{
		l = 0, u = 0;	
		for(int j = 1; j <= M; j++)
		{
			l += L[i][j], u += U[i][j];	
			sumL[i][j] = sumL[i - 1][j] + l;
			sumU[i][j] = sumU[i - 1][j] + u;
		}
	}

	while(Q--)
	{
		int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		int num1 = getNum1(x1, y1, x2, y2);
		int numConnect = getConnect(x1, y1, x2, y2);
		printf("%d\n", num1 - numConnect);
	}
}

int main()
{
	Init();
	Solve();
}

Measured memory_bytes: 84352
n, m, q = gets.chomp.split.map(&:to_i)
kumi = []
q.times do
  kumi.push(gets.chomp.split.map(&:to_i))
end

ar = []
1.upto(m) do |t|
  ar.push([t])
end
while ar.first.size < n
  new_a = []
  ar.each do |arr|
    last = arr.last
    last.upto(m) do |u|
      new_a.push(arr.dup.push(u))
    end
  end
  ar = new_a
end

ans = 0
ar.each do |arr|
  tmp = 0
  q.times do |i|
    a, b, c, d = kumi[i]
    if (arr[b-1] - arr[a-1]) == c
      tmp += d
    end
  end
  if tmp > ans
    ans = tmp
  end
end
p ans


Measured memory_bytes: 63848
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int D, N;
    cin >> D >> N;
    if (N == 100) N++;
    cout << N;
    rep(i, 0, D) cout << "00";
    cout << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
template<class T>void sort(vec<T> &v){sort(v.begin(),v.end());}
template<class T>void rsort(vec<T> &v){sort(v.rbegin(),v.rend());}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,n; cin >> a >> b >> n;
    if(n >= b)cout << a*(b-1)/b - a*((b-1)/b) << endl;
    else cout << a*n/b - a*(n/b) << endl;

}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<string> c(h);
    rep(i,h) cin >> c[i];
    int ans = 0;
    for (int bi = 0; bi < (1<<h); ++bi) {
        for (int bj = 0; bj < (1<<w); ++bj) {
            int tmp = 0;
            for (int i = 0; i<h; ++i) {
                for (int j = 0; j<w; ++j) {
                    if ((bi & (1<<i)) | (bj & (1<<j))) continue;
                    else if (c[i][j] == '#') ++tmp;
                } 
            }
            if (tmp == k) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    int tot=0;
    F0R(i,n)
        cin >> a[i];
    F0R(i,n)
    {
        cin >> b[i];
        tot+=b[i];
    }
    // cout << tot << endl;
    F0R(i,n-1)
        cin >> c[i];
    FOR(i,1,n)
    {
        if(a[i-1]+1==a[i])
            tot+=c[a[i-1]-1];
    }
    cout << tot;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;


int main() {
    int n,m;
    cin>>n>>m;
    int work=0;
    for(int i=0; i<m; ++i) {
        int a;
        cin>>a;
        work+=a;
    }
    int ans=n-work;
    cout<<((ans>=0)?ans:-1)<<endl;

    return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    balls = [list(map(int, input().split())) for _ in range(N)]
    diffs = []
    for i in range(N):
        for j in range(i + 1, N):
            diffs.append([balls[i][0] - balls[j][0],
                          balls[i][1] - balls[j][1]])
    max_balls_on_line = 1
    for d in diffs:
        count = 0
        for e in diffs:
            if (d[0] == e[0] and d[1] == e[1]) or (d[0] == -e[0] and d[1] == -e[1]):
                count += 1
        if count > max_balls_on_line:
            max_balls_on_line = count

    if N == 1:
        print(1)
    else:
        print(N - max_balls_on_line)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40816
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    vector<string> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int cnt_ab = 0;
    int cnt_end_a = 0;
    int cnt_start_b = 0;
    int cnt_end_start = 0;
    for (int i = 0; i < n; i++) {
        if (v[i].front() == 'B' && v[i].back() == 'A')
            cnt_end_start++;
        else if (v[i].front() == 'B')
            cnt_start_b++;
        else if (v[i].back() == 'A')
            cnt_end_a++;
        for (int j = 0; j < v[i].size() - 1; j++) {
            if (v[i][j] == 'A' && v[i][j + 1] == 'B')
                cnt_ab++;
        }
    }

    int sum1 = cnt_ab;
    if (cnt_end_start) {
        if (cnt_end_a + cnt_start_b) {
            sum1 += cnt_end_start + min(cnt_end_a, cnt_start_b);
        }
        else {
            sum1 += cnt_end_start - 1;
        }
    }
    else {
        sum1 += min(cnt_end_a, cnt_start_b);
    }
    cout << sum1 << "\n";
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<int>l(N+1);
  l[0]=2,l[1]=1;
  rep(i,2,N+1)l[i]=l[i-1]+l[i-2];
  cout<<l[N]<<endl;


  return 0;
}


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

int main() {
  string S;
  cin >> S;
  if (S == "RSR") cout << 1 << endl ;
  else {
    int count = 0;
    for (int i=0 ; i < 3 ; i++ ) {
      if (S[i]=='R') count++;
    }
    cout << count << endl;
  }
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<pair<ll, ll>> A(N);
    rep(i, N){
        cin >> A[i].first >> A[i].second;
    }
    vector<pair<ll, ll>> Chev(N);
    rep(i, N){
        Chev[i].first = A[i].first - A[i].second;
        Chev[i].second = A[i].first + A[i].second;
    }
    sort(Chev.begin(), Chev.end());
    ll ans = Chev[N-1].first - Chev[0].first;
    rep(i, N) swap(Chev[i].first, Chev[i].second);
    sort(Chev.begin(), Chev.end());
    ans = max(ans, Chev[N-1].first-Chev[0].first);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    int n;
    ll ans = 0;
    ll m = 0;
    cin >> n;
    rep(i, n){
        ll a;
        cin >> a;
        m = max(m, a);
        ans += max((ll)0, m-a);
    }
    cout << ans << endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, lint> Pr;
const int N = 1 << 24;
const lint INF = 1ll << 56;

int n;
lint d;
lint x[30], y[30];

vector<Pr> v1, v2;

bool next_pat(int pat[])
{
	pat[0]++;
	for (int i = 0; i < 15; i++){
		if (pat[i] == 3){
			pat[i] = 0;
			pat[i + 1]++;
		}
		else return true;
	}
	return false;
}

void makeSeq(vector<Pr> &v, lint x[], lint y[])
{
	v.reserve(14348907);
	int pat[16] = {};
	do {
		Pr p(0, 0);
		for (int i = 0; i < 15; i++){
			if (pat[i] == 1){
				p.first += x[i];
				p.second += y[i];
			}
			else if (pat[i] == 2){
				p.first -= x[i];
				p.second -= y[i];
			}
		}
		v.push_back(p);
	} while (next_pat(pat));
	
	sort(v.begin(), v.end());
}

int main()
{
	cin >> n >> d;
	for (int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	n = 30;
	
	makeSeq(v1, x, y);
	makeSeq(v2, x + 15, y + 15);
	reverse(v2.begin(), v2.end());
	
	lint res = 0;
	deque<int> dq;
	int l = 0, r = 0;
	for (int i = 0; i < v1.size(); i++){
		Pr pl(-v1[i].first + d, INF);
		Pr pr(-v1[i].first - d, -INF);
		
		while (r < v2.size() && v2[r] > pr){
			while (dq.size() && v2[dq.back()].second <= v2[r].second){
				dq.pop_back();
			}
			dq.push_back(r++);
		}
		
		while (l < v2.size() && v2[l] > pl){
			if (dq.size() && dq.front() == l){
				dq.pop_front();
			}
			l++;
		}
		
		if (dq.size()){
			res = max(res, v1[i].second + v2[dq.front()].second);
		}
	}
	
	/*for (int i = 0; i < v1.size(); i++){
		if (abs(v1[i].first) <= d) res = max(res, v1[i].second);
		if (abs(v2[i].first) <= d) res = max(res, v2[i].second);
	}*/
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 449572
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8").trim();

if (input === "A") {
  console.log("T");
} else if (input === "T") {
  console.log("A");
} else if (input === "C") {
  console.log("G");
} else {
  console.log("C");
}


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

ll gcd(ll a, ll b) {
  ll A = max(a, b);
  ll B = min(a, b);
  if (A < 1 || B < 1) {
    return A;
  }
  return gcd(B, A % B);
}

ll lcm(ll a, ll b) {
  if (a < 1 || b < 1) {
    return 0;
  } else {
    return a / gcd(a, b) * b;
  }
}

int main() {
  ll n, m, i, ans, j;
  string s, t;
  cin >> n >> m >> s >> t;
  ll g = gcd(n, m);
  ll l = n / g * m;
  ans = l;
  ll p = l / n, q = l / m;
  i = 0;
  j = 0;
  while (i < n && j < m) {
    if (s[i] != t[j]) {
      ans = -1;
      break;
    }
    i += q;
    j += p;
  }
  cout << ans << "\n";
  return 0;
}


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

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

const long long MOD = 1000000007;

int main(){
  float n,d;
  cin >> n>>d;
  cout << ceil(n/(2*d+1)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> H(N); rep(i,N) cin >> H[i];
  ll ans = 0;
  sort(rall(H));
  rep(i,N){
    if(i<K) continue;
    else ans += H[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#define SIZE 1000001

int main(void)
{
  int i, j, k, n;
  int memo[SIZE] = {};

  memo[0] = 1;
  memo[1] = 1;
  for (i = 2; i <= SIZE; i++) {
    if (memo[i] == 0) {
      for (j = i * 2; j <= SIZE; j = j + i) {
        memo[j] = 1;
      }
    }
  }
  
  while (scanf("%d", &n) != EOF) {
    k = 0;
    for (i = n; i > 0; i--) {
      if (memo[i] == 0) k++;
    }
    std::printf("%d\n", k);
  }
}



Measured memory_bytes: 6660
#include<stdio.h>

int main(){
	int mt[10]={0};
	int i,j,tmp;

	for(i=0;i<10;i++){
		scanf("%d",&mt[i]);
		for(j=0;j<i;j++){
			if(mt[i]>mt[j]){
				tmp=mt[i];
				mt[i]=mt[j];
				mt[j]=tmp;
			}
		}
	}

	for(i=0;i<3;i++)
		printf("%d\n",mt[i]);

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s;
    for(auto c:s){
        if(c!='x')t+=c;
    }
    int ts=t.size();
    for(int i=0;i<ts;i++){
        if(t[i]!=t[ts-i-1]){
            cout<<-1<<endl;
            return 0;
        }
    }
    string le,ri;
    int r=s.size()-1,l=0;
    int res=0;
    while(l<r){
        if(s[l]!=s[r]){
            res++;
            if(s[l]=='x')l++;
            else r--;
        }
        else{
            l++;
            r--;
        }
    }
    cout<<res<<endl;
}

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

using namespace std;

int N, A[101];
void print_r() {
	for (int i = 0; i < N; i++) {
		cout << A[i];
		if (i != N - 1) cout << " ";
	}
	cout << endl;
}
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	bool flag = true;
	int c = 0;
	while (flag) {
		flag = false;
		for (int i = N - 1; i >= 1; i--) {
			if (A[i] < A[i-1]) {
				int p = A[i];
				A[i] = A[i-1];
				A[i-1] = p;
				c++;
				flag = true;
			}
		}
	}
	print_r();
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<ll> dp(n+1);
    dp[0] = 0;
    for(int i=1;i<=n;i++){
        dp[i] = i;
        for(int j=6;j<=i;j*=6){
            dp[i] = min(dp[i],dp[i-j]+1);
        }
        for(int j=9;j<=i;j*=9){
            dp[i] = min(dp[i],dp[i-j]+1);
        }
    }
    cout << dp[n] << endl;
}

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

int main(){
  int count = 0;
string str;
  cin >> str;
  vector<char> a(str.begin(), str.end());
  for(int i = 0; i < 3; i++){
    if(a.at(i) == 'R')
      count++; 
  }
  if(count == 2 && a.at(1) == 'S')
    count = 1;
  
  cout << count << endl;
    
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t;
	t=1;
	while(t--)
	{
		int x;
		cin >> x ;
		if(x==0)
		cout << "1";
		else if(x==1)
		cout << "0";
		
	}
}




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

int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        bool flag=false;
        for(int i=0;i<10;i++){
            if((n>>i)&1){
                if(flag)printf(" ");
                else flag=true;

                printf("%d",1<<i);
            }
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1200
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt(), a2 = sc.nextInt(), a3 = sc.nextInt();
		int ans = Math.abs(Math.max(Math.max(a1, a2), a3) - Math.min(Math.min(a1, a2), a3));
		System.out.println(ans);
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int INF = 1e9;
int main(){
    int N;
    cin >> N;
    vector<int>a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int ans = INF;
    for(int i = -100; i <= 100; i++) {
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            cnt+=(i-a[j])*(i-a[j]);
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <array>
#include <functional>
#include <iomanip>
#include <iostream>
#include <vector>

template <class T>
std::ostream &operator<<(std::ostream &stream, const std::vector<T> &vec) {
  for (auto val : vec) {
    if (std::is_fundamental<T>::value)
      stream << " " << val;
    else
      stream << std::endl << val;
  }
  return stream;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i)
    std::cin >> a[i];

  std::vector<std::vector<std::vector<double>>> dp(
      N + 3,
      std::vector<std::vector<double>>(N + 3, std::vector<double>(N + 3, 0.0)));

  std::function<double(int, int, int)> rec = [&](int x, int y, int z) {
    if (dp[x][y][z] > 0.0)
      return dp[x][y][z];
    if (x == 0 && y == 0 && z == 0)
      return dp[x][y][z] = 0.0;
    double res = 0.0;
    if (x > 0)
      res += rec(x - 1, y, z) * x;
    if (y > 0)
      res += rec(x + 1, y - 1, z) * y;
    if (z > 0)
      res += rec(x, y + 1, z - 1) * z;
    res += N;
    res /= x + y + z;
    return dp[x][y][z] = res;
  };

  std::array<int, 3> c{0, 0, 0};
  for (int i = 0; i < N; ++i)
    c[a[i] - 1] += 1;
  double res = rec(c[0], c[1], c[2]);

  std::cout << std::setprecision(12);
  std::cout << res << std::endl;
}


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

#define rep(i, j) for (ll i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vll;
typedef vector<pii> vpii;

const ll inf = (1LL << 50);
vector<pair<ll, ll>> es[100005];

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n, m;
    cin >> n >> m;
    for(int i = 1; i < n; i++) es[i].emplace_back(i - 1, 0);
    rep(i, m) {
        int l, r, c;
        cin >> l >> r >> c;
        l--, r--;
        es[l].emplace_back(r, c);
    }

    vll d(n, inf);
    vector<bool> used(n, false);
    typedef pair<ll, ll> P;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.emplace(0, 0);
    while(!pq.empty()) {
        auto p = pq.top(); pq.pop();
        ll dist = p.first;
        ll u = p.second;
        if (used[u]) continue;
        used[u] = true;
        d[u] = dist;
        for(auto& e: es[u]) {
            pq.emplace(dist + e.second, e.first);
        }
    }

    if (d[n - 1] == inf) {
        cout << "-1" << endl;
    } else {
        cout << d[n - 1] << endl;
    }


    return 0;
}


Measured memory_bytes: 11000
#include<stdio.h>


int insertionsort(int a[], int n, int g, int cnt)
{
	int v, j, i;
	for(i=g; i<n; i++){
		v = a[i];
		j = i-g;
		while (j>=0 && a[j]>v){
			a[j+g] = a[j];
			j=j-g;
			cnt++;
		}
		a[j+g] = v;
	}
	return cnt;
}


void shellsort(int a[], int n)
{
	int i;
	int cnt = 0;
	int g[n];
	int m = 0;
	
	for(int h=1; ;){
		if(h > n) break;
		g[m] = h;
		h = 3*h+1;
		m++;
	}
	
	printf("%d\n", m);
	
	for(i=m-1; i>=0; i--){
		if(i != m-1) printf(" ");
		printf("%d", g[i]);
	}
	printf("\n");
	
	for(i=m-1; i>=0; i--){
		cnt = insertionsort(a, n, g[i],cnt);
	}
	printf("%d\n", cnt);
	for(i=0; i<n; i++){
		printf("%d\n", a[i]);
	}
}


int main(void)
{
	int n;
	scanf("%d", &n);
	int a[n];
	int i;
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	
	shellsort(a, n);
	
	
	return 0;
}



Measured memory_bytes: 5660