akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn._
object Main extends App {

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val bits = readLine.trim.split(' ').map(_.toInt).toRunLength
  val target = readLine.trim.split(' ').map(_.toInt).toList
  println(solve(bits, target))

  def solve(from: List[Int], to: List[Int]): Int = {
    def swap(from: List[Int], to: List[Int]): Option[Int] = {
      (from, to) match {
        case (Nil, Nil) ⇒ Some(0)
        case (0::t, _) ⇒ straight(t, to)
        case (_, 0::t) ⇒ straight(from, t)
        case (ff::fs::ft, tf::tt) if tf < fs ⇒ straight(ff::fs-tf::ft, tt).map(_ + tf * ff)
        case (ff::fs::ft::fr, tf::tt) ⇒ swap(ff+ft::fr, tf-fs::tt).map(_ + fs * ff)
        case (ff::fs::Nil, tf::tt) ⇒ swap(ff::Nil, tf-fs::tt).map(_ + fs * ff)
        case _ ⇒ None
      }
    }
    def straight(from: List[Int], to: List[Int]): Option[Int] = {
      (from, to) match {
        case (Nil, Nil) ⇒ Some(0)
        case (0::t, _) ⇒ swap(t, to)
        case (_, 0::t) ⇒ swap(from, t)
        case (ff::ft, tf::tt) if ff <= tf ⇒ swap(ft, tf - ff::tt)
        case (ff::ft, tf::tt) ⇒ swap(ff-tf::ft, tt)
        case _ ⇒ None
      }
    }
    List(swap(from, to), straight(from, to)).flatten.min
  }
  implicit class ArrayWrapper(val value: Array[Int]) {
    def toRunLength: List[Int] = {
      var last = 0
      var result = Nil: List[Int]
      for (i ← value.indices.tail){
        if (value(i) != value(i - 1)) {
          result ::= i - last
          last = i
        }
      }
      (value.size - last::result).reverse
    }
  }
  implicit class Wrapper[T](val value: List[T]) {
    def minOption(implicit ord: Ordering[T]): Option[T] = {
      if (value.isEmpty) None
      else Some(value.min)
    }
  }
  implicit class Extension[T](val value: T) extends AnyVal {
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
    @inline def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


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


int main(){
    int n,m,a[100000],sum=0;
    cin >> n >> m;
    for (int i = 0;i<m;i++){
        cin >> a[i];
    }
    for(int i = 0;i < m;i++){
        sum += a[i];
    }
    if (sum <= n)
        cout << n - sum <<endl;
    else
    {
            cout << "-1" << endl;    }
    

}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define pb emplace_back
#define inf (int)1e9
#define ff first
#define ss second
#define ll long long
#define sp(n) cout << setprecision(n) << fixed
#define hellcat ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define give(x) cout << #x << " " << x << endl
#define debug cout << "dddd" << '\n'
#define debarr(a, n) for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

template <class S, class T>
inline S smax(S &l, T r) {
  return l = max(l, (S)r);
}
template <class S, class T>
inline bool smin(S &l, T r) {
  return l = min(l, (S)r);
}

const int MAXN = 1e5 + 10;
ll a[MAXN];

int32_t main () {
  hellcat;

	int n = 100;
	
	a[0] = n;
	for (int i = 1; i < MAXN; ++i)
		a[i] = a[i - 1] + (a[i - 1] / 100);

	ll x;
	cin >> x;

	for (int i = 0; i < MAXN; ++i)
		if (x <= a[i]) {
			cout << i << '\n';
			return 0;
		}


	return 0;
}


Measured memory_bytes: 4436
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n);
    bool f=false;
    rep(i,n)cin>>a[i],f|=a[i]==0;
    if(f){
        cout<<0<<endl;
        return;
    }
    int p=1;
    rep(i,n){
        if(a[i]>1000000000000000000/p){
            cout<<-1<<endl;
            return;
        }
        p*=a[i];
    }
    cout<<p<<endl;
}

