akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

typedef std::pair<int,int> P;


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<std::vector<int>> E(N);
  std::vector<P> T(N-1);
  rep(i,N-1) {
    int a,b; std::cin >> a >> b;
    E[a-1].push_back(b-1);
    E[b-1].push_back(a-1);
    T[i].first = a-1;
    T[i].second = b-1;
  }
  int emax = 0;
  rep(i,N) emax = std::max(emax, sz(E[i]));
  std::cout << emax << std::endl;

  std::vector<bool> used(N,false);
  std::vector<std::unordered_map<int,int>> C(N);
  std::stack<int> s;
  s.push( 0 );
  used[0] = true;
  while(!s.empty()) {
    int c = s.top(); s.pop();
    int color = 1;
    int noncolor = -1;
    for(auto&& e : E[c]) {
      if ( used[e] ) noncolor = C[c][e];
    }
    for(auto&& e : E[c]) {
      if ( used[e] ) continue;
      if ( color == noncolor ) color++;
      C[c][e] = color;
      C[e][c] = color;
      color++;
      used[e] = true;
      s.push( e );
    }
  }
  rep(i,N-1) std::cout << C[T[i].first][T[i].second] << std::endl;
  return 0;
}


Measured memory_bytes: 22784
#include<stdio.h>
#include<stdbool.h>
 struct TC{
   char s;
   char v;
 };
 void bubble(struct TC A[],int N){
  int i,j;
   for(i=0;i<N;i++){
     for(j=N-1;j>=i+1;j--){
       if(A[j].v<A[j-1].v){
        struct TC t=A[j];
         A[j]=A[j-1];
         A[j-1]=t;
       }
     }
   }
 }
void selection(struct TC A[],int N){
int i,j;
  for(i=0;i<N;i++){
    int minj=i;
    for(j=i;j<N;j++){
      if(A[j].v<A[minj].v)minj=j;
    }
struct TC t=A[i];
A[i]=A[minj];
A[minj]=t;
  }
}
void print(struct TC A[],int N){
int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%c%c",A[i].s,A[i].v);
  }
printf("\n");
}
bool isS(struct TC c1[],struct TC c2[],int N){
int i;
for(i=0;i<N;i++){
  if(c1[i].s != c2[i].s)return false;
}
return true;
}
int main(){
  struct TC c1[100],c2[100];
  int N,i;
  char ch;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c %c",&c1[i].s,&c1[i].v);
  }
