akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b)
{
    for (;;)
    {
        if (a == 0) return b;
        b %= a;
        if (b == 0) return a;
        a %= b;
    }
}

long long lcm(long long a, long long b)
{
    long long temp = gcd(a, b);

    return temp ? (a / temp * b) : 0;
}

int get_zeroes(int n) {
    int zeroes = 0;
    for (int i = 1; i <= n; i++) {
        int x = i;
        while (x) {
            int d = x % 10;
            if (d == 0) zeroes++;
            else break;
            x /= 10;
        }
    }
    return zeroes;
}


int main() {
    long long n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    long long div = 10;
    while (n / div > 0) {
        ans += n / div;
        div *= 5;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    if(s[0] != 'A' || not ('a' <= s[1] && s[1] <= 'z')){
        cout << "WA" << endl;
        return 0;
    }

    bool ans = true;
    int c = 0;
    for(int i = 2; i < (int)s.length(); i++){
        if(s[i] == 'C' && i != (int)s.length() - 1){
            c++;
            continue;
        }
        if('A' <= s[i] && s[i] <= 'Z'){
            ans = false;
        }
    }

    if(c == 1 && ans){
        cout << "AC" << endl;
        return 0;
    }
    cout << "WA" << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, m = 1e9, t = 0; lint a = 0; bool b = 0;
  scanf("%d", &n);
  v1i v(n);
  rep(i, n) scanf("%d", &v[i]);
  rep(i, n){
    if(v[i] < 0){
      ++t;
      v[i] *= -1;
    }
    a += v[i];
    m = min(m, v[i]);
  }
  if(!b && t & 1) a -= 2 * m;
  printf("%ld\n", a);
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> c(n);
    for (int i = 1; i < n; ++i) {
        c[n - 1 - i] = max(c[n - i], a[n - i]);
    }
    int ans = 1;
    int m = -inf;
    for (int i = 0; i < n; ++i) {
        int diff = c[i] - a[i];
        if (diff == m)
            ++ans;
        else if (diff > m) {
            ans = 1;
            m = diff;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
ll dp[101][100001];

int main(int argc, char const* argv[])
{
  int n, W;
  cin >> n >> W;
  vector<int> w(n);
  vector<ll> v(n);
  rep(i, n)cin >> w[i] >> v[i];
  rep(i, n){
    rep(j, W+1){
      dp[i+1][j] = dp[i][j];
      if(j-w[i]>=0)dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
    }
  }
  cout << dp[n][W] << endl;
	return 0;
}


Measured memory_bytes: 78336
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
string s;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	if (s == "ABC")puts("ARC");
	else puts("ABC");
	ggr
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
	
	    ll n, i, A[100000], num=1e18, flag=0;
	    cin>>n;
	    for(i=0; i<n; i++)
	    cin>>A[i];
	    ll s=1;
	    for(i=0; i<n; i++)
	    {
	        if(A[i]==0)
	        flag=1;
	    }
	    if(flag==1)
	    cout<<0;
	    else
	    {
	    for(i=0; i<n; i++)
	    {
	        if((num/s)/A[i]==0)
	        {
	            s=-1;
	            break;
	        }
	        s*=A[i];
	        
	    }
	    cout<<s;
	    }
	return 0;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005],b[3]= {2,3,5};
void dfs(ll x,int w) {
	if(w==3) {
		a[++a[0]]=x;
		return ;
	}
	while(x<=1000000000000000000ll) {
		dfs(x,w+1);
		x*=b[w];
	}
}
unordered_map<ll,ll> f;
ll n,A,B,C,D;
ll dp(ll x) {
	if(f.count(x))return f[x];
	if(x<=0)return 5e18;
	ll ret=5e18;
	if(x>=2e9) {
		for(ll i=x-1; i<=x+1; i++) {
			if(i%2)continue;
			ret=min(ret,dp(i/2)+abs(x-i)*D+A);
		}
		for(ll i=x-2; i<=x+2; i++) {
			if(i%3)continue;
			ret=min(ret,dp(i/3)+abs(x-i)*D+B);
		}
		for(ll i=x-4; i<=x+4; i++) {
			if(i%5)continue;
			ret=min(ret,dp(i/5)+abs(x-i)*D+C);
		}
		return f[x]=ret;
	}
	for(int i=x-1; i<=x+1; i++) {
		if(i%2)continue;
		ret=min(ret,dp(i/2)+abs(x-i)*D+min(i/2*D,A));
	}
	for(int i=x-2; i<=x+2; i++) {
		if(i%3)continue;
		ret=min(ret,dp(i/3)+abs(x-i)*D+min(i/3*2*D,B));
	}
	for(int i=x-4; i<=x+4; i++) {
		if(i%5)continue;
		ret=min(ret,dp(i/5)+abs(x-i)*D+min(i/5*4*D,C));
	}
	return f[x]=ret;
}
int main() {
	dfs(1,0);
	sort(a+1,a+a[0]+1);
	int T;
	cin>>T;
	while(T--) {
		cin>>n>>A>>B>>C>>D;
		f.clear(),f[1]=D;
		cout<<dp(n)<<endl;
		/*unordered_map<ll,ll> f;
		f[1]=D;
		for(int i=2;i<=a[0];i++){
			if(a[i]%2==0)f[a[i]]=(f[a[i]]==0?f[a[i]/2]+A:min(f[a[i]],f[a[i]/2]+A));
			if(a[i]%3==0)f[a[i]]=(f[a[i]]==0?f[a[i]/3]+A:min(f[a[i]],f[a[i]/3]+B));
			if(a[i]%5==0)f[a[i]]=(f[a[i]]==0?f[a[i]/5]+A:min(f[a[i]],f[a[i]/5]+C));
			for(int j=i-1;j>=0&&a[i]-a[j]<=1e9;j--)f[a[i]]=min(f[a[i]],f[a[j]]+(a[i]-a[j])*D);
		}
		for(int i=1;i<=a[0];i++){
			f[n]=(f[n]==0?f[a[i]]+D*:min(f[a[i]],f[a[i]/2]+A));
		}
		cout<<f[n];*/
	}
}


Measured memory_bytes: 4244
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define RPT(n) for (int i = 0; i < n; i++)
#define MOD (1000000007)

const vector<int> pn = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

map<int, int> PrimeFactorization(int N)
{
    map<int, int> ret = {};
    if (N < 2) return ret;

    int cur = N;
    for (auto it = pn.begin(); it != pn.end(); it++) {
        if ((*it)*(*it) > N) break;
        while (cur % (*it) == 0) {
            cur = cur / (*it);
            ret[*it]++;
        }
    }
    if (cur > 1) ret[cur]++;

    return ret;
}

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

    map<int, int> cur_pf;
    RPT(N) {
        map<int, int> tmp_pf = PrimeFactorization(i+1);
        for (auto it = tmp_pf.begin(); it != tmp_pf.end(); it++) {
            cur_pf[it->first] += it->second;
        }
    }

    long long output = 1;
    for (auto it = cur_pf.begin(); it != cur_pf.end(); it++) {
        output *= (it->second + 1); 
        output %= MOD;
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int r=0,m=0;
	for(int i=0;i<5;i++){
		int a;
		cin>>a;
		int b=(a+9)/10*10;
		r+=b;
		m=max(m,b-a);
	}
	cout<<r-m<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,c;
  char op;
  
  while(1){
    scanf("%d %c %d", &a,&op,&b);
    if(op=='?'){
      break;
    }   
    if(op=='+'){
      c=a+b;
      printf("%d\n",c);
    }
    if(op=='-'){
      c=a-b;
      printf("%d\n",c);
    }
    if(op=='*'){
      c=a*b;
      printf("%d\n",c);
    }
    if(op=='/'){
      c=a/b;
      printf("%d\n",c);
    }
  }
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    string s;
    cin >> s;
    map<char,bool> mm;
    for(auto c:s){
        mm[c]=true;
    }

    if((mm['E']&&!mm['W'])||(mm['W']&&!mm['E'])||(mm['N']&&!mm['S'])||(mm['S']&&!mm['N'])) {
        out("No");
    } else {
        out("Yes");
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <ostream>
#include <queue>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cstring>

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



inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

int main() {
  init();

  int A, B, C, ans = 0;

  cin >> A >> B >> C;

  if (A == B && B == C) {
    cout << 0 << endl;
    return 0;
  }

  int max = std::max({ A, B, C });

  int dif = abs(max - A) + abs(max - B) + abs(max - C);

  if (dif % 2 == 0) {
    cout << dif / 2 << endl;
  }
  else {
    cout << dif / 2 + 2 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] s = new int[n][2];
        for (int i = 0; i < n; i++) {
            s[i][0] = i;
            s[i][1] = sc.nextInt();
        }
        Arrays.sort(s, Comparator.comparingInt(s1 -> s1[1]));
        StringJoiner sj = new StringJoiner(" ");
        for (int i = 0; i < n; i++) {
            sj.add(String.valueOf(s[i][0] + 1));
        }
        System.out.println(sj.toString());
    }

}



Measured memory_bytes: 64156
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

int main() {
	int N;
	string s, t;
	cin >> N >> s >> t;
	
	string ans = s + t;
	REP(i, N) {
		if (s.substr(i) == t.substr(0, N - i)) {
			ans = s + t.substr(N - i);
			break;
		}
	}

	cout << ans.length() << endl;
	return 0;
}

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

using namespace std;

int main(void){
	int n, a, b;
	cin >> n >> a >> b;

	int cnt[3] = {0};
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		if(p <= a){
			cnt[0]++;
		}
		if(a < p && p <= b){
			cnt[1]++;
		}
		if(b < p){
			cnt[2]++;
		}
	}

	cout << min(cnt[0], min(cnt[1], cnt[2])) << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,w; cin >>n>>w;
    vector<ll> c(n); vector<ll> v(n);
    REP(i,n) cin >> c[i] >> v[i];

    vector<vector<ll> > dp(n+1, vector<ll>(100100, INFLL));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 100100; j++) {
            dp[i+1][j] = dp[i][j];
            if (j-v[i] >= 0) {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]]+c[i]);
            } 
        }
    }

    int ans = 0;
    for (int j = 0; j < 100100; j++) {
        if(dp[n][j] <= w){
            ans = j;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI       3.1415926535897932384626433832795028841971
#define INF 1000000000
#define EPS      1e-10
#define MOD      1000003
using namespace std;
typedef long long ll;
typedef pair<double,double> P;
typedef pair<double,P> PQ;

struct edge{
    int dis;
    int from;
    int to;
    bool operator<(const edge& right) const{
        return dis < right.dis;
    }
};

int n, m;
ll x[50000];
int to[50000];
vector<edge> e;

void func(int st, int en){
    ll y = 1;
    int now = st;
    while(now != (en+1)%n){
        y = y*x[now]%MOD;
        now = (to[now]+1)%n;
    }
    now = (st+1)%n;
    ll yy = 1;
    while(now != en){
        yy = yy*x[now]%MOD;
        now = (to[now]+1)%n;
    }
    y = (y+yy)%MOD;
    
    x[st] = y;
    to[st] = en;
}

ll calc(int st, int en){
    ll ret = 1;
    int now = st;
    while(now != (en+1)%n){
        ret = ret*x[now]%MOD;
        now = (to[now]+1)%n;
    }
    return ret;
}

int main(){
    while(cin >> n >> m){
        if(n == 0 && m == 0) break;
        e.clear();
        rep(i,n) to[i] = (i+1)%n;
        rep(i,n) x[i] = 1;
        
        rep(i,m){
            int a, b;
            cin >> a >> b;
            a--; b--;
            if(a > b) swap(a,b);
            if((b-a)%2==0) continue;
            edge tmp;
            if(b-a <= a+n-b){
                tmp.dis = b-a;
                tmp.from = a;
                tmp.to = b;
            } else{
                tmp.dis = a+n-b;
                tmp.from = b;
                tmp.to = a;
            }
            e.push_back(tmp);
        }
       if(n&1){
            cout << 0 << endl;
            continue;
        }
        if(e.size() == 0){
            cout << 2 << endl;
            continue;
        }
       
        sort(e.begin(),e.end());
        
        for(int i = 0; i < e.size()-1; i++){
            edge ee = e[i];
            func(ee.from,ee.to);
        }
        ll ans = 0;
        edge ee = e[e.size()-1];
        ll p1 = calc(ee.from,ee.to);
        ll p2 = calc((ee.to+1)%n,(ee.from-1+n)%n);
        ll p3 = calc(ee.to,ee.from);
        ll p4 = calc((ee.from+1)%n,(ee.to-1+n)%n);
        ans = (ans+p1*p2)%MOD;
        ans = (ans+p3*p4)%MOD;
        ans = (ans+p2*p4)%MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4028
n,k = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
ax = sorted(a)
ans = 10**19
for i in range(n-1):
    for j in range(i+1,n):
        a_use = ax[i:j+1]
        xnum = len(a_use)
        sx = a_use[-1][0]-a_use[0][0]
        a_use.sort(key = lambda x:x[1])
        if xnum<k:
            continue
        for y1 in range(xnum-k+1):
            y2 = y1+k-1
            s = sx*(a_use[y2][1]-a_use[y1][1])
            ans = min(ans,s)
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
using namespace std;

struct Team{
	char name;
	int win, lose;
	bool operator < (const Team &a) const{
		return (win == a.win) ? lose < a.lose : win > a.win;
	}
};

int main(){
	int N, R;
	while(cin >> N, N){
		Team t[10] = {};
		for(int i = 0; i < N; i++){
			cin >> t[i].name;
			for(int j = 0; j < N-1; j++){
				cin >> R;
				if(R == 0) t[i].win++;
				if(R == 1) t[i].lose++;
			}
		}

		sort(t, t + N);

		for(int i = 0; i < N; i++){
			printf("%c\n", t[i].name);
		}
	}
	return 0;
}

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

int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	int now;
	cin >> now;
	long long ans = 0;
	for (int i = 1; i < N; i++) {
		int next;
		cin >> next;
		ans += min(A * (next - now), B);
		now = next;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int n;

int main()
{

  cin >> n;

  cout << (1000-n%1000)%1000 << endl;
  return 0;
}


Measured memory_bytes: 3620
import sys
from collections import deque

read = sys.stdin.readline

H, W = map(int, input().split())
S = [list('#' * (W + 2))] + [['#'] + list(read().rstrip()) + ['#'] for _ in range(H)] + [list('#' * (W + 2))]


def bfs(grid, start):
    distance = [[-1] * (W + 2) for _ in range(H + 2)]
    queue = deque([start])
    distance[start[0]][start[1]] = 0
    while queue:
        x, y = queue.popleft()

        for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            new_y, new_x = y + j, x + i
            if grid[new_x][new_y] == '.' and distance[new_x][new_y] == -1:
                distance[new_x][new_y] = distance[x][y] + 1
                queue.append((new_x, new_y))
        if not queue:
            return distance[x][y]


answer = 0
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == '#':
            continue

        cnt = 0
        for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            new_y, new_x = dy + j, dx + i
            if S[new_x][new_y] == '.':
                cnt += 1

        if cnt > 2:
            continue

        tmp = bfs(S, (i, j))
        if tmp > answer:
            answer = tmp

print(answer)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long
typedef pair<ll , ll > pii;
ll mod=998244353;
ll p=1e9+7;
const double PI = 3.14159265358979323846;
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double a,b,h,m;
    cin>>a>>b>>h>>m;
    long double t=60.0*h+m;
    long double x1=2.0*PI*(t/(12.0*60.0));
    long double x2=2.0*PI*(m/60.0);
    long double x=abs(x2-x1);
    long double ans=sqrt(a*a+b*b-2*a*b*cos(x));
    cout<<fixed<<setprecision(12)<<ans;
    
    return 0;
}
 

Measured memory_bytes: 4184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//long a = Long.parseLong(sc.next());
		String t = sc.next();
		String buff="";
		//long b = Long.parseLong(sc.next());
		//int c = Integer.parseInt(sc.next());
		//int n = Integer.parseInt(sc.next());
		//long res=n;
		//int l = Integer.parseInt(sc.next());
		//int sum=0;
		//String s = sc.next();
		//String t = sc.next();
		//String b = sc.next();
		//int a = Integer.parseInt(sc.next());
		//String t = sc.next();

		/*if(t.equals("+")) {//a、e、i、o、u
			System.out.println(a+b);
		}else {
			System.out.println(a-b);
		}*/
		for(int i=0;i<t.length();i++) {
			if(t.substring(i,i+1).equals(",")) {
				buff+=" ";
			}else {
				buff+=t.substring(i, i+1);
			}
		}
		System.out.println(buff);
	}
}




Measured memory_bytes: 23636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] a) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = "";
        StringTokenizer st;
        int add = 0;
        while ((str = br.readLine()) != null) {
            st = new StringTokenizer(str, " ");
            add = Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken());
            int keta = Integer.toString(add).length();
	    System.out.println(keta);
        }
    }
}

