akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#define b(n)c##n=v(B[*(d+n)][i]),
#define g(a,b,k)if(c##a==B[*(d+b)][j])h|=1<<k;
std::string B[8];int u(int f,int r){int t[]={0,2,4,1,3,0,3,0,0,5,0,2,1,5,0,0,0,4,4,0,0,0,5,1,2,0,5,0,0,3,0,3,1,4,2,0};return t[f*6+r];}int q(int h){return 5-h;}int v(int c){return c+(c>96?-32:32);}int o(int f,int x){for(int i=0,c=0;i<6;i++)if(f!=i&&q(f)!=i){if(c==x)return i;c++;}}int w[4],z[4];bool C(int*d,int x,int nest,int*l,int e,bool(*f)(int*)){int c=v(B[*d][x]),i,a;if(nest==3){for(a=0;a<4;a++){int ar=o(e,a);if(c==B[*(d-3)][ar]){l[0]=u(ar,e);return true;}}}else{d++;for(i=0;i<6;i++)if(c==B[*d][i])for(a=0;a<4;a++){int ar=o(i,a);l[nest+1]=u(i,ar);if(C(d,ar,nest+1,l,e,f)){if(nest==2){if(f(d))return true;}else{return true;}}}}return false;}bool S(int*l){l-=7;for(int i=0;i<4;i++)if(v(B[l[i]][q(w[i])])!=B[(l+4)[i]][z[i]])return false;return true;}bool K(int*d){++d;for(int i=0;i<6;i++)if(C(d,i,0,z,i,S))return true;return false;}bool p(int*d){int h=0,i=0,k;for(;i<6;i++){int b(0)b(1)b(2)b(3)b(4)b(5)b(6)b(7)j;for(j=0;j<6;j++){g(0,1,0)g(1,2,1)g(2,3,2)g(3,0,3)g(4,5,4)g(5,6,5)g(6,7,6)g(7,4,7)g(0,4,8)g(1,5,9)g(2,6,10)g(3,7,11)if(h==4095){for(k=0;k<6;k++)if(C(d,k,0,w,k,K)){puts("YES");return true;}return false;}}}return false;}int main(){for(;;){int i,j,k,a,d[8],e[6];for(i=0;i<8;++i){std::getline(std::cin,B[i]);if(B[i]=="0")return 0;}d[0]=0;for(i=1;i<8;++i){d[5]=i;for(j=0,a=1;j<6;++j,++a)e[j]=a==i?++a:a;do{d[3]=e[2];d[4]=e[3];d[6]=e[4];d[7]=e[5];for(k=0;k<2;++k){d[1+k]=e[0];d[2-k]=e[1];if(p(d))goto n;}}while(std::next_permutation(e+1,e+6));}puts("NO");n:;}}

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

using namespace std;

int n,i,a[2000005];

deque <pair<int, int> > b;

int main(){
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	long long res = 0;
	long long s = 0;
	
	for(i = 0; i < n; i++){
		int cnt = 1;
		while(b.size() && b.back().first > a[i]){
			s -= (long long)b.back().second * b.back().first;
			cnt += b.back().second;
			b.pop_back();
		}
		
		s += (long long)cnt * a[i];
		res += s;
		b.push_back({a[i], cnt});
	}
	
	printf("%lld\n", res);
}


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

int main() {
    int D;
    cin >> D;
    
    switch (D) 
    {
        case 22:
            cout << "Christmas Eve Eve Eve";
            break;
        case 23:
            cout << "Christmas Eve Eve";
            break;
        case 24:
            cout << "Christmas Eve";
            break;
        case 25:
            cout << "Christmas";
            break;
    }
    return 0;
}

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