for(i=0;i<N;i++)c2[i]=c1[i];
bubble(c1,N);
selection(c2,N);
print(c1,N);
printf("Stable\n");
print(c2,N);
if(isS(c1,c2,N)){
  printf("Stable\n");
}
else{
  printf("Not stable\n");
}
return 0;
}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }

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

    int i = 0;
    if(n%2 == 1) {
        for(int l=1, r=n-1; l < r; l++, r--) {
            if(i >= m) break;
            printf("%d %d\n", l, r);
            i++;
        }
    } else {
        bool flag = false;
        for(int l=1, r=n-1; l < r; l++, r--) {
            if(i >= m) break;
            // 対角線を超えた段階でずらさないといけない
            if(r-l <= n/2 && !flag) {
                l++;
                flag = true;
            }
            printf("%d %d\n", l, r);
            i++;
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

char S[5];

int main()
{
  cin >> S;
  int price = 700;

  REP(i,0,3) {
    if (S[i] == 'o') price += 100;
  }

  cout << price << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,st,sa,sb;
	cin>>st>>s;
	sa=s.substr(0,s.size()-1);
	if(sa==st){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        x *= x *= x;
        System.out.println(x);
    }
}

Measured memory_bytes: 24340
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class DLuckyPIN {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n;cin >> n;
        string s;cin >> s;
        int a[10][10][10];
        rep(i,10)rep(j,10)rep(k,10)a[i][j][k] = 0;
        int f[10],l[10];rep(i,10)f[i] = l[i] = -1;
        rep(i,n){
            int x = s[i] - '0';
            if(f[x] == -1)f[x] = i;
        }
        for(int i = n-1;i >= 0;i--){
            int x = s[i] - '0';
            if(l[x] == -1)l[x] = i;
        }

        rep(i,10)rep(j,10){
            if(f[i] == -1 or l[j] == -1 or f[i] >= l[j])continue;
            for(int k = f[i]+1;k < l[j];k++){

                int y = s[k] - '0';
                a[i][j][y]++;
            }
        }
        int ans = 0;
        rep(i,10)rep(j,10)rep(k,10){
            if(a[i][j][k] > 0)ans++;
        }
        cout << ans << endl;
    }
};

int main() {
	DLuckyPIN solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int cnt=0;
  for(int i=0;i<=100;i++){
    if((a<=i && i<b) && (c<=i && i<d))cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	int len1,len2,minn,maxx;
	cin>>a>>b;
	len1=a.length();
	len2=b.length();
	minn=min(len1,len2);
	maxx=max(len1,len2);
	for(int i=0;i<minn;i++)
	cout<<a[i]<<b[i];
	if(len1>len2)
        for(int i=minn;i<maxx;i++)
            cout<<a[i];
    else for(int i=minn;i<maxx;i++)
            cout<<b[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,A,B;
  cin >> N >> A >> B;
  ((B-A) % 2) == 0 ? cout << "Alice" << endl : cout <<"Borys" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n;
ll a[4005], b[4005];
ll x[4005][4005], y[4005][4005];
ll d[4005][4005];

int main()
{
    cin>>n;
    for(ll i = 0; i < 2 * n; i++)
    {
        char t1;
        ll t2;
        cin>>t1>>t2;
        if(t1 == 'B') a[t2] = i;
        else b[t2] = i;
    }
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 0; j <= 2 * n; j++) x[i][j] = x[i - 1][j];
        for(ll j = a[i] + 1; j <= 2 * n; j++) x[i][j]++;
        for(ll j = 0; j <= 2 * n; j++) y[i][j] = y[i - 1][j];
        for(ll j = b[i] + 1; j <= 2 * n; j++) y[i][j]++;
    }
    d[0][0] = 0;
    for(ll i = 0; i <= n; i++)
    {
        for(ll j = 0; j <= n; j++)
        {
            if(i == 0 && j == 0) continue;
            d[i][j] = 4e18;
            if(i > 0) d[i][j] = min(d[i][j], d[i - 1][j] + a[i] - (x[i][a[i]] + y[j][a[i]]));
            if(j > 0) d[i][j] = min(d[i][j], d[i][j - 1] + b[j] - (x[i][b[j]] + y[j][b[j]]));
        }
    }
    cout<<d[n][n]<<endl;
    return 0;
}


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

int main()
{
  int N, L;
  cin >> N >> L;
  
  vector<string> S;
  rep(i, N)
  {
    string tmp;
    cin >> tmp;
    S.push_back(tmp);
  }
  
  sort(S.begin(), S.end());
  
  string s = S[0];
  for (int i = 1; i < N; i++)
  {
    s += S[i];
  }
  
  cout << s << endl;

  return 0;
}

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

int main() {
	int n;
  	string s,t;
  	cin >> n >> s >> t;
  	bool ok;
	for(int i = 0; i < n; i++) {
    	ok = true;
      	for(int j = 0; i+j < n; j++) {
        	if(s[i+j] != t[j]) {
            	ok = false;
              	break;
            }
        }
      	if(ok){
        	cout << n+i<<endl;
          	return 0;
        }
    }
  	cout << 2*n<<endl;
}


Measured memory_bytes: 256
n,m,x = map(int,input().split())
a_inputs = [int(i) for i in input().split()]

map_list = [0 for i in range(n+1)]

for i in range(n+1):
    if i in a_inputs:
        map_list[i]=1

ans1,ans2=0,0
for i in range(x,n+1):
    ans1+=map_list[i]
for i in range(x,-1,-1):
    ans2+=map_list[i]
print(min(ans1,ans2))







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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;


void solve()
{
	string s;
	cin >> s;
	int n = s.size();
	map<int, int>mp;
	int x = 1;
	int r = 0;
	int ans = 0;
	rloop(i, n - 1, 0)
	{
		r = (r + ((s[i] - '0') * x) % 2019) % 2019;
		//bug(r);
		if (mp.find(r) == mp.end()) mp[r] = 1;
		else
		{
			ans += mp[r];
			mp[r]++;
		}
		if (r == 0) ans++;
		x = (x * 10) % 2019;


	}
	cout << ans << endl;

}

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



	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

Measured memory_bytes: 3808
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    double a,b,h,m;
    cin >> a >> b >> h >> m;

    double PI = 3.14159265358979323846;

    double alpha = (2.0*PI/12.0)*h + (m/60.0)*(2.0*PI/12.0);
    double beta = (2.0*PI/60.0)*m;
    
    double sa = abs(alpha-beta);
    if(sa > PI){
        sa = 2*PI - sa;
    }
    double ans;
    ans = pow(a,2.0) + pow(b,2.0) - 2*a*b*cos(sa);
    
    ans = sqrt(ans);

    printf("%.15f",ans);
}

Measured memory_bytes: 4216
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int n;
	cin >> n;
	cin.ignore();
	
	vector<int> vr;

	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		vr.push_back(t);
	}

	int profit = vr[1] - vr[0];
	for (int i = 0; i < vr.size() -1; ++i)
	{
		for (int j = i + 1; j < vr.size(); ++j)
		{
			profit = max(profit, vr[j] - vr[i]);
			if (vr[j] - vr[i] < 0)break;
		}
	}
	cout << profit << endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