Measured memory_bytes: 24300
S = list(map(int,input()))[::-1] #逆順

counter = 0
amari = [0]*2019
amari[0] = 1

s,d = 0,1

for i in S:
    s += i *d
    amari[s%2019] += 1
    d *= 10
    d %= 2019


for i in range(2019):
    counter += amari[i] * (amari[i]-1) / 2


print(int(counter))

Measured memory_bytes: 12024
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_V = 100005;
int N, K,X,Y;
int main(void) {
	cin >> N >> K >> X >> Y;
	if (N > K)ct(K*X + (N - K)*Y);
	else ct(N*X);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll binomial(ll a){
    
    if(a==1){
        return 0;
    }
    else{
        return (a*(a-1))/2;
    }
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,i,j,count=1,sum=0;
	cin>>n;
	string s[n];
	for(i=0;i<n;i++){
	    cin>>s[i];
	    sort(s[i].begin(),s[i].end());
	}
	sort(s,s+n);
	for(j=1;j<n;j++){
	  if(s[j]==s[j-1]){
	      count++;
	  }  
	  else{
	      sum+=binomial(count);
	      count=1;
	  }
	}
	sum+=binomial(count);
	cout<<sum;
	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
long long n,k;
long long w[109],v[109];
long long dp[109][100009];
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	for(int i=0;i<n;i++){
		for(int j=1;j<100009;j++){
			dp[i][j] = 1000000000000009;
		}
	}
	dp[0][v[0]] = w[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<100009;j++){
			if(j-v[i] >= 0) dp[i][j] =  min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	for(int i=100001;i>=0;i--){
		if(dp[n-1][i] <= k){
			cout<<i<<endl;
			exit(0);
		}
	}
}


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

#define N (1<<17)
#define ll long long
#define ld long double
#define M 1000000007
#define INF 0x5ADFACE5
#define LINF 0x51DEEFFEC7C0DECALL
#define pii pair<ll, ll>
#define pll pair<long long, long long>
#define F first
#define S second

using namespace std;

int n;
vector<ll> v[101];

ll dfs (int i, int m) {
	if (i == n + 1) return 0;
	if (i >= m) return v[i].back() + dfs(i + 1, m);
	if (v[i].back() >= 0) return v[i].back() + dfs(i + 1, m);
	ll pri = 0;
	for (int j = i; j <= n; j += i) {
		v[j].push_back(0);
	}
	pri = dfs(i + 1, m);
	for (int j = i; j <= n; j += i) {
		v[j].pop_back();
	}
	ll alt = v[i].back() + dfs(i + 1, m);
	return max(pri, alt);
}
	
int main () {
	srand(time(0));
	cin>>n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ll x;
		cin>>x;
		v[i].push_back(x);
	}
	for (int i = n; i >= (n + 1) - (n + 1) / 2; i--) {
		if (v[i].back() < 0) {
			v[i].back() = 0;
		}
	}
	ll q = dfs(1, (n + 1) - (n + 1) / 2);
	cout<<q<<endl;
}

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

int to_int(string s) {
  int S = 0;  
  int num = 1;
  for ( int i = 0; i < (int)s.size(); i++ ) {
    if ( s[i] == 'm' ) {
      S += num*1000;
      num = 1;
    } else if ( s[i] == 'c' ) {
      S += num*100;
      num = 1;
    } else if ( s[i] == 'x' ) {
      S += num*10;
      num = 1;
    } else if ( s[i] == 'i' ) {
      S += num;
      num = 1;
    } else {
      num = s[i]-'0';      
    }
  }

  return S;
}

string to_str(int S) {  
  string s = "";
  int div = 1000;
  
  while ( S ) {
    int res = S/div;
    if ( res > 1 ) {
      s += (char)('0'+res);      
    }

    if ( res ) {
      if ( div == 1000 ) s += 'm';
      if ( div == 100  ) s += 'c';
      if ( div == 10   ) s += 'x';
      if ( div == 1    ) s += 'i';
    }
    
    S %= div;
    div /= 10;    
  }
  
  return s;  
}

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

  while ( n-- ) {
    string s, t;
    cin >> s >> t;

    int sum = to_int(s)+to_int(t);    
    cout << to_str(sum) << endl;    
  }
  
  return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a,b;
    vector<pair<ll,ll>>v;
    for(ll i=0;i<n;i++)
    {
        cin>>a>>b;
        v.push_back(make_pair(b,a));
    }
    sort(v.begin(),v.end());
    ll flag=1;
    if(v[0].second>v[0].first)
    {
        flag=0;
    }
    ll cur=v[0].second;
    for(ll i=1;i<n;i++)
    {
        cur+=v[i].second;
        //cout<<cur<<" "<<v[i].first<<endl;
        if(v[i].first<cur)
        {
            flag=0;
        }
    }
    if(flag==0)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
}

