akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

double D(double a){
    return a * a;
}
double d(pair<double, double> A, pair<double, double> B){
    return (sqrt(D(A.first - B.first) + D(A.second - B.second)));
}
int main(){

    int N;
    cin >> N;
    vector<pair<double, double>> IN(N);
    vector<int> C(N);
    double a, b;
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        IN[i] = mpair(a, b);
        C[i] = i;
    }
    double sum = 0.0;
    int cnt = 0;
    do{
        cnt++;
        for(int i = 0; i < N-1; i++){
            sum += d(IN[C[i]], IN[C[i+1]]);
        }
    } while(next_permutation(all(C)));
    //cout << sum / cnt << endl;
    printf("%0.12f\n", sum/cnt);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	while(true){
	int parts[301],d[1000][3],g[1000];
	int a,b,c,N;
	cin >> a >> b >> c;
	if(a==0 && b==0 && c==0)
	break;
	cin >>N;
	for(int i=1;i<=a+b+c;i++){
		parts[i]=2;
	}
	for(int i=0;i<N;i++){
		cin >> d[i][0] >> d[i][1] >> d[i][2] >> g[i];
		if(g[i]==1){
			for(int j=0;j<3;j++)
			parts[d[i][j]]=1;
		}
	}
	for(int i=0;i<N;i++){
		if(g[i]==0){
			for(int j=0;j<3;j++){
				if(parts[d[i][(j+1)%3]]==1 && parts[d[i][(j+2)%3]]==1)
					parts[d[i][j]]=0;
			}
		}
	}
		for(int i=1;i<=a+b+c;i++){
		cout << parts[i] << endl;
	}
}
	return 0;
}

Measured memory_bytes: 1176
import java.util.*;

public 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();
    }

    sc.close();

    int count = 0;

    boolean valid = true;

    while (valid) {

      count++;

      for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
          A[i] = A[i] / 2;
        } else {
          count--;
          valid = false;
          break;
        }
      }

    }
    
    System.out.println(count);

  }

}

Measured memory_bytes: 22996
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

int compare(const void *b1, const void *b2){
  return strcmp((const char*)b1,(const char*)b2);
}

int main(){
  int n;
  scanf("%d",&n);
  char s[n][20];
  int count=0;
  F(i,0,n){
    scanf("%s",s[i]);
  }
  qsort(s,n,sizeof(*s),compare);
  F(i,0,n-1){
    if(strcmp(s[i],s[i+1])==0) count++;
  }
  printf("%d\n",n-count);
  
  return 0;
}

Measured memory_bytes: 9144
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<LL,LL> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%d%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%lld%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}

vector<P> path[305];
vector<LL> path2[305];
bool used[305];
priority_queue<P,vector<P>,greater<P> > q1;
LL num[305][305];
LL dis[305];

void queue_clear(){
    priority_queue<P,vector<P>,greater<P> > q2;
    swap(q1,q2);
}

int main(){
    LL n,m,p;
    LL i,j,k;
    LL a,b,c;
    cin>>n>>m>>p;
    for(i=0;i<m;i++){
        cin>>a>>b>>c;
        a--,b--;
        path[a].push_back(make_pair(b,c));
        path[b].push_back(make_pair(a,c));
    }
    for(i=0;i<n;i++){
        memset(used,false,sizeof(used));
        memset(dis,-1,sizeof(dis));
        if(!q1.empty())queue_clear();
        q1.push(make_pair(0,i));
        while(!q1.empty()){
            a=q1.top().first,b=q1.top().second,q1.pop();
            if(a>p || used[b])continue;
            used[b]=true;
            if(i!=b)path2[i].push_back(b);
            for(auto it:path[b]){
                if(used[it.first])continue;
                if(dis[it.first]!=-1 && dis[it.first]<=a+it.second)continue;
                dis[it.first]=a+it.second;
                q1.push(make_pair(a+it.second,it.first));
            }
        }
    }
    memset(num,-1,sizeof(num));
    
    for(i=0;i<n;i++){
        memset(used,false,sizeof(used));
        memset(dis,-1,sizeof(dis));
        if(!q1.empty())queue_clear();
        q1.push(make_pair(-1,i));
        while(!q1.empty()){
            a=q1.top().first,b=q1.top().second,q1.pop();
            if(used[b])continue;
            used[b]=true;
            num[i][b]=a;
            for(auto it:path2[b]){
                if(used[it])continue;
                if(dis[it]!=-1 && dis[it]<=a+1)continue;
                dis[it]=a+1;
                q1.push(make_pair(a+1,it));
            }
        }
    }
    cin>>m;
    for(i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        cout<<num[a][b]<<endl;
    }
}