template<class T>
void chmax(T& a,T b){
	a=max(a,b);
}

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

template<class T>
void ResetVector(vector<T>& v,int n,const T& t){
	v.clear();
	v.resize(n,t);
}

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
	int n=read(),m=read(),q=read();
	vi a;
	REP(i,q)a.PB(read()-1);
	vector<bool> used(m,false);
	vi t;
	for(int i=q-1;i>=0;i--){
		if(!used[a[i]]){
			used[a[i]]=true;
			t.PB(a[i]);
		}
	}
	REP(i,m)if(!used[i])
		t.PB(i);
	vi idx(m);
	REP(i,m)
		idx[t[i]]=i;
	vi frek(m+1,0);
	frek[0]=n;
	for(int i=q-1;i>=0;i--){
		int k=idx[a[i]];
		if(frek[k]>0){
			frek[k]--;
			frek[k+1]++;
		}
	}
	REP(i,m+1)if(frek[i]>0){
		int last=-1;
		FOR(j,i,m)
			if(last<t[j]){
				last=t[j];
			}else
				No();
		break;
	}
	Yes();
}


Measured memory_bytes: 1912
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int A, B;
    cin >> A >> B;
    cout << (A*B);

    return 0;
}


Measured memory_bytes: 3092
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>
#define INF 1000000000000
const long long MOD = 1000000007;

using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

llong dfs(llong node, vector<vector<llong> > &graph, vector<llong> &dp){
    llong maxv = 0;
    if(dp[node]!=-1){
        return dp[node];
    }
    for(auto next_node:graph[node]){
        maxv = max(maxv, dfs(next_node, graph, dp)+1);
    }
    dp[node] = maxv;
    return maxv;
}