Measured memory_bytes: 6512
n, s = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, 0)
mod = 998244353
dp = [[0] * (s + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(s + 1):
        dp[i][j] += 2 * dp[i - 1][j]
        dp[i][j] %= mod
        if a[i] <= j:
            dp[i][j] += dp[i - 1][j - a[i]]
            dp[i][j] %= mod
ans = dp[n][s]
print(ans)

Measured memory_bytes: 135412
n=int(input())
n+=-1
lentharray=(26,702,18278,475254,12356630,321272406,8353082582,217180147158,5646683826134,146813779479510,3817158266467286)
i0=0
i1=0
s="abcdefghijklmnopqrstuvwxyz"
for i in lentharray:
  i0+=1
  if n < i:
    break
  i1=i
i2=n-i1
r=[]
for j in range(i0):
  i3=i2%26
  r.append(s[i3])
  i2=i2//26
print("".join(reversed(r)))

Measured memory_bytes: 9148
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static class Page {
		String name;
		int l[], r[], t[], b[];
		String button[];
		int num, k;

		Page(String name, int k, int num) {
			this.name = name;
			l = new int[k];
			r = new int[k];
			t = new int[k];
			b = new int[k];
			button = new String[k];
			this.num = num;
			this.k = k;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		Page p[];
		int buf[], index, end;
		TreeMap<String, Integer> tm = new TreeMap<String, Integer>();

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			sc.nextInt();
			sc.nextInt();

			p = new Page[n];
			for (int i = 0; i < n; i++) {
				String name = sc.next();
				int k = sc.nextInt();
				p[i] = new Page(name, k, i);
				tm.put(p[i].name, p[i].num);
				for (int j = 0; j < p[i].k; j++) {
					p[i].l[j] = sc.nextInt();
					p[i].t[j] = sc.nextInt();
					p[i].r[j] = sc.nextInt();
					p[i].b[j] = sc.nextInt();
					p[i].button[j] = sc.next();
				}
			}

			m = sc.nextInt();
			buf = new int[100000];
			index = 0;
			end = 1;
			for (int i = 0; i < m; i++) {
				String order = sc.next();
				Page now = p[buf[index]];
				if (order.equals("click")) {
					int x = sc.nextInt();
					int y = sc.nextInt();
					for (int j = 0; j < now.k; j++) {
						if (now.l[j] <= x && x <= now.r[j] && now.t[j] <= y && y <= now.b[j]) {
							index++;
							buf[index] = tm.get(now.button[j]);
							end = index + 1;
							break;
						}
					}
				} else if (order.equals("show")) {
					System.out.println(now.name);
				} else if (order.equals("back")) {
					index = Math.max(index - 1, 0);
				} else if (order.equals("forward")) {
					index = Math.min(index + 1, end - 1);
				}
			}
		}
	}
}

Measured memory_bytes: 29768
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> h(N); cin >> h;
  sort(h.begin(), h.end());

  int vmin = 1e9;
  for (int i = 0; i + K - 1< N; ++i) {
    vmin = min(vmin, h[i + K - 1] - h[i]);
  }
  cout << vmin << endl;
}


