akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

vector<int> V(10);
vector<int> T(10);
int N;
int ans = 1001001001;
int INF = 1001001001;
int A, B, C;

void calc(vector<int> v){
    int now = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    for (int i = 0; i < N; i++){
        if(v[i] == 0){
            if(a != 0){
                now += 10;
            }
            a += T[i];
        } else if(v[i] == 1){
            if(b != 0){
                now += 10;
            }
            b += T[i];
        } else if(v[i] == 2){
            if(c != 0){
                now += 10;
            }
            c += T[i];
        } else {
            continue;
        }
    }
    if(a == 0 || b == 0 || c == 0){
        now = INF;
    } else {
        now += abs(A-a) + abs(B-b) + abs(C-c);
    }

    ans = min(ans, now);
    
    return;
}

void dfs(int depth, vector<int> &v){
    if(depth == N){
        calc(v);
    } else {
        for (int i = 0; i < 4; i++){
            v[depth] = i;
            dfs(depth+1, v);
        }
    }
    return;
}

int main() {
    cin >> N >> A >> B >> C;
    rep(i, N){
        cin >> T[i];
    }

    dfs(0, V);

    cout << ans << endl;

    return 0;
}

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

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 29;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

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

    int n = s.size();
    REP(i, 1, n) {
        if(s[i-1] == s[i]) {
            cout << i << " " << i+1 << endl;
            return 0;
        }
    }

    REP(i, 2, n) {
        if(s[i-2] == s[i]) {
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
	
    return 0;
}

Measured memory_bytes: 512
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var s = o.a(String);
  var count = s.split("").filter(x => x === "x").length;
  console.log(count > 7 ? "NO":"YES");
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22080
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>

using namespace std;

int main(){
  int a,b,c,n,m;
  cin >> n;
  cin >> a;
  cin >> b;
  int cnt = 0;
  for(int i = 2; i < n; i++){
    cin >> c;
    if((a<b && b < c) || (a > b && b > c)) cnt++;
    a = b;
    b = c;
  }


  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}

void solve()
{
	int n;
	cin >> n;
	ll a[n];
	vector<ll> cnt(n + 1, 0);
	for(int i = 1; i <= n; ++i){
		int le = i - 1;
		int ri = n - i;
		cnt[abs(le - ri)]++;
		cin >> a[i];
	}
	ll res = 1;
	for(int i = 1; i <= n; ++i){
		res *= cnt[a[i]];
		res %= mod;
		cnt[a[i]]--;
	}
	cout << res;

}	 

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}


Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010],b[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	ll A=0,B=0;
	for(int i=0;i<n;i++){
		if(a[i]>b[i]){
			B+=a[i]-b[i];

		}
		else{
			A+=b[i]-a[i];
						if((b[i]-a[i])%2!=0){
				A--;
			}
		}
	}
	if(A>=2*B){
		cout << "Yes";
		return 0;
	}
	else{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	int n,m,a;
	int now;
	int yoco[1000][3];
	int cop,copp;
	int i,j,k;
	while(1){
	scanf("%d %d %d",&n,&m,&a);
	if(n==0 && m==0 && a==0) break;
	now=a;
	for(i=0;i<m;i++){
		scanf("%d %d %d",&yoco[i][0],&yoco[i][1],&yoco[i][2]);
		j=yoco[i][0];
		cop=yoco[i][1];
		copp=yoco[i][2];
		k=i-1;
		while(k>=0 && j<yoco[k][0]){
			yoco[k+1][0]=yoco[k][0];
			yoco[k+1][1]=yoco[k][1];
			yoco[k+1][2]=yoco[k][2];
			k--;
		}
		yoco[k+1][0]=j;
		yoco[k+1][1]=cop;
		yoco[k+1][2]=copp;
	}

	for(i=m-1;i>=0;i--){
		if(yoco[i][1]==now) now=yoco[i][2];
		else if(yoco[i][2]==now) now=yoco[i][1];
	}
	printf("%d\n",now);
	}
	return 0;
}

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


void trace(int A[],int N){
    for (int i=0; i<N; i++) {
        if (i<N-1) {
            cout <<A[i]<<" ";
        } else {
            cout <<A[i]<<endl;
        }
    }
}

void insertionSort(int A[],int N){
    int j,i,v;
    for (i=1; i<N; i++) {
        v=A[i];
        j=i-1;
        while (j>=0&&A[j]>v) {
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A, N);
    }
    
}



int main(int argc, const char * argv[]) {
    int A[105];
    int N;
    cin >> N;
    for (int i=0; i<N; i++) {
        cin >>A[i];
    }
    trace(A, N);
    insertionSort(A, N);
    
    return 0;
}



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

using namespace std;
#define int long long 
#define mod 1000000007
#define MOD 226732710
#define N 666666
int arr[N],a[N],b[N];
vector<int> v[N];
signed main(){
	int n,m;
	cin>>n>>m;
	int ans=0;
	for(int i=m;i<=n+1;i++){
		int L=((i)*(i-1)/2);
		int R=((i)*(n+n-i+1)/2);
		//cout<<L<<" "<<R<<'\n';
		ans=(ans+(R-L+1))%mod;
	}
	cout<<ans;
	return 0;
}



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

int main(void){
    int count=0,ans=0;
    char s[300000],t[300000];
    scanf("%s",s);
    for (int i=0; i<strlen(s); i++){
        if (s[i]!='x'){
            t[count]=s[i];
            count++;
        }
    }
    t[count]='\0';
    for (int i=0; i<strlen(t)/2; i++){
        if (t[i]!=t[strlen(t)-1-i]){
            printf("-1\n");
            return 0;
        }
    }
    int n=strlen(s);
    for (int i=0; i<n/2; i++){
        if (s[i]!=s[n-1-i]){
            if (s[i]=='x'){
                ans++;
                n++;
            } else {
                ans++;
                n--;
                i--;
            }
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001

int main() {
    string s, t;
    cin >> s >> t;
    int sn = s.size(), tn = t.size();

    int sub = -1;
    for(int i=0; i<sn-tn+1; ++i) {
        int ptr;
        for(ptr=0; ptr<tn; ++ptr) {
            if (!(s[i+ptr]==t[ptr] || s[i+ptr] == '?')) break;
        }
        if (ptr == tn) sub = i;
    }

    if (sub == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for(int i=0; i<tn; ++i) s[sub+i] = t[i]; 
    for(int i=0; i<sn; ++i) {
        if (s[i] == '?') s[i] = 'a';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m;
  cin >> n >>m;
  vector<string> a(n),b(m);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,m){
    cin >> b[i];
  }
  int isMatch = 1;
  if(n==m){
    rep(i,n)if(a[i] != b[i]) isMatch = 0;
    if(isMatch){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  rep(i,n){
    rep(j,n){
      isMatch = 1;
      if(i > n-m || j > n-m) continue;
      rep(k,m){
        string s = a[i+k].substr(j,m);
        if(s != b[k])isMatch=0;
      }
      if(isMatch){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

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

const int INF = 1001001001;

int n, m, x;
vector<vector<int>> data;

int main() {
  cin >> n >> m >> x;
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) {
    for (int j = 0; j < m + 1; j++) {
      cin >> a[i][j];
    }
  }
  int ans = INF;
  rep(s, 1<<n){
    vector<int> su(m);
    int cost = 0;
    rep(i, n){
      if(s>>i&1){
        // cout << "ok" << endl;
        cost += a[i][0];
        rep(j, m) su[j] += a[i][j + 1];
      }
    }
    // cout << su[0] << " " << su[1] << " " << su[2] << endl;
    bool ok = true;
    rep(i, m) if (su[i] < x) ok = false;
    if(ok) ans = min(ans, cost);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main() {
  int a, b;
  cin >> a >> b;
  for(int i=1; i<=1200;i++) {
    if(a == floor(0.08 * i) && b == floor(0.1 * i)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N = reader.nextInt();
		int[] A = new int[N];
		int first = -1;
		int second = -1;
		for (int i=0; i<N; i++) {
		    A[i] = reader.nextInt();
		    if (A[i] < second) continue;
		    if (first <= A[i]) {
		        second = first;
		        first = A[i];
		    } else {
		        second = A[i];
		    }
		}
		for (int i=0; i<N; i++) {
		    if (A[i] == first) System.out.println(second);
		    else System.out.println(first);
		}
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 71368
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int h, w, a, b;
    cin >> h >> w >> a >> b;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j < a && i < b) {
                cout << 1;
            } else if (j >= a && i >= b) {
                cout << 1;
            } else {
                cout << 0;
            }
        }
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();

        int x = A + (A-1);
        int y = B + (B-1);
        int z = A + B;
        
        System.out.println(Math.max(z, Math.max(x, y)));
    }
}


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

int main(){
    char s[3];
    cin >> s;
    if (s[0]!=s[1] or s[1]!=s[2] or s[2]!= s[0]){
        cout << "Yes" << endl;

    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int h[N];
  for(int i = 0; i < N; i++){
    cin >> h[i];
  }
  int ans = 0;
  int m = 0;
  for(int i = 0; i < N-1; i++){
    if(h[i+1]-h[i] < 0){
      ans += h[i] - h[i+1];
    }
  }
  ans += h[N-1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, A[101010];

bool check(int x) {
    int now = A[x];
    for (int i = 0; i < N; i++) {
        if (i == x)
            continue;
        if (now * 2 >= A[i])
            now += A[i];
        else
            return false;
    }
    return true;
}

void solve() {
    sort(A, A + N);
    int ng = -1;
    int ok = N - 1;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << N - ok << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

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

    solve();
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int b = 0;
    vector<int> c(n);
    for(int i = 0; i < n; i++){
        char ch;
        cin >> ch;
        if(ch == 'R'){
            c[i] = 1;
            b++;
        } else {
            c[i] = 0;
        }
    }
    int lred = 0;
    for(int i = 0; i < n; i++){
        if(c[i] && i < b)
            lred++;
    }
    cout << b - lred << endl;
    return 0;
}

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

signed main(){
  string S,ans="No";
  cin>>S;
  if(S[0]==S[1]&&S[1]==S[2])ans="Yes";
  if(S[1]==S[2]&&S[2]==S[3])ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


S = input().rstrip()

na, a, ab, abc = 1, 0, 0, 0
for s in S:
    if s == 'A':
        a = (a + na) % MOD
    if s == 'B':
        ab = (ab + a) % MOD
    if s == 'C':
        abc = (abc + ab) % MOD
    if s == '?':
        # abc, ab, a, naの順で計算しないと値が上書きされる
        abc = (abc * 3 + ab) % MOD
        ab = (ab * 3 + a) % MOD
        a = (a * 3 + na) % MOD
        na = (na * 3) % MOD

print(abc)


Measured memory_bytes: 3188
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, Y = map(int, readline().split())

    Y //= 1000

    x, y, z = -1, -1, -1
    for i in range(N + 1):
        for j in range(N + 1):
            k = N - i - j
            if k >= 0 and 10 * i + 5 * j + k == Y:
                x, y, z = i, j, k
                break

    print(x, y, z)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8920
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans =0;
	for(int i = 0; i < s.size() - 2; i ++ )
		ans += (s[i] == 'A' && s[i + 1] == 'B'&& s[i + 2] == 'C' );
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
long double chg_DegRad(long double deg) {
	return deg * PI / 180.0;
}

//radian → degree
long double chg_RadDeg(long double rad) {
	return rad * 180.0 / PI;
}
 
//桁数
ll CountDigit(ll n) {
	ll digit = 1;
	while ((n /= 10) != 0) digit++;
	return digit;
}

//距離
double dis(double xa, double ya, double xb, double yb) {
	return pow(pow(xa - xb, 2.0) + pow(ya - yb, 2.0), 0.5);
}

//abs()平均
//pow(,)累乗


//提出コード↓

string s;
bool J = true;

int main() {
	cin >> s;
	if (s[2] != s[3]) J = false;
	if (s[4] != s[5]) J = false;
	if (J) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}



Measured memory_bytes: 256
#include <iostream>

#define V_MAX 100000
#define INF 1L<<61

using namespace std;
using LL = long long;

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

    LL dp[V_MAX + 1];
    fill(dp, dp + V_MAX + 1, INF);
    dp[0] = 0;

    LL w, v;
    for (int i = 0; i < N; i++) {
        cin >> w >> v;
        for (int j = V_MAX; j >= v; j--) {
            dp[j] = min(dp[j], dp[j - v] + w);
        }
    }

    LL ans = 0;

    for (int i = V_MAX; i >= 0; i--) {
        if (dp[i] <= W)
            ans = max(ans, (LL) i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 4050
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    REP(i,n)cin>>v[i];
    map<int,int>p;
    map<int,int>q;
    for(int i=0;i<n;i+=2){
        p[v[i]]++;
    }
    for(int i=1;i<n;i+=2){
        q[v[i]]++;
    }
    P p1,p2;
    P q1,q2;
    for(auto s:p){
        if(p1.second<s.second){
            p2=p1;
            p1=s;
        }else if(p2.second<s.second){
            p2=s;
        }
    }
    for(auto s:q){
        if(q1.second<s.second){
            q2=q1;
            q1=s;
        }else if(q2.second<s.second){
            q2=s;
        }
    }
    int ans=n;
    if(p1.first==q1.first){
        ans-=max(p1.second+q2.second,p2.second+q1.second);
    }else{
        ans-=p1.second+q1.second;
    }
    OUT(ans);
    return 0;
}

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

using namespace std;

int main()
{
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;

    double mxd = 0.00f;

    int sug = 0;
    int ansf = 0;

    double mxc = 0.00f;

    int mxl = 100;


    for(int a=0; a<=mxl; a++)
    {
        for(int b=0; b<=mxl; b++)
        {
            for(int c=0; c<=mxl; c++)
            {
                for(int d=0; d<=mxl; d++)
                {
                    int f = a*100*A
                            + b*100*B
                            + c*C + d*D;

                    int csug = c*C + d*D;

                    int lp = E*(a*100*A
                                + b*100*B);
                    int rp = 100*(c*C + d*D);
                    mxc = (100.00)*(csug)/(1.00*f);


                    if(f<=F && lp>=rp)
                    {
                        //cout<<"aha"<<endl;
                        //cout<<a<<" "<<b<<endl;
                        double curd
                            = (100.00*csug)/((1.00)*(f));

                        if(curd>=mxd)
                        {
                            mxd = curd;
                            ansf = f;
                            sug = csug;
                        }


                    }

                }
            }
        }
    }

    //cout<<mxc<<endl;

    printf("%d %d\n",ansf,sug);
    return 0;
}


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

int main(){
    
    int N;
    int T;
    int maxcost = 10000;
    int maxtime;

    cin>>N>>T;
    for(int i = 0; i < N; i++){
        int c;
        int t;
        cin>>c>>t;
        if(t <= T){
            if(c < maxcost){
                maxcost = c;
            }
        }
    }

    if(maxcost==10000){
        printf("TLE\n");
    }else{
        printf("%d\n", maxcost);
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
vector<pair<int,int> >g[110000];
int v[110000];
long long ijk_L[110000];
long long ijk_R[110000];
 
long long L[110000];
long long R[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	int s,t;scanf("%d%d",&s,&t);s--;t--;
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);p--;q--;
		g[p].push_back(make_pair(q,r));
		g[q].push_back(make_pair(p,r));
	}
	for(int i=0;i<a;i++){
		ijk_L[i]=inf;
	}
	ijk_L[s]=0;
	priority_queue<pair<long long,int> > Q;
	Q.push(make_pair(0LL,s));
	L[s]=1;
	while(Q.size()){
		long long cost=-Q.top().first;
		int at=Q.top().second;
		Q.pop();
		if(v[at])continue;
		v[at]=1;
		for(int i=0;i<g[at].size();i++){
			int to=g[at][i].first;
			long long tmp=cost+g[at][i].second;
			if(!v[to]&&ijk_L[to]>=tmp){
				if(ijk_L[to]>tmp){
					ijk_L[to]=tmp;
					L[to]=L[at];
					Q.push(make_pair(-ijk_L[to],to));
				}else{
					L[to]=(L[to]+L[at])%mod;
				}
			}
		}
	}
	for(int i=0;i<a;i++){
		ijk_R[i]=inf;
		v[i]=0;
	}
	ijk_R[t]=0;
	R[t]=1;
	Q.push(make_pair(0LL,t));
	while(Q.size()){
		long long cost=-Q.top().first;
		int at=Q.top().second;
		Q.pop();
		if(v[at])continue;
		v[at]=1;
		for(int i=0;i<g[at].size();i++){
			int to=g[at][i].first;
			long long tmp=cost+g[at][i].second;
			if(!v[to]&&ijk_R[to]>=tmp){
				if(ijk_R[to]>tmp){
					ijk_R[to]=tmp;
					R[to]=R[at];
					Q.push(make_pair(-ijk_R[to],to));
				}else{
					R[to]=(R[to]+R[at])%mod;
				}
			}
		}
	}
	long long D=ijk_L[t];
	long long ret=L[t]*R[s]%mod;
	long long ng=0;
	for(int i=0;i<a;i++){
		if(ijk_L[i]+ijk_R[i]>D)continue;
		if(ijk_L[i]==ijk_R[i]){
			ng=(ng+L[i]*R[i]%mod*L[i]%mod*R[i])%mod;
		}
		for(int j=0;j<g[i].size();j++){
			if(ijk_L[i]+g[i][j].second+ijk_R[g[i][j].first]==D){
				if((ijk_L[g[i][j].first]>ijk_R[g[i][j].first])&&(ijk_L[i]<ijk_R[i])){
					ng=(ng+L[i]*R[g[i][j].first]%mod*L[i]%mod*R[g[i][j].first])%mod;
				}
			}
		}
	}
	ret=(ret+mod-ng)%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 14064
#include <stdio.h>


int main(){
	int n, a, b, c, count;
	while(scanf("%d", &n) != EOF){
		count = 0;
		for(a = 0; a <= 9; a++){
			if(a == n){
				count++;
				break;
			}
			if(n - a > 27) continue;
			for(b = 0; b <= 9; b++){
				if(a + b == n){
					count++;
					break;
				}
				if(n - (a + b) > 18) continue;
				for(c = 0; c <= 9; c++){
					if(a + b + c == n){
						count++;
						break;
					}
					if(n - (a + b + c) <= 9)	count++;
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main()
{
  int a,b,c = 0;
  cin >> a ;
  cin >> b;
  for (int i = 1; i <= 1000; i++)
  {
    if((int)(i * 0.08) == a && (int)(i * 0.1) == b)
    {
      cout << i << endl;
      c = 1;
      break;
    }
  }
  if(c == 0)
  {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
//        int nLen = String.valueOf(n).length();


        int[][] cnt = new int[9][9];

        int ans = 0;


        for (int i=1; i<=n; i++){
            int nLen = String.valueOf(i).length();

            if (String.valueOf(i).length()==1) {
                cnt[i-1][i-1]++;
                continue;
            }
            int top = i/(int)Math.pow(10, nLen-1);
            int bottom = i%10;
            if (top==0 || bottom==0) continue;
            cnt[top-1][bottom-1]++;
        }

        for (int i=0; i<9; i++){
            for (int j=0; j<9; j++){
                ans += cnt[i][j]*cnt[j][i];
            }
        }
        System.out.println(ans);

    }
}


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

int main() {
  char c;
  cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<int>> matrix;
const int64_t m = 1e18;
void solve()
{
    ll a;
    string b;
    cin >> a >> b;
    ll n = b.length();
    ll sum = 0;
    fr(i, n)
    {
        if (b[i] == '.')
            continue;
        sum = sum * 10 + (b[i] - '0');
    }
    a = a * sum / 100;
    cout << a << endl;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL K, X;
	in >> K >> X;
	out << (500 * K >= X ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
N = gets.chomp.to_i

note = []

N.times{|n|
  s, p = gets.chomp.split(" ")
  p = p.to_i
  note[n] = [s, p, n + 1]
}

note.sort_by!{|n| n[1]}.reverse!.sort_by!{|n| n[0]}

note.each{|n|
  puts n[2]
}


Measured memory_bytes: 1788
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    int res=0;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
        if(i != minj) res++;
        swap(a[i],a[minj]);
    }
    for(int i=0;i<n-1;i++) cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
    cout<<res<<endl;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e9;
ll power(ll x, ll n, ll mod)
{
  ll res = 1;
  x %= mod;
  while (n)
  {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll c=0;
  ll a,b,d;
  cin>>a>>b>>d;
  for(ll i=a;i<=b;i++)
  {
    if(i%d==0)
      c++;
  }
  cout<<c;
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int count=0;
    for(char i:s){
        if(i=='C'&&count==0) count++;
        if(i=='F'&&count==1) count++;
    }
    if(count==2) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
def inpl(): return list(map(int, input().split()))

N, K = inpl()
S = [0]*26
for _ in range(N):
    S[ord(input()[0]) - 65] += 1

ans = 0
while True:
    S = sorted(S, reverse=True)
    s = S[K-1]
    if s == 0:
        break
    ans += 1
    for i in range(K):
        S[i] -= 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <bits/stdc++.h>
                 
using namespace std;
                 
int main(){
  int A, B, C, X;
  int ans = 0;
  cin >> A >> B >> C >> X;
  
  for(int i = 0; i<= A; i++){
    for(int j = 0; j<= B; j++){
      for(int k = 0; k<= C; k++){
        if(i * 500 + j * 100 + k *50 == X) ans ++;
      }
    }
  }
  cout << ans;
}

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

using namespace std;

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

    vector<int> b(m);

    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        vector<int> a(m);
        for (int j = 0; j < m; j++) {
            cin >> a[j];
        }

        int x = c;

        for (int j = 0; j < m; j++) {
            x += a[j] * b[j];
        }
        
        if (x > 0) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define sc second
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define rep1(i, n) repi(i, 1, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define sp(n) cout << fixed << setprecision(n)
#define ma(n, o) map<n, o>
#define pr(n, o) pair<n, o>
#define so(n) sort(n.begin(), n.end())
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗

int main() {
  int N, K;
  st S;
  ci(N, K, S);
  S.at(K - 1) += 32;
  co(S);
} 


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from heapq import heappop, heappush
from collections import defaultdict
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n, m = map(int, input().split())

    d = defaultdict(list)
    for _ in range(n):
        a, b = map(int, input().split())
        d[a].append(b)

    s = 0
    c = []
    for i in range(m):
        for j in d[i + 1]:
            heappush(c, -j)
        if c:
            s += -heappop(c)

    print(s)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */


int main() {
#ifdef MY_DEBUG
    while (true) {
#endif

        ll n, k;
        ll ans = 1;
        cin >> n >> k;

        vvl ab(n);
        rep(i, n - 1) {
            ll a, b;
            cin >> a >> b;
            a--, b--;
            ab[a].eb(b);
            ab[b].eb(a);
        }
        vector<bool> seen(n);
        queue<P> que;
        que.push(P(0, k));
        while (!que.empty()) {
            P now = que.front();
            que.pop();

            ans *= now.S;
            ans %= mod;
            seen[now.F] = true;

            ll cost = now.F == 0 ? (k - 1) : (k - 2);
            each(e, ab[now.F]) {
                if (!seen[e]) que.push(P(e, cost--));
            }
        }
        cout << ans << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 8180
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
 
int main(){
    string t="MARCH",s;
   ll n,cnt[5]={0};
   cin>>n;
   lol(i,n){
       cin>>s;
       lol(j,5)if(t[j]==s[0])cnt[j]++;
   }
   ll ans=0;
   lol(i,5){
       for(int j=i+1;j<5;j++){
	   for(int k=j+1;k<5;k++){
	       ans+=cnt[i]*cnt[j]*cnt[k];
	   }
       }
   }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll a[3][3];
	rep(i,3) rep(j,3) cin >> a[i][j];
	set<ll> se;
	ll n; cin >> n;
	rep(i,n){
		ll b; cin >> b;
		se.insert(b);
	}
	ll c[3][3] = {};
	rep(i,3){
		rep(j,3){
			if(se.find(a[i][j]) != se.end()) c[i][j] = 1;
			else c[i][j] = 0;
		}
	}
	if(c[0][0]&&c[1][1]&&c[2][2]) puts("Yes");
	else if(c[0][2]&&c[1][1]&&c[2][0]) puts("Yes");
	else{
		bool flag = false;
		rep(i,3){
			rep(j,3){
				if(!c[i][j]) break;
				if(j==2){
					puts("Yes");
					return 0;
				}
			}
		}
		rep(j,3){
			rep(i,3){
				if(!c[i][j]) break;
				if(i==2){
					puts("Yes");
					return 0;
				}
			}
		}
		puts("No");
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int N,M;
  int A[1000]={0};
  scanf("%d %d",&N,&M);
  int i;
  double sum=0;
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    sum+=A[i];    
  }
  int num=0,flag=0;
  double n;
  n=sum/(4*M);
  for(i=0;i<N;i++){
  	if(A[i]>=n){
      num++;
      if(num>=M){
        flag=1;
      }
  	}
  }
  if(flag==1)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 1712
# coding: utf-8
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(0,A+1):
    for b in range(0,B+1):
        for c in range(0,C+1):
            if (500 * a + 100 * b + 50 * c) == X:
                count += 1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define GODSPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;
int add(int a,int b){return (a%mod + b%mod)%mod;}
int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a,int b){return (a%mod * b%mod)%mod;}
int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
signed main()
{
    GODSPEED;
    int n;
    cin>>n;
    cout<<n*(n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256