int main(){
    llong N,M;
    cin >> N >> M;
    vector<vector<llong> > graph(N);//隣接リスト表現、他にも隣接行列がある。
    llong x,y;
    for(int i=0; i<M; i++){
        cin >> x >> y;
        graph[x-1].push_back(y-1);
    }
    llong maxv=0;
    vector<llong> dp(N, -1);
    for(llong node=0; node<N; node++){
        maxv = max(maxv, dfs(node, graph, dp));
    }
    cout << maxv << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    vector<int> b = a;
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int max1 = a.at(0);
    int max2 = a.at(1);
    rep(i, n) {
        if(b.at(i) == max1) {
            cout << max2 << endl;
        }
        else {
            cout << max1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>
#include<bitset>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define MOD 1000000007;
using namespace std;
int n,m;
int a[105];
int main(){
    int sum=0;
    cin>>n>>m;
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    int c=0;
    rep(i,0,n){
        if(a[i]>=sum/4.0/m){
            c++;
        }
    }
    if(c>=m){
        puts("Yes");
    }else{
        puts("No");
    }
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,ans=LINF;
	cin>>n;
	range(i,1,sqrt(n)+2){
		ll j=n/i;
		if(i*j==n)chmin(ans,i+j-2);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    int A[3][3];
    int C[3][3];
    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            cin >> A[i][j];
            C[i][j]=0;
        }
    }
    int N;
    cin >> N;
    int b[N];
    for(int i=0;i<N;++i){
        cin >> b[i];
    }
    bool exist=false;
    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            for(int k=0;k<N;++k){
                if(A[i][j]==b[k]){
                    C[i][j]=1;
                    break;
                }
            }
        }
    }
    for(int i=0;i<3;++i){
        if(C[i][0]==1 && C[i][1]==1 && C[i][2]==1){
            exist=true;
        }
    }
    
    for(int j=0;j<3;++j){
        if(C[0][j]==1 && C[1][j]==1 && C[2][j]==1){
            exist=true;
        }
    }
    if(C[0][0]==1 && C[1][1]==1 && C[2][2]==1){
        exist=true;
    }
    
    if(C[0][2]==1 && C[1][1]==1 && C[2][0]==1){
        exist=true;
    }
    if(exist){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

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

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

    if(a+b<10){
        cout<<a+b<<endl;
    }
    else{
        cout<<"error"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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 vl = vector<ll>;
using Graph = vector<vector<int>>;  // int <=> ll
using P = pair<int, int>;  // int <=> ll
const int INFTY = 1e9+7;

Graph G;

void dp(vector<string> &maze, int H, int W) {
  queue<P> q;
  q.push(P(0,0));

  while (!q.empty()) {
    int x, y;
    tie(x,y) = q.front(); q.pop();
    
    if (x-1 >= 0 && maze[x-1][y] == '.' && G[x-1][y] == -1) {  // up
      G[x-1][y] = G[x][y] + 1;
      q.push(P(x-1,y));
    }
    if (x+1 < H && maze[x+1][y] == '.' && G[x+1][y] == -1) {  // down
      G[x+1][y] = G[x][y] + 1;
      q.push(P(x+1,y));
    }
    if (y-1 >= 0 && maze[x][y-1] == '.' && G[x][y-1] == -1) {  // left
      G[x][y-1] = G[x][y] + 1;
      q.push(P(x,y-1));
    }
    if (y+1 < W && maze[x][y+1] == '.' && G[x][y+1] == -1) {  // right
      G[x][y+1] = G[x][y] + 1;
      q.push(P(x,y+1));
    }
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> maze(H);
  rep(i,H) cin >> maze[i];

  int white = 0;
  rep(i,H) rep(j,W) if (maze[i][j] == '.') ++white;

  G.assign(H, vi(W, -1));
  G[0][0] = 0;

  dp(maze, H, W);

  if (G[H-1][W-1] == -1) cout << -1 << endl;
  else cout << white - (G[H-1][W-1] + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 100;
const int mod = 1e9 + 7;
int q,f,a,b,x,flag;
ll suml,sumr,sum,szl,szr;
priority_queue<int, vector<int>, greater<int> >r;
priority_queue<int, vector<int>, less<int> >l;
int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    scanf("%d", &q);
    while (q--)
    {
        scanf("%d", &f);
        if (f == 2)
        {
            ll ans = (ll)x * szl - (ll)x * szr - suml + sumr + sum;
            printf("%d %lld\n", x, ans);
            continue;
        }
        scanf("%d%d", &a, &b);
        sum += b;
        if (!flag)
        {
            x = a;
            suml += a;
            ++szl;
            l.emplace(a);
            flag = 1;
            continue;
        }
        if (a < x)
            l.emplace(a), suml += a, ++szl;
        else
            r.emplace(a), sumr += a, ++szr;
        if (szl > szr)
        {
            x = l.top();
            suml -= x;
            sumr += x;
            r.emplace(x);
            l.pop();
            --szl;
            ++szr;
        }
        if (szr > szl + 1)
        {
            x = r.top();
            sumr -= x;
            suml += x;
            r.pop();
            l.emplace(x);
            --szr;
            ++szl;
        }
        if (szl == szr)
            x = l.top();
        else
            x = r.top();
    }
    return 0;
}

Measured memory_bytes: 3452
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        a: i32,
        b: i32,
    }

    if a < 10 && b < 10 {
        println!("{}", a * b);
    } else {
        println!("-1");
    }
}


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

int main() {
  int N;
  cin >> N;
  int P[200001];
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }

  // i = 0 (1)は必ず満たす
  int P_min = P[0], answer = 1;
  for (int i = 1; i < N; i++) {
    if (P_min > P[i]) P_min = P[i];

    if (P_min == P[i] and P[i - 1] > P[i]) {
      answer++;
    }
  }

  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265



bool nine(string s){
  FOR(i,1,s.size()){
    if(s[i]!='9') return false;
  }

  return true;
}

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


  if(nine(s))
    cout<<s[0]-'0'+9*(s.size()-1)<<endl;
  else
    cout<<s[0]-'0'-1+9*(s.size()-1)<<endl;

  return 0;
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$array = explode(" ", trim(fgets(STDIN)));
$sarray = $array;
sort($sarray);
$l = $sarray[$n/2-1];
$r = $sarray[$n/2];
foreach($array as $num){
    if($num > $l){
        echo $l."\n";
    }else{
        echo $r."\n";
    }
}

Measured memory_bytes: 33140
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

vector<bool> fail(501000);
vector<bool> fail2(501000);

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

  int n, k; cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  vector<int> bit(64);
  vector<ll> sums;
  for(int k=1;k<=n;k++) {
    ll sum = 0;
    for(int j=0; j<n; j++) {
      sum += a[j];
      if (j >= k) {
        sum -= a[j-k];
      }
      if (j>=k-1) {
        sums.push_back(sum);
      }
    }
  }

  ll ans = 0;
  int si = sums.size();

  for(int i=60; i>=0; i--) {
    ll s = 1LL<<i;
    int cnt = 0;
    rep(j, si) {
      if (fail[j]) continue;
      if ((s & sums[j]) == 0) {
        fail2[j] = true;
      } else {
        cnt++;
        fail2[j] = false;
      }
    }
    if (cnt>=k) {
      //debug(s);debug(cnt);debugln(i);
      ans += s;
      rep(j, si) {
        fail[j] = fail[j] || fail2[j];
        //debug(j); debugln(fail[j]);
      }
    }
  }

  cout << ans << endl;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


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

    priority_queue<ll> q;
    map<ll, vector<int>> works;

    rep(_, n) {
        ll a, b;
        cin >> a >> b;
        a--;
        works[m - 1 - a].push_back(b);
    }

    ll ans = 0;
    for (int i = m - 1; i >= 0; i--) {
        for (ll l : works[i]) q.push(l);
        if (q.empty()) continue;
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;

}

Measured memory_bytes: 14084
import Control.Monad
import Control.Applicative

solve :: Int -> Int -> Int
solve s d
    | s == d = 0
    | odd s && odd d = 2 + solve ((s+1)`div`2) ((d-1)`div`2)
    | odd s = 1 + solve ((s+1)`div`2) (d`div`2)
    | odd d = 1 + solve (s`div`2) ((d-1)`div`2)
    | otherwise = solve (s`div`2) (d`div`2)

main :: IO ()
main = do
    n <- readLn
    replicateM_ n $ do
        [s,d] <- map read . words <$> getLine
        print $ solve s d

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

int main(){
    int N;
    cin>>N;
    vector<int> h(N);
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    vector<int> cost(N);
    cost.at(0)=0;
    cost.at(1)=abs(h[1]-h[0]);
    for(int i=2;i<N;i++){
        int a=cost.at(i-2)+abs(h.at(i)-h.at(i-2));
        int b=cost.at(i-1)+abs(h.at(i)-h.at(i-1));
        cost.at(i)=min(a,b);
    }
    int ans=cost.at(N-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
int h, w, d;
int a[305][305];
P p[300*300+5];
int power[300*300+5];
int q;
vector<int> l, r;
/**********************************************/

signed main(){
    cin >> h >> w >> d;
    REP(i, h){
        REP(j, w){
            cin >> a[i][j];
            p[a[i][j]] = P(i, j);
        }
    }

    cin >> q;
    l.resize(q);
    r.resize(q);
    REP(i, q) cin >> l[i] >> r[i];
    
    for(int c = 1; c <= d; c++) power[c] = 0;
    for(int c = d+1; c <= h*w; c++){
        power[c] = power[c-d] + abs(p[c].first - p[c-d].first) + abs(p[c].second - p[c-d].second);
    }

    REP(i, q){
        cout << power[r[i]] - power[l[i]] << endl;
    }
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n, d[100], sum=0,t =0;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> d[i];

	sort(d, d + n);

	for (int i = 0; i < n; i++){
		if (t < d[i]) {
			t = d[i];
			sum++;
		}
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys,math
countrect = 0
countloze = 0
for line in sys.stdin.readlines():
   x , y , d1 = map(int,line.split(','))
   if x == y:
       d2 = 4*x*x - d1*d1
       if d1*d1 + d2 == 4*x*x:
           countloze += 1
   else:
       if x*x + y*y == d1*d1:
           countrect += 1
print(countrect)
print(countloze)

Measured memory_bytes: 7644
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <sstream>
// #include <cmath>
// #include <map>
// #include <set>
// #include <deque>
// #include <stack>
// #include <vector>
using namespace std;
#define debug freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
// #define PI acos(-1)
typedef long long ll;
const int mod=1e9+7;

int main()
{
	//debug;
	ios;
	int x;
	cin>>x;
	if(x==0)
		cout<<"1";
	else
		cout<<"0";
	return  0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

typedef pair<double, int> mypair;

const int maxn = 105;
const double PI = 3.14159265359;
pii p[maxn];

int main() {
#ifdef LOCAL
    freopen("inp", "r", stdin);
    //freopen("outp", "w", stdout);
#else
    // freopen(TASKNAME ".in", "r", stdin);
    // freopen(TASKNAME ".out", "w", stdout);
#endif
    int n;
    scanf("%d", &n);
    forn(i, n) {
        scanf("%d%d", &p[i].fi, &p[i].se);
    }
    forn(i, n) {
        vector<mypair> events;
        forn(j, n) {
            if (i == j)
                continue;
            int deltax = p[j].fi - p[i].fi;
            int deltay = p[j].se - p[i].se;
            double alpha = atan2(deltay, deltax);
            double fin = alpha + PI;
            if (fin < PI) {
                events.pb({alpha, +1});
                events.pb({fin, -1});
            } else {
                events.pb({alpha, +1});
                events.pb({PI, -1});
                events.pb({-PI, +1});
                events.pb({fin - 2 * PI, -1});
            }
        }
        sort(events.begin(), events.end());
        double s = 0.0;
        int balance = 0;
        double prev = 0;
        for (mypair& p : events) {
            if (balance == n - 1)
                s += p.fi - prev;
            prev = p.fi;
            balance += p.se;
        }
        printf("%.10lf\n", s / (2 * PI));
    }
}



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

int main(){
	long n,a,b;
	cin >> n >> a >> b;
	vector<int> x(n);
	for(int i = 0; i < n; i++)
		cin >> x[i];
	
	long count = 0;
	
	for(int i = 0; i < n-1; i++)
		count += ((x[i+1] - x[i]) * a < b) ? (x[i+1] - x[i]) * a : b;

	cout << count << endl;
}



Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int y,l,u;
    char k;
    int s[14]={};
    int h[14]={};
    int c[14]={};
    int d[14]={};
    cin>>y;
    for(int j=1;j<=y;j++){
        cin>>k>>l;
        if(k=='S') s[l]=1;
        if(k=='H') h[l]=1;
        if(k=='C') c[l]=1;   
        if(k=='D') d[l]=1;
    }
    u=0;
    for(int i=1;i<=52;i++){
        u++;
        if(i<=13){
            if(s[u]==0) cout<<"S "<<u<<endl;
        }else if(i<=26){
            if(h[u]==0) cout<<"H "<<u<<endl;
        }else if(i<=39){
            if(c[u]==0) cout<<"C "<<u<<endl;
        }else{
            if(d[u]==0) cout<<"D "<<u<<endl;
        }
        if(u%13==0){
            u=0;
        }
    }
}


Measured memory_bytes: 3076
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7;

long[][] pascal(int n) {
    auto g = new long[][](n + 1, n + 1);
    g[0][0] = 1;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            g[i][j] = g[i-1][j];
            if (j > 0) {
                g[i][j] += g[i-1][j-1];
                g[i][j] %= MOD;
            }
        }
    }
    return g;
}

long[][] C;

void calc(int n, int k) {
    C = pascal(n + k);

    for (int i = 1; i <= k; i++) {
        // すき間のどこに入れるか
        long x = C[n - k + 1][i];

        // i 個のすき間にボールを入れる
        // 最低 1 つは入れる必要があるので、あらかじめ i 個分を引く
        long y = C[k - i + i - 1][i - 1];
        writeln(x * y % MOD);
    }
}

void main() {
    int n, k; scan(n, k);
    calc(n, k);
}


Measured memory_bytes: 129148
#include<stdio.h>
int main()
{
    int n,k,x,y,r,result;
    while(scanf("%d%d%d%d",&n,&k,&x,&y)==4)
    {
        if(n<=k)
        {
            result=x*n;
        }
        else
        {
            r=n-k;
            result=((k*x)+(r*y));
        }
        printf("%d\n",result);
    }
}


Measured memory_bytes: 1732
#!/usr/bin/env python3
#AGC3 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
b = sorted(a)
cnt = 0
for i in range(n):
    if a[i] != b[i]:
        r = bl(b,a[i])
        if i % 2 ^ r % 2 == 0:
            continue
        cnt += 1
print(cnt//2)


Measured memory_bytes: 46044
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    string s, t; cin>>s>>t;
    int n=s.size(), m=t.size();

    vector<vector<string>> dp(2, vector<string>(m+1, ""));
    int cur=0, nxt=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(s[i]==t[j] && dp[nxt][j+1].size()<dp[cur][j].size()+1){
                dp[nxt][j+1]=dp[cur][j]+s[i];
            }
                
            if(dp[nxt][j+1].size()<dp[cur][j+1].size()){
                dp[nxt][j+1]=dp[cur][j+1];
            }
            if(dp[nxt][j+1].size()<dp[nxt][j].size()){
                dp[nxt][j+1]=dp[nxt][j];
            }
        }
        swap(cur, nxt);
    }
    cout << dp[cur][m] << endl; 
}

Measured memory_bytes: 18580
s = input()
ans = "AC"
if s[0] != 'A':
    ans = "WA"
s = list(s)
s[0] = 'a'
f = 0
for i in range(2,len(s)-1):
    if s[i] == "C":
        if f:
            ans = "WA"
        else:
            f = 1
            s[i] = "c"

if not f:
    ans = "WA"
for si in s:
    if si not in "abcdefghijklmnopqrstuvwxyz":
        ans = "WA"
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

constexpr uint_fast64_t MOD = 1e9 + 7;


template<class StoreT, class AddT, class MulT, StoreT MOD>
class ModInt
{
    using self_type = ModInt<StoreT, AddT, MulT, MOD>;
    StoreT i;

public:
    ModInt(StoreT i)
        : i(i)
    {}

    ModInt(const self_type& i)
        : i(i.i)
    {}

    constexpr uint_fast32_t getI() const noexcept
    {
        return i;
    }

    ModInt& operator +=(self_type rhs)
    {
        AddT i64 = static_cast<AddT>(i);
        StoreT a32 = static_cast<StoreT>((i64 + rhs.i) % MOD);
        i = a32;
        return *this;
    }

    constexpr ModInt operator +(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        newInt += rhs;
        return newInt;
    }

    ModInt& operator -=(self_type rhs)
    {
        AddT i64 = static_cast<AddT>(i);
        StoreT a32 = static_cast<StoreT>((i64 + MOD - rhs.i) % MOD);
        i = a32;
        return *this;
    }

    constexpr ModInt operator -(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        newInt -= rhs;
        return newInt;
    }

    ModInt& operator *=(self_type rhs)
    {
        MulT i64 = static_cast<MulT>(i);
        StoreT a32 = static_cast<StoreT>((i64 * rhs.i) % MOD);
        i = a32;
        return *this;
    }

    constexpr ModInt operator *(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        newInt *= rhs;
        return newInt;
    }

    constexpr ModInt operator /(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        self_type rhsInv = rhs.inv();
        newInt *= rhsInv;
        return newInt;
    }

    constexpr ModInt pow(int n) const noexcept
    {
        ModInt a = *this;
        ModInt res = 1;

        while (n > 0)
        {
            if (n & 1)
            {
                res *= a;
            }
            a *= a;
            n >>= 1;
        }
        return res;
    }

    constexpr self_type inv() const noexcept
    {
        return pow(MOD - 2);
    }
};

template<class StoreT, class AddT, class MulT, StoreT MOD>
std::ostream& operator <<(std::ostream& ost, ModInt<StoreT, AddT, MulT, MOD> i)
{
    ost << i.getI();
    return ost;
}

using MyModInt = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, MOD>;

MyModInt combination(MyModInt n, MyModInt r)
{
    MyModInt bunbo = 1, bunshi = 1;
    for (int i = n.getI(); i > (n - r).getI(); i--)
    {
        bunshi *= i;
    }
    for (int i = r.getI(); i > 0; i--)
    {
        bunbo *= i;
    }

    return bunshi / bunbo;
}

int keta_k(int n, int k)
{
	int keta = 0;
	while (n)
	{
		n /= k;
		keta++;
	}
	return keta;
}


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

    MyModInt two = 2;
    MyModInt ans = two.pow(n) - combination(n, a) - combination(n, b) - 1;

    std::cout << ans;
}

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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK" << endl

const double PI = M_PI;
const long long INF = int(10e9-1);
const long long MOD = int(10e9+7);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t start = clock();
        solve();
        clock_t end = clock();
        const double time = static_cast<double>(end-start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
   GET(N);
   GET(A);
   GET(B);
   cout << min(A,B) << " " << max(A+B-N,0) << endl;
}


Measured memory_bytes: 256