Measured memory_bytes: 3692
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <list>


using namespace std;

#define N 10

char mat[N][N];
bool vis[N][N];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%s", mat[i]);
    }

    if (mat[0][0] == '#') {
        int cx = 0, cy = 0;
        bool ok = 1;
        vis[0][0] = 1;
        for (int i = 0; i < n; i++) {
            while (cy + 1 < m && mat[cx][cy + 1] == '#') {
                cy++;
                vis[cx][cy] = 1;
            }
            if (i == n - 1) break;
            if (mat[cx + 1][cy] == '#') {
                cx++;
                vis[cx][cy] = 1;
            }
            else {
                ok = 0;
                break;
            }
        }

        if (ok) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (mat[i][j] == '#') {
                        if (!vis[i][j]) {
                            ok = 0;
                            break;
                        }
                    }
                }
            }

            if (ok && cx == n - 1 && cy == m - 1)
                puts("Possible");
            else
                puts("Impossible");
        }
        else {
            puts("Impossible");
        }
    }
    else {
        puts("Impossible");
    }

    return 0;
}


Measured memory_bytes: 256
def solve(n, m, arr):
    arr.sort()
    for i in range(m):
        if arr[-1 - i] < sum(arr) * (1 / (4 * m)):
            return False
    return True

if __name__ == "__main__":
    n, m = map(int, input().split(' '))
    arr = [int(s) for s in list(input().split())]
    if solve(n, m, arr):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

