akhauriyash/Code-Regression huggingface dataset:
// 12:41
//

// w[0], w[1], ..., w[n-1]
// ex. 9 7 6 1
//  -> 1 6 7 9 
// このように 1, 9の交換, 6,7の交換のようにペアの交換で済む場合は,
// ex. 2 3 1
//  -> 1 2 3 
// このように, 1, 2, 3の3つ以上の巡回置換の場合は,
// ...
// まとめると, 辿っていくと問題がある. 
// 
// 10 7  8  9
// 7  8  9 10
// 7+10
// 7+8
// 8+9
// 9+10

#include <iostream>
#include <cstdio>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <numeric>
using namespace std;
using ll = long long;

struct Value {
	ll v;
	ll idx;
};

class lesserValue{
public:
	bool operator()(const Value &x, const Value &y) {
		return x.v < y.v;
	}
};

void print(const vector<Value> &x) {
	for (ll i=0;i<x.size();++i) {
		if (i!=0) cout << " ";
		//cout << x[i].v << "," << x[i].idx;
		cout << x[i].v;
	}
	cout << endl;
}

int main() {
	ll n;
	cin >> n;
	vector<Value> w(n);
	for (ll i=0;i<n;++i) {
		scanf("%lld", &w[i].v);
		w[i].idx = i;
	}
	//print(w);
	vector<Value> orig(w);
	//print(orig);
	// sort by ascending order
	sort(w.begin(), w.end(), lesserValue()); 
	//print(w);
	unordered_set<ll> memo;
	ll ans = 0;
	for (ll i=0;i<n;++i) {
		// orig: 4 2 3
		// 0 1 2
		// w:    2 3 4
		// 1 2 0
		// w[0].v = 2;
		// i = 0; 
		// j = w[i].idx;
		// w[0].idx = 1;
		// w[1].idx = 2;
		// w[2].idx = 0;
		//cout << "[" << i << "]: "; 
		if (memo.end() != memo.find(i)) {
			//cout << "skipped " << i << endl;
			continue;
		}
		memo.insert(i);
		//cout << "inserted " << i << " ";
		ll cnt = 0;
		ll j = w[i].idx;
		while (i != j) {
			cnt++;
			memo.insert(j);
			ans += w[i].v + w[j].v;
		 	j	= w[j].idx;
			//cout << "inserted " << j << " " << endl;
		}
		if (cnt > 1 && w[i].v != w[0].v) {
			ans += min(0LL, 2 * (w[i].v + w[0].v) + cnt * (w[0].v - w[i].v));
		}
//		ans += accumulate(t.begin(), t.end(), 0);
//		if (t.size() > 0) {
//			ans -= *max_element(t.begin(), t.end());
//		}
		//cout << "ans[" << i << "] = " << ans << endl;
	}
	//print(w);
	cout << ans << endl;
	return 0;
}

//	3 2 1
//	1 2 3 
//	1 + 3 = 4
//
//  3 2 1 5 4 	
//  1 2 3 4 5
//
//  4 1 5 3 2
//  1 2 3 4 5
//
//  4 2 5 3 1 : 1 + 2 = 3
//  4 2 1 3 5 : 1 + 5 = 6 
//  4 2 3 1 5 : 1 + 3 = 4 
//  1 2 3 4 5 : 1 + 4 = 5



Measured memory_bytes: 3308
A,B = map(int, input().split())
am = int(A * 12.5)
am -= (am % 100)
ans = -1
for i in range(100):
  if int((am + i) * 0.08) == A and int((am + i) * 0.1) == B:
    ans = am + i
    break
print(ans)

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

#define ll long long int

using namespace std;


vector<int> s;
map<int,int> d;

bool f(int n, int index){
	
	if (d[n] >= 2){
		return false;
		}
		
	
	for(int i=1; i*i <= n; i++){
		
		if (n%i == 0){
			

			if (*lower_bound(s.begin()+index , s.end(), i, greater<int>() ) == i)
				return false;
				

			if (*lower_bound(s.begin()+index , s.end(), n/i, greater<int>() ) == n/i)
				return false;
				
			}
		}
	
	return true;	
	}


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

	
	int temp;
	for(int i=0; i<n; i++){
		cin>>temp, s.push_back(temp), d[temp] += 1;
		}
		
		
	sort(s.begin(), s.end(), greater<int>());
		
	
		
		
	int cnt = 0;
	for(int i=0; i<n; i++){
		
		if ( f(s[i], i+1) ){
			
			cnt += 1;
			}
		
		}
	
		
	cout<<cnt<<endl;

	return 0;
	}


int main(){
	

	solve();
	
	return 0;
}