Measured memory_bytes: 3980
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N, M;
    read(N, M);
    vector<int> A(M);
    vector<int> B(M);
    vector<vector<int>> v(N);
    for(int i = 0; i < M; i++){
        read(A[i], B[i]);
        A[i]--;
        B[i]--;
        v[A[i]].push_back(B[i]);
        v[B[i]].push_back(A[i]);
    }
    vector<int> prev(N, -1);
    vector<int> d(N, INT_MAX);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    d[0] = 0;
    q.push(make_pair(0, 0));
    while(!q.empty()){
        pair<int, int> p = q.top();
        q.pop();
        int x = p.second;
        if(d[x] < p.first) continue;
        for(int i = 0; i < v[x].size(); i++){
            if(d[v[x][i]] > d[x] + 1){
                d[v[x][i]] = d[x] + 1;
                prev[v[x][i]] = x;
                q.push(make_pair(d[v[x][i]], v[x][i]));
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; i++){
        cout << prev[i] + 1 << endl;
    }
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 12616
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String a = "";
		char[] ch = s.toCharArray();

		for (int i = 0; i < s.length(); i++) {
			if (ch[i] == '0') {
				a = a + "0";
			} else if (ch[i] == '1') {
				a = a + "1";
			} else if (ch[i] == 'B') {
				if (a.length() >= 1) {
					a = a.substring(0, a.length() - 1);
				}
			}
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 21716
#include<stdio.h>

#define MAX 10000
#define MIN 3

void Call(int n);

int main(void)
{
	int n;
	
	if( scanf( "%d", &n ) == 1 )
	{
		if( ( n >= MIN ) && ( n <= MAX ) )
		{
			Call( n );
		}
		else
		{
			return -1;
		}
	}
	else
	{
		return -1;
	}
	
	return 0;
}

void Call( int n )
{
	for( int i=1 ; i-1 < n ; i++ )
	{
		int x = i;
		
		if( x % 3 == 0 )
		{
			printf( " %d", i );
		}
		else
		{
			x = i;
			while(x>0)
			{
				if( x % 10 == 3 )
				{
					printf( " %d", i );
					break;
				}
				else
				{
					x/=10;
				}
			}
		}
	}
	
	printf("\n");
}

Measured memory_bytes: 1816
from sys import stdin
 
N = int(stdin.readline().rstrip())
 
A = [int(x) for x in stdin.readline().rstrip().split()]

B = sorted(A)
 
for i in range(N):  
  if A[i] < B[N//2]:
    print(B[N//2])
  else:
    print(B[N//2-1])

Measured memory_bytes: 26180
s = gets.chomp
n = s.length
if (s == s.reverse && s[0...((n-1)/2)] == s[0...((n-1)/2)].reverse && s[(((n+3)/2)-1)...n] == s[(((n+3)/2)-1)...n].reverse)
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
S = input()
n = len(S)
S1 = S[0:int((n-1)/2)]
S2 = S[int((n+3)/2-1):n]

if (S[::-1] == S) and (S1[::-1] == S1) and S2[::-1] == S2:
    print("Yes")
else:
    print("No")

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

int main(){
    int n,sum;
    cin>>n>>sum;
    int w[n],val[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>val[i];
    }
    ll dp[n+1][sum+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=sum;j++){
            if(i==0||j==0) dp[i][j] =0;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=sum;j++){
            if(w[i-1] <= j){
                dp[i][j] = max(val[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][sum]<<endl;
    return 0;
}


Measured memory_bytes: 82448
#include <stdio.h>

#define MAXN 1000
#define QQQ 1000000007

int S[MAXN+1][MAXN+1];

int grid ( int n, int m)
{
	int i,j;

	for ( i = 0; i <= n; i++ ) S[i][0] = 0;
	for ( i = 0; i <= m; i++ ) S[0][m] = 0;
	S[1][1] = 1;

	for ( i = 1; i <= n; i++ ) {
		for ( j = 1; j <= m; j++ ) {
			if ( S[i][j] == -1 ) S[i][j] = (S[i-1][j]+S[i][j-1])%QQQ ;
		}
	}

	return S[n][m];
}

int main ( void )
{
	int n,m,i,j,c;

	scanf("%d%d", &n,&m);
	getchar();

	for ( i = 1; i <= n; i++ ) {
		for ( j = 1; j <= m; j++ ) {
			c = getchar();
			if ( c == '#' ) S[i][j] = 0;
			else S[i][j] = -1;
		}
		getchar();
	}

	printf("%d\n", grid(n,m));

	return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	int N; cin >> N;
	int a[200010];
	REP(i, N)cin >> a[i];
	int ans = 0;
	int key = 1;
	REP(i, N) {
		if (a[i] == key) {
			ans++;
			key++;
		}
	}
	if (ans == 0)cout << -1 << endl;
	else {
		cout << N - ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
n = int(input())
X = list(map(int, input().split()))
larger_idx = n//2
smaller_idx = larger_idx-1
sorted_X = sorted(X)
for x in X:
    if x <= sorted_X[smaller_idx]:
        print(sorted_X[larger_idx])
    else:
        print(sorted_X[smaller_idx])


Measured memory_bytes: 25224
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll n; cin >> n;
	ll ans = 0;
	rep(i, 0, n) {
		ll a; cin >> a;
		ll cnt = 0;

		while (!(a % 2)) {
			a /= 2;
			cnt++;
		}
		ans += cnt;
	}

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

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int main(){
  int n,a;
  cin >> n >> a;
  Yn(n%500<=a);
  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;


int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  rep(i,m) cin >> a[i] >> b[i];
  vector<int> road(n);
  rep(i,n) road[i] = 0;
  rep(i,m) {
    road[a[i]-1] += 1;
    road[b[i]-1] += 1;
  }
  rep(i,n) cout << road[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,m;
    cin>>n>>m;
    vp j(n);
    cin>>j;
    sort(all(j));
    int p=0; // used(pushed) j count
    priority_queue<int> q;
    ll ans=0;
    REP(i,1,m+1){
        while(p<n && j[p].F<=i)q.push(j[p++].S);
        if(!q.empty()){
            ans+=q.top();
            dprint(q.top(), "残り日数:", i);
            //for(const int a:q)cerr<<a<<' ';cerr<<endl;
            q.pop();
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n,d;
  cin>>n>>d;
  int count=0;
  for(int i=0;i<n;i++)
  {
    int x,y;
    cin>>x>>y;
    if(sqrt(pow(x,2)+pow(y,2))<=d)
    {
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3632
/*Rabbi Zidni Ilma*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define mod 1000000007
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)

ll dp[100005],ar[100005];

int main()
{
	ll n,k,i,j;
    scll(n,k);
    for(i=1;i<=n;i++)
    scl(ar[i]);
    
    dp[n]=0;
    for(i=n-1;i>=1;i--)
    {
    	dp[i]=INT_MAX;
    	for(j=1;j<=k;j++)
    	{
    		if(i+j<=n)
    		dp[i]=min(dp[i],dp[i+j]+abs(ar[i]-ar[i+j]));
    		else
    		break;
		}
	}
    printf("%lld\n",dp[1]);
}



Measured memory_bytes: 5252
#include <iostream>
//#include <algorithm>
#include <sstream>

using namespace std;

int main(){
	string HRSP[22]={"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", 
		"Dragon", "Devil", "Lightning", "Gun","Rock", "Fire", "Scissors", "Snake", "Human", "Tree","Wolf"};
	int number; //numberÍ1000¢
	int i,j,b,sum,count,index;
	bool hands[22];
	bool flag;
	string hand;
	while(cin >> number){
//		bool hands[22];
		for(b=0;b<22;b++){
			hands[b]=1;
		}
		if(!number) break; // 0ªfalse¾ÆvÁÄ¢é
		//		if(!number) break;

		for(j=0;j<number;j++){
			cin >> hand;
			for(i=0;i<15;i++){
				if(hand == HRSP[i]){
					hands[i] = 0;
					break;
				}
			}
		}
		//for(int i=0;i<15;i++){
		//	cout << i << ":" << hands[i] << endl;
		//}

		sum = 0;
		for(i=0;i<15;i++){
			sum += !hands[i];
		}

		//handîñÌRs[
		for(i=0;i<7;i++){
			hands[i+15] = hands[i];
//			cout << hands[i] << endl;
		}

		flag = 1;
		count = 0;
		string win_hand = "Draw";

//		cout << sum << endl;
		if(sum == 1){ // ¢±ÌêÅèªêÊè
//			cout <<"hitotoori" << endl;
			cout << win_hand << endl;
			continue;
		}

		for(index=0;index < 22;index++){
			flag &= hands[index];
			if(count >= 7 && !flag){
				win_hand = HRSP[index];
				break;
			}
			else if(!flag){
				flag = !flag;
				count = 0;
			}
			else{
				count++;
			}
		}
		cout << win_hand << endl;
	}
}

//Rock, Fire, Scissors, Snake, Human, Tree, Wolf, Sponge, Paper, Air, Water, Dragon, Devil, Lightning, and Gun.

Measured memory_bytes: 920
#include<iostream>

using namespace std;

int main()
{
	int N,A,B;

	cin >> N >> A >> B;

	int c = B - A - 1;

	if(c%2 == 0)
	{
		cout << "Borys" << endl;
	}
	else
	{
		cout << "Alice" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
let rec make_list a b k i =
    if i = b then [b]
    else if i <= a + k - 1 || b - k + 1 <= i then i :: make_list a b k (i + 1)
    else make_list a b k (i + 1)

let () =
    Scanf.scanf "%d %d %d\n" (fun a b k ->
        List.iter (Printf.printf "%d\n") (make_list a b k a)
    )


Measured memory_bytes: 384
from heapq import heappush, heappop

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

h = []

for v in v_list:
    heappush(h, v)

while len(h) >= 2:
    a = heappop(h)
    b = heappop(h)
    heappush(h, (a + b) / 2)

print(heappop(h))


Measured memory_bytes: 38256
#include<stdio.h>
int main(){
int input, angka1=0, angka2=0, angka3=0;
	
	scanf("%d", &input);
	
	angka1=input/100;
	angka2=(input-(angka1*100))/10;
	angka3=input%10;

	
	if(angka1 == 7 || angka2 == 7){
	printf("Yes\n");
	}
	else if (angka3 == 7){
		printf("Yes\n");
	}
	else{
		puts("No\n");
	}
	
	
return 0;
}

Measured memory_bytes: 1632
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  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() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; 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 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();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    long N = sc.nextInt();
    long ans = 0;
    for(int i=1; i<=N; i++){
      ans += (long)i-1;
    }
    out.println(ans);
  }
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int x[5], y[5];
	x[0] = 0;
	y[0] = 0;
	cin >> x[1] >> y[1] >> x[2] >> y[2];

	x[3] = y[1] - y[2] + x[2];
	y[3] = -x[1] + x[2] + y[2];
	x[4] = -y[2] + y[1] + x[1];
	y[4] = x[2] - x[1] + y[1];

	cout << x[3] << " " << y[3] << " " << x[4] << " " << y[4];

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
typedef pair<int, int> P;

int dist[100005][3];

signed main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
    }

    int sv, tv;
    cin >> sv >> tv;
    --sv; --tv;

    queue<P> q;
    q.push(P(sv,0));
    rep(i,n)rep(j,3) dist[i][j] = inf;
    dist[sv][0] = 0;
    while(q.size()!=0) {
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for(int u: to[v]) {
            int nl = (l+1)%3;
            if(dist[u][nl] != inf) continue;
            dist[u][nl] = dist[v][l]+1;
            q.push(P(u, nl));
        }    
    }
    int ans = dist[tv][0];
    if(ans==inf)ans = -1;
    else ans /= 3;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8064
#define _CRT_SECURE_NO_WARNING
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

// #include <stack>
// #include <queue>
// #include <set>
// #include <tuple>
// #include <list>
// #include <numeric>
// #include <random>
// #include <regex>
// #include <utility>

using namespace std;
const int INF = (int)1e9;

//#define DEBUG

void solution() {
	string s;
	cin >> s;
	bool b = true;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 1&& s[i] == 'R' || i % 2 != 1 && s[i] == 'L') {
			b = false;
			break;
		}
	}
	cout << (b ? "Yes" : "No");
}

int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
	solution();
  return 0;		
}


Measured memory_bytes: 256
from itertools import accumulate
N, K, *A = map(int, open(0).read().split())
for _ in range(min(K, 41)):
    next_A = [0] * (N + 1)
    for i, a in enumerate(A):
        next_A[max(0, i - a)] += 1
        next_A[min(N, i + a + 1)] -= 1
    A = list(accumulate(next_A))
A.pop()
print(*A)

Measured memory_bytes: 185848
#include <stdio.h>
#define Max(a,b) (a>b?a:b)
#define T 3
#define Bignum 114514

int ThreeMax(int a,int b,int c){
    int max = Max(a,b);
    max = Max(max,c);
    return max;
}


int main(void){
    int n;
    scanf("%d",&n);
    int hap[Bignum][T],dp[Bignum][T];
    for(int i=0;i<Bignum;i++)
    {
        for(int j=0;j<T;j++)
        {
            hap[i][j] = dp[i][j] = 0;
        }
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<T;j++)
        {
            scanf("%d",&hap[i][j]);
        }
    }
    
    for(int i=0;i<n;i++)
    {
        if(!i)
        {
            for(int j=0;j<T;j++)
            {
                dp[i][j] = hap[i][j];
            }
            continue;
        }
        for(int j=0;j<T;j++)
        {
            dp[i][j]=Max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+hap[i][j];
        }
    }
    
    int maxhap = ThreeMax(dp[n-1][0],dp[n-1][1],dp[n-1][2]);
    printf("%d\n",maxhap);
    return 0;
}

Measured memory_bytes: 2816
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# 約数列挙
def find_divisor(n):
    divisors=[]
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            if i*i!=n:
                divisors.append(n // i)
    return divisors


def main():
    N=I()
    A=LI()
    candidate = set(find_divisor(A[0]) + find_divisor(A[1]))
    ans = 0
    for c in candidate:
        ng_cnt = 0
        for a in A:
            if a%c:
                ng_cnt+=1
        if ng_cnt<=1:
            ans = max(ans, c)
    print(ans)
        
    
    
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 85100
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  int ok = 0;
  rrep(i, 1, n + 1) {
    tmp = i * (i + 1);
    tmp /= 2;
    if (tmp == n) {
      tmp = i, ok = 1;
      break;
    }
  }
  if (!ok) {
    Cout("No");
    return 0;
  }
  ll ans[tmp + 10][tmp + 10] = {}, up = 2, clock = 2;
  ll ma_x = 0, ma_y = 1;
  ans[0][0] = 1;
  ans[1][0] = 1;
  while (1) {
    ll curr = up;
    if (curr - 1 == n) break;
    rep(i, ma_y + 1) ans[i][ma_x + 1] = curr++;
    curr = up;
    rep(i, ma_x + 2) ans[ma_y + 1][i] = curr++;
    up += clock;
    clock++;
    ma_y++;
    ma_x++;
  }
  Cout("Yes");
  Cout(tmp + 1);
  rep(i, tmp + 1) {
    cout << tmp << " ";
    rep(j, tmp) cout << ans[i][j] << " ";
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 5176
S = input()
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
for i, s in enumerate(S):
  if i%2 == 0:
    if not s in odd:
      print('No')
      exit()
  else:
    if not s in even:
      print('No')
      exit()
print('Yes')

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
  cin>>s;
  int l = 0, r = s.size()-1;
  while(s[l]!='A') l++;
  while(s[r]!='Z') r--;
  cout<<r-l+1<<endl;
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long X = long.Parse(str[1]);
		string[] str2 = Console.ReadLine().Split();
		long[]A = new long[N];
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]);
		}
		long ans = Math.Abs(A[0]-X);
		for(var i=1;i<N;i++){
			ans = Gcd(ans,Math.Abs(A[i]-X));
		}
		Console.WriteLine(ans);
	}
	
	public static long Gcd(long a, long b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}

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

#define ll long long
#define pb push_back
#define pf push_front
#define np next_permutation
#define pp prev_permutation
#define all(x) (x).begin(),(x).end()

using namespace std;
int main()
{
    int n,m=200001,c=0;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
    {
        m=min(m,a[i]);
        if(m==a[i])
            c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 4328
# ARC062C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report
def main():
    N, *TA = map(int, open(0).read().split())
    t, a = TA[:2]
    for i, j in zip(*[iter(TA[2:])] * 2):
        x = max((t + i - 1) // i, (a + j - 1) // j)
        t, a = i * x, j * x
    print(t + a)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
a, b, c = map(int, input().split())

l = list()
cost = list()

l.append(a)
l.append(b)
l.append(c)

for i in range(3):
  for j in range(3):
    if i != j:
      cost.append(l[i] + l[j]) 

print( min(cost) )

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main ()
{
  char s[2][105];
  int i,j;

  for(i=0;i<2;i++)
    scanf("%s",s[i]);

  int len;

  len = strlen(s[0]);

  int ch = 0;
  char c;
  
  for(i=0;i<len;i++)
    {
      c = s[0][0];
      
      for(j=0;j<len-1;j++)
	s[0][j] = s[0][j+1];

      s[0][len-1]=c;

      if(strcmp(s[0],s[1])==0)
	{
	  ch++;
	  break;
	}

      
    }

  if(ch==0)
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => long.Parse(i)).ToArray();

            var d = new Dictionary<long,long>();
            for(var i = 0; i < n; i++){
                var x = a[i];
                if(d.ContainsKey(x)){
                    d[x] += 1;
                }else{
                    d.Add(x, 1);
                }

                if(d.ContainsKey(x+1)){
                    d[x+1] += 1;
                }else{
                    d.Add(x+1, 1);
                }

                if(d.ContainsKey(x-1)){
                    d[x-1] += 1;
                }else{
                    d.Add(x-1, 1);
                }
            }

            var max = d.Max(t => t.Value);
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 25440
import java.util.Scanner;

public class Main {
	static int []p;
	static int []c;
	static int min;
	static int G;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int D = scan.nextInt();
		G = scan.nextInt() / 100;
		p = new int[D];
		c = new int[D];
		int num = 0;

		for(int i = 0; i < D; i++) {
			int t1 = scan.nextInt();
			int t2 = scan.nextInt() / 100;
			p[i] = t1;
			c[i] = t2;
			num += p[i];
		}
		scan.close();
		min = num;

		int []bit = new int[D];
		rec(0, D, bit);
		System.out.println(min);

	}
	static void rec(int k, int n, int[] S) {
        if(k == n) {
        	solve(S);
            return;
        }
        rec(k + 1, n, S);
        S[k] = 1;
        rec(k + 1,n, S);
        S[k] = 0;
    }
	static void solve(int[] S) {
		int point = 0;
		int cnt = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] == 1) {
				point += p[i] * (i + 1) * 1 + c[i];
				cnt += p[i];
			}
		}
		if(point >= G) {
			if(min > cnt) {
				min = cnt;
			}
		}else {
			int res = G - point;
			for(int i = S.length - 1; i >= 0; i--) {
				if(S[i] == 0) {
					int t = (i + 1) * 1;
					int k = (int)Math.ceil((double)res / t);
					if(k <= p[i] - 1) {
						if(min > cnt + k) {
							min = cnt + k;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 21844
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

from collections import defaultdict
rows, cols = map(int, input().split())
n = rows*cols
ns = defaultdict(set)
ss = [None] * rows
color = [None] * n
for i in range(rows):
    s = input()
    ss[i] = s
    for j,c in enumerate(s):
        u = i*cols+j
        color[u] = c
        if i>0:
            if c!=ss[i-1][j]:
                v = u - cols
                ns[u].add(v)
                ns[v].add(u)
        if j>0:
            if c!=s[j-1]:
                v = u - 1
                ns[u].add(v)
                ns[v].add(u)
seen = [False] * n
ans = 0
for u in range(n):
    if seen[u]:
        continue
    q = [u]
    s = set([u])
    while q:
        u = q.pop()
        for v in ns[u]:
            if seen[v]:
                continue
            seen[v] = True
            s.add(v)
            q.append(v)
    ans += sum(color[item]=="#" for item in s) * sum(color[item]=="." for item in s)
print(ans)

Measured memory_bytes: 116828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;


	co(min(a, b) + min(c, d));

	Would you please return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ALDS1_4
{
    class Program
    {
        static void Main()
        {
            var h = new HashSet<string>();
            var l = int.Parse(Console.ReadLine());

            for (var i = 0; i < l; i++)
            {
                var _t = Console.ReadLine().Split();
                if (_t[0] == "insert")
                    h.Add(_t[1]);
                else
                    Console.WriteLine(h.Contains(_t[1]) ? "yes" : "no");
            }
        }
    }
}

Measured memory_bytes: 39796
#include <cstdio>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int K;
	long long ans = 0;
	scanf("%d", &K);
	for (int i = 1; i <= K; ++i) {
		for (int j = 1; j <= K; ++j) {
			for (int k = 1; k <= K; ++k) ans += gcd(i, gcd(j, k));
		}
	}
	printf("%lld", ans);
	return 0;
}

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

int main() {
  map<string, int> m;

  int N; cin >> N;
  for (int i = 0; i < N; ++i) {
    string s; cin >> s;
    if (m.find(s) == m.end()) m[s] = 0;
    m[s]++;
  }

  int M; cin >> M;
  for (int i = 0; i < M; ++i) {
    string s; cin >> s;
    if (m.find(s) == m.end()) m[s] = 0;
    m[s]--;
  }

  int vmax = 0;
  for (auto p : m) {
    vmax = max(vmax, p.second);
  }
  cout << vmax << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a > b) {
            System.out.println("a > b");
        } 
        else if(a < b) {
            System.out.println("a < b");
        }
        else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26328
n, k, q = gets.split.map(&:to_i)
norm = q - k + 1
count = {}
count.default = 0
q.times{|i|
    count[gets.to_i] += 1
}

(1..n).each{|i|
    puts count[i] >= norm ? 'Yes' : 'No'
}


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

int const nmax = 3000;
int const modulo = 998244353;

int dp[5 + nmax][5 + nmax];

int main() {
  int n, m, q, p;
  std::cin >> n >> m >> p >> q;
  dp[p][q] = 1;
  for(int i = p; n <= i; i--)
    for(int j = q; m <= j; j--)
      dp[i][j] += (modulo + 1LL * dp[i][j + 1] * i + 1LL * dp[i + 1][j] * j - 1LL * dp[i + 1][j + 1] * i % modulo * j % modulo) % modulo;
  std::cout << dp[n][m];
}


Measured memory_bytes: 38804
S=input()
if S=="SUN":
    print(7)
if S=="MON":
    print(6)
if S=="TUE":
    print(5)
if S=="WED":
    print(4)
if S=="THU":
    print(3)
if S=="FRI":
    print(2)
if S=="SAT":
    print(1)

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
 
#include <iostream>
#include <algorithm>
 
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>
 
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
 
 
using namespace std;
#define int long long
 
typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
 
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
 
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

struct UnionFind {
	vector<int> par, rank;    //rank[i]:=??????i????±?????????????????????±???(????´???§?????´????????????)
	//int cmps;    ??£?????????????????°
	//vector<int> cmp_cnt;    cmp_cnt[i]:=??????i????±?????????£???????????????????´???°    
	
	UnionFind() {}

	UnionFind(int n) : par(n), rank(n, 1) {
		//cmps = n;
		for (int i = 0; i < n; i++) {
			par[i] = i;
			//cmp_cnt[i] = 1;
		}
	}

	int find_root(int now) {
		if (par[now] == now) return now;
		return par[now] = find_root(par[now]);
	}

	void unite(int u, int v) {
		int x = find_root(u);
		int y = find_root(v);
		if (x == y) return;

		if (rank[x] < rank[y]) swap(x, y);
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
		//cmps--;
		//cmp_cnt[x] += cmp_cnt[y];
	}

	bool same(int u, int v) {
		return find_root(u) == find_root(v);
	}

	
	/*??????x????±?????????£??????????????°????±???????
	int count_same(int x) {
		return cmp_cnt[find_root(x)];
	}
	*/

};

int n, q;

signed main() {	
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> n >> q;
	UnionFind uf(n);
	rep(i, q) {
		int com, u, v;
		cin >> com >> u >> v;
		if (com == 0) {
			uf.unite(u, v);
		}
		else {
			cout << uf.same(u, v) << endl;
		}
	}
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<char> Alphabet = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char> alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main()
{
  cout << fixed << setprecision(10);
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  rep(i,26)
  {
    if(s1[0]==alphabet[i])
    {
      cout << Alphabet[i];
    }
  }
  rep(i,26)
  {
    if(s2[0]==alphabet[i])
    {
      cout << Alphabet[i];
    }
  }
  rep(i,26)
  {
    if(s3[0]==alphabet[i])
    {
      cout << Alphabet[i] << endl;
    }
  }
  return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll ans;

bool step(vector<ll>& vec){

  int n;
  n = vec.size();
  ll max_val = 0;
  int ind = 0;
  rep(i, n){
    if(chmax(max_val, vec[i])){
      ind = i;
    }
  }

  ll cnt = vec[ind] / n;
  vec[ind] = vec[ind] % n;
  rep(i, n){
    if(i != ind){
      vec[i] += cnt;
    }
  }

  ans += cnt;

  bool ok = true;
  rep(i, n){
    if(vec[i] >= n){
      ok = false;
    }
  }
  return ok;

}

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

  int N;
  cin >> N;
  vector<ll> a(N);
  ll max_val = 0;
  rep(i, N){
    cin >> a[i];
    chmax(max_val, a[i]);
  }

  if(max_val < N){
    cout << 0 << endl;
    return 0;
  }

  while(!step(a));

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<ll> d(n);
    rep(i,n){
        d[i] = a[i]-(i+1);
    }
    sort(all(d));

    ll b = d[n/2];
    ll ans = 0;
    rep(i,n){
        ans += abs(a[i]-(b+i+1));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    long long ans = 0;
    for(int i =0 ;i < M; i++) {
        cin >> a[i];
        ans += a[i];
    }
    if(N < ans){
        cout << -1 << endl;
        return 0;
    }
    cout << N - ans << endl;
}

Measured memory_bytes: 3668