n_kabu = 0
shojikin = 1000
is_upper = False
is_under = False
for n in range(0,N-1):
    if not is_upper and A[n] < A[n+1]:
        is_upper = True
        is_under = False
        # 購入
        n_kabu = int(shojikin/A[n])
        shojikin -= n_kabu*A[n]
    elif not is_under and A[n] > A[n+1]:
        is_under = True
        is_upper = False
        # 売却
        shojikin += n_kabu*A[n]
        n_kabu = 0

print(shojikin+(n_kabu*A[N-1]))

Measured memory_bytes: 61960
#include "bits/stdc++.h"
using namespace std;
long long mod=1e9+7;

int main(){
  long long n;
  cin>>n;
  vector<long long> a1(1e5+1,0);
  vector<long long> a2(1e5+1,0);
  for(int i=0;i<n;i++){
    long long a;
    cin>>a;
    if(i%2==0)a1[a]++;
    else a2[a]++;
  }
  long long aa1=0;
  long long aa12=0;
  long long aa1id;
  long long aa2=0;
  long long aa22=0;
  long long aa2id;
  for(long long i=0;i<1e5+1;i++){
    if(aa1<a1[i]){
      aa12=aa1;
      aa1=a1[i];
      aa1id=i;
    }else if(aa12<a1[i]){
      aa12=a1[i];
    }
    if(aa2<a2[i]){
      aa22=aa2;
      aa2=a2[i];
      aa2id=i;
    }else if(aa22<a2[i]){
      aa22=a2[i];
    }
  }
  long long ans;
  if(aa1id==aa2id){
    ans=min(n-(aa1+aa22),n-(aa2+aa12));
    ans=min(ans,n-(aa12+aa22));
  }else ans=n-(aa1+aa2);
  cout<<ans<<endl;
}


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