Measured memory_bytes: 5240
n = int(input())
List=list(map(int,input().split()))
result = 0


for i in range(200):
	for j in range(n):
		if List[j]%2 != 0:
			break
		List[j] /= 2

	else:
		result += 1
		continue
	break
  
print(result)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

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

    Graph G(n);
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    while (!que.empty())
    {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v])
        {
            if (dist[nv] != -1)
                continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = v;
            que.push(nv);
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (dist[i] == -1)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++)
    {
        cout << dist[i] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10132
# Try AtCoder
# author: Leonardone @ NEETSDKASU
############################################################
def gs() gets.chomp end
def gi() gets.to_i end
def gf() gets.to_f end
def gss() gs.split end
def gis() gss.map(&:to_i) end
def nmapf(n,f) n.times.map{ __send__ f } end
def ngs(n) nmapf n,:gs end
def ngi(n) nmapf n,:gi end
def ngss(n) nmapf n,:gss end
def ngis(n) nmapf n,:gis end
def arr2d(h,w,v=0) h.times.map{[v] * w} end
def for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end
def nsum(n) n * (n + 1) / 2 end
def vcount(d,r=Hash.new(0)) d.inject(r){|m,e| m[e]+=1;m} end
MV4 = [[0, 1], [1, 0], [0, -1], [-1, 0]]
MV8 = MV4 + [[1, 1], [1, -1], [-1, -1], [-1, 1]]
DV7 = 7 + 10 ** 9
############################################################

N, M = gis
XY = ngis M

t = [0] * (N + 1)
u = [1] * (N + 1)

t[1] = 1

XY.each do |x, y|
    
    t[y] += t[x]
    if u[x] == 1
        t[x] = 0
    end
    
    u[x] -= 1
    u[y] += 1
    
end

p t.count{|c| c > 0}



Measured memory_bytes: 11132
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().mainrun();
	}

	Scanner scan;
	int A,B;

	private void mainrun() {
		scan = new Scanner(System.in);

		while(scan.hasNext()) {
			A = scan.nextInt();
			B = scan.nextInt();

			System.out.println(A + B);
		}

		scan.close();
	}

}