Measured memory_bytes: 13388
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>
#include<math.h>


int main(void){
    int A, B;
    scanf("%d %d", &A, &B);
    int i;
    int count = 0;
    for(i=A; i<=B; i++) {
        char s[100000];
        sprintf(s, "%d", i);
        int len = strlen(s);
        int j;
        int flag = 1;
        for(j=0; j<len; j++) {
            if(s[j] != s[len-j-1]) {
                flag = 0;
                break;
            }
        }
        if(flag == 1) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

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

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 tuple<int, int, int> iii;
typedef vector<iii> viii;
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;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

void solve() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    int sm = 0;
    rep(i, s.length()) {
        if (s[i] != t[i]) sm++;
    }
    cout << sm << endl;
}

void querySolve() {
    int n;
    cin >> n;
    while (n--) {
        solve();
    }
}

int main() {
    //querySolve();
    solve();
    
}


Measured memory_bytes: 3868
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main()
{
	int n;
	cin >> n;
	while(n--){
		int x;
		cin >> x;
		a[x-1]++;
		a[x]++;
		a[x+1]++;
	}
	int max = 0;
	for(int i=0;i<N;i++)
		if(a[i]>max)
			max = a[i];
	cout << max << endl;
}

Measured memory_bytes: 640
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair< int, pair<int, int> >
#define plpll pair< ll, pair<ll, ll> >

using namespace std;

const ll maxn = 305, inf = LONG_LONG_MAX/ 2;
int dis[maxn][maxn], ans[maxn][maxn];

int32_t main(){
    int n, m, l;
    cin >>n >>m >>l;
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < n; j ++){
            dis[i][j] = (dis[j][i] = inf);
            ans[i][j] = (ans[j][i] = inf);
        }
    }
    for(int i = 0; i < m; i ++){
        int u, v, w;
        cin >>u >>v >>w;
        u --; v --;
        dis[u][v] = dis[v][u] = w;
    }
    for(int k = 0; k < n; k ++){
        for(int i = 0; i < n; i ++){
            for(int j = 0; j < n; j ++){
                xmin(dis[i][j], dis[i][k] + dis[k][j]);
                dis[j][i] = dis[i][j];
            }
        }
    }
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < n; j ++){
            if(dis[i][j] <= l){
                ans[i][j] = (ans[j][i] = 0);
            }
        }
    }
    for(int k = 0; k < n; k ++){
        for(int i = 0; i < n; i ++){
            for(int j = 0; j < n; j ++){
                xmin(ans[i][j], ans[i][k] + ans[k][j] + 1);
                ans[j][i] = ans[i][j];
            }
        }
    }
    int q;
    cin >>q;
    for(int i = 0; i < q; i ++){
        int u, v;
        cin >>u >>v;
        u --; v --;
        if(ans[u][v] > n)
            cout <<- 1 <<'\n';
        else
            cout <<ans[u][v] <<'\n';
    }
    return false;
}


Measured memory_bytes: 1920
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val A = readLine()!!.split(" ").map { it.toInt() }
            .groupBy { it }
            .map { it.value.count() }
            .sortedDescending()
            .filterIndexed { ind, v -> ind >= K }
            .sum()
    println(A)
}


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

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		Integer num = Integer.parseInt(s.nextLine());
		Integer[] seq = new Integer[num];
		Integer index = 0;
		while(s.hasNext()){
			String input = s.next();
			if(!input.equals("")){
				seq[index] = Integer.parseInt(input);
			}
			index++;
		}
		s.close();
		for(int j = 1;j < seq.length; j++){
			print_seq(seq);
			Integer key = seq[j];
			Integer i = j - 1;
			while(i >= 0 && seq[i] > key){
				Integer bkp = seq[i+1];
				seq[i+1] = seq[i];
				seq[i] = bkp;
				i -= 1;
			}
		}
		print_seq(seq);
	}

	private static void print_seq(Integer[] seq){
		for(int i = 0; i < seq.length; i++){
			if(i == seq.length - 1){
				System.out.print(seq[i]);
			}
			else{
				System.out.print(seq[i] + " ");
			}
		}
		System.out.print("\n");
	}
}

Measured memory_bytes: 24216
from itertools import permutations
def check(i,j):
    if j==N-2 and x[j] in G[i]:
        return True
    if x[j] in G[i]:
        return check(x[j],j+1)
    return False
    
N,M = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
cnt = 0
for x in permutations(range(2,N+1),N-1):
    if check(1,0):
        cnt += 1
print(cnt)   

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