//型定義
typedef long long ll;

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1e+9+7 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>=(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入



int main(){
    string s,t;
    cin >> s >> t;
    int N_t=t.size();
    int N_s=s.size();
    vector<int> alpha_s[26];
    vector<bool> bool_s(26,false);
    int char_cur;

    //s数え上げ
    REP(i,N_s){
        char_cur=s[i]-'a';
        alpha_s[char_cur].push_back(i);
        bool_s[char_cur]=true;
    }

    //t数え上げ
    REP(i,N_t){
        char_cur=t[i]-'a';
        if(bool_s[char_cur]==false){
            cout << -1 << endl;
            return 0;
        }
    }


    int num_cur=-1;
    int itr;
    ll ans=0;
    REP(i,N_t){
        char_cur=t[i]-'a';
        itr=upper_bound(alpha_s[char_cur].begin(),alpha_s[char_cur].end(),num_cur)-alpha_s[char_cur].begin();
        if(itr==alpha_s[char_cur].size()){

            ans+=(N_s-(num_cur-alpha_s[char_cur][0]));
            num_cur=alpha_s[char_cur][0];
        }else{
            ans+=(alpha_s[char_cur][itr]-num_cur);
            num_cur=alpha_s[char_cur][itr];

        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1216
s = gets.chomp
t = gets.chomp
arr = t.split('')
i = 0
count = 0
while i < s.size - (t.size - 1)
  arr1 = s.slice(i,t.size).split('')
  j = 0
  c = 0
  while j < arr.size
    if arr[j] == arr1[j]
      c += 1
    end
    j+= 1
  end
  # p c
  if count < c
    count = c
  end
  i += 1
end
p t.size-count

Measured memory_bytes: 14560
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N;

int main(){
	LL ans;
	cin>>ans;
	LL a=ans/500;
	ans%=500;
	LL b=ans/5;
	cout<<a*1000+b*5<<endl;
}

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

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

string S;
int did[26];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	
	
	if(S.size()<26) {
		FORR(c,S) did[c-'a']=1;
		FOR(i,26) if(did[i]==0) {
			S+=(char)('a'+i);
			break;
		}
	}
	else {
		for(j=25;j>=0;j--) {
			char c='z'+1;
			x=-1;
			for(i=j+1;i<26;i++) {
				if(S[i]>S[j]&&S[i]<c) {
					x=i;
					c=S[i];
				}
			}
			if(x>j) {
				swap(S[j],S[x]);
				S.resize(j+1);
				break;
			}
		}
		if(j<0) return _P("-1\n");
	}
	cout<<S<<endl;
	
	
	
}


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


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

int dp[1<<26];
const int INF = 1e8;

int main() {
    string s;
    cin >> s;
    rep(i,(1<<26)) dp[i] = INF;
    dp[0] = 0;
    int stat = 0;
    rep(i, s.size()) {
        stat ^= 1 << (s[i] - 'a');
        rep(j, 26) {
            int tmp = (stat^(1<<j));
            dp[stat] = min(dp[stat], dp[tmp]+1);
            //cout << tmp << " ";
        }
        //cout << endl << stat << ", " << dp[stat] << endl;
    }
    cout << (dp[stat] ? dp[stat] : 1) << endl;
}


Measured memory_bytes: 262788
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;
ll n;
ll a[100005];
ll ans;
int main()
{
        cin >> n;
        ans = 0;
        for(ll i=1;i<=n;i++) {
                cin >> a[i];
                if(a[i]%2 == 1) ans++;
        }
        if(ans) cout << "first\n";
        else cout << "second\n";
        return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char *argv[]) {
	int n,a=0,b=0; cin>>n;
	for(int i=1;i<=n;++i){
		int x; cin>>x;
		a+=x;
		b+=(x*x);
	}
	float t=a*1.0/n;
	int k=floor(t);
	if(t-k>=0.5) cout<<n*(k+1-t)*(k+1-t)+b-a*a*1.0/n<<endl;
	else cout<<n*(k-t)*(k-t)+b-a*a*1.0/n<<endl;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  double w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << w*h/2 << ' ';
  if(w/2 == x && h/2 == y) cout << 1 << endl;
  else cout << 0 << endl;
}

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

using namespace std;

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

	string s;
	cin >> s;

	int r = 0, b = 0;
	for (int ii = 0; ii < N; ii++) {
		if (s[ii] == 'R') r++;
		else if (s[ii] == 'B') b++;
	}

	if (r > b) printf("Yes");
	else printf("No");
	

	return 0;
}

Measured memory_bytes: 256
a1,a2,a3 = input().split()
a4,a5,a6 = input().split()
a7,a8,a9 = input().split()
alist = [a1,a2,a3,a4,a5,a6,a7,a8,a9]
N = int(input())
for i in range(N):
  b = input()
  acnt = 0
  for a in alist:
    if a==b:
      alist[acnt] = -1
      break
    acnt += 1 
if (alist[0]==alist[4]==alist[8]
    or alist[2]==alist[4]==alist[6]
    or alist[0]==alist[1]==alist[2]
    or alist[3]==alist[4]==alist[5]
    or alist[6]==alist[7]==alist[8]
    or alist[0]==alist[3]==alist[6]
    or alist[1]==alist[4]==alist[7]
    or alist[2]==alist[5]==alist[8]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << #x << "=" << (x) << " | "

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

int add(int a, int b) {
    a += b;
    return (a >= MD) ? a - MD : a;
}

void solve() {
    inn(n);
    inn(m);

    std::string a[n]; rep(i, n) in(a[i]);

    int dp[m] = {1};
    repr(j, 1, m) dp[j] = dp[j - 1] and a[0][j] == '.';

    repr(i, 1, n) {
        dp[0] &= a[i][0] == '.';
        repr(j, 1, m) {
            dp[j] = add(dp[j], dp[j - 1]) * (a[i][j] == '.');
        }
    }

    out(dp[m - 1]);
}

int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        PBDS;

#define int long long
#define endl "\n"
#define MOD 1000000007
const int mxN = 1e6 + 500;

int a[mxN];



// taskkill -im D.exe -f
int32_t main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n; cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;

	vector<string> v;

	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		v.push_back(s);
	}

	for (int i = 0; i < v.size(); ++i)
	{
		/* code */
		if (v[i] == "AC") {
			ac++;
		}
		else if (v[i] == "TLE") {
			tle++;
		}

		else if (v[i] == "WA") {
			wa++;
		}

		else {
			re++;
		}

	}
	/*	AC x 3
	WA x 1
	TLE x 2
	RE x 0*/


	cout << "AC " << "x " << ac << endl;
	cout << "WA " << "x " << wa << endl;
	cout << "TLE " << "x " << tle << endl;
	cout << "RE " << "x " << re << endl;

	//cout << endl;



	return 0;

}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll  		long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
void ISO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
int main() {

	ISO();
	online_judge();
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	ans = ((a >= k)?(ans +(k)):((b >= (k-a))?(ans + a):((ans + a) - (k-a-b))));
	cout << ans <<"\n";

	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
  long n;
  cin >> n;

  long num = n;
  int strlen = 0;
  while (true)
  {
    strlen++;
    if (num <= pow(26, strlen))
    {
      break;
    }
    else
    {
      num -= pow(26, strlen);
    }
  }
  num -= 1;
  // cout << strlen << ":" << num << "\n";

  string str(strlen, 'a');
  int count = 0;
  while (num > 0)
  {
    int rem;

    if (num / 26 < 0)
    {
      // cout << num << "\n";
      str[strlen - count - 1] = 'a' + num;
    }
    else
    {
      // cout << num / 26 << "\n";
      // cout << num - (26 * (num / 26)) << "\n";
      str[strlen - count - 1] = 'a' + num - (26 * (num / 26));
    }
    num = num / 26;
    count++;
  }

  cout << str << "\n";

  return 0;
}

Measured memory_bytes: 4048
fn main() {
    // N M C
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let chars: Vec<char> = buf.chars().collect();

    for i in 0..n {
        let c = if i == k-1 {
            match chars[i] {
                'A' => 'a',
                'B' => 'b',
                _ => 'c',
            }
        }
        else {
            chars[i]
        };
        print!("{}", c);
    }

    println!("");
}


Measured memory_bytes: 4352
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-18 19:54:49
*/

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

#define all(v) (v).begin(),(v).end()

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    vector<pair<int, int>> l(100001), r(100001);
    for (int i = 0; i < 100001; i++)
        l[i] = r[i] = make_pair(0, i);

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) l[v[i]].first++;
        else r[v[i]].first++;
    }

    sort(all(l)); sort(all(r));

    int ans;
    if (l[100000].second != r[100000].second) {
        ans = ((n+1)/2-l[100000].first)+(n/2-r[100000].first);
    } else {
        int a = ((n+1)/2-l[99999].first)+(n/2-r[100000].first);
        int b = ((n+1)/2-l[100000].first)+(n/2-r[99999].first);
        ans = min(a, b);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
#include<vector>
#include<queue>
#include<iostream>
using namespace std;

int main() {
  int t, n, k;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%d %d", &n, &k);
    if (n <= k) {
      int X[n];
      for ( int j = 0; j < n; j++ ) scanf("%d", &X[j]);
      cout << 0 << endl;
      continue;
    }
    int X[n];
    priority_queue<int, vector<int>, greater<int> > V;
    for ( int j = 0; j < n; j++ ) {
      scanf("%d", &X[j]);
      if ( j ) V.push(X[j] - X[j - 1]);
    }
    int result = 0;
    for ( int j = 0; j < n - k; j++) {
      result = result + V.top();
      V.pop();
    }
    printf("%d\n", result);
  } 
  return 0;
}