Measured memory_bytes: 26312
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n; cin >> n;
    string s1;cin >> s1;
    string s2;cin >> s2;
    vector<ll> dp(n+5);
    vector<int> typ(n+1);
    typ[0] = 0;
    rep(i,n){
        if(s1[i] == s2[i])typ[i+1] = 1;
        else if(i > 0 && s1[i-1] == s1[i])typ[i+1] = 3;
        else typ[i+1] = 2;
    }
    dp[0] = 1;
    rep(i,n+1){
        if(typ[i] == 0){
            if(typ[i+1] == 1)dp[i+1] = dp[i] * 3;
            else dp[i+1] = dp[i] * 6;
        }
        else if(typ[i] == 1){
            if(typ[i+1] == 1)dp[i+1] = dp[i] * 2;
            if(typ[i+1] == 2)dp[i+1] = dp[i] * 2;
        }
        else if(typ[i] == 2)dp[i+1] = dp[i];
        else if(typ[i] == 3){
            if(typ[i+1] == 1)dp[i+1] = dp[i];
            if(typ[i+1] == 2)dp[i+1] = dp[i] * 3;
        }
        dp[i] %= MOD;
        // cout << dp[i] << endl;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Created at: 2019 January 12 17:21:40
Created by: MpleDrop
*/
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 4e2;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
char c[N + 1][N + 1];
bool used[N + 1][N + 1];
int dx[] = {0, 1, -1, 0, 0};
int dy[] = {0, 0, 0, 1, -1};
int n, m;
bool can(int x, int y) {
    if (x > n || x < 1 || y < 1 || y > m || used[x][y])
        return false;
    return true;
}
int cn1, cn2;
void dfs(int x, int y) {
    used[x][y] = true;
//    cout << x << " -- " << y << " " << c[x][y] << "\n";
    if (c[x][y] == '.') {
        cn1++;
        for (int j = 1; j <= 4; j++) {
            int kx = dx[j] + x, ky = dy[j] + y;
            if (can(kx, ky) && c[kx][ky] == '#') {
                dfs(kx, ky);
            }
        }
    }
    if (c[x][y] == '#') {
        cn2++;
        for (int j = 1; j <= 4; j++) {
            int kx = dx[j] + x, ky = dy[j] + y;
            if (can(kx, ky) && c[kx][ky] == '.') {
                dfs(kx, ky);
            }
        }
    }
}
main() {
    n = readInt(), m = readInt();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (!used[i][j] && c[i][j] == '#') {
                cn1 = cn2 = 0;
                dfs(i, j);
//                cout << cn1 << " ! " << cn2 << "\n";
                ans += cn1 * cn2;
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

vector<ll> divisor;

void get_divisor(ll num){
	for (int i = 1; i*i <= num; i++){
		if (num % i == 0){
			divisor.push_back(i);
			if (num != i*i) divisor.push_back(num/i);
		}
	}
	return;
}

int main(){
	ll n, k, sum = 0;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	get_divisor(sum);
	sort(divisor.begin(), divisor.end());

	ll ans = 1;
	for (auto x : divisor){
		ll temp = 1000000000000000000;
		vector<ll> vec1, vec2;
		vector<ll> sum1(n+1), sum2(n+1);
		sum1[0] = 0, sum2[0] = 0;
		for (int i = 0; i < n; i++){
			vec1.push_back(a[i]%x);
			vec2.push_back(abs(a[i]%x-x));
		}
		sort(vec1.begin(), vec1.end());
		sort(vec2.begin(), vec2.end());
		for (int i = 0; i < n; i++){
			sum1[i+1] = sum1[i] + vec1[i];
			sum2[i+1] = sum2[i] + vec2[i];
		}
		for (int i = 1; i <= n; i++){
			if (sum1[i] == sum2[n - i]){
				temp = min(temp, sum1[i]);		
			}
		}
		if (temp <= k) ans = x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

long long pow5(long long x)
{
    return x*x*x*x*x;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long x;
    cin>>x;
    for(long long i=-120;i<=120;i++)
        for(long long j=-120;j<=120;j++)
            if(pow5(i)-pow5(j)==x)
                return cout<<i<<" "<<j,0;
    return 0;
}


Measured memory_bytes: 3632
#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, t, x, y;
  cin >> n;
  ll now_t = 0, now_x = 0, now_y = 0;
  rep(i, n) {
    cin >> t >> x >> y;
    ll t1 = t - now_t;
    ll t2 = abs(now_x - x) + abs(now_y - y);
    if (t1 < t2 || (t1 - t2) % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
    now_t = t;
    now_x = x;
    now_y = y;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s[0] == 'R')
        if (s[1] == 'R')
            if (s[2] == 'R')
                cout << 3;
            else
                cout << 2;
        else
            cout << 1;
    else if (s[1] == 'R')
        if (s[2] == 'R')
            cout << 2;
        else
            cout << 1;
    else if (s[2] == 'R')
        cout << 1;
    else
        cout << 0;
    return 0;
}

Measured memory_bytes: 3160
import sys
read = sys.stdin.read
def main():
    n = int(input())
    a = input()
    if not 'WR' in a:
        print(0)
        sys.exit()
    a = list(a)
    rnum = a.count('R')
    r = 0
    for i1 in range(rnum):
        r += a[i1] == 'W'
    for j1 in range(n - rnum):
        r += a[rnum + j1] == 'R'
    r = r // 2
    print(r)
if __name__ == '__main__':
    main()


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int H,W; cin >> H >> W;
    int N; cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];

    vector<vector<int>> G(H,vector<int>(W,0));

    int h=0,w=0;
    REP(i,N){
        while(a[i]>0){
            G[h][w] = i+1;
            a[i]--;
            if(h%2==0){
                if(w!=W-1) w++;
                else h++;
            }else{
                if(w!=0) w--;
                else h++;
            }
        }
    }

    REP(i,H){
        REP(j,W){
            cout << G[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

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

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

using namespace std;

int main() {

    int n; cin >> n;
    int cur = 1;
    int ans = 0;
    vector<int> a(n+1);
    vector<bool> l(n+1);
    rep(i,n) cin >> a[i+1];
    rep(i,n) l[i+1] = false;

    while(1){
        if(l[cur]) break;
        else{
            if(cur == 2) break;
            l[cur] = true;
            cur = a[cur];
            ans ++;
        }
    }

    if(cur == 2) cout << ans;
    else cout << -1;

    return 0;
}











Measured memory_bytes: 3656
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
prime = [True] * (10 ** 6 + 10)

b = sorted(set(a))

for i in b:
    num = i * 2
    while True:
        if num >= 10 ** 6 + 1:
            break
        prime[num] = False
        num += i

ans = 0
for s in a:
    if prime[s] == True and c[s] == 1:
        ans += 1

print(ans)

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

const int N = 1e5;
bool is_prime[N+5];
int d[N+5]; //d[i]=iの最小の素因数  
int main(){
  for(int i = 0; i < N+5; i++) is_prime[i]=true; //エラトステネス
  for(int i = 2; i < N+5; i++){
    if(is_prime[i]) d[i] = i;
    for(int j = i + i; j < N+5; j += i){
      is_prime[j] = false;
      if(is_prime[i] && d[j]==0) d[j] = i;
    }
  }
  int a[N+5] = {0};
  for(int i = 3; i < N+5; i = i+2){
    if(is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
  }
  int s[N+5] = {0};
  for(int i = 0; i < N+5; i++) s[i+1]=s[i]+a[i];
  int q; cin >> q;
  for(int i = 0; i< q; i++){
    int l, r;
    cin >> l >> r;
    int ans = s[r+1]-s[l];
    cout << ans << endl;
  }
  return 0;
}
    

Measured memory_bytes: 4836
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

const int MOD = 1000000007;

struct K {
  int lb;
  int ub;
};

ll mypow(ll x, ll n) {
  if (n == 0) return 1;
  if (n & 1) return mypow(x * x % MOD, n / 2) * x % MOD;
  return mypow(x * x % MOD, n / 2);
}

int table[410][410];

int n;
K vs[410];

ll memo[410][410];
ll solve(int pos, int rest) {
  ll& res = memo[pos][rest];
  if(res < 0) {
    res = 0;
    if(pos == n-1) {
      for(int x = vs[pos].lb; x <= vs[pos].ub; ++x) { 
        res = (res + mypow(x, rest)) % MOD;
      }
    } else {
      for(int i = 0; i <= rest; ++i) {
        ll solveRest = solve(pos+1, rest-i);
        ll xx = (table[i][vs[pos].ub+1] - table[i][vs[pos].lb] + MOD) % MOD;
        res = (res + xx * solveRest) % MOD;
      }
    }
    // cerr << "solve(" << pos << ", " << rest << ") = " << res << endl;
  }
  return res;
}



int main(void) {
  for(int i = 0; i <= 400; ++i) {
    for(int x = 0; x <= 400; ++x) {
      table[i][x+1] = (table[i][x] + mypow(x, i)) % MOD;
    }
  }
  
  int nCandy;
  scanf("%d%d", &n, &nCandy);
  REP(i, n) {
    scanf("%d", &vs[i].lb);
  }
  REP(i, n) {
    scanf("%d", &vs[i].ub);
  }

  memset(memo, -1, sizeof memo);
  ll res = solve(0, nCandy);
  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 2176
/*input
1 2
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

int main() {
	int a, b, ok = 0;
	cin >> a >> b;
	if (a > b) swap(a, b);
	for (int i = 1; i <= 3; i++) {
		if (a * i * b % 2 == 1) ok = 1;
	}
	cout << (ok ? "Yes" : "No");
	return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j]<<" ";cout<<endl;}};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  
  for(i=1;i<=3500;i++){
    for(j=1;j<=3500;j++){
      buf=4*i*j-n*i-n*j;
      ll buf2=n*i*j;
      if(buf>0&&buf2%buf==0&&buf2/buf<=3500){
        cout<<i spa j spa buf2/buf<<endl;
        goto label;
      }
      
    }
  }
  label:
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<ii , int> iii;
ll n , x[200000] , prefix[200000] , ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> x[i];
	}
	sort(x + 1 , x + n + 1);
	for(int i = 1 ; i <= n ; i++){
		prefix[i] = prefix[i - 1] + x[i];
	}
	x[n + 1] = 0;
	for(int i = n ; i >= 1 ; i--){
		if(2*prefix[i] >= x[i + 1])ans++;
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5200
n,k=map(int,input().split())
s=[0]*n
a=list(map(int,input().split()))
for i,h in enumerate(a):
    if i!=0:
        g=0 if i-k<0 else i-k
        s[i]=min([abs(h-d)+p for d,p in zip(a[g:i],s[g:i])])
print(s[-1])

Measured memory_bytes: 14744
#include <iostream>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <sstream>
#include <cstdlib>

using namespace std;

string itos(int x, int l){
	stringstream ss;
	ss << x;
	string s = ss.str();
	return string(l - s.size(), '0') + s;
}

int main(){
	while(true){
		int x, l;
		cin >> x >> l;
		if(x == 0 && l == 0){ break; }
		map<int, int> mp;
		int answer = 0;
		while(mp.find(x) == mp.end()){
			mp.insert(make_pair(x, answer));
			string s = itos(x, l);
			sort(s.begin(), s.end());
			int small = atoi(s.c_str());
			reverse(s.begin(), s.end());
			int large = atoi(s.c_str());
			x = large - small;
			++answer;
		}
		cout << mp[x] << " " << x << " " << answer - mp[x] << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
using vd = vector<double>;

int N;

int main() {
	ios_base::sync_with_stdio(false);
	vd inp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		double a; cin >> a;
		inp.push_back(a);
	}
	sort(inp.begin(), inp.end());
	double max = inp.back();
	inp.pop_back();
	if (inp.size() == 1) {
		cout << max << " " << inp[0] << endl;
		return 0;
	}
	double ans1, ans2;
	auto ans_iter = lower_bound(inp.begin(), inp.end(), max / 2.0);
	if (ans_iter == inp.end()) {
		ans1 = numeric_limits<double>::max();
	}
	else {
		ans1 = *ans_iter;
	}
	--ans_iter;
	if (ans_iter == inp.end()) {
		ans2 = numeric_limits<double>::max();
	}
	else {
		ans2 = *ans_iter;
	}
	double ans;
	if (abs(max / 2.0 - ans1) < abs(max / 2.0 - ans2)) {
		ans = ans1;
	}
	else {
		ans = ans2;
	}
	cout << (int)max << " " << (int)ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
 
#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

ll MOD = 1000000007;
 
void solve() {
    int n;
    ll k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    int vt = 1;
    int seen[n];
    memset(seen, 0, sizeof seen);
    int t = 1;
    int c = -1;
    vi cyc;
    while (true) {
        if (seen[vt - 1]) {
            int start = seen[vt - 1] - 1;
            int len = t - seen[vt - 1];
            cout << cyc[start + (k - start) % len] << endl;
            return;
        }
        if (t >= k + 1) {
            cout << vt << endl;
            return;
        }
        cyc.pb(vt);
        seen[vt - 1] = t;
        vt = a[vt - 1];
        t++;
    }
}
 
void querySolve() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    solve();
    //querySolve();
}



Measured memory_bytes: 5724
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
typedef long long ll;
typedef long l;
int return_max(int a,int b){
  if(a>b){
    return a;
  }else{
    return b;
  }
}

int return_min(int a,int b){
  if(a<b){
    return a;
  }else{
    return b;
  }
}

int main(void)
{
  int l,r,d;
  int count=0;
  scanf("%d %d %d",&l,&r,&d);
  for(int i=l;i<=r;i++){
    if(i%d==0){
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
using namespace std;

struct People{
    int weight, start, end;
};

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        set<int> times;
        vector<People> people(n);
        for (int i = 0; i < n; i++) {
            cin >> people[i].weight >> people[i].start >> people[i].end;
            times.insert(people[i].start);
            times.insert(people[i].end);
        }
        string result = "OK";
        int weight = 0;
        for (set<int>::iterator it = times.begin(); it != times.end(); it++) {
            queue<int> idx_qu;
            for (int i = 0; i < n; i++) {
                if (*it == people[i].start || *it == people[i].end) {
                    idx_qu.push(i);
                }
            }
            while (idx_qu.empty() == false) {
                int idx = idx_qu.front();
                idx_qu.pop();
                if (*it == people[idx].end) {
                    weight -= people[idx].weight;
                }
                if (*it == people[idx].start) {
                    weight += people[idx].weight;
                }
            }
            if (weight > 150) {
                result = "NG";
                break;
            }
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,d;
    cin>>n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>d;
        deq.emplace_back(d);
    }
    int sum=0;
    int pointer=0;
    while (pointer<n) {
        for (int j=pointer+1;j<n;j++) {
            sum+=deq[pointer]*deq[j];
        }
        pointer++;
    }
    cout<<sum<<endl;
}

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


int main() {
    int K;
    cin >> K;
    if (K == 1) {
        cout << "1\n";
        return 0;
    }
    if (K % 2 == 0 || K % 5 == 0) {
        cout << "-1\n";
        return 0;
    }

    if (K % 7 == 0) K /= 7;
    K *= 9;
    int a = 10;
    for (int i = 0; i <= 10 * K; i++) {
        if (a % K == 1) {
            cout << i + 1 << "\n";
            return 0;
        }
        a = (a * 10) % K;
    }
   
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  char C[H][W];
  REP(i,H)REP(j,W)cin>>C[i][j];
  REP(i,2*H){
    REP(j,W)cout<<C[i/2][j];
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    REP(i,s.length()){
        if((i+1)%2){
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
                
            }
           else{
               cout << "No" << endl;
                return 0;
           }
        }
        else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
                
            }
            else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		int hash[]=new int[n+1];
		int a[]=new int[n+1];
		for(int i=1;i<=n;i++)
		{
			a[i]=nextInt();
			hash[a[i]]++;
		}
		long ans=0;
		for(int i=1;i<=n;i++)
			ans+=1l*hash[i]*(hash[i]-1)/2;
		for(int i=1;i<=n;i++)
		{

			out.println(ans-(1l*hash[a[i]]*(hash[a[i]]-1)/2)+(1l*(hash[a[i]]-1)*(hash[a[i]]-2)/2));
		}
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 50896
#include<cstdio>

int SUM(int n, int a, int b)
{
	int sum = 0, k;
	for(int i = 1; i <= n; i++)
	{
		if(i < 10)
			k = i;
		if(i < 100 && i >= 10)
			k = i % 10 + i / 10;
		if(i < 1000 && i >= 100)
			k = i % 10 + (i % 100) / 10 + i / 100;
	    if(i < 10000 && i >= 1000)
	    	k = i % 10 + (i % 100) / 10 + (i % 1000) / 100 + i / 1000;
	    if(i == 10000)
	    	k = 1;
        if(k <= b && k >= a)
        	sum += i;
	}
	return sum;
}

int main()
{
	int sum, a, b, n;
 	scanf("%d %d %d", &n, &a, &b);
    sum = SUM(n, a, b);
    printf("%d\n", sum);
    return 0 ;
}  

Measured memory_bytes: 128
S = input()
ans = 0
r = [0] * 2019
r[0] = 1
t = 0
base = 1
for c in S[::-1]:
    t = (t + base * int(c)) % 2019
    base = (base * 10) % 2019
    r[t] += 1

for k in r:
    ans += k * (k - 1) // 2

print(ans)


Measured memory_bytes: 68560
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
#include <map>
#include <set>
using namespace std;
int main ()
{
	int n,k;
	scanf("%i%i",&n,&k);
	double a[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%lf",&a[i]);
	}
	double s=0,b[n+1],r=0,maks=0;
	for(int i=1;i<=n;i++)
	{
		s=a[i]*(a[i]+1)/2;
		b[i]=s/a[i];
		s=0;
	}
	for(int i=1;i<=k;i++)
	{
		r+=b[i];
	}
	maks=r;
	for(int i=2;i<=n-k+1;i++)
	{
		r=r-b[i-1]+b[i+k-1];
		if(r>maks)
		{
			maks=r;
		}
	}
	printf("%f",maks);
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N;
    string s;
    cin >> N >> s;
    if (N % 2 == 1)
    {
        cout << "No" << endl;
        return 0;
    }
    string s1 = s.substr(0, N / 2);
    string s2 = s.substr(N / 2);
    if (s1 == s2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int x,y,b,p;
		cin>>x>>y>>b>>p;
		int f1=x*b+y*p;
		if(b<5){
			b=5;
		}
		if(p<2){
			p=2;
		}
		int f2=(x*b+y*p)*4/5;
		if(f1<f2){
			cout<<f1<<endl;
		}else{
			cout<<f2<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3112
import java.util.Scanner;

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();
		
		for(int i = Math.min(a, b); i <= Math.max(a, b); i++) {
			if(i == c) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, w, h, n);
  vector<int> x(n), y(n), a(n);
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> a[i];

  int left = 0, down = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1) left = max(left, x[i]);
    if (a[i] == 2) w = min(w, x[i]);
    if (a[i] == 3) down = max(down, y[i]);
    if (a[i] == 4) h = min(h, y[i]);
  }

  cout << (w < left || h < down ? 0 : (w - left) * (h - down)) << endl;

  return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int l;
        cin >> l;
        v.push_back(l);
    }
    sort(v.begin(), v.end());

    int sum = 0;
    for (int i = 0; i < n - 1; i++)
    {
        sum += v[i];
    }
    sum -= v[n - 1];
    if (sum > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int>A(N);
  vector<int>B(3);
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]%4==0)B[0]++;
    else if(A[i]%2==0)B[1]++;
    else B[2]++;
  }
  if(B[1]==0){
    if(B[0]+2>B[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else{
    if(B[0]+1>B[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

int n,s,dp[350][10][1 << 10];

int rec(int sum,int cnt,int bit){
  if(sum < 0) return 0;
  if(cnt == n) return sum == 0;
  if(dp[sum][cnt][bit] != -1) return dp[sum][cnt][bit];
  int res = 0;
  for(int i=0;i<=9;i++){
    if(bit >> i & 1)
      res += rec(sum - i*(cnt+1),cnt+1,bit & ~(1 << i));
  }
  return dp[sum][cnt][bit] = res;
}
      

int main(){
  while(cin >> n >> s){
    memset(dp,-1,sizeof(dp));
    int ans = 0;
    if(s > 330) s = 0;
    cout << rec(s,0,(1 << 10)-1) << endl;
  }
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;

int main(){
    int n;
    cin >> n;
    vs w(n),x(n);
    rp(i,n){
        cin >> w.at(i);
        x.at(i)=w.at(i);
    }
    sort(x);
    unique(x);
    if(x.size()!=w.size()){
        cout << "No" << endl;
    }else{
        rp(i,n-1){
            if(w.at(i).at(w.at(i).size()-1)!=w.at(i+1).at(0)){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func diff(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	var a, b, c, d, e, k int
	fmt.Scan(&a, &b, &c, &d, &e, &k)
	if diff(a, b) > k || diff(a, c) > k || diff(a, d) > k || diff(a, e) > k || diff(b, c) > k || diff(b, d) > k || diff(b, e) > k || diff(c, d) > k || diff(c, e) > k || diff(d, e) > k {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c,x,cnt=0;
    cin>>a>>b>>c>>x;
    for(int i=0; i<=a; i++)
    {
        for(int j=0; j<=b; j++)
        {
            for(int k=0; k<=c; k++)
            {
                if(((500*i)+(100*j)+(50*k))==x){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    char str[1010];
    bool n = 0, w = 0, s = 0, e = 0;

    cin >> str;

    for (int i = 0; i < strlen(str); i++) {
        if (str[i] == 'N') n = true;
        if (str[i] == 'W') w = true;
        if (str[i] == 'S') s = true;
        if (str[i] == 'E') e = true;
    }

    if (n && s && !w && !e) {
        cout << "Yes" << endl;
    }
    else if (!n && !s && w && e) {
        cout << "Yes" << endl;
    }
    else if (n && s && w && e) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
    {
      	Scanner in = new Scanner(System.in);
      	String s = in.next();
      	int zer = 0, one = 0, len = s.length();
      	for (int i = 0; i < len; i++)
        	if (s.charAt(i) == '0')
            	zer++;
     	one = len-zer;
      	System.out.println(2*(int)(Math.min(zer, one)));
      	in.close();
    }
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

int main()
{
  int n, k;
  int64_t ans = 0;

  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  sort(h.begin(), h.end());
  for (int i = 0; i < n - k; i++)
    ans += h[i];
  cout << ans << endl;
}

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

int main() {
	int d;
  cin >> d;
  int t;
  cin >> t;
  int s;
  cin >> s;
  if (t*s>=d) {
    cout << "Yes";
  } else {
    cout << "No";
  }
	return 0;
}


Measured memory_bytes: 3624
import collections
n = int(input())
a = list(map(int,input().split()))
count = collections.Counter(a)
max = 0
for i in count:
    if count[i] + count[i-1] + count[i+1] > max:
        max = count[i] + count[i-1] + count[i+1]
print(max)

Measured memory_bytes: 14692
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();
		System.out.println(a1+a2+a3 >= 22 ? "bust" : "win");

		sc.close();
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;

void solve() {
	cin >> N >> M;
	cout << (N == M ? "Yes" : "No") << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    int n,k;
    cin >> n >> k;
    int a[n] = {};
    for(int i = 0;i < k;i++)
    {
        int d;
        cin >> d;
        for(int j = 0;j < d;j++)
        {
            int ad;
            cin >> ad;
            a[ad - 1]++;
        }
    }
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        if(a[i] == 0)
        {
            ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
int aCb(int a,int b,int m){
  long long s=1,i;
  if(b>a-b)b=a-b;
  for(i=0;i<b;i++)s=(((s*(a-i))%m)*inv(i+1,m))%m;  
  return (int)s;
}
int main(){
  int h,w,a,b,i,M=1e9+7;
  long long s=0,ans=0,n=1,m=1;
  scanf("%d %d %d %d",&h,&w,&a,&b);
  for(i=0;i<h+w-b-i-2;i++)m=(m*i)%M;
  m=aCb(h+w-b-2,w-b-1,M);//printf("%d %d %lld\n",h+w-b-2,w-b-1,m);
  for(i=0;i<h-a;i++){//printf("%lld %lld\n",n,m);
    s=(n*m)%M;
    ans=(ans+s)%M;
    n=(n*inv(i+1,M))%M;
    n=(n*(b+i))%M;
    m=(m*inv(h+w-i-b-2,M))%M;
    m=(m*(h-i-1))%M;
    //n=(n*aCb(h-i+w-b-2,w-b-1,M))%M;
    //printf("%d %d %d %d %lld\n",b+i-1,i,h-i+w-b-2,w-b-1,n);
    //s=(s+n)%M;//printf("%lld\n",s);
  }
  printf("%lld\n",ans);
  return 0;
}


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

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

    int n; cin >> n;
    vector<int> x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];

    vector<int> town;
    REP(i, n) town.push_back(i);

    int tmp = n;
    int sum = 1;
    while (tmp != 1) {
        sum *= tmp;
        tmp--;
    }
    // cout << sum << '\n';

    double dist = 0.0;
    REP(i, sum) {
        REP(j, n - 1) {
            dist += hypot(x[town[j]] - x[town[j + 1]], y[town[j]] - y[town[j + 1]]);
        }
        next_permutation(town.begin(), town.end());
    }

    dist /= sum;

    printf("%.10f\n", dist);
    return 0;
}


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

#define endl '\n'

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

  int n, m;
  cin>>n>>m;
  set<int> s;
  int v[n];
  for(int i = 0; i<n;i++){
    cin>>v[i];
    s.insert(i+1);
  }

  int a, b;
  for(int i = 0; i<m;i++){
    cin>>a>>b;
    if(v[a-1]>v[b-1])
      s.erase(b);
    else if(v[a-1]<v[b-1])
      s.erase(a);
    else{
      s.erase(a);
      s.erase(b);
    }
  }

  cout<<s.size()<<endl;

  return 0;

}


Measured memory_bytes: 8692