akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		String sl = s.next();
		String[] sa = new String[4];

		for (int i = 0; i < 4; i++) {
			sa = sl.split("");
		}

		int a = Integer.parseInt(sa[0]);
		int b = Integer.parseInt(sa[1]);
		int c = Integer.parseInt(sa[2]);
		int d = Integer.parseInt(sa[3]);

		if ((a == b && b == c) || (b == c && c == d)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
using System;

public class Program
{
  private static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    
    double a = double.Parse(input[0]);
    double b = double.Parse(input[1]);
    double x = double.Parse(input[2]) / a;
    
    double angle;
    
    if(x <= (a * b) / 2)
      angle = 180 / Math.PI * Math.Atan(b / ((x * 2) / b));
    else
      angle = 90 - 180 / Math.PI * Math.Atan(a / (((a * b - x) * 2) / a));
    
    Console.WriteLine(angle);
  }
}
 

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort(v.begin(), v.end())
#define veci(a, n) vector<int> a(n)
#define vecs(a, n) vector<string> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define sp(n) cout << setprecision(n) << fixed

long long lucdp [86];
long long lucas(int n){
    if(n == 0) return 2;
    else if(n == 1) return 1;
    else if(lucdp[n] !=0) return lucdp[n];
    return lucdp[n] = lucas(n-1) + lucas(n-2);
}