#define debug_input freopen("stdin.in", "r", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORALL(i, n) for(int i = 0; i < n; i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)
#define SORT(a) sort(a.begin(), a.end())
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())
#define ALL(a) a.begin, a.end()
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	string s;
	getline(cin , s);

	if(s[s.length() - 1] == 's') {
		s += "es";
	}	 
	else {
		s += "s";
	}

	cout << s << endl;
	return 0;
}

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

int main() {
	long long int i,n,k,t,r,f,se,j,ans=0;
	string s;
	cin>>s;
	n=s.size();
	long long int dp[2][2019];
	memset(dp,0,sizeof(dp));
	for(i=1;i<=n;i++){
	    k=(int)(s[i-1]-'0');
	    se=i%2;
	    f=se^1;
	    for(j=0;j<=2018;j++){dp[se][j]=0;}
	    for(j=0;j<=2018;j++){
	        r=(j*10)+k;
	        r=r%2019;
	        dp[se][r]+=dp[f][j];
	    }
	    dp[se][k]++;
	    ans+=dp[se][0];
	}cout<<ans;
	return 0;
}


Measured memory_bytes: 3748
import collections

n = int(input())
def sort_string(st):
  res = list(st)
  res.sort()
  return "".join(res)

s = [sort_string(input()) for _ in range(n)]
c = collections.Counter(s)
ans = 0
for n in c.values():
  ans += n*(n-1)//2