Measured memory_bytes: 4380
#include<stdio.h>
#include<string.h>
#include<algorithm>

using namespace std;

int main()
{
    int l1,l2,i,j,ans,m;
    char s1[1002],s2[1002];

    scanf("%s%s",s1,s2);
    l2=strlen(s2);
    l1=strlen(s1);
    l1=l1-l2+1;
    for(i=0,ans=l2;i<l1;i++)
    {
        for(j=0,m=0;j<l2;j++)
        {
            if(s1[i+j]!=s2[j])
                m++;
        }
        ans=min(ans,m);
    }
    printf("%d\n",ans);

    return 0;
}


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

using namespace std;

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

    for (int i=1;i<=9;i++) {
        for (int j=1;j<=9;j++) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  int ans=0;
  rep(i,s.size()/2) {
    if(s[i]!=s[s.size()-1-i]) ans++;
  }
  pr(ans);

}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const int INF = 1000000000;
const int mod = 1000000007;
//range add + range maximum query
struct lazy_segtree{
	const static int s = (1<<20);
	ll seg[s];
	ll lazy[s];
	void lazy_evaluate(int k){
		if(k*2+2>=s) return ;
		lazy[k*2+2]+=lazy[k];
		lazy[k*2+1]+=lazy[k];
		seg[k*2+2]+=lazy[k];
		seg[k*2+1]+=lazy[k];
		lazy[k]=0;
	}
	ll update(int beg,int end,int idx,int lb,int ub,ll num){
		if(ub<beg||end<lb){
			return seg[idx];
		}
		if(beg<=lb&&ub<=end){
			lazy[idx]+=num;
			seg[idx]+=num;
			return seg[idx];
		}
		if(lazy[idx]){
			lazy_evaluate(idx);
		}
		return seg[idx]=max(update(beg,end,idx*2+1,lb,(lb+ub)/2,num),update(beg,end,idx*2+2,(lb+ub)/2+1,ub,num));
	}
	ll update(int beg,int end,ll num) { return update(beg,end,0,0,s/2-1,num); }
	ll query(int beg,int end,int idx,int lb,int ub){
		if(ub<beg||end<lb){
			return -1000000000000000000LL;
		}
		if(beg<=lb&&ub<=end){
			return seg[idx];
		}
		if(lazy[idx]){
			lazy_evaluate(idx);
		}
		return max(query(beg,end,idx*2+1,lb,(lb+ub)/2),query(beg,end,idx*2+2,(lb+ub)/2+1,ub));
	}
	ll query(int beg,int end) { return query(beg,end,0,0,s/2-1); }
}kaede;
int n,q;
int main(){
	//if you don't use scanf / printf
	ios::sync_with_stdio(false);
	cin >> n >> q;
	rep(i,q){
		int id; cin >> id;
		if(id == 0){
			int x,y; ll val; cin >> x >> y >> val; kaede.update(x,y,val);
		}
		else{
			int L; cin >> L;
			cout << kaede.query(L,L) << '\n';
		}
	}
}