int main(){
    long long N;
    cin >> N;
    cout << lucas(N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll gcd (ll p, ll q) {
  if (q == 0) return p;
  return gcd(q, p % q);
}

void solve () {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a < b) {
    cout << "No" << '\n';
    return;
  }
  
  if (d < b) {
    cout << "No" << '\n';
    return;
  }
  
  if (b <= c) {
    cout << "Yes" << '\n';
    return;
  }

  c %= b;
  a %= b;
  d = gcd(b, d);

  // find least x s.t. a + kd = x, and x > c
  if (a > c) {
    cout << "No" << '\n';
    return;
  }

  ll k = (c - a) / d + 1;
  ll x = a + k * d;
  if (x >= b) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}

int main () {
  ios::sync_with_stdio(false);

  int testc;
  cin >> testc;

  for (int t = 0; t < testc; t++) {
    solve();
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa

using namespace std;

const int maxn = (1<<18), maxq = 100000, spr = (1<<9);
int v[maxn+5], w[maxn+5], d[maxq+5][spr+5], dep[maxn+5], lg[maxn+5], nod[maxq+5], l[maxq+5];
pii ds[spr+5];

///d[w][nod] = valoare maxima pt lant nod, greutate = w
///!! nod se afla in PRIMA jumatate a adancimii arborelui binar
///-- SMEN SPRANCEANA GROASA
///faci asa: rucsac traditional pentru prima jumatate a adancimii
///si completezi cu dinamica pe stari pentru ultima jumatate (O(2^sz)!! nu O(sz*2^sz))
///asa ai aceeasi complexitate pe ambele jumatati

void umax (int &a, int b) {
  a = max(a, b);
}

int lsb (int x) {
  return x&(-x);
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z;
  for (i = 2; i <= maxn; i++) lg[i] = lg[i>>1] + 1; ///!!e de la DOI nu UNU
  for (i = 1; i <= n; i++) cin >> v[i] >> w[i];
  int md = lg[n]/2+1, q, nn, ml = 0; cin >> q; ///<-- +1 de la md daunator? NU, gresisei lg...
  for (i = 1; i <= q; i++) {
    cin >> nod[i] >> l[i];
    umax(ml, l[i]);
  }
  for (i = 1; i <= n; i++) {
    dep[i] = dep[i>>1] + 1;
    if (dep[i] <= md) {
      for (z = 1; z <= ml; z++) d[z][i] = d[z][i>>1];
      for (z = ml; z >= w[i]; z--) umax(d[z][i], d[z-w[i]][i] + v[i]);
      for (z = 1; z <= ml; z++) umax(d[z][i], d[z-1][i]);
    }
  }
  vi u;
  for (z = 1; z <= q; z++) {
    nn = nod[z];
    u.clear();
    while (dep[nn] > md) {
      u.pb(nn);
      nn >>= 1;
    }
    fill (ds, ds+(1<<sz(u)), pii(0, 0));
    int ans = 0, conf;
    for (conf = 0; conf < 1<<sz(u); conf++) {
      i = conf - lsb(conf); ///lsb sau dfs ca sa scapi de sz din O(sz*2^sz)
      j = (conf? u[lg[lsb(conf)]]: 0); /// fara -1
      ds[conf] = pii(ds[i].fi + v[j], ds[i].se + w[j]);
      if (ds[conf].se <= l[z]) umax(ans, ds[conf].fi + d[l[z]-ds[conf].se][nn]);
    }
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 210420
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323

ll dp[404][404], a[404], sum[404];

void solve()
{
       ll n;
       cin>>n;
       rep(i,1,n+1) cin>>a[i];
       sum[0]=0;
       rep(i,1,n+1) sum[i] = sum[i-1]+a[i];
       for(ll l=n; l>0; l--){
              for(ll r=l; r<=n; r++){
                     if(l==r) dp[l][r] = 0;
                     else
                     {
                            dp[l][r] = inf;
                            ll s = sum[r] - sum[l-1];
                            for(ll i=l; i<r; i++)
                                   dp[l][r] = min(dp[l][r], dp[l][i] + dp[i+1][r] + s);
                     }
              }
       }
       cout<<dp[1][n]<<endl;
}

int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


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

int main(){
  char c;
  cin >> c;
  if (c <= 'Z'){
    cout << 'A' << endl;
  }else{
    cout << 'a' << endl;
  }
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	x=N;
	y=0;
	while(x) {
		y+=x%10;
		x/=10;
	}
	
	if(N%y==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define call(x) (x).cbegin(), (x).cend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
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 (b<a) {a=b; return 1;} return 0;}
const int INF = INT_MAX;
const int MOD = 1000000007;
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int main() {
    int N;
    cin >> N;
    vll dp(100500, INF);
    dp[0] = 0;
    reps(i, N) {
        int j = 0;
        while (i - pow(6, j) >= 0) {
            chmin(dp[i], dp[i - pow(6, j)] + 1);
            j++;
        }
        j = 0;
        while (i - pow(9, j) >= 0) {
            chmin(dp[i], dp[i - pow(9, j)] + 1);
            j++;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1152
N,x = gets.split.map(&:to_i)
a = gets.strip.split.map(&:to_i)
answer = 0

for i in 0..N-2

    if a[i+1] + a[i] > x
        
        answer += a[i+1] + a[i] - x
        
        if a[i+1] >= a[i+1] + a[i] - x

            a[i+1] -= a[i+1] + a[i] - x

        else

            a[i+1] = 0
            a[i] -= a[i] - x

        end

    end

end

puts answer 

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

int main(){
    int n,m;
    cin>>n>>m;
    int b,s,l=0,r=1000000;
    rep(i,m){
        cin>>s>>b;
        l=max(s,l);
        r=min(b,r);
    }
    int ans=min(n-l+1,r-l+1);
    if(ans>=0)cout<<ans<<endl;
    else cout<<'0'<<endl;
    return 0;
}

Measured memory_bytes: 3584
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let a = read::<i32>();
    let b = read::<i32>();
    let c = read::<i32>();
    if a == b && b == c {
        println!("1");
    } else if a == b || b == c || c == a {
        println!("2");
    } else {
        println!("3");
    }
}


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

int main(){
  string s,t,u;
  int a,b;
  cin >>s>>t>>a>>b>>u;
  
  if(s.size()==u.size() && s==u)
    cout << a-1 << " " << b << endl;
  else
    cout << a << " " << b-1 << endl;
  
  return 0;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int m;
vector<ll> dp;
vector<vector<int>> edges;
vector<vector<P>> d;

ll dfs1(int i,int p = -1) {
    ll ret = 1;
    for (int j : edges[i]) if (j != p) {
        ll a = dfs1(j,i)+1;
        d[i].push_back(P(a,j));
        ret *= a;
        ret %= m;
    }
    return ret;
}

void dfs2(int i,ll p_res = 1,int p = -1) {
    if (p != -1) d[i].push_back(P(p_res+1,p));
    int n = d[i].size();
    vector<ll> prod_l(n+1,1),prod_r(n+1,1);
    for (int x = 0;x < n;++x) {
        prod_l[x+1] = prod_l[x]*d[i][x].first%m;
        prod_r[n-1-x] = prod_r[n-x]*d[i][n-1-x].first%m;
    }
    dp[i] = prod_r[0];
    for (int j = 0;j < n;++j) {
        int x = d[i][j].second;
        if (x != p) dfs2(x,prod_l[j]*prod_r[j+1]%m,i);
    }
}

int main() {
    int n;
    cin >> n >> m;
    edges.resize(n);
    d.resize(n);
    dp.resize(n);
    for (int i = 0;i < n-1;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    dfs1(0);
    dfs2(0);
    for (int i = 0;i < n;++i) cout << dp[i] << "\n";
    return 0;
}

Measured memory_bytes: 26624
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main()
{
	cin >> s;
	REP(i, 4) cout << s[i];
	cout << " ";
	REP(i, s.size() - 4) cout << s[i + 4];
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<chrono>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;

int main() {
	cin >> N >> M >> Q;
	vector<vector<int>>t(N + 1, vector<int>(N + 1, 0));
	vector<vector<int>>c(N + 1, vector<int>(N + 1, 0));
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		t[L][R]++;
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			c[i][j] = c[i][j - 1] + t[i][j];
		}
	}
	vector<int>res;
	for (int x = 0; x < Q; x++) {
		int p, q;
		cin >> p >> q;
		int tmp = 0;
		for (int i = p; i <= q; i++) {
			tmp += c[i][q] - c[i][p - 1];
		}
		res.push_back(tmp);
	}
	for (int i : res)cout << i << endl;
}

Measured memory_bytes: 3452
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>

using namespace std;
const int64_t INF=10000000000000000;
struct Person{
	vector<int64_t> block_list;
	vector<int64_t> friend_list;
	bool issearched=false;
	set<int64_t> *friend_candidate;
};

void search_connected(Person* SNS,int64_t begin_index){
	set<int64_t> *answer=new set<int64_t>();
	std::queue<int64_t> q;
	q.push(begin_index);
	answer->insert(begin_index);
	SNS[begin_index].friend_candidate=answer;
	while(!q.empty()){
		int64_t temp_index = q.front();
		q.pop();
		if(!SNS[temp_index].issearched){
			SNS[temp_index].issearched=true;
			answer->insert(temp_index);
			SNS[temp_index].friend_candidate=answer;
			for(auto i1=SNS[temp_index].friend_list.begin();i1!=SNS[temp_index].friend_list.end();i1++){
				if(!SNS[*i1].issearched){
					q.push(*i1);
				}

			}
		}
	}

}
int main(){
	int64_t n,m,k;
	cin>>n>>m>>k;
	Person *SNS=new Person[n];
	for(int64_t i1=0;i1<m;i1++){
		int64_t p1,p2;
		cin>>p1>>p2;
		SNS[p1-1].friend_list.push_back(p2-1);
		SNS[p2-1].friend_list.push_back(p1-1);
	}
	for(int64_t i1=0;i1<k;i1++){
		int64_t p1,p2;
		cin>>p1>>p2;

		SNS[p1-1].block_list.push_back(p2-1);
		SNS[p2-1].block_list.push_back(p1-1);
	}
	for(int64_t i1=0;i1<n;i1++){
		if(!SNS[i1].issearched){
			search_connected(SNS,i1);
		}
	}
	for(int64_t i1=0;i1<n;i1++){
		int64_t temp_ans = SNS[i1].friend_candidate->size()-SNS[i1].friend_list.size()-1;
		for(auto p1=SNS[i1].block_list.begin();p1!=SNS[i1].block_list.end();p1++){
			if(SNS[i1].friend_candidate->find(*p1)!=SNS[i1].friend_candidate->end()){
				temp_ans--;
			}
		}
		cout<<temp_ans<<" ";
	}
	cout<<endl;

}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;


template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n;
  cin >> n;
  vector<P> inc, dec;
  int total = 0;
  rep(i, n) {
    string s;
    cin >> s;
    int now = 0;
    int min = 0;
    for(auto c : s) {
      if(c == '(') ++now; else --now;
      chmin(min, now);
    }
    if(now > 0) inc.emplace_back(min, now);
    else dec.emplace_back(min-now, -now);
    total += now;
  }

  sort(inc.rbegin(), inc.rend());
  sort(dec.rbegin(), dec.rend());

  auto check = [&](vector<P> vec) {
    int now = 0;
    for(auto v : vec) {
      if(now+v.first < 0) return false;
      now += v.second;
    }
    return true;
  };

  if(check(inc) && check(dec) && total == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

const int N=200010,mo=int(1e9+7);
struct edge{int s,t,w,n;}e[2*N];
int n,h[N],fac[N],ifac[N],vis[N],f[N],siz[N],ecnt,cnt,S,p,ans,res;

int qpow(int a,int b)
{
	int x=a;  a=1;
	while (b)
		{
			if (b&1)  a=1LL*a*x%mo;
			x=1LL*x*x%mo,b>>=1;
		}
	return a;
}

int C(int n,int m){return 1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo;}

void dfs(int x,int fa)
{
	vis[x]=1,cnt++;
	for (int i=h[x],y; y=e[i].t,i; ecnt++,i=e[i].n)
		if (!vis[y])  f[y]=i,dfs(y,x);
		else  if ((y!=fa)&&(!S)) S=i;
}

void dfs2(int x,int fe)
{
	siz[x]=0,f[x]=1;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if ((i!=fe)&&((i^p)>1))
			{
				dfs2(y,i^1);
				if (e[i].w>e[fe].w)  res=1LL*res*ifac[siz[y]]%mo*f[y]%mo;
				else  siz[x]+=siz[y],f[x]=1LL*f[x]*f[y]%mo*C(siz[x],siz[y])%mo;
			}
	siz[x]++;
}

void work()
{
	scanf("%d",&n),fac[0]=1;
	for (int i=1; i<=2*n; i++)  fac[i]=1LL*fac[i-1]*i%mo;
	ifac[2*n]=qpow(fac[2*n],mo-2);
	for (int i=2*n; i; i--)  ifac[i-1]=1LL*ifac[i]*i%mo;
	for (int i=1,x,y,tot=1; i<=2*n; i++)
		{
			scanf("%d %d",&x,&y),y+=n;
			e[++tot]=(edge){x,y,x+y,h[x]},h[x]=tot;
			e[++tot]=(edge){y,x,x+y,h[y]},h[y]=tot;
		}
	ans=fac[2*n];
	for (int i=1,s; i<=2*n; i++)
		if (!vis[i])
			{
				ecnt=cnt=S=s=0,dfs(i,0);
				if (cnt!=ecnt/2)  puts("0"),exit(0);
				p=S;
				for (int j=S; e[j].s!=e[S].t; j=f[e[j].s],p=(e[p].w<e[j].w?j:p));
				res=1,dfs2(e[p].s,p),s+=1LL*ifac[siz[e[p].s]]*f[e[p].s]%mo*res%mo;
				res=1,dfs2(e[p].t,p),s+=1LL*ifac[siz[e[p].t]]*f[e[p].t]%mo*res%mo;
				ans=1LL*ans*s%mo;
			}
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


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


int main ()
{

 int A,B,C;
 cin >> A >> B >> C;
 
 if(C-(A-B)>=0)
 {
 cout << C-(A-B) << endl;
}
else
{
	cout << "0" << endl;
}
	return 0;
}











Measured memory_bytes: 3172
from collections import deque

H,W = list(map(int,input().split()))
D_h = {}
D_w = {}

for h in range(H):
    D_h[h]=deque([-1])
    
for w in range(W):
    D_w[w]=deque([-1])
    
for h in range(H):
    D = list(input())
    for w in range(W):
        if D[w] =='#':
            D_h[h].append(w)
            D_w[w].append(h)
            
    D_h[h].append(W)
    
for w in range(W):
    D_w[w].append(H)
    
Lamp_h = [ [0] * W  for h in range(H) ]

for d_h in D_h.keys():
    obst = D_h[d_h]
    for o_ed in range(1,len(obst)):
        o_st = o_ed-1
        
        o_st = obst[o_st]
        o_ed = obst[o_ed]
        
        for o in range(o_st+1,o_ed):
            Lamp_h[d_h][o] = o_ed-1 - o_st
    
Lamp_w =  [ [0] * H  for w in range(W) ]
for d_w in D_w.keys():
    obst = D_w[d_w]
    for o_ed in range(1,len(obst)):
        o_st = o_ed-1
        
        o_st = obst[o_st]
        o_ed = obst[o_ed]
        
        for o in range(o_st+1,o_ed):
            Lamp_w[d_w][o] = o_ed-1 - o_st
    
ans = 0
for h in range(H):
    for w in range(W):
        ans_ = Lamp_h[h][w] + Lamp_w[w][h] 
        if ans < ans_:
            ans =ans_
        
print(ans-1)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	ll A, B, K; cin >> A >> B >> K;

	for (ll i = 0;i < K;i++){
		if(A+i > B) continue;
		cout << A+i << endl;
	}

	for (ll i = 0;i < K;i++){
		if(B-K+i+1 < A+K) continue;
		cout << B-K+i+1 << endl;
	}

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  int a,b;
  cin >> a>>b;
  
  int ans=0;
  
  rep(i,a) {
    int x;
    cin >> x;
    if(x>=b) ans++;
  }
  
  cout << ans << endl;       
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<v[_]<<" ";cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")


int n,now;
vvi G;
vi in,out;
void dfs(int a,int p){
  rep(i,G[a].size())if(G[a][i]-p)
    dfs(G[a][i],a);
  out[a]=in[now++];
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

  cin>>n;
  G=vvi(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  in=out=vi(n);
  rep(i,n)cin>>in[i];
  sort(all(in));

  dfs(0,-1);
  int sum=0;
  rep(i,n-1)sum+=in[i];
  cout<<sum<<endl;
  show1d(out);
}


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

int main(){
  int N,cnt=0;
  cin>>N;
  vector<int> X(N);
  for(int i=0;i<N;i++) cin>>X[i];
  for(int i=1;i<N-1;i++){
    if(X[i-1]<X[i]&&X[i]<X[i+1]) cnt++;
    else if(X[i-1]>X[i]&&X[i]>X[i+1]) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  int P1, P2;
  cin >> N >> A >> B;
 
  P1 = A * N;
  P2 = B;

  if (P1 >= P2) {
    cout << P2 << endl;
  }
  else {
    cout << P1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  if(s[0]=='A')cout<<'T'<<endl;
  if(s[0]=='T')cout<<'A'<<endl;
  if(s[0]=='G')cout<<'C'<<endl;
  if(s[0]=='C')cout<<'G'<<endl;
}

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

const int nmax = 10000000;
char nums[nmax];

int main(){
	int n;
	for(int i = 2; i < nmax; i++){
		nums[i] = '1';
	}
	for(int i = 2; i * i < nmax; i++){
		if(nums[i] == '1'){
			for(int k = 2; k * i < nmax; k++){
				nums[i*k] = '0';
			}
		}
	}
	while(cin >> n){
		if(n == 0) break;
		int i = n;
		while(nums[i] == '0' || nums[i-2] == '0' || nums[i-6] == '0' || nums[i-8] == '0') i--;
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 10000
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int Q = scanner.nextInt(); //0.25L
        int H = scanner.nextInt(); //0.5 L
        int S = scanner.nextInt(); //1   L
        int D = scanner.nextInt(); //2   L
        int N = scanner.nextInt();
        
        double lack = N;
        long cost = 0;
        //System.err.println("2L");
        //System.err.println(2L * S + "\n" + D + "\n");
        //System.err.println(4L * H + "\n" + D + "\n");
        //System.err.println(8L * Q + "\n" + D + "\n");
        if(2L * S >= D && 4L * H >= D && 8L * Q >= D) {
            //System.err.println("2L:" + (int)(lack / 2));
            //System.err.println(lack % 2);
            cost += D * (long)(lack / 2L);
            lack = lack % 2;
        }
        //System.err.println("1L");
        //System.err.println(2L * H + "\n" + S + "\n");
        //System.err.println(4L * Q + "\n" + S + "\n");
        if(2L * H >= S && 4L * Q >= S) {
            //System.err.println("1L: " + (int)(lack / 1));
            //System.err.println(lack % 1);
            cost += S * (long)(lack / 1L);
            lack = lack % 1;
        }
        //System.err.println("0.5L");
        //System.err.println(2L * H + "\n" + H + "\n");
        if(2L * Q >= H) {
            //System.err.println("0.5L: " + (int)(lack / 0.5));
            //System.err.println(lack % 0.5);
            cost += H * (long)(lack * 2L); //lack / 0.5
            lack = lack % 0.5;
        }
        {
            //System.err.println("0.25L: " + (int)(lack / 0.25));
            //System.err.println(lack % 0.25);
            cost += Q * (long)(lack * 4L); //lack / 0.25
            lack = lack % 0.25;
        }
        assert lack == 0;
        System.out.println(cost);
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
int main(){
  ll n;
  scanf("%lld",&n);
  ll num2=0,num4=0,numo=0;
  rep(i,n){
    ll num;
    scanf("%lld",&num);
    if( num%2 != 0 ){
      numo++;
    }else{
      if( num%4 == 0 ){
        num4++;
      }else{
        num2++;
      }
    }
  }
  
  if( numo <= num4 || ( n%2 == 1 && numo - num4 == 1 ) ){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
// *start on @date: 2020-02-16 20:23 
using namespace std;
typedef long long ll;
const int maxn = 1000 + 5;
const int inf  = 0x3f3f3f3f;




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

    int n[10],m,k;
    
    int t = 3;
    set<int> s;
    while (t--)
    {
        cin>>m;
        s.insert(m);
    }

    if(s.size() == 2){
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    ops = [i for i in range(len(s) - 1)]

    powset = []
    for i in range(1 << len(ops)):
        powset.append([ops[j] for j in range(len(ops)) if ((i >> j) & 1) == 1])

    # print(powset)

    expressions = []
    for places in powset:
        f = ''
        for i, char in enumerate(s):
            if i in places:
                f += char + '+'
            else:
                f += char
        expressions.append(f)

    # print(expressions)

    total = sum(map(eval, expressions))
    print(total)


main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	int n=nxi(),q=nxi();
	if(q==0){
		printf("%lld\n",(lint)n*n);
		return 0;
	}
	lint ans=0;
	for(int i=q; i<=n; ++i){
		//fprintf(stderr,"%d: %d\n",i,(n/i)*(i-q)+std::max(0,n%i-q+1));
		ans+=(n/i)*(i-q)+std::max(0,n%i-q+1);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
f = lambda: map(int,input().split())
h,w = f()
a = [list(f()) for _ in range(h)]
for i in range(h):
    if i%2 == 0:
        a[i].reverse()

count = 0
ans = []

for i in range(h):
    for j in range(w):
        if i == h-1 and j == w-1:
            break
        if i&1:
            if a[i][j]&1:
                count += 1
                if j == w-1:
                    ans.append([i+1,w,i+2,w])
                    a[i+1][0] += 1
                else:
                    ans.append([i+1,j+1,i+1,j+2])
                    a[i][j+1] += 1
        else:
            if a[i][j] & 1:
                count += 1
                if j == w - 1:
                    ans.append([i + 1, 1, i + 2, 1])
                    a[i+1][0] += 1
                else:
                    ans.append([i+1, w-j, i+1, w-j-1])
                    a[i][j+1] += 1
print(count)
for i in range(count):
    print(*ans[i])



Measured memory_bytes: 30248
package main

import "fmt"

func main() {
	var a, b, N, c int
	var A, B []int
	fmt.Scan(&N)

	for i := 0; i < N; i++ {
		fmt.Scan(&a, &b)
		A = append(A, a)
		B = append(B, b)
	}

	ans := 0

	for i := 1; i <= N; i++ {
		c = (B[N-i] - (A[N-i]+ans)%B[N-i])
		if c != B[N-i] {
			ans += c
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6528
import Control.Applicative
import Control.Monad
import Data.Maybe
import Data.List

main = read . head . words <$> getLine >>= flip replicateM getLine >>= mapM_ (putStrLn . unwords . map (show . fromMaybe (-1)) . tail . scanl f Nothing)
  where
    f _ 'c' = Just 0
    f m '.' = (+1) <$> m


Measured memory_bytes: 4560
N,M = map(int,input().split())
A = set(int(input()) for _ in range(M))
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))

Measured memory_bytes: 469812
#include <string>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    string S;
    int K;
    cin >> K >> S;

    if (S.length() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) + "..." << endl;
    }

    return 0;
}

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

int main() {
  int H, W, count;
  cin >> H >> W;
  
  vector<char> vec((H+2)*(W+2), '_');

  for (int h = 1; h < H+1; h++) {
    for (int w =1; w<W+1;w++){
      cin >> vec.at(w+(W+2)*h);
    }
  }
//  for(int h=0;h<H+2;h++){
//   for(int w=0;w<W+2;w++){
//      cout << vec.at((W+2)*h+w);
//    }
//    cout << endl;
//  }

  for(int h=1;h<H+1;h++){
    for(int w=1;w<W+1;w++){
      if(vec.at((W+2)*h+w)=='.'){
          count=0;
          for(int i=0;i<3;i++){
              for(int j=0;j<3;j++){
                  if(vec.at((W+2)*(h+i-1)+w+j-1)=='#'){
                      count++;
                  }
              }
          }
          int p=(W+2)*h+w;
          if(count==0){vec.at(p)='0';}
          if(count==1){vec.at(p)='1';}
          if(count==2){vec.at(p)='2';}
          if(count==3){vec.at(p)='3';}
          if(count==4){vec.at(p)='4';}
          if(count==5){vec.at(p)='5';}
          if(count==6){vec.at(p)='6';}
          if(count==7){vec.at(p)='7';}
          if(count==8){vec.at(p)='8';}
      }
      cout << vec.at((W+2)*h+w);
    }
    cout << endl;
  }
  
}


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

int main (void){
	long long n,k;
  	cin >> n >> k;
    long long li[1000000];
  	for (long long i=0;i<1000000;i++){
      li[i]=0;
    }
  	for (long long i=0;i<n;i++){
      long long a,b;
      cin>>a>>b;
      li[a]+=b;
    }
  //cout << n << ","<<k<<endl;  	
  long long s =0;
  for (long long i=0;i<1000000;i++){
      s+=li[i];
      if(s>=k){
        cout << i << endl;
        break;
      }
      //cout << li[i] << "," << s << endl;
    }
}




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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int s[3] = {};
    scanf("%d/%d/%d", &s[0], &s[1], &s[2]);
    if(s[0] > 2019){
        print("TBD");
        return 0;
    } else if(s[0] < 2019){
        print("Heisei");
        return 0;
    } else if(s[1] > 4){
        print("TBD");
        return 0;
    } else if(s[1] < 4){
        print("Heisei");
        return 0;
    } else if(s[2] > 30){
        print("TBD");
        return 0;
    } else{
        print("Heisei");
        return 0;
    }
}

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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};



int main(){
	llong int N, in;
	vector<int> b;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> in;
		b.pb(in);
	}
	sort(b.begin(), b.end());
	llong int sum = 0;
	llong int num = b[0];
	llong int cnt = 0;
	for(llong int i = 0; i < N; i++){
		if(num == b[i]) cnt++;
		if(num != b[i]){
			if(cnt >= num) sum += cnt - num;
			else sum += cnt;
			num = b[i];
			cnt = 1;
		}
		if(i == N -1){
			if(cnt >= num) sum += cnt - num;
			else sum += cnt;
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 892
import sys
import math

while True:
    w, h = map(int, sys.stdin.readline().split())
    if w == 0:
        break
    field = [[-2 for i in xrange(h + 2)] for j in xrange(w + 2)]
    white = [[0 for i in xrange(h + 2)] for j in xrange(w + 2)]
    black = [[0 for i in xrange(h + 2)] for j in xrange(w + 2)]
    
    cand_white = []
    cand_black = []
    for i in xrange(h):
        line = raw_input()
        for j in xrange(w):
            if line[j] == 'W':
                field[j + 1][i + 1] = 1
                cand_white.append((j + 1, i + 1))
            elif line[j] == 'B':
                field[j + 1][i + 1] = -1
                cand_black.append((j + 1, i + 1))
            else:
                field[j + 1][i + 1] = 0
    next = [(-1, 0), (1, 0), (0, 1), (0, -1)]
    while len(cand_white) > 0:
        cur_x, cur_y = cand_white.pop()
        for n_x, n_y in next:
            if field[cur_x + n_x][cur_y + n_y] == 0 and white[cur_x + n_x][cur_y + n_y] == 0:
                cand_white.append((cur_x + n_x, cur_y + n_y))
                white[cur_x + n_x][cur_y + n_y] = 1
    while len(cand_black) > 0:
        cur_x, cur_y = cand_black.pop()
        for n_x, n_y in next:
            if field[cur_x + n_x][cur_y + n_y] == 0 and black[cur_x + n_x][cur_y + n_y] == 0:
                cand_black.append((cur_x + n_x, cur_y + n_y))
                black[cur_x + n_x][cur_y + n_y] = 1
    count_black = 0
    count_white = 0
    for i in xrange(h):
        for j in xrange(w):
            if white[j + 1][i + 1] > black[j + 1][i + 1]:
                count_white += 1
            if black[j + 1][i + 1] > white[j + 1][i + 1]:
                count_black += 1
    print count_black, count_white

Measured memory_bytes: 4624
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

long long a[111111],b[111111];
int n,m,numn,numm,i,j,x;
long long ans;

int main()
{
   
    scanf("%d%d",&n,&m);
    
    
    for (i = 0; i < n; ++i) {
        scanf("%d",&x);
        a[i] = x;
    }
    for (i = 0; i < m; ++i) {
        scanf("%d",&x);
        b[i] = x;
    }
    sort(a,a+n);
    sort(b,b+m);
    i=0;j=0;
    a[n]=111111111;
    b[m]=a[n];
    numn=0;
    numm=0;
    ans =0;
    while(i<n||j<m){
        if(a[i]<b[j]){
            ans=ans+a[i]*(m-numm+1);
            //printf("%lld %d\n",a[i],m-numm);
            numn++;
            i++;
        }else{
            ans=ans+b[j]*(n-numn+1);
            //printf("%lld %d\n",b[j],n-numn);
            numm++;
            j++;
        }
    }
    cout <<ans <<endl;

    return 0;
}

Measured memory_bytes: 1920
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SORT(v) sort(all(v))
#define TROS(v) sort(all(v), std::greater<Type>());
#pragma endregion

int main() {
    // template
    string s,t;cin>>s>>t;
    bool ans = false;
    rep(i,s.size()){
        if(s==t) ans=true;
        s=s.back()+s.substr(0,s.size()-1);
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}


Measured memory_bytes: 3612
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(double base, ll power){
	if (power == 1) return base;
	if (power % 2 == 0) return fast_power((base*base), power / 2);
	else return(base*fast_power((base*base), power / 2));
}
//#pragma warning (disable : 4996)
void Qalbaz()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
}

int a, b, c, x;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int sum = 0, ans = 0, s1, s;
	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++)
			{
				s = i * 500 + j * 100 + k * 50;
				if (s == x)
					ans++;
			}
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
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));

        try{
//          ?????°????????????????????????????§????????????????????????????????????????1???????????????????????????????????????
            while(true){

                String input = br.readLine();
                String[] strArray = input.split(" ");

                int a = Integer.parseInt(strArray[0]);
                String op = strArray[1];
                int b = Integer.parseInt(strArray[2]);

                int ans = 0;

//              op???"?"?????¨??????????????????
                if(op.equals("?")){
                    break;
                }

                if(op.equals("+")){
                    ans = a + b;
                }
                if(op.equals("-")){
                    ans = a - b;
                }
                if(op.equals("*")){
                    ans = a * b;
                }
                if(op.equals("/")){
                    ans = a / b;
                }
                System.out.println(ans);
            }

        }catch(ArithmeticException ex){
                System.err.println(ex);
        }
    }
}

Measured memory_bytes: 24148
n = int(input())
p = [i for i in map(int,input().split())]
ans = 0
for i in range(1,n-1):
  if p[i-1] < p[i] and p[i] < p[i+1]:
    ans += 1
  elif p[i+1] < p[i] and p[i] < p[i-1]:
    ans += 1
    
print(ans)

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n)cin>>a[i];

	k = min(50,k);
	rep(j,k){
		vector<int> l(n), r(n);
		priority_queue<int, vector<int>, greater<int>> que;
		int L = 0, R = 0;
		rep(i,n){
			while(que.size() && que.top() < (i + 1)){
				L--;
				que.pop();
			}
			l[i] = L;
			L++;
			que.push((i+1)+a[i]);
		}

		priority_queue<int> que2;
		for(int i = n - 1; i >= 0; i--){
			while(que2.size() && que2.top() > (i + 1)){
				R--;
				que2.pop();
			}
			r[i] = R;
			R++;
			que2.push((i+1)-a[i]);
		}
		rep(i,n){
			a[i] = l[i] + r[i] + 1;
		}
	}
	for(auto x: a){
		cout << x << " ";
	} cout << endl;
}


Measured memory_bytes: 8204
#include<stdio.h>
int main(void)
{
    int a,b,c,i,j,x;
    while(scanf("%d %d %d",&a,&b,&c)!=EOF){
        x=20-a-b;
        j=0;
        for(i=1;i<11;i++){
            if(i != a && i != b && i != c){
               if(i <= x)
                   j++;
            }
        }
        if(j>3)
            printf("YES\n");
        else
            printf("NO\n");
    }
  return 0;
}

Measured memory_bytes: 2512
function f(N,dp,A,C)
	for i=1:2^N
		id=i-1
		dp[(id|C)+1]=min(dp[(id|C)+1],dp[i]+A)
	end
	dp
end
function main()
	N,M=map(x->parse(Int,x),split(readline()))
	dp=ones(Int,2^N)*1145141919
	dp[1]=0
	for i=1:M
		A,b=map(x->parse(Int,x),split(readline()))
		C=0
		for c=map(x->parse(Int,x),split(readline()))
			C+=1<<(c-1)
		end
		dp=f(N,dp,A,C)
	end
	ans=dp[end]
	println(ans < 1145141919 ? ans : -1)
end
main()


Measured memory_bytes: 169940
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int N = one.get(0);
		int K = one.get(1);
		long output = 0;
		ArrayList<Integer> list = nextIntArray();
		Collections.sort(list, Comparator.reverseOrder());
		for(int i = K; i < N; i++){
			output += list.get(i);
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 64024
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: -int(x), input().split()))
heapq.heapify(a)
for i in range(m):
    x = heapq.heappop(a)
    heapq.heappush(a, -1 * (-x // 2))
print(-1 * sum(a))


Measured memory_bytes: 14180