akhauriyash/Code-Regression huggingface dataset:
n,ma,mb = map(int, input().split())
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
#dp[i][j][k] := i番目まで考えたとき,薬品がjg, kgになる最小コスト
inf = 10**9
dp = [[[inf for i in range(n*11)] for j in range(n*11)] for k in range(n+1)]
for i in range(n):
    #0g, 0g にするためのコストは0
    dp[i][0][0] = 0
for i in range(1,n+1):
    typeA,typeB,cost = data[i-1]
    for j in range(n*11-typeA):
        for k in range(n*11-typeB):
            if dp[i][j+typeA][k+typeB] > dp[i-1][j][k] + cost:
                dp[i][j+typeA][k+typeB] = dp[i-1][j][k] + cost
            dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k])
ans = inf
for i in range(1,n*11):
    for j in range(1,n*11):
        if i / j == ma / mb:
            #print("{} {} {}".format(i,j,dp[n][i][j]))
            ans = min(ans, dp[n][i][j])
if ans == inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 111324
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b


using namespace std;




int main()
{
	Nayon;
	ll n,i,cnt=0;
	cin>>n;
	string s;
	cin>>s;
	for(i=0;i<n;i++){
		if(s[i]=='W'){
			cnt++;
		}
	}
	ll x=n-cnt;
	cnt=0;
	for(i=0;i<x;i++){
		if(s[i]=='W'){
			cnt++;
		}
	}
	cout<<cnt<<nl;
	return 0;
}


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

//Bの左上をAの(x,y)に合わせて一致するかを返す関数
bool check(vector<string> &a, vector<string> &b, int y, int x){
  int n = a.size(), m = b.size();
  
  for (int i=0; i<m; i++){
    for (int j=0; j<m; j++){
      if (b.at(i).at(j) != a.at(i+y).at(j+x)){
        return false;
      }
    }
  }
  
  return true;
}