print(ans)

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

int main(){
  int n, a, b;
  cin >> n;
  if(n == 1){
    cout <<"Hello World" << endl;
  }
  else {
    cin >> a >> b;
    cout << a+b << endl; 
  }
}


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

#define maxN 2000001
#define maxData 10000
int boxA[maxN], boxB[maxN], boxC[maxData];

int main(void)
{
/* *** initialize *** */
	int dataN = 0;
	boxA[maxN] = {0};
	boxB[maxN] = {0};
	boxC[maxData] = {0};

/*  *** input Data *** */
	cin >> dataN;
//	cout << "dataN = " << dataN << endl;		//Debug
	
	for(int n = 1; n <= dataN; n++)
	{
		cin >> boxA[n];
//		cout << "boxA[" << n << "] = " << boxA[n] << endl;		//Debug
		
		boxC[boxA[n]]++;
//		cout << "boxC[" << boxA[n] << "] = " << boxC[boxA[n]] << endl;		//Debug
	}
	
/* *** data analysis *** */
	for(int c = 1; c <= maxData; c++)
	{
		boxC[c] += boxC[c-1];
//		cout << "boxC[" << c << "] = " << boxC[c] << endl;		//Debug
	}
	
/* *** sort *** */
	for(int b = dataN; b >= 1; b--)
	{
		boxB[boxC[boxA[b]]] = boxA[b];
		boxC[boxA[b]]--;
	}
	
/* *** result *** */
	for(int data = 1; data <= dataN; data++)
	{
		if(data == dataN)
		{
			cout << boxB[data] << endl;
		}
		else
		{
			cout << boxB[data] << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 18748
// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>

using namespace std;

void A();
void B();
void C();
void D();
void E();

int main()
{
	B();
}

void A() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}

void B() {
	int n, m;
	cin >> n >> m;

	vector<int> items(n);

	for (int& num : items) cin >> num;

	int sum = 0;
	for (int num : items) sum += num;

	int popular = 0;

	const double popularAmt = (double)sum / (4 * m);

	for (int num : items) {
		if (num >= popularAmt) popular++;
	}

	if (popular >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
	
}

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  ll a, b, c, k; cin >> a >> b >> c >> k;
  if (k%2 == 0 && a-b > 1000000000000000000) {
    cout << "Unfair" << endl;
  } else if (k%2 == 1 && b-a > 1000000000000000000){
    cout << "Unfair" << endl;
  } else if (k % 2 == 0) {
    cout << a-b << endl;
  } else {
    cout << b-a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int a, b, c;
  	cin >> a >> b >> c;
  	cout << a+b+c - max(a, max(b,c)) <<endl;
    
  	return 0;
}



Measured memory_bytes: 256
use proconio::{fastout, input, marker::Usize1};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        p: [Usize1; n],
        c: [i128; n],
    }

    let mut max_score = std::i128::MIN;
    for i in 0..n {
        let mut point = i;
        let mut score = 0;
        let mut scorelist = vec![];
        let mut visited = vec![-1i128; n];
        let mut loop_start = -1;
        let mut loop_end = -1;
        for count in 0..=std::cmp::min(n, k - 1) {
            point = p[point];
            score += c[point];
            scorelist.push(score);
            if visited[point] < 0 {
                visited[point] = count as i128;
            } else {
                loop_start = visited[point];
                loop_end = (count - 1) as i128;
                break;
            }
        }

        max_score = std::cmp::max(
            max_score,
            if loop_start >= 0 {
                let loop_start: usize = loop_start as usize;
                let loop_end: usize = loop_end as usize;
                let loop_length = loop_end - loop_start + 1;
                let loop_num = (k - loop_start) / loop_length;
                let before_loop_score = if loop_start > 0 {
                    scorelist[loop_start - 1]
                } else {
                    0
                };
                let loop_score = scorelist[loop_end] - before_loop_score;
                let loop_remain = (k - loop_start) % loop_length;

                let remain_score = match scorelist[loop_start..(loop_start + loop_remain)]
                    .iter()
                    .max()
                    .copied()
                {
                    Some(s) => s,
                    None => 0,
                };

                if loop_score > 0 {
                    before_loop_score
                        + loop_score * (loop_num as i128 - 1)
                        + std::cmp::max(
                            scorelist[loop_start..loop_end]
                                .iter()
                                .max()
                                .copied()
                                .unwrap(),
                            loop_score + remain_score,
                        )
                } else {
                    scorelist.iter().max().copied().unwrap()
                }
            } else {
                scorelist.iter().max().copied().unwrap()
            },
        );
    }

    println!("{}", max_score);
}


Measured memory_bytes: 2464
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;
  if(abs(A-B) > (V-W)*T) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 3624
N=list(map(int, input().split()))
a=N[0]
b=N[1]
c=N[2]
d=N[3]
if a<c:
    if b<=c:
        print(0)
    else:
        if b<=d:
            print(b-c)
        else:
            print(d-c)
else:
    if d<=a:
        print(0)
    else:
        if d<=b:
            print(d-a)
        else:
            print(b-a)    

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int a, b, c, d;

int main(){
    cin >> a >> b >> c >> d;
    if (a+b > c+d) {
        puts("Left");
    } else if (a+b == c+d) {
        puts("Balanced");
    } else {
        puts("Right");
    }
}
































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

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

  for(i=1;i<=N;i++){
    int a = i;
    int b = 0;
    do{
      b += a%10;
      a = a/10;
    }while(a>0);
    if(A <= b && b <= B)
    sum += i;
  }
  cout << sum << endl;
}


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

int main(){
	string s;
	cin >> s;
	vector<bool> alp(26,false);
	
	for(int i=0;i<s.size();i++){
		alp[(int)(s[i]-'a')]=true;
	}
	
	for(int i=0;i<26;i++){
		if(alp[i]==false){
			cout << (char)('a'+i) << endl;
			return 0;
		}
	}
	
	cout << "None" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) <<  endl;
}

Measured memory_bytes: 256
import numpy as np 

listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

sum=np.sum(listA[2])
for i in range(len(listA[1])-1):
  if listA[1][i+1]-listA[1][i]==1:
    b=listA[1][i]-1
    sum+=listA[3][b]
    
print(sum)

Measured memory_bytes: 14468
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    val l = readLine()!!.split(" ").map { it.toInt() }
    var a = 999999999
    for (i in 0 .. x - y){
        a = Math.min(a, Math.abs(l[i + y - 1]) + Math.abs(l[i + y - 1] - l[i]))
        a = Math.min(a, Math.abs(l[i]) + Math.abs(l[i + y - 1] - l[i]))
    }
    println(a)
}

Measured memory_bytes: 51724