Measured memory_bytes: 6316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,k,t;
char c[100010];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	cin>>c[i];
	for(int i=1;i<n;i++)
		if(c[i]!=c[i-1])
			t++;
	printf("%d",min(n-1-t+k*2,n-1));
 } 

Measured memory_bytes: 384
#include <cstdio>
using namespace std;

struct Node {
	Node *parent;
	Node *left;
	Node *right;
	int key;
};

Node *NIL = NULL;

void preorder(Node *v) {
	if (v == NIL) return;
	printf(" %d", v->key);
	preorder(v->left);
	preorder(v->right);
}

void inorder(Node* v) {
	if (v == NIL) return;
	inorder(v->left);
	printf(" %d", v->key);
	inorder(v->right);
}

void postorder(Node* v) {
	if (v == NIL) return;
	postorder(v->left);
	postorder(v->right);
	printf(" %d", v->key);
}

void insert(Node* &T, Node *z) {
	Node *y = NIL;
	Node *x = T;
	while (x != NIL) {
		y = x;
		if (z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;

	if (y == NIL)
		T = z;
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
}

bool find(Node* T, int key) {
	Node *x = T;
	if (x == NIL) return false;
	if (x->key == key)
		return true;
	else if (key < x->key)
		return find(x->left, key);
	else
		return find(x->right, key);
}

Node* findNext(Node *z) {
	if (z == NIL) return NIL;
	if (z->right != NIL) {
		Node *x = z->right;
		while (x->left != NIL) {
			x = x->left;
		}
		return x;
	}

	Node *y = z->parent;
	while (y != NIL && y->right == z) {
		z = y;
		y = z->parent;
	}
	return y;
}

void del(Node* z, int key) {
	if (z == NIL) return;
	if (z->key == key) {
		if (z->left == NIL && z->right == NIL) {
			Node *w = z->parent;
			if (w != NIL && w->left == z) {
				w->left = NIL;
			} else if (w != NIL && w->right == z) {
				w->right = NIL;
			}
			delete z;
		} else if (z->right == NIL) {
			Node *w = z->parent;
			Node *x = z;
			Node *y = z->left;
			z = y;
			if (w != NIL) {
				if (w->left == x) w->left = z;
				else              w->right = z;
			}
			delete x;
		} else if (z->left == NIL) {
			Node *w = z->parent;
			Node *x = z;
			Node *y = z->right;
			z = y;
			z->parent = w;
			if (w != NIL) {
				if (w->right == x) w->right = z;
				else               w->left = z; 
			}
			delete x;
		} else {
			Node* x = findNext(z);
			z->key = x->key;
			del(x, x->key);
		}
	} else if (key < z->key) {
		del(z->left, key);
	} else {
		del(z->right, key);
	}	
}

int main()
{
	int n;
	scanf("%d", &n);

	Node *T = NIL;
	for (int i = 0; i < n; ++i) {
		char cmd[20];
		int v;
		scanf("%s", cmd);
		if (cmd[0] == 'i') {
			scanf("%d", &v);
			Node *p = new Node;
			p->key = v;
			p->left = NIL;
			p->right = NIL;
			insert(T, p);
		} else if (cmd[0] == 'f') {
			scanf("%d", &v);
			printf("%s\n", find(T, v) ? "yes" : "no");
		} else if (cmd[0] == 'p') {
			inorder(T);
			printf("\n");
			preorder(T);
			printf("\n");
		} else if (cmd[0] == 'd') {
			scanf("%d", &v);
			del(T, v);
		}
	}

	return 0;
}

Measured memory_bytes: 19796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    string s;
    cin>>s;
    int cnt=0;
    for(char c:s){
        if(c=='p')cnt++;
    }
    cout<<(int)s.size()/2-cnt<<endl;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int[] days = {31,29,31,30,31,30,31,31,30,31,30,31};
        String[] dates = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
        while(true){
            int M = sc.nextInt();
            int D = sc.nextInt();
            if(M == 0 && D == 0)
                break;
            int count = -1;
            for(int i = 0 ; i < M-1 ; i++)
                count += days[i];
            count += D;
            System.out.println(dates[count % 7]);
        }
    }
}