template<typename T, typename U> 
T modpow(T a, U n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % 2019;
        a = a * a % 2019;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    int N = S.size();
    reverse(all(S));
    map<int, ll> mp;
    mp[0]++;
    ll tmp = 0;
    ll ans = 0;
    rep(i,N){
        tmp += (modpow(10,i)*(S[i]-'0'))%(2019);
        tmp %= 2019;
        if(i >= 3)ans += mp[tmp];
        mp[tmp]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3748
#include <iostream>

using namespace std;

int dp[100010];

int main()
{
  int SN[12];
  SN[0]=1; SN[1]=6; SN[2]=9;

  for(int i=3;i<10;i+=2)SN[i]=SN[i-2]*6;
  for(int j=4;j<9;j+=2)SN[j]=SN[j-2]*9;
  SN[10]=SN[9]*6; SN[11]=SN[8]*9;

  int n,ans=0;
  cin >> n;

  for(int i=0;i<100010;i++)dp[i]=999999999;
  dp[0]=0;

  for(int i=1;i<n+1;i++){
    for(int j=0;j<12;j++)
      if(i-SN[j]>=0 && dp[i-SN[j]] + 1 < dp[i])dp[i]=dp[i-SN[j]]+1;
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 768
k = int(input())

ans = list(range(1, 10))
next_ans = ans

while len(ans)<k:
  temp_ans = []
  
  for a in next_ans:
    a_0 = int(str(a)[-1])
    new_ans = [int(str(a)+str(a_0+i)) for i in [-1,0,1] if 0<=a_0+i<=9]
    temp_ans.extend(new_ans)
  
  ans.extend(temp_ans)
  next_ans = temp_ans
  
  
print(ans[k-1])

Measured memory_bytes: 12376
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
const ll INF = 1e18L+7;
 
int main(){
int n,w;
cin>>n>>w;
vector<int> weight(n) , value(n);
 
for(int i=0;i<n;i++){
	cin>>weight[i]>>value[i];
}
 
ll sum=0;
for(auto aa:value){
	sum+=aa;
}
 
vector<ll> dp(sum+1,INF);
 
dp[0]=0;
 
for(ll i=0;i<n;i++){
 
    for(ll val_already = sum - value[i] ; val_already>=0 ; val_already--){
 
         if( dp[val_already]!=INF){
         	dp[val_already + value[i]] = min( dp[val_already + value[i]] , dp[val_already] + weight[i] );
         }
 
    }
}
 
ll ans=0;
 
for(ll i=sum ;i>=0;i--){
	if(dp[i]<=w){
		ans=i;break;
	}
}
 
 
cout<<ans;
 
}

Measured memory_bytes: 1024
function main()
    N = pread(Int)
    a = readvec(Int, N)
    s = 0
    for i in 2:N
        if a[i-1] > a[i]
            s += a[i-1]-a[i]
            a[i] = a[i-1]
        end
    end
    println(s)
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


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

char nyuryoku[12][12];

void fun(int y,int x,char masume){
	if((x<0)||(12<=x)||(y<0)||(12<=y)){
		return;
	}
	if(masume!=nyuryoku[y][x])
		return;
	else
		nyuryoku[y][x]='+';
	fun(y+1,x,masume);
	fun(y-1,x,masume);
	fun(y,x+1,masume);
	fun(y,x-1,masume);
}

int main(){
	while(cin >> nyuryoku[0][0]){
		for(int j=1;j<12;j++)
			cin >> nyuryoku[0][j];
		for(int i=1;i<12;i++){
			for(int j=0;j<12;j++){
				cin >> nyuryoku[i][j];
			}
		}
		int count=0;
		for(int i=0;i<12;i++){
			for(int j=0;j<12;j++){
				if(nyuryoku[i][j]!='+'){
					if(nyuryoku[i][j]=='1')
						count++;
					fun(i,j,nyuryoku[i][j]);
				}
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	// #ifndef ONLINE_JUDGE
	// freopen("inputf.in",  "r",   stdin);
	// freopen("outputf.in", "w",  stdout);
	// #endif
	FastIO
	lld n, i;
	cin >> n;
	lld B[n-1];
	lld A[n];
	foi(i,n-1){
		cin >> B[i];
	}
	A[n-1] = B[n-2];
	for(i = n-2; i > 0; i--){
		A[i] = B[i] < B[i-1] ? B[i] : B[i-1];
	}
	A[0] = B[0];
	lld sum = 0;
	foi(i,n){
		sum += A[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
def __main__():
    s = input()
    result = cal(s)
    print(result[0])

# return (下階層の和の合計, 下階層の和のパターン数)
def cal(s):
    if len(s) == 0:
        return(0, 1)
    elif len(s) == 1:
        return (int(s), 1)
    else:
        sum, times = 0, 0
        for i in range(len(s)):
            num = int(s[0:(i + 1)])
            result = cal(s[(i + 1):len(s)])
            sum += num * result[1] + result[0]
            times += result[1]
        return (sum, times)
            
__main__()

Measured memory_bytes: 3064
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

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

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

const int N = 2e5 + 10;
const ll inf = 1e18 + 42;

ll a[N], dp[N][10];

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j < 5; ++j) {
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j < 5; ++j) {
			// cout << i << ' ' << j << ' ' << dp[i][j] << endl;
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
			ll cost = 0;
			if (j == 0 or j == 4) {
				cost += a[i + 1];
			} else if (j == 2) {
				cost += 1 - (a[i + 1] % 2);
			} else {
				cost += (a[i + 1] % 2);
				cost += (!a[i + 1] ? 2 : 0);
			}
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cost);
		}
	}
	cout << dp[n][4] << endl;
}

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


using namespace std;

const int N = 200010;

int noNodes , noMuchii ;
char val[ N ];
int gradA[ N ] , gradB [ N ]  , viz [ N ] ;
vector < int  > allMuc [ N ] ;
queue < int > que ;


int main(){


    scanf("%d%d",&noNodes , &noMuchii);

    scanf("%s",val + 1);

    for ( int i = 0 ; i < noMuchii ; i++ ){
        int x , y ;
        scanf("%d %d",&x,&y);
        allMuc [ x ].push_back( y );
        allMuc [ y ].push_back( x );
        if ( val [ x ] == 'A'){
            gradA [ y ] ++ ;
        }else{
            gradB [ y ] ++ ;
        }
        if ( val [ y ] == 'A'){
            gradA [ x ] ++ ;
        }else{
            gradB [ x ] ++ ;
        }
    }

    for ( int i = 1 ; i <= noNodes ; i++ ){
        if ( !gradA [ i ] || !gradB [ i ] ){
            que.push( i ) ;
            viz [ i ] = 1 ;
        }
    }

    while ( !que.empty() ){
        int crNode = que.front();
        que.pop();

//        if ( crNode == 13 ){
//            printf("ohahalera");
//        }

        for ( int vec : allMuc [ crNode ]){
            if ( viz [ vec ] ){
                continue ;
            }

            if ( val [ crNode ] == 'A'){
                gradA [ vec ]-- ;
            }else{
                gradB [ vec ]-- ;
            }
            if ( !gradA [ vec ] || !gradB [ vec ] ){
                viz [ vec ] = 1 ;
                que.push( vec );
            }

        }

    }

    for ( int i = 1 ; i <= noNodes ; i++ ){
        if ( viz [ i ] == 0 ){
            printf("Yes");
            return 0 ;
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+20;
//题意:n个点的树,给出M个操作,m,n<=1e5.初始每条边权值为0,每次操作(ai,bi) 使ai->bi路径上的边权值+1,问最后每条边权值是否为偶数？
//当根为rt,若只考虑奇偶性,a->b路径上边+1等价于p=lca(a,b):(r->a)+1,(r->b)+1 即(r->p)+2 (a->b)+1 奇偶性不变
//则设f[i] r->i的累加次数.则query中点的出现次数为even时才有解 
int n,m,f[N]; 
int main()
{
	
	while(cin>>n>>m)
	{
		int a,b;
		memset(f,0,sizeof(f));
		for(int i=0;i<m;i++)
		{
			scanf("%d%d",&a,&b);
			f[a]++;
			f[b]++;	
		}
		bool flag=true;
		for(int i=1;i<=n;i++)
		{
			if(f[i]%2)
				flag=false;
		}
		if(flag)
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}

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

int main() {
  int N,L;
  cin >> N >> L;
  vector<string> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int j = 0;j < N;j++) {
    cout << vec.at(j);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//入力
ll n;
vector<ll>a;

int main(){
    cin >> n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    a.push_back(0);
    bool ok = true;
    if(a[0]!=0)ok=false;
    rep(i,n-1){
        if(a[i+1]-a[i]>=2)ok=false;
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    rep(i,n){
        if(a[i+1]!=a[i]+1){
            ans += a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6392
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;



int dp[41][420][420];

int main(){
  int n,ma,mb;
  cin >> n >> ma >> mb;
  REP(i,n+1){
    REP(j,420){
      REP(k,420){
	dp[i][j][k] = INF;
      }
    }
  }
  int ta,tb,tc;
  cin >> ta >> tb >> tc;
  dp[1][0][0] = 0;
  dp[1][ta][tb] = tc;
  
  rep(i,1,n){
    int a,b,c;
    cin >> a >> b >> c;
    
    REP(j,401){
      REP(k,401){
	if(dp[i][j][k] != INF){
	  dp[i+1][j+a][k+b] = min(dp[i+1][j+a][k+b],dp[i][j][k] + c);
	  dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
	}
      }
    }
  }
  int y = 1;
  int cost = INF;
  while(ma*y < 401 && mb*y < 401){

    if(dp[n][ma*y][mb*y] != INF){
      cost = min(cost,dp[n][ma*y][mb*y]);
    }
    y++;
  }
  if(cost != INF)
    cout << cost << endl;
  else
    cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 28544
n = int(input())
a = list(map(int, input().split()))

mp = {}
for i, ai in enumerate(a):
    df = ai - (i + 1)
    if df in mp:
        mp[df] += 1
    else:
        mp.update({df: 1})
ans = 0
for i, ai in enumerate(a):
    s = -(ai + i + 1)
    if s in mp:
        ans += mp[s]

print(ans)


Measured memory_bytes: 40580
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll D, G;
  cin >> D >> G;
  G /= 100;

  ll max_p = 300000;
  vll dp(max_p, INF);
  dp[0] = 0;
  rep(i, D + 1) {
    if (i == 0) continue;
    ll p, c;
    cin >> p >> c;
    c /= 100;

    vll next = dp;
    rep(j, p + 1) {
      if (p == 0) continue;
      rep(k, max_p) {
        ll ni = k + i * j;
        if (ni >= max_p) continue;
        if (j == p) ni += c;
        next[ni] = min(next[ni], dp[k] + j);
      }
    }
    dp = next;
  }

  ll ans = INF;
  rep2(i, G, max_p) {
    ans = min(ans, dp[i]);
  }
  ANS;

  return 0;
}

Measured memory_bytes: 8044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int N;
    cin >> N;
    vi L;
    L.resize(2 * N);
    REP(i, 2 * N)
    cin >> L[i];

    sort(ALL(L));

    int ans = 0;
    REP(i, N)
    ans += min(L[2 * i], L[2 * i + 1]);

    cout << ans << endl;
    //system("pause");
}

Measured memory_bytes: 256
from bisect import bisect_left
from bisect import bisect_right

n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)

ans = 0
visited = [False]*n

while a:
    s = a.pop()
    if visited.pop():
        continue
    m = 1
    while m <= s:
        m *= 2
    r = bisect_right(a, m-s)
    l = bisect_left(a, m-s)
    for x in range(l, r)[::-1]:
        if not visited[x]:
            visited[x] = True
            ans += 1
            break

print(ans)


Measured memory_bytes: 94544
#include<stdio.h>
int gcd(int a,int b){
  if(a==0)
    return b;
  else if(b==0)
    return a;
  int i;
  while(a!=0 && b!=0){
    i=b;
    b=a%b;
    a=i;
  }
  return a;
}
int main(){
  int n,i;
  scanf("%d",&n);
  int a[n+2];
  a[0]=0;
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
    a[i]=gcd(a[i-1],a[i]);
  }
  printf("%d\n",a[n]);
  return 0;
}


Measured memory_bytes: 512
S = input()

ret = 1
pre = S[0]
flag = True
i = 1
while i < len(S) :
    if flag and S[i] == pre :
        if i == len(S) - 1 :
            break
        flag = False
        i += 2
    else :
        flag = True
        pre = S[i]
        i += 1
    ret += 1
    
print(ret)

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

int main() {
  ll l, r;
  cin >> l >> r;
  ll ans = 2018LL * 2018LL;
  for (ll i = 0; i < min(2019LL, r - l); i++) {
    ll in = (l + i) % 2019;
    for (ll j = 1; j < min(2019LL, r - l) - i + 1; j++) {
      ll jn = (in + j) % 2019;
      ll calc = in * jn % 2019;
      ans = min(ans, calc);
    }
  }

  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  int ans = 0;
  int last;
  for(int i = 1; ans < n; i++){
    ans += i;
    last = i;
  }
  
  int r = ans - n;
  for(int i = 1; i <= last; i++){
    if(i == r) continue;
    cout << i << endl;
  }
}

Measured memory_bytes: 256
def solve(h, n, a_list):
    if sum(a_list) >= h:
        return "Yes"
    else:
        return "No"


def main():
    h, n = map(int, input().split())
    a_list = list(map(int, input().split()))
    res = solve(h, n, a_list)
    print(res)


def test():
    assert solve(10, 3, [4, 5, 6]) == "Yes"
    assert solve(20, 3, [4, 5, 6]) == "No"
    assert solve(210, 5, [31, 41, 59, 26, 53]) == "Yes"
    assert solve(211, 5, [31, 41, 59, 26, 53]) == "No"


if __name__ == "__main__":
    test()
    main()


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

bool check(int n, vector <int> array1 , vector <int> array2){
    int check = 0;
    for(int i = 0; i < n ; i++){
        if(array1[i]!= array2[i]) check = 1;
    } 
    if(check == 1) return false;
    else return true;
}



int main(){
    int n;
    cin >> n;
    vector <int> p(n);
    vector <int> q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    int ans = 0;
    vector <int> s(n);
    rep(i,n){
        s[i] = i+1;
    }
    int g = 1;
    int h = 0;
    int j = 0;
    //next_permutation
    do{
        for(int i = 0; i < n; i++){
            if(check(n, p ,s)) h = g;
            if(check(n, q, s)) j = g;
            
        }
        g++;
    }while(next_permutation(s.begin(), s.end()));
    ans = h - j;
    if(ans < 0) ans *= (-1);
    cout << ans << endl;
    return 0;
}

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

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N;
    while((scanf("%d",&N),N)){
        vector<int> imos(101010);
        rep(i,N){
            int a,b,c;
            scanf("%d:%d:%d",&a,&b,&c);
            imos[a*3600+b*60+c]++;
            scanf("%d:%d:%d",&a,&b,&c);
            imos[a*3600+b*60+c]--;
        }
        rep(i,101001)imos[i+1]+=imos[i];
        printf("%d\n",*max_element(imos.begin(),imos.end()));
    }
}

int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 3604
import numpy as np

S = int(input())
count = 0

dim = len(str(S))

box = np.zeros(([4]*dim),dtype='int64')

for j in range(dim):
    for i in range(4):
        I = [slice(None)]*box.ndim
        I[j] = i
        if i == 0:
            None
        else:
            box[tuple(I)]+= (i*2+1)*10**j

box = box.reshape(4**dim)

for i in np.sort(box).tolist():
    ss = [int(x) for x in list(str(i))]

    if i > S:
        break

    if list(set(ss)) == [3, 5, 7]:

        count = count + 1
print(count)

Measured memory_bytes: 26704
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
int main()
{
    ll n,m,ans=0;cin>>n>>m;
    priority_queue<double>pq;
    while(n--){
        int x;cin>>x;
        pq.push(x);
    }
    while(m--){
        int nw=pq.top();
        nw/=2.0;
        pq.pop();
        pq.push(nw);
    }
    while(!pq.empty()){ans+=(ll)pq.top();pq.pop();}
        cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<class V> struct BIT {
    BIT() {}  // [L, R)
    int NV;vector<V> bit;
    BIT(int n){ init(n); }
    void init(int n) { NV = 1; while (NV < n)NV *= 2; bit.resize(NV); clear(); }
    V operator[](int e) { V s = 0; e++; while (e) s += bit[e - 1], e -= e&-e; return s; }
    void add(int e, V v) { e++; while (e <= NV) bit[e - 1] += v, e += e&-e; }
    int lower_bound(V val) { 
        V tv = 0; int i, ent = 0; for (i = NV - 1; i >= 0; i--)
        if(tv+bit[ent+(1<<i)-1]<=val)tv+=bit[ent+(1<<i)-1],ent += (1 << i);return ent;
    }
    V get(int L, int R) {
        assert(0 <= L); assert(R <= NV); assert(L <= R);
        V res = 0; if(R) res += operator[](R - 1); if (L) res -= operator[](L - 1);return res;
    }
    void clear() { rep(i, 0, NV) bit[i] = 0; }
	void update(int e, V v) { add(e, v - get(e, e + 1)); }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, V, P, A[101010];
BIT<ll> bit(101010);
//---------------------------------------------------------------------------------------------------
bool check(int i) {
	int bigger = 0, less = 0;
	ll other = 0;
	rep(j, 0, N) if (j != i) {
		if (A[i] + M < A[j]) bigger++;
		else if (A[j] <= A[i]) less++;
		else other++;
	}

	if (P <= bigger) return false;
	
	ll rest = V - 1 - bigger - less;
	if (rest <= 0) return true;

	ll tot = 0;
	ll cnt = 0;
	rep(j, 0, N) if (A[i] < A[j] and A[j] <= A[i] + M) {
		tot += A[i] + M - A[j];
		
		cnt++;
		ll ok = min({ tot / M, other, rest });
		ll ng = rest - ok;
		if (bigger + ng < P and cnt + ng <= other) {
			return true;
		}
	}

	return false;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> V >> P;
	rep(i, 0, N) cin >> A[i];
	sort(A, A + N);

	int ng = -1, ok = N;
	while (ng + 1 != ok) {
		int md = (ng + ok) / 2;
		if (check(md)) ok = md;
		else ng = md;
	}

	int ans = N - ok;
	cout << ans << endl;
}







Measured memory_bytes: 1664
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

s, ans = 0, 0
(1...N).to_a.reverse.each{|i|
  s = (s + A[i]) % MOD
  ans = (ans + s * A[i-1]) % MOD
}

puts ans


Measured memory_bytes: 33552
#include <iostream>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>

using namespace std;

int main(){

	string in;
	string end("0");
	int sum;

	while (1){
		getline(cin, in);
		if (in == end) break;

		sum = 0;
		for (int i = 0; i < in.size(); i++){
			sum += in[i] - 48;
		}

		cout << sum << endl;
	}


	return 0;
}

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

int main()
{
  string str;
  int ans=0;
  cin >> str;
  
  if( str.size() == 1)	cout << "0" << endl;
  else{
    for(int i=1;i<str.size();i++){
      if(str[i-1] == str[i]){
      	if(str[i]=='0')	str[i] = '1';
        else			str[i] = '0';
        ans++;
      }
    }
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 200005
#define lg 18
//<<fixed << setprecision(9)
ll bit[space];

void update(int x,ll v)
{
    for(int i=x;i<space;i+=(i&(-i)))
    {
        bit[i]=max(bit[i],v);
    }
}

ll query(int x)
{
    ll ans=0;
    for(int i=x;i>0;i-=(i&(-i)))
    {
        ans=max(ans,bit[i]);
    }
    return ans;
}

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int ht[n],bea[n];
    rep(i,0,n)
    {
        cin>>ht[i];
    }
    rep(i,0,n)cin>>bea[i];

    ll ans=0,lst;
    rep(i,0,n)
    {
        lst=query(ht[i]-1);
        lst+=bea[i];
        ans=max(ans,lst);
        update(ht[i],lst);
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3328
N = int(input())
A = list(map(str, input().split()))

import collections as cl
c_A = cl.Counter(A)
sum_c_A=0
for i in c_A.keys():
	if c_A[i]>1:
		sum_c_A += c_A[i]*(c_A[i]-1)/2

for j in A:
	print(int(sum_c_A-c_A[j]+1))

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 4000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,k;cin>>n>>k;
  if (k==1) {
    cout << 1 << endl;
    return 0;
  }

  vi x(n),y(n);
  vi unzipx(n),unzipy(n);
  rep(i, n){
    cin>>x[i]>>y[i];
    unzipx[i]=x[i]; unzipy[i]=y[i];
  }

  uni(unzipx); uni(unzipy);
  int h, w; h = sz(unzipx); w = sz(unzipy);

  int res = INF;
  rep(i, h){
    rep(j, h){
      rep(s, w){
        rep(t, w){
          if (i>=j or s>=t) continue;
          int area = 1;
          area *= (unzipx[j] - unzipx[i]);
          area *= (unzipy[t] - unzipy[s]);
          int cnt = 0;
          rep(idx, n){
            if (unzipx[i]<=x[idx] and x[idx]<=unzipx[j]) {
              if (unzipy[s]<=y[idx] and y[idx]<=unzipy[t]) {
                cnt++;
              }
            }
          }
          if (cnt>=k) chmin(res, area);
        }
      }
    }
  }
  cout << res << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, k;
  cin >> n >> k;
  // ll n, m, k;
  // cin >> n >> m >> k;
  for(ll i = k; i <= n + 1; i++) {
    ll buttom = i * (i - 1) / 2;
    ll top = i * (2 * n - i + 1) / 2;
    // printf("%lld %lld\n", buttom, top);
    (ans += (top - buttom + 1)) %= MOD;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main() {
int s;
cin>>s;
int a,b;
b=s%100;
a=s/100;
if(a>=1&&a<=12)
{
    if(b>=1&&b<=12)
    {
        cout<<"AMBIGUOUS";

    }
    else
    {
        cout<<"MMYY";
    }
}
else
{
if(b>=1&&b<=12)
 cout<<"YYMM";
 else
 cout<<"NA";
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i,n) rep2(i,0,n)
using namespace std;
using ll = long long;
class UnionFind{
    int l_, cnt_, *parent_, *rank_;
public:
    UnionFind(int l):l_(l),cnt_(l){ parent_=new int[l]; rep(i,l)parent_[i]=-1; rank_=new int[l]; rep(i,l)rank_[i]=0; }
    ~UnionFind(){ delete[] parent_; delete[] rank_; }
    int root(int x){ return (parent_[x]<0)?x:(parent_[x]=root(parent_[x])); }
    void unite(int x,int y){ int rx=root(x),ry=root(y); if(rx!=ry){ --cnt_;
        if(rank_[rx]>rank_[ry]){ parent_[rx]+=parent_[ry]; parent_[ry]=rx; }
        else{ if(rank_[rx]==rank_[ry])++rank_[ry]; parent_[ry]+=parent_[rx]; parent_[rx]=ry; }}}
    bool isSameTree(int x,int y){ return root(x)==root(y); }
    int sizeOf(int x){ return -parent_[root(x)]; }
    int count_component(){ return cnt_; }
};
int main(){
    int n,m,lack_edge;
    cin >> n >> m;
    lack_edge=n-1-m;
    if(lack_edge==0){
        cout << 0 << endl;
        return 0;
    }
    if(n<2*lack_edge){
        cout << "Impossible" << endl;
        return 0;
    }
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    UnionFind uf(n);
    rep(i,m){
        int x,y;
        cin >> x >> y;
        uf.unite(x,y);
    }
    vector<vector<pair<int,int>>> connected_components(n);
    rep(i,n)connected_components[uf.root(i)].push_back({a[i],i});
    rep(i,n)sort(connected_components[i].begin(),connected_components[i].end());
    ll ans=0;
    vector<int> rest;
    rep(i,n){
        for(auto itr=connected_components[i].begin();itr!=connected_components[i].end();++itr){
            if(itr==connected_components[i].begin())ans+=(*itr).first;
            else rest.push_back((*itr).first);
        }
    }
    sort(rest.begin(),rest.end());
    rep(i,2*lack_edge-(n-m))ans+=rest[i];
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> x(n), y(n), h(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            ll H = 0;
            for (int i = 0; i < n; i++) {
                if (h[i] == 0) continue;
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
            }

            if (H == 0) continue;

            bool f = true;
            for (int i = 0; i < n; i++) {
                ll th = max(H - (abs(x[i] - cx) + abs(y[i] - cy)), 0LL);
                if (th != h[i]) {
                    f = false;
                    break;
                }
            }
            if (!f) continue;
            cout << cx << " " << cy << " " << H << endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    a.at(0) = 1;
    for (int i = 1; i < n; i++) {
        a.at(i) = a.at(i - 1) + n;
    }
    b.at(n - 1) = 1;
    for (int i = n - 2; i >= 0; i--) {
        b.at(i) = b.at(i + 1) + n;
    }
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        p--;
        a.at(p) += i;
    }

    for (int i = 0; i < n; i++) {
        printf("%d ", a.at(i));
    }
    cout << endl;
    for (int i = 0; i < n; i++) {
        printf("%d ", b.at(i));
    }
    cout << endl;
}

Measured memory_bytes: 768
n, a, b = map(int, input().split(' '))
total = 0

for i in range(1, n+1):
    letter_list = []
    for letter in str(i):
        letter_list.append(letter)
    num_list = list(map(int, letter_list))

    if a <= sum(num_list) <= b:
        total += i

print(total)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAX = 1e15 + 10ll;
ll h;
vector<ll> pw;
int main() {
	ll p = 1;
	while(p < MAX) {
		pw.emplace_back(p);
		p *= 2;
	}
	cin>>h;
	auto it = upper_bound(pw.begin(), pw.end(), h);
	int idx = it - pw.begin();
	ll ans = pw[idx] - 1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 1000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ans = min(b/a,c);
    cout << ans << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;
vector<int> G[N];
bool vis[N];
int f[N];
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 0, u, v; i < m; i++) {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    queue<int> qu;
    qu.push(1), vis[1] = true;
    while(!qu.empty()) {
        int u = qu.front();
        qu.pop();
        for(auto v : G[u]) {
            if(vis[v]) continue;
            f[v] = u;
            qu.push(v), vis[v] = true;
        }
    }
    bool flag = false;
    for(int i = 1; i <= n; i++) {
        if(!vis[i]) flag = true;
    }
    if(flag) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    for(int i = 2; i <= n; i++) {
        printf("%d\n", f[i]);
    }
    return 0;
}

Measured memory_bytes: 10628
import java.util.Scanner;
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int i = 0;
        Scanner sc = new Scanner(System.in);
        while (true) {
            int x = sc.nextInt();
            String op = sc.next();
            int y = sc.nextInt();
            if (op.equals("+")) {
                System.out.println((x + y));
            } else if (op.equals("-")) {
                System.out.println((x - y));
            } else if (op.equals("*")) {
                System.out.println((x * y));
            } else if (op.equals("/")) {
                System.out.println((x / y));
            } else {
                break;
            }
        }
    }
}


Measured memory_bytes: 26200