int main() {
  int n, m; cin >>n >>m;
  vector<string> a(n);
  for (int i=0; i<n; i++) cin >> a.at(i);
  vector<string> b(m);
  for (int i=0; i<m; i++) cin >> b.at(i);
  
  int times = n-m+1;
  bool ans = false;
  bool esc = false;
  
  for (int i=0; i<times; i++){
    for (int j=0; j<times; j++){
      if (check(a,b,i,j)){
        ans = true;
        esc = true;
        break;
      }
    }
    if(esc){
      break;
    }
  }
  
  if(ans){
    cout <<"Yes" <<endl;
  }else{
    cout <<"No" <<endl;
  }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define mem(a) memset(a, 0, sizeof(a))
#define sqr(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int mn = 1e5 + 5;
const int mod = 1e9 + 7;
#define P mod

int k,a,b;

int main() {
#ifdef LOCAL
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%d%d%d",&k,&a,&b);
    ll ans=k+1;
    if (a<b){
        int uk=k-(a-1);
        ll uans=a;
        if (uk%2)uk--,uans++;
        uans+=1ll*(uk/2)*(b-a);
        ans=max(ans,uans);
    }
    printf("%lld\n",ans);

    return 0;
}


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


int a[52]={0};
long long int dp[2][52]={0};
int main(){
    int n, p;
    cin >> n >> p;
    int odd=0, even=0;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    dp[0][0] = 1;
    for(int i=1;i<=n;++i){
        int oe = a[i] & 1;
        for(int j=0;j<2;++j){
            int tmp = (oe + j) & 1;
            dp[j][i] += dp[j][i-1];
            dp[tmp][i] += dp[j][i-1];
        }
    }
    cout << dp[p][n] << endl;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
liA=list(map(int,input().split()))
liA.sort()
#print(liA)

liB=[0]*(m-1)
for i in range(m-1):
  liB[i]=liA[i+1]-liA[i]
  
liB.sort()
#print(liB)
ans=0
for i in range(m-n):
  ans=ans+liB[i]
  #print(ans)
print(ans)

Measured memory_bytes: 13968
//
//AtCoder Beginner Contest 177
//B
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    string s, t;
    cin >> s >> t;
    int slen=s.size();
    int tlen=t.size();

    int ans = slen;
    REP(i, slen-tlen+1){
        int cnt=0;
        REP(j, tlen){
            if (s[i+j]!=t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int H,W;
char a[110][110];
int main(){
  cin>>H>>W;
  rep(i,H){
    rep(j,W){
      cin>>a[i][j];
    }
  }
  int cn[26];
  fill(cn,0);
  rep(i,H){
    rep(j,W){
      int index=a[i][j]-'a';
      cn[index]++;
    }
  }
  int f=H/2*(W/2),t,o;
  if(H%2==1&&W%2==1){
    o=1;
    t=H/2+W/2;
  }
  else if(H%2==1){
    o=0;
    t=W/2;
  }
  else if(W%2==1){
    o=0;
    t=H/2;
  }
  else{
    o=0;
    t=0;
  }
  rep(i,26){
    int x=cn[i]/4;
    if(x>0){
      if(f>=x){
	cn[i]-=4*x;
	f-=x;
      }
      else{
	cn[i]-=4*f;
	f=0;
	break;
      }
    }
  }
  rep(i,26){
    int x=cn[i]/2;
    if(x>0){
      if(t>=x){
	cn[i]-=2*x;
	t-=x;
      }
      else{
	cn[i]-=2*t;
	t=0;
	break;
      }
    }
  }
  bool ff;
  if(f!=0||t!=0) ff=false;
  else ff=true;
  rep(i,26){
    if(cn[i]>1){
      ff=false;
      break;
    }
    else if(cn[i]==1){
      if(o==0){
	ff=false;
	break;
      }
      else o=0;
    }
    else continue;
  }
  if(ff) prin("Yes");
  else prin("No");
  return 0;
}


Measured memory_bytes: 256
s=gets.chomp
t=gets.chomp
k=-1
for i in 0...s.size
  ok=true
  for j in 0...t.size
    ok=false if !s[i+j] || s[i+j]!=?? && s[i+j]!=t[j]
  end
  k=i if ok
end

for i in k...k+t.size
  s[i]=t[i-k]
end

if k<0
  puts "UNRESTORABLE"
else
  puts s.tr(??, ?a)
end


Measured memory_bytes: 1788
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	long long int odd = 0, even = 0;
	for (int i = 0; i < N; i++) {
		cin >> M;
		if (M % 2) {
			odd++;
		}
		else {
			even++;
		}
	}
	cout << pow(3, N) - pow(2, even) << endl;
	return 0;
}


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

int main(){
    const long long MODULO = (1e9) + 7;
    int N;
    cin >> N;

    long long pow8 = 1;
    long long pow9 = 1;
    long long pow10 = 1;
    for(int i = 1; i <= N; ++i){
        pow8 = (8 * pow8) % MODULO;
        pow9 = (9 * pow9) % MODULO;
        pow10 = (10 * pow10) % MODULO;
    }

    long long answer = (pow10 - 2 * pow9 + pow8 + 2 * MODULO) % MODULO; 
    cout << answer;

    return 0;
}

Measured memory_bytes: 3596
S=input()
n=len(S)
if n%2==0:
    count=0
else:
    count=1
for i in range(n):
    if i%2==0 and S[i]!="h":
        count+=1
    elif i%2==1 and S[i]!="i":
        count+=1
if count==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
def f(b, n):
  return n % b + f(b, n // b) if n > 0 else 0
n = int(input())
s = int(input())
for i in range(2, 5**8):
  if f(i, n) == s:
    print(i)
    exit()
for i in range(n - s >> 18, 0, -1):
  if f((n - s) // i + 1, n) == s:
    print((n - s) // i + 1)
    exit()
print(n + 1 if n == s else -1)

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

int main() {
  int i,j,n,k,a,b,aa=0,bb=0,min=100000000;
  cin>>n;
  for(i=1;i<n;i++){
    a=i;
    b=n-i;
    aa=0;
    bb=0;
    while(a>0){
      aa+=a%10;
      a/=10;
    }
    while(b>0){
      bb+=b%10;
      b/=10;
    }
    if(aa+bb<min){
      min=aa+bb;
    }
   // cout<<aa<<" "<<bb<<" "<<min<<endl;
  }
  
  cout<<min<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string a,b,c;
    cin>>a>>b>>c;
    int A,B,C;
    A=a.size();
    B=b.size();
    C=c.size();
    if(a[A-1]==b[0]&&b[B-1]==c[0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++)
#define ll long long

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    int sum = 0;
    rep(i, 0, n) {
        cin >> s[i];
        cin >> t[i];
        sum += t[i];
    }
    string x;
    cin >> x;
    int diff = 0;
    int flag = 0;
    rep(i, 0, n) {
        if(s[i] == x) {
            flag = 1;
        }
        else {
            if(flag == 1) {
                diff += t[i];
            }
        }
    }

    cout << diff << endl;

    return 0;
}

Measured memory_bytes: 256
local n=io.read("n")
for i=1,3500 do
    for j=1,3500 do
        local k=n*i*j/(4*i*j-n*j-n*i)
        if math.fmod(k,1)==0 and k>=0 then
            print(i.." "..j.." "..string.format("%d",k))
            return
        end
    end
end

Measured memory_bytes: 2852
#include <iomanip>
#include <iostream>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int K;
  cin >> K;
  queue<int64_t> que;
  for (int64_t i = 1; i <= 9; ++i) que.emplace(i);
  while (--K) {
    int64_t x = que.front();
    que.pop();
    int64_t x0 = 10 * x + (x % 10);
    int64_t x1 = x0 - 1;
    int64_t x2 = x0 + 1;
    if ((x % 10) != 0) que.emplace(x1);
    que.emplace(x0);
    if ((x % 10) != 9) que.emplace(x2);
  }
  cout << que.front() << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; 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;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

string s;

void solve() {
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();

        var sumA = A.Sum();
        var sumDoubleEvenA = A.Where((x, i) => i % 2 == 0).Select(x => x * 2).Skip(1).Sum();
        var sumDoubleOddA = A.Where((x, i) => i % 2 == 1).Select(x => x * 2).Sum();

        var R = new long[N];

        for (int i = 0; i < N; i++)
        {
            if(i % 2 == 0)
            {
                R[i] = sumA - sumDoubleOddA;
                sumDoubleOddA -= A[(i + 1 + N) % N] * 2;
                sumDoubleOddA += A[(i + 0 + N) % N] * 2;
            }
            else
            {
                R[i] = sumA - sumDoubleEvenA;
                sumDoubleEvenA -= A[(i + 1 + N) % N] * 2;
                sumDoubleEvenA += A[(i + 0 + N) % N] * 2;
            }
        }

        for (int i = 0; i < N; i++)
            Write($"{R[i]}{(i < N - 1 ? ' ' : '\n')}");
    }
}


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

int main() {
    int n, h, w, cnt=0;
    cin >> n >> h >> w;
    for (int i=0; i<n; i++) {
        int a, b;
        cin >> a >> b;
        if (a>=h && b>=w) {
            cnt += 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 888
import sys

input = sys.stdin.readline

mod = 998244353

n, k = map(int, input().split())

lr = [list(map(int, input().split())) for _ in range(k)]
lr.sort()

a = [0] * n
a[0] = 1
a[1] = -1
f = [1]

for i in range(n - 1):
    for l, r in lr:
        if i + l < n:
            a[i + l] += f[i]
            a[i + l] %= mod
        else:
            break
        if i + r + 1 < n:
            a[i + r + 1] -= f[i]
            a[i + r + 1] %= mod
        else:
            break
    f.append((f[i] + a[i + 1]) % mod)
print(f[n - 1])


Measured memory_bytes: 86780
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
long long int pows(int a, int b) {
    long long int g = 1;
    for (int i = 0; i < b; i++) {
        g *= a;
        g %= 1000000007;
    }
    return g;
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort (a, a + n);
    int ans1 = 0;
    if (n % 2 == 1) {
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] == 0) {
                ans++;
            }
            if (a[i] % 2 == 1) {
                cout << 0;
                return 0;
            }
        }
        if (ans != 1) {
            cout << 0;
            return 0;
        }
        for (int i = 1; i < n - 1; i += 2) {
            if (a[i] == a[i + 1] && a[i] < n) {
                ans1 ++;
            }
            else {
                cout << 0;
                return 0;
            }
            if (a[i] > 1) {
                if (a[i] == a[i - 2]) {
                    cout << 0;
                    return 0;
                }
            }
        }
        if (ans1 == n / 2) {
            long long int b = pows(2, n / 2);
            cout << b;
            return 0;
        }
    }
    else {
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0) {
                cout << 0;
                return 0;
            }
        }
        for (int i = 0; i < n - 1; i += 2) {
            if (a[i] == a[i + 1] && a[i] < n) {
                ans1++;
            }
            else {
                cout << 0;
                return 0;
            }
            if (a[i] > 1) {
                if (a[i] == a[i - 2]) {
                    cout << 0;
                    return 0;
                }
            }
        }
        if (ans1 == n / 2) {
            long long int b = pows(2, n / 2);
            cout << b;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 640
while true
	h, w = gets.split( " " ).map { | val | val.to_i }
	break if 0 == h && 0 == w
	
	pa = [ "#", "." ]
	for i in ( 0 ... h ) 
		for j in ( 0 ... w )
			print( "#{pa[(i+j)%2]}" )
		end
		print( "\n" )
	end
	print( "\n" )
end

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, a; cin >> n >> a;
  cout << n * n - a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a[10000];
    gets(a);
    for (int i=0;i<strlen(a);i++)
    {
    	if (i==0)
    	cout<<a[i];
    	else
    	if (a[i]==' ')
    	cout<<a[i+1];
	}
	cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int MaxPrime = 1300000;

bool prime[MaxPrime];

void init_prime() {
  prime[0] = prime[1] = false;
  for (int i=2;i<MaxPrime;i++) prime[i] = true;
  for (int i=2;i<MaxPrime;i++) {
    if (!prime[i]) continue;
    for (int j=i+i;j<MaxPrime;j+=i) prime[j] = false;
  }
}

int main() {
  init_prime();
  int n;
  while (scanf("%d", &n), n!=0) {
    if (prime[n]) {
      puts("0");
      continue;
    }
    int b = n, e = n;
    while (!prime[b]) b--;
    while (!prime[e]) e++;
    printf("%d\n", e-b);
  }
  return 0;
}

Measured memory_bytes: 3928
let () = 
  Printf.printf "%d\n" @@
  List.length @@
  Scanf.scanf "%d" (fun n -> List.filter (( >= ) n)) @@
  List.map (List.fold_left (fun acc -> ( + ) @@ 10 * acc) 0) @@
  List.filter (fun acc ->
    List.mem 7 acc && List.mem 5 acc && List.mem 3 acc) @@
  fst @@ Array.fold_left (fun (acc, curr) ds ->
    curr @ acc, List.concat @@ List.map (fun d ->
      List.map (fun curr -> d :: curr) curr) ds) ([[]], [[]]) @@
  Array.make 10 [7; 5; 3]

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

const int MOD = 1e9 + 7;

int add(int x,int y)
{
	return ((x % MOD) + (y % MOD)) % MOD;
}

char tab[1010][1010];
int DP[1010][1010];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	for (int i = 1 ; i <= n ; i++)
		for (int j = 1 ; j <= m ; j++)
			cin >> tab[i][j];
	DP[1][1] = 1;
	for (int i = 2 ; i <= m ; i++)
		DP[1][i] = (tab[1][i] == '.') * DP[1][i - 1];
	for (int i = 2 ; i <= n ; i++)
		DP[i][1] = (tab[i][1] == '.') * DP[i - 1][1];
	for (int i = 2 ; i <= n ; i++)
		for (int j = 2 ; j <= m ; j++)
		{
			if (tab[i][j] == '#')
				DP[i][j] = 0;
			else
				DP[i][j] = add(DP[i - 1][j],DP[i][j - 1]);
		}
	// for (int i = 1 ; i <= n ; i++)
	// {
	// 	for (int j = 1 ; j <= m ; j++)
	// 		cout << DP[i][j] << " ";
	// 	cout << endl;
	// }
	cout << DP[n][m] << endl;
}

Measured memory_bytes: 5248
N = int(input())

def divisor(n):
    res = []
    i = 1
    while i*i <= n:
        if n % i == 0:
            res.append(i)
            if i != n//i:
                res.append(n // i)
        i += 1
    return res

ans = 0
for i in range(1, N+1, 2):
    res = len(divisor(i))

    ans += 1 if res == 8 else 0

print(ans)


Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
typedef long long ll;
using namespace std;

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

const long long INF = 1LL << 60;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
ll ma = 1000000000 + 7;


ll N,h,n,w;
int main() {
	cin >> N;
	for (int i = 1;i <= 3500;i++) {
		for (int j = 1;j <= 3500;j++) {
			h = i;n = j;
			if (4 * h*n - N * n - N * h != 0&& (N*h*n) % (4 * h*n - N * n - N * h)==0) {
				w = (N*h*n) / (4 * h*n - N * n - N * h);
				if (w >= 1) {
					cout << h << " " << n << " " << w << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int n;
  cin >> n;
  if(90<=n){cout<<"Yes"<<endl;}
  else if(n%10==9){cout<<"Yes"<<endl;}
  else{cout << "No" << endl;}
 
  return 0;
}

Measured memory_bytes: 256
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()

def main():
    S = IS()
    T = IS()
    if len(S)+1 == len(T) and S == T[:-1]: print('Yes')
    else: print('No')
if __name__ == '__main__':
    main()

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

long long A[200005], B[200005];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int n, m, k;
    cin >> n >> m >> k;

    for (int i=1; i<=n; i++)
        cin >> A[i];
    
    for (int i=1; i<=m; i++)
    {
        cin >> B[i];
        B[i] += B[i-1];
    }

    int ans = upper_bound(B+1, B+1+m, k) - B - 1;

    for (int i=1; i<=n; i++)
    {
        k -= A[i];

        if (k < 0)
            break;
        
        ans = max(ans, i + (int) (upper_bound(B+1, B+1+m, k) - B - 1));
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6760
def make_divisors(n):
    divisors = {}
    tmp = n
    for div in range(2, int(n**0.5)+1):
        if n % div == 0:
            divisors[div] = 0
        while n % div == 0:
            n //= div
            divisors[div] += 1
        div += 1
    if n > 1:
        divisors[n] = 1
    return divisors

def resolve():
    n = int(input())
    div = make_divisors(n)
    ans = 0
    for k,v in div.items():
        cnt = 1
        while v >= cnt:
            ans += 1
            v -= cnt
            cnt += 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9404
using System;
using System.IO;

namespace Binary_search_trees
{
    class Binary_Search_Tree_I
    {
        class BinaryTree
        {
            public class Node
            {
                internal int val;
                internal Node left, right, parent;

                internal Node() : this(0, null) { }

                internal Node(int val, Node parent)
                {
                    this.val = val;
                    this.parent = parent;
                    left = right = null;
                }
            }

            Node root;

            public BinaryTree()
            {
                root = null;
            }

            public void Insert(int elem)
            {
                if (root == null)
                {
                    root = new Node(elem, null);
                    return;
                }

                Node n = root;
                Node p = null;
                while (n != null)
                {
                    p = n;
                    if (n.val > elem) n = n.left;
                    else n = n.right;
                }

                n = new Node(elem, p);
                if (p.val > elem) p.left = n;
                else p.right = n;
            }

            public void PrintPreorder(Node n)
            {
                if (n == null) return;
                Console.Write(" " + n.val);
                PrintPreorder(n.left);
                PrintPreorder(n.right);
            }

            public void PrintPreorder()
            {
                PrintPreorder(root);
                Console.WriteLine();
            }

            public void PrintInorder(Node n)
            {
                if (n == null) return;
                PrintInorder(n.left);
                Console.Write(" " + n.val);
                PrintInorder(n.right);
            }

            public void PrintInorder()
            {
                PrintInorder(root);
                Console.WriteLine();
            }
        }

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var bt = new BinaryTree();
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine();
                if (line.Length == 5) { bt.PrintInorder(); bt.PrintPreorder(); }
                else bt.Insert(int.Parse(line.Substring(7)));
            }

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 46672
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    colors = [0] * 9
    rate = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801]

    for ai in a:
        for k in range(9):
            if rate[k] <= ai < rate[k + 1]:
                colors[k] += 1
                break

    count = 0

    for i in range(7):
        if colors[i] > 0:
            count += 1

    red = colors[7]
    legend = colors[8]

    if (red == 0) and (legend == 0):
        print(count, count)
    elif (red > 0) and (legend == 0):
        print(count + 1, count + 1)
    elif (red == 0) and (legend > 0):
        print(count + 1, count + legend)
    else:
        print(count + 1, count + 1 + legend)


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int h,n,i,a[1000000];
   
    scanf("%d%d",&h,&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    i=0;
    while(i<n){
        h-=a[i];
        i++;
    }
    if(h<=0) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define fread           freopen("input.txt","r",stdin)
#define fwrite          freopen("output.txt","w",stdout)
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define memo(ara,val)   memset(ara,val,sizeof(ara))
#define II              ( { int a ; read(a) ; a; } )
#define LL              ( { ll a ; read(a) ; a; } )
#define DD              ({double a; scanf("%lf", &a); a;})
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              printf("\n")
#define sc(x)           scanf("%lld",&x)
#define scw(x)          scanf("%I64d",&x)
#define sci(x)          scanf("%d",&x)
#define sc2(x,y)        scanf("%lld %lld",&x,&y)
#define sc3(x,y,z)      scanf("%lld %lld %lld",&x,&y,&z)
#define Found(a, b)     a.find(b) != a.end()
// bool operator< (const node& sx) const { return sx.val < val; }
//set<ll,greater<ll> >st;
//priority_queue<ll , vector<ll> , greater<ll> >
template<class T>inline bool read(T &x){ int c=getchar();int sgn=1;
  while(~c&&c<'0'|c>'9'){if(c=='-')sgn=-1;c=getchar();}
  for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())x=x*10+c-'0';x*=sgn;return ~c;
}
const ll N = 100005;
const ll MOD = 1e9+7;
ll ara[N];
int main(){
    ll n = LL;
    rep1(i, n) ara[i] = LL;
    ll s = 0;
    for(ll i = 1; i<=n-2; ++i){
          vector<ll>v;
          v.eb(ara[i]);
          v.eb(ara[i+1]);
          v.eb(ara[i+2]);
          sort(all(v));
          if(v[1]==ara[i+1]) ++s;
    } pf(s),ln;
}












Measured memory_bytes: 256
from heapq import heappush, heappop,heapify
N,M = map(int,input().split())


A_list = list(map(lambda a : -int(a),input().split()))
#print(A_list)
heapify(A_list)
#print(-heappop(A_list))
for i in range(M):
    tmp = -heappop(A_list)//2
    heappush(A_list,-tmp)
print(-sum(A_list))

'''
3 3 
8 6 5
4 4
8 7 6 5 
10 6
10 7 6 5 8 9 10 11 12 13
'''



Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const double PI = acos(-1);

int main() {
    double r; cin >> r;
    cout << fixed << setprecision(10) << 2 * PI * r << endl;
}


Measured memory_bytes: 3764
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
 
using namespace std;
int main(void){
    // Your code here!
    int abcd;
    int s_int[4];
    int sum;
    string ans = "";
    cin >> abcd;
    for(int i = 3; i >= 0; i--){
        s_int[i] = abcd % 10;
        abcd /= 10;
    }
    for(int i = 0; i < 8; i++){
        int k = i;
        sum = s_int[0];
        ans = to_string(s_int[0]);
        
        for(int j = 1; j < 4; j++){
            if(k % 2 == 0){
                sum += s_int[j];
                ans = ans + "+" + to_string(s_int[j]);
            }else{
                sum -= s_int[j];
                ans = ans + "-" + to_string(s_int[j]);
            }
            k /= 2;
        }
        if(sum == 7){
            cout << ans <<"=7";
            break;
        }
    }
}

Measured memory_bytes: 256
N=int(input())
list=list(map(int,input().split()))

list=sorted(list)[::-1]
A=0
B=0

for i in range(0,len(list)):
  if i%2==0:
    A=A+list[i]
  else:
    B=B+list[i]
    
print(A-B)

Measured memory_bytes: 3060
import sys

# sys.stdin = open('d1.in')


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    k = read_int()
    n = 50
    q, r = divmod(k, n)
    a = [n - 1 + q] * n
    for i in range(r):
        a[i] += n - r + 1
    for i in range(r, n):
        a[i] += -r
    return n, a


def main():
    n, a = solve()
    print(n)
    print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
using llint = long long int;
using lint = long int;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		cin >> c[i];
	}
	int ans = 0;
	rep(i, n) {
		if (v[i] - c[i] > 0) {
			ans += v[i] - c[i];
		}
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int n,m;
    cin >> n >> m;
    vector<int>h(n+1);
    for(int i=1;i<=n;i++)cin >> h[i];
    vector<bool>v(n+1,true);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        if(h[a]>h[b])v[b]=false;
        if(h[a]<h[b])v[a]=false;
        if(h[a]==h[b]){
            v[a]=v[b]=false;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(v[i])ans++;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3764
def c_anti_division(A, B, C, D):
    from fractions import gcd

    def num_calc(n):
        """1からnまでの、CでもDでも割り切れない整数の数"""
        return n - (n // C + n // D - n * gcd(C, D) // (C * D))
    return num_calc(B) - num_calc(A - 1)

A, B, C, D = [int(i) for i in input().split()]
print(c_anti_division(A, B, C, D))

Measured memory_bytes: 5040
#include<cstdio>
#define N 100005
#define mod 1000000007
int n,k,a[105],dp[105][N],sum[N];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;++i)scanf("%d",&a[i]);
	sum[0]=1;
	for(int i=1;i<=k;++i)sum[i]=1;
	for(int i=0;i<n;++i){
		for(int j=0;j<=k;++j)dp[i][j]=(sum[j]+mod-(j-a[i]-1<0?0:sum[j-a[i]-1]))%mod;
		sum[0]=dp[i][0];
		for(int j=1;j<=k;++j)sum[j]=(sum[j-1]+dp[i][j])%mod;
	}
	printf("%d\n",dp[n-1][k]);
	return 0;
}

Measured memory_bytes: 41088
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;
ll possum[MAX], psum[MAX];

int main()
{
	int i, j, k;
	ll x;
	scanf("%d%d", &N, &K);
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &x);
		psum[i] = psum[i - 1] + x;
		possum[i] = possum[i - 1] + (x > 0LL ? x : 0LL);
	}
	ll maxi = -LINF;
	for (i = 1; i + K - 1 <= N; ++i) {
		maxi = max(maxi, possum[N] - possum[i + K - 1] + possum[i - 1]);
		maxi = max(maxi, possum[N] - possum[i + K - 1] + possum[i - 1] + psum[i + K - 1] - psum[i - 1]);
	}
	printf("%lld", maxi);
}

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

//point
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
	bool cmp_y(const P &a, const P &b){
		return a.imag() != b.imag() ? a.imag() < b.imag() : a.real() < b.real();
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}
P n_vector(P a){
  double l = abs(a);
  return P(-a.imag(), a.real())/l;
}

// line
struct L : public vector<P> {
	L(const P& a, const P& b) {
		push_back(a); push_back(b);
	}
};

P projection(const L &l, const P &p) {
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}
double distanceLP(const L &l, const P &p) {
	return abs(p - projection(l, p));
}

// circle
struct C {
	P p; double r;
	C(const P& p, double r) : p(p), r(r) {}
};

int intersectCC(const C& a, const C& b) {
	double dist = sqrt(norm(a.p-b.p)), r1 = a.r + b.r, r2 = abs(a.r - b.r);
	if(r1 < dist) return 4;		//??\?????????
	if(dist == r1) return 3;	//?????\
	if(r2 < dist && dist < r1) return 2; //?????????
	if(dist == r2) return 1; //?????\
	return 0;	//??????
}

vector<P> crossPointCL(C c, L l) {
	double d = distanceLP(l, c.p), r = c.r;
	P m = projection(l, c.p);
	P x = sqrt(r*r-d*d)/abs(l[1]-l[0])*(l[1]-l[0]);
	vector<P> ret(2,m);
	ret[0] -= x;
	ret[1] += x;
	sort(ret.begin(), ret.end());	//!!!
	return ret;
}

vector<P> crossPointCC(C a, C b) {
	double d = abs(a.p-b.p);
	double t = (a.r*a.r-b.r*b.r+d*d)/2/d, h = sqrt(a.r*a.r-t*t);
	P m = t/abs(b.p-a.p)*(b.p-a.p)+a.p;
	P n = n_vector(a.p-b.p);
	vector<P> ret(2, m);
	ret[0] -= h*n;
	ret[1] += h*n;
	sort(ret.begin(), ret.end());	//!!!
	return ret;
}	

vector<P> tangentLC(P p, C c) {
	C c2 = C((p+c.p)/2.0, abs(p-c.p)/2.0);
	return crossPointCC(c, c2);
}

int main() {
	double x1, y1, r1, x2, y2;
	cin >> x2 >> y2 >> x1 >> y1 >> r1;
	C c1(P{x1, y1}, r1);
	P p(x2, y2);
	vector<P> ans =	tangentLC(p, c1);
	cout << fixed << setprecision(15) << ans[0].real()+0 << " " << ans[0].imag()+0 << endl << ans[1].real()+0 << " " << ans[1].imag()+0 << endl;
}

Measured memory_bytes: 3292
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define pb push_back
#define s(a) (int)(a).size()
#define all(x) (x).begin(),(x).end()
#define endl ("\n")

using ll = long long;
using ld = long double;
const ll M = 1000000007;
const ld pi = 3.14159265358979323846;

long long mod(long long x)
{
    return ((x%M + M)%M);
}

long long add(long long a, long long b)
{
    return mod(mod(a)+mod(b));
}

long long mul(long long a, long long b)
{
    return mod(mod(a)*mod(b));
}

void solve()
{
	int n, k;
	cin >> n >> k;
	map <int, int> mp;
	for(int i = 0; i < k; i++)
	{
		int t;
		int a;
		cin >> t;
		while(t--)
		{
			cin >> a;
			mp[a]++;
		}
	}
	ll sum = 0;
	for(int i = 1; i <= n; i++)
	{
		if(mp[i] == 0)
			sum++;
	}
	cout << sum << endl;
}

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

	int tt = 1;
	//cin >> tt;
	for(int test_case = 1; test_case <= tt; test_case++)
	{
		//cout << "Case #" << test_case << ": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;


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

	int ans;
	if (n >= 10) {
		ans = r;
	} else {
		ans = r + 100 * (10 - n);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
word = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n = int(input())
s = input()
answer = ''
for i in range(len(s)):
    iti = word.find(s[i])
    if iti + n + 1 > len(word):
        answer += word[iti+n-len(word)]
    else:
        answer += word[iti+n]
print(answer)

Measured memory_bytes: 73456
#include<stdio.h>

int main(void){

    int N;
    scanf("%d", &N);

    N%=10;

    if(N==3){
        printf("bon");
    }
    else if(N==2||N==4||N==5||N==7||N==9){
        printf("hon");
    }
    else{
        printf("pon");
    }

    return 0;
}

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

int main(){
  int k,x;
  scanf("%d%d",&k,&x);
  
  for(int i = x-k+1;i<x+k;i++){
    printf("%-5d",i);
  }
}
  

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

int main()
{
  int a[6], k;
  for (int i = 0; i < 5; i++)
  {
    cin >> a[i];
  }

  cin >> k;

  for (int i = 0; i < 5; ++i)
  {
    for (int j = i + 1; j < 5 - i; j++)
    {
      if(a[j] - a[i] > k)
      {
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;
  
  return 0;
}


Measured memory_bytes: 256
_ = input()
A = map(int, input().split())
prev = next(A)
up = None
count = 1
for i in A:
    if prev < i:
        if up is None:
            up = True
        elif not up:
            count += 1
            up = None
    elif prev > i:
        if up is None:
            up = False
        elif up:
            count += 1
            up = None
    prev = i
print(count)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   
   long int n;
   cin>>n;
   n %= 26;


   string s;
   cin>>s;

   for(long int i = 0; i < s.size(); i++){
      s[i] = (s[i] + n);
      if(s[i] > 'Z'){
         s[i] = s[i] - 'Z' + 'A' - 1;
      }
   }   

   cout<<s;
   return 0;
}

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

signed main()
{
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int a;
 cin>>a;
 int sum = 0;
 sum+=a+pow(a,2)+pow(a,3);
 cout<<sum<<"\n";



  return 0;
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
int n,a[100010];
int main(){
	int i,j;
	scanf("%d",&n);
	for(i = 1;i <= n;++i) scanf("%d",&a[i]);
	int as = 0;
	for(i = 1;i <= n + 1;++i) as += abs(a[i] - a[i - 1]);
	int tmp;
	for(i = 1;i <= n;++i){
		tmp = abs(a[i + 1] - a[i - 1]) - abs(a[i + 1] - a[i]) - abs(a[i] - a[i - 1]);
		printf("%d\n",as + tmp);
	}  
	return 0;
} 

Measured memory_bytes: 1664
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        double c = (double)a/b;
        String d = String.format("%.5f", c);
        System.out.println(a/b+" "+a%b+" "+d);
    }
}



Measured memory_bytes: 26256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string o,e;
void input(){
    fast_io();
    cin >> o >> e;
}

int solve(){
    string ans;
    for (int i = 0; i < o.length(); i++)
    {
        ans += o[i];
        if(i<e.length()) ans += e[i];
    }
    cout << ans << endl;
    
    return 0;
}   

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

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

int main(){
    std::string S, T;
    std::cin >> S >> T;
    
    int max = 0;
    for(int i=0; i<S.size() - T.size() + 1; i++){
        int cnt = 0;
        for(int j=0; j<T.size(); j++){
            if(S[i+j] == T[j]){
                cnt++;
            }
        }
        if(max < cnt){
            max = cnt;
        }
    }
    
    std::cout << T.size() - max << std::endl;
    
    
    return 0;
    
}


Measured memory_bytes: 3620
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(3*n**2)
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39152
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string a, b;
	cin >> a >> b;

	if ((a == "H") && (b == "H")) cout << "H\n";
	else if ((a == "D") && (b == "D")) cout << "H\n";
	else cout << "D\n";

	return 0;
}



Measured memory_bytes: 256
using System;


public class A
{
	public static void Main()
	{
		int D = Int32.Parse(Console.ReadLine());
		switch(D)
		{
			case 25:
				Console.WriteLine("Christmas");
				break;
				
			case 24:
				Console.WriteLine("Christmas Eve");
				break;
				
			case 23:
				Console.WriteLine("Christmas Eve Eve");
				break;
				
			case 22:
				Console.WriteLine("Christmas Eve Eve Eve");
				break;
				
			default:
				break;			
		}
	}	
}

Measured memory_bytes: 13140
// 0584.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n, a[10000];

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n);
	if (n == 3) {
		a[3] = 10001;
	}

	vector<int> vec;
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			if (i == j)
				continue;
			vec.push_back(stoi(to_string(a[i]) + to_string(a[j])));
		}
	}
	sort(vec.begin(), vec.end());
	cout << vec[2] << endl;

    return 0;
}

Measured memory_bytes: 3264