Measured memory_bytes: 26152
#include<iostream>                                                     
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

#define REP(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
    int n; cin >> n;
    int max_number = 0, second_max_number = 0;
    int index;

    REP(i, n){ 
        int x; cin >> x;
        if(max_number <= x){ 
            index = i;  
            second_max_number = max_number;
            max_number = x;
        }else second_max_number = max(second_max_number, x); 
    }   

    REP(i, n){ 
        if(index != i) cout << max_number << '\n';
        else cout << second_max_number << '\n';
    }   
}


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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2003;
int n;
pii a[N];
ll dp[N][N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].F;
		a[i].S = i;
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			if (j > 0) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + (ll)a[i].F * abs(a[i].S - j));
			}
			int s = i - j;
			if (s > 0) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j] + (ll)a[i].F * abs(a[i].S - (n - s + 1)));
			}
		}
	}
	ll res = 0;
	for (int i = 0; i <= n; i++) {
		res = max(res, dp[n][i]);
	}
	cout << res;
}


Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, n) cin >> a[i], dp[i] = 1e9;
	dp[0] = 0;
	repn(i, 1, n){
		repn(j, 1, k + 1) if(i - j >= 0){
			dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
N=int(input())
for i in range(N):
    a,b,c=map(int,input().split())
    A=min(a,min(b,c))
    C=max(a,max(b,c))
    B=a+b+c-A-C
    if A**2+B**2==C**2:
        print("YES")
    else:
        print("NO")


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

#define MAX 55555

bool isp(int x){

  if(x <= 1) return false;

  for(int i = 2; i*i <= x; i++){
    if(x % i == 0) return false;
  }

  return true;
}

signed main(){

  int N, count = 0;

  cin>>N;

  for(int i = 0; i*5 <= MAX; i++){
    if(isp(i*5+1)){
      if(count) cout<<" ";
      cout<<i*5+1;
      count++;
      if(count >= N) break;
    }
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <map>
//#include <boost/math/common_factor_rt.hpp>
#include<fstream>
#define EPS (1e-7)
using namespace std;
#define ll long long




int main() {

	int a;
	string s;

	cin >> a >> s;

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(b*2==a+c) puts("YES");
    else puts("NO");
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int B_sum = 0;
  for(int i=0; i<N; ++i) if(S[i]=='B') B_sum++;
  
  long long ans = 0;
  for(int i=0; i<N; ++i){
    for(int j=i+1; j<N; ++j){
      if(S[i]=='R' && S[j]=='G') goto LABEL;
      if(S[i]=='G' && S[j]=='R') goto LABEL;
      continue;
LABEL:
      ans += B_sum;
      
      // BRG or BGR
      int k1 = i-(j-i);
      if(k1>=0){
        if(S[k1]=='B') ans--;
      }
      
      // RBG or GBR
      int k2 = (i+j)/2;
      if((i+j)%2==0){
        if(S[k2]=='B') ans--;
      }
      
      // RGB or GRB
      int k3 = j+(j-i);
      if(k3<N){
        if(S[k3]=='B') ans--;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


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

ll mod = 1e9 + 7;

int main() {
    string s; cin >> s;
    int n = s.length();
    int a[1 << 17];
    for(int i=0; i<n; i++) {
        int ln = i;
        while(i + 1 < n && s[i] == s[i + 1]) i++;
        int len = i - ln + 1;
        if(s[i] == 'L') {
            a[ln] += (len + 1) / 2;
            a[ln - 1] += len / 2;
        }
        else {
            a[i] += (len + 1) / 2;
            a[i + 1] += len / 2;
        }
    }
    for(int i=0; i<n; i++) cout << a[i] << " ";
}

Measured memory_bytes: 4132
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = 0;
    ans += (N / (A + B)) * A;
    ans += min(N % (A + B), A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        if V[i] > C[i]:
            ans += (V[i] - C[i])
    return ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 38384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, K;
string S;
vi zeroIndex, zeroLast;

int main() {
    cin >> N >> K >> S;

    if (S[0] == '0') zeroIndex.push_back(0);
    rep(i, 1, N) {
        if (S[i - 1] == '1' && S[i] == '0') zeroIndex.push_back(i);
        if (S[i - 1] == '0' && S[i] == '1') zeroLast.push_back(i);
    }
    if (S[N - 1] == '0') zeroLast.push_back(N);

    if (zeroIndex.size() <= K) {
        write(N);
        return 0;
    }

    int ans = zeroIndex[K] - 0;
    rep(i, zeroIndex.size() - K - 1) {
        ans = max(ans, zeroIndex[i + K + 1] - zeroLast[i]);
    }
    ans = max(ans, N - zeroLast[zeroIndex.size() - K - 1]);

    write(ans);
}

Measured memory_bytes: 1024
function Main(input) {
  var data = input.split("\n");
  var toInt = function(d) {
    return parseInt(d);
  }
  var fields = data[0].split(' ').map(toInt);
  var N = fields[0];
  var T = fields[1];

  var minCost = 1001;

  for (var i = 1; i < N + 1; i++) {
    var d = data[i].split(' ').map(toInt);
    var c = d[0];
    var t = d[1];
    if (t <= T) {
      if (c < minCost) {
        minCost = c;
      }
    }
  }

  if (minCost === 1001) {
    console.log('TLE');
  } else {
    console.log(minCost);
  }
}

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

Measured memory_bytes: 21064
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void chmin(ll &a,ll b){	a=min(a,b);	return;	}

const ll inf=1000000000000000000;

int main(){
	ll a,b,c,x,y;
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
	ll ans=inf;
	for(ll r=0;r<=2*max(x,y);r+=2) chmin(ans,a*max(0ll,x-r/2)+b*max(0ll,y-r/2)+c*r);
	printf("%lld\n",ans);
}

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

using namespace std;

//#define FILE_IO

char a[100005], b[100005];
int lg2[100005];

int nxt[3][3] = {
    0, 1, 2,
    1, 2, 0,
    2, 0, 1
};

class ABString
{
public:
    string s;
    int N;
    int val[100005][20];

    ABString()
    {
        s = "";
        N = 0;
    }

    ABString(string _s)
    {
        s = _s;
        N = s.size();
    }

    void precalc()
    {
        for(int i = 0; i < N; i++)
            val[i + 1][0] = s[i] - 'A' + 1;
        for(int j = 1; (1 << j) <= N; j++)
            for(int i = 1; i + (1 << j) - 1 <= N; i++)
                val[i][j] = nxt[ val[i][j - 1] ][ val[i + (1 << (j - 1))][j - 1] ];
    }

    int get(int st, int dr)
    {
        if(st > dr) return 0;
        if(st == dr)    return val[st][0];
        int pw = lg2[dr - st + 1];
        int v1 = val[st][pw];
        int v2 = get(st + (1 << pw), dr);
        return nxt[v1][v2];
    }
};

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    for(int i = 2; i <= 100000; i++)
    {
        lg2[i] = lg2[i - 1];
        if( (2 << lg2[i]) == i )
            lg2[i]++;
    }

    scanf("%s", (a + 1));
    scanf("%s", (b + 1));

    ABString s1( (string)(a + 1) );
    ABString s2( (string)(b + 1) );

    s1.precalc();
    s2.precalc();

    int Q;
    scanf("%d", &Q);
    while(Q--)
    {
        int st1, dr1, st2, dr2;
        scanf("%d%d%d%d", &st1, &dr1, &st2, &dr2);

        int v1 = s1.get(st1, dr1);
        int v2 = s2.get(st2, dr2);

        if(v1 == v2)
            printf("YES\n");
        else
            printf("NO\n");
    }


    return 0;
}


Measured memory_bytes: 17024
#include<cstdio>
#define MAX 10000
#define NIL -1
 
struct Node {int parent, left, right; };
 
Node T[MAX];
int n, D[MAX], H[MAX];
 
void setDepth(int u, int d){
    if( u == NIL)
        return;
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}
 
int setHeight(int u){
    int h1 = 0, h2 = 0;
    if( T[u].left != NIL)
        h1 = setHeight(T[u].left) + 1;
    if( T[u].right != NIL)
        h2 = setHeight(T[u].right) + 1;
    return H[u] = (h1 > h2 ? h1: h2);
}
 
int getSibling(int u){
    if( T[u].parent == NIL)
        return NIL;
    if( T[T[u].parent].left != u && T[T[u].parent].left != NIL)
        return T[T[u].parent].left;
    if( T[T[u].parent].right != u && T[T[u].parent].right != NIL)
        return T[T[u].parent].right;
    return NIL;
}
 
void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if( T[u].left != NIL) deg++;
    if( T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);
 
    if( T[u].parent == NIL){
        printf("root\n");
    } else if (T[u].left == NIL && T[u].right == NIL){
        printf("leaf\n");
    } else {
        printf("internal node\n");
    }
}
 
int main (){
    int v, l, r, root = 0;
    scanf("%d", &n);
     
    for(int i = 0; i < n; i++) T[i].parent = NIL;
 
    for(int i = 0; i <  n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if( l != NIL ) T[l].parent = v;
        if( r != NIL ) T[r].parent = v;
    }
 
    for(int i = 0; i < n; i++){
        if(T[i].parent == NIL )
            root = i;
    }
    setDepth(root, 0);
    setHeight(root);
 
    for(int i = 0; i < n; i++)
        print(i);
 
    return 0;
}

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

int main() {
  long N;
  cin >> N;
  vector<pair<int,int>> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i].first;
    p[i].second = i+1;
  }
  sort(p.begin(),p.end());
  for(int i=0;i<N;i++){
    if(i!=N-1) cout<<p[i].second<<" ";
    else cout<<p[i].second<<endl;;
  }



}


Measured memory_bytes: 1664
month,day = map(int,input().split())

def takahashi(m,d):
    if d//10<2:
        return False
    if d%10<2:
        return False

    return (d//10) * (d%10) == m

cnt=0
for m in range(1,month+1):
    for d in range(1,day+1):
        if takahashi(m,d):
            cnt+=1
print(cnt)


Measured memory_bytes: 67116
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

using namespace std;

int K;
int getMin(int i, int num){
    if(i > 0){

        if(num * 2 > num + K){
            num = getMin(i - 1, num + K);
        }else{
            num = getMin(i - 1, num * 2);
        }
    }
    return num;

}

int main(){
    ios::sync_with_stdio(false);
    int num = 1;
    int N;
    cin >> N;
    cin >> K;
    cout << getMin(N, num) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>

int main() {
	int x;
	cin >> x;
	int a, b;
	a = x / 500;
	x = x % 500;
	b = x / 5;
	int k;
	k = 1000 * a + 5 * b;
	cout << k;

	return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 3005, M = 998244353;
ll dp[N][N], a[N];

int main() {
    int n, s;
    cin >> n >> s;
    for (int i = 1; i <= n; i++) cin >> a[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i][j] = 2 * dp[i - 1][j] % M;
            if (a[i] <= j) dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % M;
        }
    }
    cout << dp[n][s];
}


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


vector<long long int>UF;

long long int pearent( long long int now ) {
	if( UF[now] == now ) {
		return now;
	} else {
		return UF[now] = pearent( UF[now] );
	}
}

void merge( long long int x, long long int y ) {
	UF[pearent( x )] = UF[pearent( y )];
}

int main() {
	long long int N, M;
	cin >> N >> M;
	UF = vector<long long int>( N );
	vector<bool>qwe( N );
	for( size_t i = 0; i < N; i++ ) {
		UF[i] = i;
	}
	for( size_t i = 0; i < M; i++ ) {
		long long int a, b;
		cin >> a >> b;
		a--; b--;
		qwe[a] = 1;
		qwe[b] = 1;
		merge( a, b );
	}
	long long int ans = 0;
	long long int num = 0;
	for( size_t i = 0; i < N; i++ ) {

		if( UF[i] == i ) {
			ans++;
			if( qwe[i] == false ) {
				num++;
			}
		}
	}
	cout << abs( (ans - num) - num ) << endl;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  vector<int> q=p;
  sort(p.begin(),p.end());
  int cnt=0;
  for(int i=0;i<n;i++){
    if(q[i]!=p[i]) cnt++;
  }
  if(cnt>2){
    cout<<"NO";
    return 0;
  }
  cout<<"YES";
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1L << 20
#define long long long


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


long H, W;

vector<string> s;
vector<vector<int>> dp(110, vector<int>(110, INF));
vector<vector<int>> dp_2(110, vector<int>(110, INF));


int main(){
	cin >> H >> W;
	s.resize(H);

	rep(i, H){
		cin >> s.at(i);
	}
	rep(i, H){
		rep(j, W){

			if (s.at(i).at(j) == '#'){
				dp_2.at(i).at(j) = 1;
			}
			else{
				dp_2.at(i).at(j) = 0;
			}
			if (i == 0 and j == 0) dp.at(i).at(j) = dp_2.at(i).at(j);
		}

	}
	
	rep(i, H){
		rep(j, W){
			if (i == 0 and j == 0 ) continue;
			dp.at(i).at(j) = INF;
			if (i > 0)  chmin(dp.at(i).at(j), dp.at(i-1).at(j) + (dp_2.at(i).at(j)&&!dp_2.at(i-1).at(j)) );
			if (j > 0)  chmin(dp.at(i).at(j), dp.at(i).at(j-1) +  (dp_2.at(i).at(j)&&!dp_2.at(i).at(j-1)) );
		}
	}

	cout << dp.at(H-1).at(W-1) << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26, 0));
vector<int> last(26, -1);
int main() {
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d, -1);
    vector<pair<int, int>> arg(26);
    for(int i = 0; i < 26; i++) {
        arg[i].first = -c[i];
        arg[i].second = i;
    }
    sort(all(arg));
    for(int i = 0; i < d; i++) {
        t[i] = arg[i % 26].second;
        cout << t[i] + 1 << endl;
    }
}

Measured memory_bytes: 3688
/**
*Keep
**Moving
***Forward
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define f( i , x , n ) for(int i = x; i < (int)(n); ++i)
#define pb push_back
#define all(c) (c).begin(),(c).end()


int main(){
    string x;
    cin >> x;
    for(int i=0;i<x.size();i+=2){
        cout << x[i];
    }
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(void) {
	int h, w;
	int bx[8] = { -1,-1,-1,0,0,1,1,1 };
	int by[8] = { -1,0,1,-1,1,-1,0,1 };

	cin >> h >> w;
	char buf[55][55] = {};
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> buf[i][j];
		}
	}
	int count = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (buf[i][j] == '.') {
				for (int k = 0; k < 8; k++) {
					int x = bx[k] + j;
					int y = by[k] + i;
					if (buf[y][x] == '#') {
						count++;
					}
					buf[i][j] = count + '0';
				}
				count = 0;
			}
		}
	}

  for (int i = 0; i < h; i++){
	 for (int j = 0; j < w; j++){
		if (j % w == 0) {
			cout<<endl;
		}
		cout << buf[i][j];
	}
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const int MAXN = 5 * 100000 + 500;
int d[MAXN + 1], dp[MAXN + 1], a[MAXN + 1];

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, D;
    cin >> n >> D;
    a[0] = D;
    for(int i = 1; i <= n; i++) {
        scanf("%d", &d[i]);
        if(abs(a[i - 1] - d[i]) < a[i - 1])
            a[i] = abs(a[i - 1] - d[i]);
        else
            a[i] = a[i - 1];
    }
    dp[n + 1] = 1;
    for(int i = n; i >= 1; i--) {
        if(dp[i + 1] <= d[i] / 2)
            dp[i] = dp[i + 1];
        else
            dp[i] = dp[i + 1] + d[i];
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++) {
        int x;
        scanf("%d", &x);
        if(a[x - 1] >= dp[x + 1])
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 7808
import math
N = int(input())
ListA = list(map(int,input().split()))
ListA.sort()
Minj = 10e8
Maxj = ListA[-1]

for j in range(N-1):
    if abs(ListA[j]*2-ListA[-1])<Minj:
        Maxj = ListA[j]
        Minj = min(abs(ListA[j]*2-ListA[-1]),Minj)

    else:
        continue


print(ListA[-1],Maxj)


Measured memory_bytes: 62704
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
const int N = 3e3 + 5;
double p[N];
double dp[N][N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> p[i];
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = 1;
		for (int j = 0; j <= i; j++) {
			dp[i][0] *= 1 - p[j];
		}
		for (int j = 1; j <= i; j++) {
			dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
		}
	}
	///**/
	//for (int i = 0; i <= n; i++) {
	//	for (int j = 0; j <= i; j++) {
	//		cout << dp[i][j] << " ";
	//	}
	//	cout << endl;
	//}
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		if (2 * i > n) {
			ans += dp[n][i];
		}
	}
	printf("%.10lf", ans);
}
/*
dp[k] = prob of K heads.
dp[i] = dp[i - 1] * p[i] + dp[i] * (1 - p[i]);



*/

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

int main(){
  long long X,K,D;
  cin >> X >> K >> D;
  X=abs(X);
  long long A=X/D;
  long long B=K-A;
  if(A>=K){
    cout << X-D*K << endl;
  }
  else if(B%2==0){
    cout << X-D*A << endl;
  }
  else{
    cout << abs(X-D*A-D) << endl;
  }
}
  

Measured memory_bytes: 3604
def extract tree
    stack, arr = [2], [1]
    tree[1..-2].each_char{|c|
        case c
        when "("
            arr << stack[-1]
            stack << stack[-1] * 2
        when ")"
            stack.pop
        when ","
            stack[-1] += 1
        end
    }
    return arr
end

def express numbers
    arr = []
    numbers.each{|x| arr[x]  = "(#{arr[x * 2]},#{arr[x * 2 + 1]})"}
    puts arr[1]
end

while line = gets
    op, tree1, tree2 = line.chomp.split
    node1 = extract(tree1)
    node2 = extract(tree2)
    nodes = (op == "i") ? (node1 - (node1 - node2)).sort.reverse : ((node1 - node2) + node2).sort.reverse
    express nodes
end


Measured memory_bytes: 6892