akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
  // 前処理
  COMinit();

  int N, M, K; cin >> N >> M >> K;

  int ans = 0;


  int a = (M - 1) * M * (M + 1) / 6;
  a %= MOD;
  int b = (N - 1) * N * (N + 1) / 6;
  b %= MOD;


  int ms = (M * M) % MOD;
  int xs = (COM(N*M - 2, K - 2) * b) % MOD;
  ans += ms * xs;
  ans %= MOD;
  int ns = (N * N) % MOD;
  int ys = (COM(N*M - 2, K - 2) * a) % MOD;
  ans += ns * ys;
  ans %= MOD;
   
  cout << ans << endl;
}


Measured memory_bytes: 12544
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(auto &I:v){cin>>I;}
    vector<ll> c(n);
    for(auto &I:c){cin>>I;}
    for(int i=0;i<n;i++){v[i]-=c[i];}
    sort(v.begin(),v.end(),greater<ll>());
    ll ans=0;
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=v[i];
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,c=0;
	cin>>n;
	vi a(n);
	vi b(n);
	REP(i,0,n-1)cin>>a[i];
	b[0]=a[0];
	REP(i,1,n-1){
		b[i]=min(a[i],b[i-1]);
	}
	REP(i,0,n-1){
		if(a[i]==b[i])c++;
	}
	cout<<c;
	
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll llf=1e18;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,m;
bool ck(int x){
	int k=m/x;
	if(k>=n) return 1;
	return 0;
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>m;
	int ans=1;
	for(int i=1;i*i<=m;i++){
		if(m%i==0){
			if(ck(i)){
				ans=max(ans,i);	
			}
			if(ck(m/i)){
				ans=max(ans,m/i);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,a[100001];
    std::cin >> n;
    ll mod = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    ll ans = 0;
    ll index = 0;
    while(true){
        sort(a,a+n);
        index = distance( a, upper_bound(a,a+n,0) );
        mod = a[index];
        // std::cout << mod << std::endl;
        // std::cout << a[0]<< " "<<a[1]<<" "<<a[2]<<" "<<a[3] << std::endl;
        if(ans == mod){
            std::cout << ans << std::endl;
            return 0;
            break;
        }else{
            ans = mod;
        }

        for (int i = index+1; i < n; i++) {
            a[i] %= mod;
        }
    }
}

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

using namespace std;

using Int = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
  string S;
  cin >> S;
  vector<string> words = {
    "dream",
    "dreamer",
    "erase",
    "eraser",
  };
  int N = S.size();
  vector<bool> dp(N + 1, false);
  dp[0] = true;
  for (int i = 0; i < N; ++i) {
    if (!dp[i]) continue;
    for (string s : words) {
      int n = s.size();
      if (i + n < N + 1 && S.substr(i, n) == s) dp[i + n] = true;
    }
  }
  if (dp[N]) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define pb push_back

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

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 += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;
using db = double;

int main() {
	IOS;
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	vector<int> dp(n);
	for (int i = 1; i < n; i++) {
		int mmin = INF;
		for (int j = i - 1; j >= i - k && j >= 0; j--) {
			mmin = min(dp[j] + abs(h[i]-h[j]), mmin);
		}
		dp[i] = mmin;
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 3940
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	float T, X;
	cin >> T >> X;

	cout.setf(ios::fixed);
	cout.precision(10);

	cout << T / X;

	return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=300050;
const int mod=998244353;
int r,g,b;
char s[N];
int main()
{
	int n;
	scanf("%i %s",&n,s+1);
	int ans=1;
	for(int i=1;i<=n;i++) ans=(ll)ans*i%mod;
	n*=3;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='R')
		{
			if(r<b && r<g) ans=(ll)ans*(min(b,g)-r)%mod;
			else if(r<max(b,g)) ans=(ll)ans*(max(b,g)-r)%mod;
			r++;
		}
		else if(s[i]=='G')
		{
			if(g<b && g<r) ans=(ll)ans*(min(b,r)-g)%mod;
			else if(g<max(b,r)) ans=(ll)ans*(max(b,r)-g)%mod;
			g++;
		}
		else if(s[i]=='B')
		{
			if(b<g && b<r) ans=(ll)ans*(min(g,r)-b)%mod;
			else if(b<max(g,r)) ans=(ll)ans*(max(g,r)-b)%mod;
			b++;
		}
	}
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 512
n = int(input())
cnt = 0
s0b = 0
sla = 0
s0bsla = 0
for i in range(n):
    s = input()
    cnt += s.count("AB")
    if s[0] == "B" and s[-1] != "A":
        s0b += 1
    elif s[0] != "B" and s[-1] == "A":
        sla += 1
    elif s[0] == "B" and s[-1] == "A":
        s0bsla += 1
if s0bsla > 0:
    cnt += s0bsla - 1
    if sla > 0:
        cnt += 1
        sla -= 1
    if s0b > 0:
        cnt += 1
        s0b -= 1
cnt += min(s0b, sla)
print(cnt)


Measured memory_bytes: 3064
import java.util.Scanner;

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

        String[] s;
        int[] A;
        s = new String[10000];
        A = new int[1000];

        int i, j, k;

        i=0;
        while(true){

            s[i] = sc.next();
            if(s[i].equals("0")){break;}

            i++;
        }

        for(k=0;k<i;k++){
            for(j=0;j<s[k].length();j++){

                A[k] += s[k].charAt(j) - '0';
            }
            System.out.println(A[k]);
        }

    }
}



Measured memory_bytes: 26232
#include <iostream>
#include <string>
#include <random>
#include <algorithm>
#include <unordered_set>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define Sort(a) sort(a.begin(),a.end())
#define cSort(a,cmp) sort(a.begin(),a.end(),cmp)
#define reSort(a) sort(a.rbegin(), a.rend())
static const ll llMAX = numeric_limits<long long>::max();
static const int intMAX = numeric_limits<int>::max();
static const ll  llMIN = numeric_limits<long long>::min();
static const int intMIN = numeric_limits<int>::min();
static const ll d_5 = 100000;
static const ll d9_7 = 1000000007;
static const ll d_9 = 1000000000;
static const double PI=3.14159265358979323846;
template<class T>
T gcd(T a,T b){
  if(a==0){
    return b;

  }else if(b==0){
    return a;
  }
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  int mode=0;
  if(mode==0){
    if(b%2==1){
      ll tmp = digitpower(a,(b-1)/2);
      tmp%=d9_7;
      tmp*=tmp;
      tmp%=d9_7;
      tmp*=a;
      return (tmp)%d9_7;
    }else{
      ll tmp = digitpower(a,(b)/2);
      tmp%=d9_7;
      tmp*=tmp;
      tmp%=d9_7;
      return (tmp)%d9_7;
    }
  }else{
    if(b%2==1){
      ll tmp = digitpower(a,(b-1)/2);
      tmp*=tmp;
      tmp*=a;
      return (tmp);
    }else{
      ll tmp = digitpower(a,(b)/2);
      tmp*=tmp;
      return (tmp);
    }
  }
  return 0;
  
}
template<class T>
void Printvector(std::vector<T> &a){
  int size = a.size();
  rep(i,size){
    cout<<a[i]<<" ";
  }
  cout<<endl;
}
template<class T>
void Printvector(std::vector<std::vector<T>> &a){
  int size = a.size();
  rep(i,size){
    int size2=a[i].size();
    rep(j,size2){
      cout<<a[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;
}
unordered_set<ll> primes(ll n){
  unordered_set<ll> ret;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0){
      ret.insert(i);
      ret.insert(n/i);
    }
  }
  return ret;
}
int main(void){
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  vl nums(k+1,-1);//パターン数
  for(ll nowk=k;nowk>=1;nowk--){
    ll num =  digitpower(k/nowk,n);
    for(ll i=2;i*nowk<=k;i++){
      num-=nums[i*nowk];
      while(num<0){
        num+=d9_7;
      }
      num%=d9_7;
    }
    nums[nowk]=num;
    ans+=num*nowk;
    ans%=d9_7;
  }
  cout<<ans<<endl;
  return 0;
}

//clang++ -g -fsanitize=address -fno-omit-frame-pointer 1.cpp -o test.exe

//<<std::setprecision(30)

//重複削除
 /* std::sort(vec.begin(), vec.end());
 
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());*/

  //ペアの全探索
  /*do{
		int s=0;
		for(int i=0;i<n/2;i++)s+=v[i]^v[i+n/2];
		r=max(s,r);
		reverse(v.begin()+n/2,v.end());
	}while(next_permutation(v.begin(),v.end()));*/


Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)

//your code here!

int main(void){
    ll N, M, a[100], b[100], c[100], d[100];
    scanf("%lld %lld", &N, &M);
    rep(i, N) scanf("%lld %lld", a+i, b+i);
    rep(i, M) scanf("%lld %lld", c+i, d+i);
    ll minlen, ans;
    rep(i, N) {
        minlen = 1e15;
        rep(j, M) {
            ll l = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(l < minlen) {
                minlen = l;
                ans = j+1;
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int n;
    cin>>n;
    int d[n+2];
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    int sum=1;
    sort(d,d+n);
    for(int i=0;i<n-1;i++){
        if(d[i]!=d[i+1]){
            sum++;
        }
    }
    cout<<sum<<"\n";
    return(0);
}

Measured memory_bytes: 3656
h, w = map(int, input().split())
mine = []
mine.append(["."] * (w + 2))
for i in range(h):
    mine.append(["."] + list(input()) + ["."])
mine.append(["."] * (w + 2))
ans = [[0] * w for i in range(h)]
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if mine[i][j] == "#":
            ans[i - 1][j - 1] = "#"
        else:
            if mine[i - 1][j - 1] == "#":
                ans[i - 1][j - 1] += 1
            if mine[i - 1][j] == "#":
                ans[i - 1][j - 1] += 1
            if mine[i - 1][j + 1] == "#":
                ans[i - 1][j - 1] += 1
            if mine[i][j - 1] == "#":
                ans[i - 1][j - 1] += 1
            if mine[i][j + 1] == "#":
                ans[i - 1][j - 1] += 1
            if mine[i + 1][j - 1] == "#":
                ans[i - 1][j - 1] += 1
            if mine[i + 1][j] == "#":
                ans[i - 1][j - 1] += 1
            if mine[i + 1][j + 1] == "#":
                ans[i - 1][j - 1] += 1
for i in ans:
    print(*i, sep="")

Measured memory_bytes: 9352
#include<bits/stdc++.h>
using namespace std;
int n,q;
int ver[200005],nxt[200005],head[200005];
int w[200005],l[200005],c[200005];
int x,y;
void dfs(int s) {
	for(int i=head[s];i;i=nxt[i]) {
		l[ver[i]]+=l[s];
		dfs(ver[i]);
	}
	//cout<<s<<" "<<l[s]<<endl;
}
int main() {
	cin>>n>>q;
	for(int i=1;i<n;i++) {
		scanf("%d%d",&x,&y);
		ver[i]=y;
		nxt[i]=head[x];
		head[x]=i;
	}
	for(int i=1;i<=q;i++) {
		scanf("%d%d",&w[i],&c[i]);
		l[w[i]]+=c[i];
	}
	dfs(1);
	for(int i=1;i<=n;i++) cout<<l[i]<<" ";
	return 0;
}

Measured memory_bytes: 13312
#include<cstdio>
#include<cstring>
const int MAXN = 200000;
char S[MAXN + 5], T[MAXN + 5];
int to[MAXN + 5][2];
int main() {
	scanf("%s%s", S, T);
	int len = strlen(S);
	for(int i=0;i<len;i++) {
		if( !to[S[i]-'a'][0] )
			to[S[i]-'a'][0] = T[i];
		else if( to[S[i]-'a'][0] != T[i] ) {
			puts("No");
			return 0;
		}
		if( !to[T[i]-'a'][1] )
			to[T[i]-'a'][1] = S[i];
		else if( to[T[i]-'a'][1] != S[i] ) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ii> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;

int main(){
    int q;cin>>q;
    int dp[1001][1001];
    for(int k=0;k<q;k++){
        string s,t;cin>>s>>t;
        int n=(int)s.size();
        int m=(int)t.size();
        for(int i=0;i<=n;i++){
            for(int j=0;j<=m;j++){
                dp[i][j]=0;
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
                if(s[i]==t[j]) dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
            }
        }
        cout<<dp[n][m]<<endl;
    }
    return 0;
}


Measured memory_bytes: 7096
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
int n;
  cin>>n;
  int a[n+1];
  for(int i=1;i<=n;i++){
    a[i]=0;
    int p;
    cin>>p;
    a[i]=p;
  }
  
  int now=1;
  for(int i=1;i<=n;i++){
    if(a[i]==now){
      now++;}
  }
  
  if(now==1){
    cout<<-1<<endl;
  return 0;}
  
  cout<<n-now+1<<endl;
  
  
  
  

}


Measured memory_bytes: 1024
N = int(input())
L = []
for i in range(N):
    A,B = map(int,input().split())
    L.append([B,A])
L = sorted(L)
t = 0
for i in range(N):
    t += L[i][1]
    if t > L[i][0]:
        print('No')
        exit()
print('Yes')

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

int main()
{
  stack<int> trains;
  int i;
  for (;;)
  {
    cin >> i;
    if (i != 0) trains.push(i);
    else
    {
      if (trains.empty()) break;
      cout << trains.top() << endl;
      trains.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 1200
//package maximumcup2018;
import java.util.*;

public class Main {

    static public int n;
    static int[] A = new int[50];
    static int[] B = new int[50];

    public Boolean fun(Long bit){
        boolean[][] arr = new boolean[51][51];
        for(int i = 0; i <= 50; i++) {
                arr[i][i] = true;
        }
        for(int i = 1;i <= 50; i++){
            if((bit & (1L<<i)) != 0){
                for(int j = 0;j <= 50;j++){
                    arr[j][j%i] = true;
                }
            }
        }

        for(int k = 0;k <= 50;k++){
            for(int i = 0;i <= 50;i++){
                for(int j = 0;j <= 50;j++){
                    arr[i][j] |= arr[i][k] & arr[k][j];
                }
            }
        }

        Boolean flag = true;

        for(int i = 0;i < n;i++){
            if(!arr[A[i]][B[i]])flag = false;
        }

        return flag;

    }

    public void solve(){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        for(int i = 0;i < n;i++) {
            A[i] = sc.nextInt();
        }
        for(int i = 0;i < n;i++) {
            B[i] = sc.nextInt();
        }

        Long ans = (1L << 51) - 1;

        if(!fun(ans)) {
            System.out.println(-1);
            return;
        }

        for(int i = 51;i >= 0;i--){
            Long tmp = ans & ~(1L << i);
            if(fun(tmp))ans = tmp;
        }

        System.out.println(ans);

    }

    public static void main(String[] args){
        new Main().solve();
    }
};

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

int main() {
    int N, A;
    cin >> N >> A;
    int ans = false;

    int num;
    num = N / 500;
    if (N % 500 == 0) {
        cout << "Yes" << endl;
    }
    else if (A > N - num * 500){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    mp[x]++;
    mp[x + 1]++;
    mp[x - 1]++;
  }
  int ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    ans = max(itr->second, ans);
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
using namespace std;
const long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long F[2<<17],I[2<<17];
int N;
vector<int>G[2<<17];
int cc[2<<17];
long dp1[2<<17];
long dfs1(int u,int p)
{
	long ret=1;
	cc[u]=1;
	for(int v:G[u])if(v!=p)
	{
		ret=ret*dfs1(v,u)%mod;
		ret=ret*I[cc[v]]%mod;
		cc[u]+=cc[v];
	}
	dp1[u]=ret;
	return ret*F[cc[u]-1]%mod;
}
long ans[2<<17];
long dfs2(int u,int p,long pr)
{
	ans[u]=dp1[u]*pr%mod*I[N-cc[u]]%mod;
	for(int v:G[u])if(v!=p)
	{
		dfs2(v,u,ans[u]*cc[v]%mod*power(dp1[v],mod-2)%mod*F[N-cc[v]-1]%mod);
	}
	ans[u]=ans[u]*F[N-1]%mod;
}
main()
{
	cin>>N;
	F[0]=1;
	for(int i=1;i<=N;i++)F[i]=F[i-1]*i%mod;
	I[N]=power(F[N],mod-2);
	for(int i=N;i--;)I[i]=I[i+1]*-~i%mod;
	for(int i=1;i<N;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs1(0,-1);
	dfs2(0,-1,1);
	for(int i=0;i<N;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 23668
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val sa = scanner.next()
    val sb = scanner.next()
    val a = Integer.parseInt(sa)
    val b = Integer.parseInt(sb)
    if(a<10 && b<10){
        println("${a*b}")
    }else{
        println("-1")
    }
}

Measured memory_bytes: 31520
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut a: Vec<i32> = (0..n + 1).map(|_| input()).collect();
    let mut b: Vec<i32> = (0..n).map(|_| input()).collect();

    let mut ans = 0i64;
    for i in 0..n {
        let t = std::cmp::min(a[i], b[i]);
        ans += t as i64;
        a[i] -= t;
        b[i] -= t;
        let t = std::cmp::min(a[i + 1], b[i]);
        ans += t as i64;
        a[i + 1] -= t;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

ans = 'NO'
distance = abs(B-A)
if V == W:
  pass
else:
  t = distance/(V-W)
  if 0 < t <= T:
    ans = 'YES'

print(ans)

Measured memory_bytes: 9100
#include<cstdio>
#include<cstring> 
using namespace std;
int cnt;
char s1[20];
int main(){
	scanf("%s",&s1);
	for(int i=0;i<strlen(s1);i++){
		if(s1[i]=='o') cnt++;
	}
	cnt+=15-strlen(s1);
	if(cnt>=8) printf("YES");
	else printf("NO");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAXN 100000

using namespace std;

int v[MAXN + 1];

int main() {
  //  fstream cin("A.in");
  //  ofstream cout("A.out");
    int n, i;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++)
       cin >> v[i];
    long long ans = 0;
    bool flag = 0;
    for(i = 1; i <= n; i++) {
        if(v[i] > 0 && flag) {
            v[i]--;
            ans++;
        }
        ans += v[i] / 2;
        if(v[i] % 2 == 1)
            flag = 1;
        else
            flag = 0;
    }
    cout << ans << endl;
   // cin.close();
   // cout.close();
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
void search(string s, char big)
{
	if(s.length()==n)
	cout<<s<<"\n";
	else
	{
		for(char c='a';c<big;c++)
		{
			
			search(s+c, big);
		}
		search(s+big, big+1);
	}
	
}
int main()
{
	
	cin>>n;
	string ans="";
	search(ans, 'a');
}	
	


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

int main()
{
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, 3)
    {
        if (S.at(i) == T.at(i))
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(i,x) for(auto &i:x)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r)
{
    return l+rng()%(r-l+1);
}
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define pii pair<int,int>
#define fi first
#define se second
#define batbit(i,x) (x|(1ll<<i))
#define getbit(i,x) ((x>>i)&1)

const int mn=1e5+10;
string s,t;
int f[mn],g[mn],q;

main()
{
    cin >> s >> t;
    int n=s.size(),m=t.size();
    s=' '+s,t=' '+t;
    forinc(i,1,n) f[i]=f[i-1]+s[i]-'A'+1;
    forinc(i,1,m) g[i]=g[i-1]+t[i]-'A'+1;
    cin >> q;
    while(q--)
    {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        if((f[b]-f[a-1])%3==(g[d]-g[c-1])%3) cout << "YES\n";
        else cout << "NO\n";
    }
}


Measured memory_bytes: 2560
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
T_min = [1]*N
T_min[0] = T[0]
for i in range(1,N):
  if T[i-1]<T[i]:
    T_min[i] = T[i]
A_min = [1]*N
A_min[N-1] = A[N-1]
for i in range(N-2,-1,-1):
  if A[i+1]<A[i]:
    A_min[i] = A[i]
M = [0]*N
M_min = [0]*N
for i in range(N):
  M[i] = min(T[i],A[i])
  M_min[i] = max(T_min[i],A_min[i])
ans = 1
mod = 10**9+7
for i in range(N):
  if M[i]<M_min[i]:
    ans = 0
  else:
    ans*=M[i]+1-M_min[i]
    ans%=mod
print(ans)



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

int main() {
  int H, W;
  cin >> H >> W;
  string all_S = "";
  string result_all_S = "";
  
  for (int k = 0-1; k < W+1; k++) {
    all_S += '.';
  }
  for (int i = 0; i < H; i++) {
    string S;
    cin >> S;
    all_S += '.' + S + '.';
  }
  for (int k = 0-1; k < W+1; k++) {
    all_S += '.';
  }

  //cout << all_S << endl;

  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W+1; j++) {
      //int x = 0;
      if (all_S.at((W+2)*i+j) == '#') {
        //result_all_S += '#';
        cout << '#';
        continue;
      }
      else if (all_S.at((W+2)*i+j) == '.') {
        int x = 0;
        if (all_S.at((W+2)*(i-1)+(j-1)) == '#') x++;
        if (all_S.at((W+2)*(i-1)+j    ) == '#') x++;
        if (all_S.at((W+2)*(i-1)+(j+1)) == '#') x++;
        if (all_S.at((W+2)*i    +(j-1)) == '#') x++;
        if (all_S.at((W+2)*i    +(j+1)) == '#') x++;
        if (all_S.at((W+2)*(i+1)+(j-1)) == '#') x++;
        if (all_S.at((W+2)*(i+1)+j    ) == '#') x++;
        if (all_S.at((W+2)*(i+1)+(j+1)) == '#') x++;
        //result_all_S += x;
        cout << x;
      }
    }
    cout << endl;
  }
}

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

using namespace std;

int main(void){
	string s,t;
	int i,j,n;
	bool flag;
	cin >> s >> t;
	n = t.length();
	for(i=(s.length()-n); i>=0; i--){
		flag=true;
		for(j=0; j<n; j++){
			if(s[i+j]!='?' && s[i+j]!=t[j]){
				flag=false;
				break;
			}
		}
		if(flag){
			for(j=0; j<n; j++){
				s[i+j]=t[j];
			}
			break;
		}
	}
	if(flag){
		for(i=(s.length()); i>=0; i--){
			if(s[i]=='?'){
				s[i]='a';
			}
		}
		cout << s << endl;
	}else{
		cout << "UNRESTORABLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(string S) {
    ll res = 0;
    S = S+"$";
    char c = S[0];
    int k = 1;
    for (int i = 1; i < S.size(); i++) {
        if (S[i] != c) {
            res += k/2;
            k = 1;
            c = S[i];
        }
        else {
            k++;
        }
    }
    return res;
}
int main () {
    string S;
    ll K;
    cin >> S >> K;
    ll a = f(S), b = f(S+S);
    cout << min(a*K-(a+a-b)*(K-1), (ll)S.size()*K/2) << endl;
}

Measured memory_bytes: 256
n = int(input())

def f_pf(n):
    pf = {}
    for i in range(2, n + 1):
        for j in range(2, i + 1):
            while i % j == 0:
                pf[j] = pf.get(j, 0) + 1
                i //= j
    return pf
    
mt75 = 0
mt25 = 0
mt15 = 0
mt5 = 0
mt3 = 0
for v in f_pf(n).values():
    if v >= 74:
        mt75 += 1
    if v >= 24:
        mt25 += 1
    if v >= 14:
        mt15 += 1
    if v >= 4:
        mt5 += 1
    if v >= 2:
        mt3 += 1
        
ans = 0
ans += mt75
ans += max(0, mt25 * (mt3 - 1))
ans += max(0, mt15 * (mt5 - 1))
ans += max(0, mt5 * (mt5 - 1) * (mt3 - 2) // 2)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b;
    cin>>a>>b;
    if(a%2!=0&&b%2!=0)
    {
        cout<<"Odd"<<NL;
    }
    else
    {
        cout<<"Even"<<NL;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define maxn 2005
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int n,a[maxn];
vector <int> adj[maxn];
bool vis[maxn];
vector <int> chi[maxn];
int gcd(int a,int b){
	if(a % b == 0) return b;
	return gcd(b,a % b);
}
void dfs(int u){
	vis[u] = true;
	for(int i=0;i<(int)adj[u].size();i++){
		int v = adj[u][i];
		if(!vis[v]){
			chi[u].push_back(v);
			dfs(v);
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a + 1,a + n + 1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i == j) continue;
			if(gcd(a[i],a[j]) != 1) adj[i].push_back(j);
		}
	}
	priority_queue <int> que;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i);
			que.push(i);
		}
	}
	for(int i=1;i<=n;i++){
		int u = que.top();que.pop();
		printf("%d%c",a[u],i == n ? '\n' : ' ');
		for(int j=0;j<(int)chi[u].size();j++){
			que.push(chi[u][j]);
		}
	}
	return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
long long dp[110000][13] = {};
const int MOD = 1000000007;

int rem[110000];

void init() {
    rem[0] = 1;
    for(int i=1; i<110000; ++i) {
        rem[i] = rem[i - 1] * 10 % 13;
    }
}

int main() {
    string S;
    cin >> S;
    reverse(begin(S), end(S));
    init();

    dp[0][0] = 1;
    for(int i=0; i<S.size(); ++i) {
        for(int j=0; j<13; ++j) {
            if(S[i] != '?') {
                int tmp = (int)(S[i] - '0') * rem[i] % 13;
                dp[i + 1][(j + tmp) % 13] += dp[i][j];
                dp[i + 1][(j + tmp) % 13] %= MOD;
            } else {
                for(int k=0; k<10; ++k) {
                    int tmp = k * rem[i] % 13;
                    dp[i + 1][(j + tmp) % 13] += dp[i][j];
                    dp[i + 1][(j + tmp) % 13] %= MOD;
                }
            }
        }
    }
    cout << dp[S.size()][5] << endl;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

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

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

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



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

  if(a<=b){
    cout<<a<<endl;
  }else{
    cout<<a-1<<endl;
  }

  return 0;
}


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

int main() {
	long n;
	cin >> n;
	map<string,long> mapa({
			{"AC",0},
			{"WA",0},
			{"TLE",0},
			{"RE",0}
			
		});
	
	while(n--){
		string temp;
		cin >> temp;
		mapa[temp]++;
	}
	
	cout << "AC" << " x " << mapa["AC"] << endl;
	cout << "WA" << " x " << mapa["WA"] << endl;
	cout << "TLE" << " x " << mapa["TLE"] << endl;
	cout << "RE" << " x " << mapa["RE"] << endl;
}



Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include<iostream>
#include<stack>
#include<cstring>
#include<algorithm>
using namespace std;

struct node{
    int x;
    int y;
    };
    bool Cmp(struct node x,struct node y){
            if(x.y==y.y)
                return x.x<y.x;
            else
            return x.y<y.y;
}
int main()
{
     int n,m,b[100002]={0};
     struct node a[100002];
     cin>>n>>m;
     for(int i=0;i<m;i++){
       int x,y;
        cin>>a[i].x>>a[i].y;
     }
     sort(a,a+m,Cmp);
     int num=0,min=n;
     for(int i=0;i<m;i++){
        if(a[i].y<min)
            min=a[i].y;
     }
     for(int i=0;i<m;i++){
       if(a[i].x>=min){
            min=a[i].y;
            num++;
        }
     }
     cout<<num+1;
}


Measured memory_bytes: 1024
#include<stdio.h>

int Fibonacci(int);

int main(){
    int i,n;
    scanf("%d",&n);
    printf("%d\n",Fibonacci(n+1));
    return 0;
}

int Fibonacci(int n){
    int i,num,m1,m2;
    if(n==0) return 0;
    if(n==1) return 1;
    num=0;
    m1=0;
    m2=1;
    for(i=0;i<n;i++){
        num=m1+m2;
        m2=m1;
        m1=num;
    }
    return num;
}


Measured memory_bytes: 2112
package main

import (
	"strings"
	"fmt"
	"bufio"
	"strconv"
	"os"
)

func projection(p1, p2, p []float64) []float64 {
	// p - p1
	v1 := []float64{
		p[0] - p1[0],
		p[1] - p1[1],
	}
	// p2 - p1
	v2 := []float64{
		p2[0] - p1[0],
		p2[1] - p1[1],
	}

	dot := v1[0]*v2[0] + v1[1]*v2[1]
	// cross := v1[0]*v2[1] - v1[1]*v2[0]
	normal := v2[0] * v2[0] + v2[1] * v2[1]

	a := dot / normal

	result := []float64{
		p1[0] + v2[0] * a,
		p1[1] + v2[1] * a,
	}
	return result
}

func reflection(p1, p2, p []float64) []float64 {
	prj := projection(p1, p2, p)

	// p to reflection
	toCrossPoint := []float64{
		2 * (prj[0] - p[0]),
		2 * (prj[1] - p[1]),
	}

	result := []float64{
		p[0] + toCrossPoint[0],
		p[1] + toCrossPoint[1],
	}

	return result
}

// solve
func solve(sc *bufio.Scanner) {
	sc.Scan()
	elements := strings.Split(sc.Text(), " ")

	n := len(elements)
	p1p2 := make([]float64, n)
	for i := 0; i < n; i++ {
		// @hack: not good xD
		pInt, _ := strconv.Atoi(elements[i])
		p1p2[i] = float64(pInt)
	}

	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())

	for i := 0; i < n; i++ {
		sc.Scan()
		pElms := strings.Split(sc.Text(), " ")
		pp := make([]float64, 2)

		// @hack not cool XD
		v, _ := strconv.Atoi(pElms[0])
		pp[0] = float64(v)
		v, _ = strconv.Atoi(pElms[1])
		pp[1] = float64(v)

		result := reflection(p1p2[:2], p1p2[2:], pp)
		fmt.Printf("%.10f %.10f", result[0], result[1])

		if i < n - 1 {
			fmt.Println()
		}
	}
}

// main
func main() {
	solve(bufio.NewScanner(os.Stdin))
}



Measured memory_bytes: 1220
char buf[10000000],out[11];
sz;
cnt[60];
main()
{
	read(0,buf,10000000);
	long N=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(;buf[sz]>='0';)
	{
		long A=0;
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			A=A*10+k-'0';
		}
		for(int i=0;i<60;i++)
		{
			cnt[i]+=A&1;
			A>>=1;
		}
	}
	long ans=0;
	for(int i=59;i>=0;i--)
	{
		ans=(ans*2+(N-cnt[i])*cnt[i])%1000000007;
	}
	int outsz=10;
	do{
		out[--outsz]=ans%10+'0';
	}while(ans/=10);
	write(1,out+outsz,10-outsz);
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
vector<double> v;
double ans,k;
int n;
int main(){
	int i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>k;
		v.push_back(k);
	}
	sort(v.begin(),v.end());
	ans=(v[0]+v[1])/2;
	for(i=2;i<v.size();i++)
	{
		ans=(ans+v[i])/2;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define F first
#define S second
const long long mod = 1000000007;

int N;
string s;
vector<pair<int, int> > vp; // 0--F  1--T
vector<int> hor, ver;
int xf, yf, xin = 0, yin = 0, abx, aby;

const int U=4000, V = 16000;
int dp[U][V];
void initialize() {
    for(int i = 0;i < U;i++) {
        for(int j = 0;j < V;j++) {
            dp[i][j] = -1;
        }
    }
}

bool possible(int i, vector<int> &A, int sum) {
    if(i == -1 and sum == 0) {
        return true;
    }
    if(i == -1) {
        return false;
    }

    if(dp[i][sum+8000] != -1) {
        return dp[i][sum+8000];
    }

    bool ans = possible(i-1, A, sum+A[i]) || 
               possible(i-1, A, sum-A[i]);

    return dp[i][sum+8000] = ans;
}

int main() {
    cin >> s;
    N = s.size();
    cin >> xf >> yf;
    int i = 0, j = 0;
    while(j < N) {
        if(s[j] == s[i]) {j++;continue;}
        vp.push_back({s[i] == 'T', j-i});
        i = j;
    }
    vp.push_back({s[i] == 'T', j-i});

    if(vp[0].F == 0) {
        xin = vp[0].S;
        vp.erase(vp.begin());
    }
    abx = abs(xf-xin);
    aby = abs(yf-yin);

    if(vp.size() != 0 && vp[vp.size()-1].F) {
        vp.pop_back();
    }

    if(vp.size() == 0) {
        if(abx == 0 and aby == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }

    bool hori = 1;
    for(int i = 0;i < vp.size();i += 2) {
        if(vp[i].S % 2 != 0) hori = !hori;
        if(hori) hor.push_back(vp[i+1].S);
        else ver.push_back(vp[i+1].S);
    }

    initialize();
    bool ans = possible(hor.size()-1, hor, abx);
    initialize();
    ans = ans && possible(ver.size()-1, ver, aby);

    if(ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using ull = unsigned long long;



void hawawa()
{
  long long h, w, n;
  cin >> h >> w >> n;
  set<pair<int, int> > s;
  unsigned long long ans[10] = {(h - 2) * (w - 2)};
  while (n--) {
    int a, b;
    cin >> a >> b;
    auto status = make_pair(a, b);
    s.insert(status);
    short cnt = 0;
    for (int i = a - 2; i <= a && i + 2 <= h; i++) {
      if (i <= 0) continue;
      for (int j = b - 2; j <= b && j + 2 <= w; j++) {
        if (j <= 0) continue;
        int cnt = 0;
        for (int k = 0; k < 3; k++) {
          for (int l = 0; l < 3; l++) {
            cnt += s.count(make_pair(i + k, j + l));
          }
        }
        if (cnt) {
          ans[cnt - 1]--;
        }
        ans[cnt]++;
      }
    }
  }
  for (auto&& i : ans) {
    cout << i << "\n";
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char* argv[]){
  std::string s;
  int a,b ;
  std::cin >> a >> b;

  if (a <= 8 && b <= 8){
    std::cout << "Yay!" << std::endl;
  } else {
    std::cout << ":(" << std::endl;      
  }

  return 0;  
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	string tmp = "keyence";
	if (s == tmp) {
		puts("YES");
		return 0;
	}
	int n = s.size();
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			string S = "";
			for (int k = 0; k < n; k++) {
				if (i <= k && k <= j) {
					continue;
				}
				else S.push_back(s[k]);
			}
			if (S == tmp) {
				puts("YES");
				return 0;
			}
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(b>=0&&b-a>=b)
    {
        cout<<"Zero"<<endl;
        return 0;
    }
    if(a>0)
    {
        cout<<"Positive"<<endl;
        return 0;
    }
    if((b-a)%2)
        cout<<"Positive"<<endl;
    else
        cout<<"Negative"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main()
{
    int i,n,l;
    cin>>n>>l;
    string s1;
    vector<string> s;
    for(i=0;i<n;i++){
        cin>>s1;
        s.push_back(s1);
    }
    sort(s.begin(),s.end());
    for(i=0;i<n;i++){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

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

int main() {
	int k, a, b;
	scanf("%d%d%d", &k, &a, &b);
	k++;

	int64_t res;
	if (b-a > 2) {
		if (k <= a) res = k;
		else res = a + (k-a)/2*(int64_t)(b-a) + (k-a)%2;
	} else res = k;

	std::cout << res << std::endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int a = 0;
		int b = 0;
		int c = 0;

		try (Scanner scanner = new Scanner(System.in)) {
			a = scanner.nextInt();
			b = scanner.nextInt();
			c = scanner.nextInt();
		}

		if(a>=0&&c<=100) {
			if(a<b&&b<c) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}

	}

}

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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    int n;
    cin >> n;
    V<int> a(n), b(n), c(n - 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; ++i) {
        cin >> c[i];
    }

    int pre = -1;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += b[a[i]];
        if (pre!=-1 && a[i] == pre + 1) {
            sum += c[pre];
        }
        pre = a[i];
    }
    cout<<sum<<endl;

    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll k, s;
	ll ans = 0;

	cin >> k >> s;

	REP(i, k + 1) {
		REP(j, k + 1) {
			if (s - i - j <= k && s - i - j >= 0) {
				ans++;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,  x,  y) for(int i = x; i <= y; i ++)
#define ll long long
#define X first
#define Y second
#define ls rt << 1
#define rs rt << 1 | 1
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n;
ll l;
string s;

int nxt[200010][2], tail = 1;
ll ans;

ll sg(int dep)
{
	ll rem = l - dep + 1;
	return rem & -rem;
}

void dfs(int cur, int dep)
{
	for(int i = 0; i < 2; i ++)
		if (nxt[cur][i] == -1) ans ^= sg(dep);
		else dfs(nxt[cur][i], dep+1);
}

int main()
{
	memset(nxt, -1, sizeof nxt);
	cin >> n >> l;
	for(int i = 0; i < n; i ++)
	{
		cin >> s;
		int it = 0;
		for(int j = 0; j < s.size(); j ++)
		{
			int dir = s[j] - '0';
			if (nxt[it][dir] == -1) nxt[it][dir] = tail++;
			it = nxt[it][dir];
		}
	}
	ans = 0LL;
	dfs(0, 1);
	puts(ans == 0 ? "Bob" : "Alice");

	return 0;
}


Measured memory_bytes: 6656
#include<iostream>
using namespace std;
int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double m=w*h;
    cout<<m/2<<endl;
    if(x==w/2&&y==h/2)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256