akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void show(vector<ll>& vc)
{
    for(auto it:vc)cout<<it<<" ";
    cout<<endl;
}
#define M 10
bool p[M+2];
vector<ll>prime;
void seive(void)
{
    memset(p,0,sizeof p);
    p[1]=1;
    p[0]=1;

    for(int i=4; i<=M; i+=2)
    {
        p[i]=1;

    }

    for(ll i=3; i*i<=M; i+=2)
    {

        if(!p[i])
        {

            for(ll j=i*i; j<=M; j+=2*i)
            {
                p[j]=1;

            }
        }
    }

    prime.push_back(2);
    for(int i=3; i<=M; i+=2)prime.push_back(i);
}
ll dx[] = {-1,-1,0,-1,1,0,1,1};
ll dy[] = {-1,0,-1,1,-1,1,0,1};

typedef pair<ll, ll> pii;
#define x first
#define y second


pii extendedEuclid(ll a, ll b)   // returns x, y | ax + by = gcd(a,b)
{
    if(b == 0) return pii(1, 0);
    else
    {
        pii d = extendedEuclid(b, a % b);
        return pii(d.y, d.x - d.y * (a / b));
    }
}

ll modularInverse(ll a, ll n)
{
    pii ret = extendedEuclid(a, n);
    return ((ret.x % n) + n) % n;
}

vector<int>grid[1005];
ll mod = 1000000007;
ll n, m ;
ll dp[1005][1005];
ll call( ll i, ll j)
{
    if( i== n-1 && j == m-1)return 1;
    if(dp[i][j]!=-1)return dp[i][j];


    ll p= 0, q = 0;
    if(i+1<n && !grid[i+1][j])
        p = call(i+1,j);
    if(j+1<m &&  !grid[i][j+1])
        q = call(i,j+1);

    return dp[i][j] = (p+q)%mod;





}

void solve(ll t)
{
    cin>>n>>m;

    for(int i=0; i<n; i++)

    {
        string s;
        cin>>s;
        for(auto it: s)
        {
            if(it=='.')grid[i].push_back(0);
            else if(it=='#') grid[i].push_back(1);
        }
    }
    memset(dp, -1,sizeof dp);
    cout<<call(0,0)<<endl;




}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //seive();


    ll t=1;
    //cin>>t;
    ll T=t;



    while(t--)
    {


        solve(T-t);

    }
}


Measured memory_bytes: 12288
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

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


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

	while (cin>>N,N) {
		vector<string>v(N);
		for (auto &i : v)cin >> i;
		vector<long long int>w(N);
		for (int i = 0; i < N; i++) {
			if (v[i] == "x")w[i] = MOD;
			else w[i] = stoi(v[i]);
		}
		L = -MOD, R = MOD;
		for (int i = 0; i < N; i++) {
			if (v[i] != "x") {
				continue;
			}
			if ((i & 1)) {
				if (i) {
					if (w[i - 1] != MOD) {
						L = max(L, w[i - 1] + 1);
					}
				}
				if (i + 1 < N) {
					if (w[i + 1] != MOD) {
						L = max(L, w[i + 1] + 1);
					}
				}
			}
			else {
				if (i) {
					if (w[i - 1] != MOD) {
						R = min(R, w[i - 1] - 1);
					}
				}
				if (i + 1 < N) {
					if (w[i + 1] != MOD) {
						R = min(R, w[i + 1] - 1);
					}
				}
			}
		//	cout << L << " " << R << endl;
		}
		for (int i = 1; i < N; i++) {
			if (v[i] != "x"&&v[i - 1] != "x") {
				if (i & 1) {
					if (w[i - 1] >= w[i])L = R + 1;
				}
				else {
					if (w[i - 1] <= w[i])L = R + 1;
				}
			}
			if (v[i] == "x"&&v[i - 1] == "x") {
				L = R + 1;
			}
		}
	//	for (int i = 0; i < N; i++) {
	//		cout<<
	//	}
		if (L == R) {
			cout << L << endl;
		}
		else if (L < R) {
			cout << "ambiguous" << endl;
		}
		else {
			cout << "none" << endl;
		}
	//	cout << L << " " << R << endl;
	}
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll n,m;

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

    if(n==1){
        cout << (m+1)%mod << endl;
        return 0;
    }

    /*
     * n?????????????´??????? s[n-1] = s[0] + d * (n-1)
     * d??????
     * 0 <= s[0] + d * (n-1) <= m
     * 
     * d = 0 --> m + 1 ??????
     *
     * d > 0 (d < 0 ???????????????????§°???)
     *  --> d?????¶?´? : 0 < d <= m/(n-1) (=ub??¨??????)
     *  --> d??????????????????????????¨????????¨
     *  --> 0 <= s[0] <= m-d(n-1) :: m+1-d(n-1) ??????
     *  --> ?£m+1-d(n-1) (0 < d <= ub)
     *        = (m+1)*ub - (n-1)*(ub*(ub+1))/2 (= a??¨??????)
     *
     *  ????????? m + 1 + 2 * a ????????????????
     */


    ll ub = m/(n-1);
    ll ubmod = ub % mod;

    ll a1 = ((m+1)%mod)*(ub%mod)%mod;    // (m+1)*ub

    ll t1 = (n-1)%mod;                  // (n-1)
    ll t2 = (ubmod*(ubmod+1))/2%mod;    // (ub*(ub+1))/2
    ll a2 = (t1*t2)%mod;
    ll a = (a1-a2+mod) % mod;
    assert(a>=0);
    
    ll b = (m+1)%mod;

    ll ans = (2*a%mod+b)%mod;
    cout << ans << endl;
}

Measured memory_bytes: 3100
#include <stdio.h>

int b[3][3];

void check(int a){
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(b[i][j] == a){
                b[i][j]=-1;
            }
        }
    }
}

int main(){
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&b[i][j]);
        }
    }
    int n;
    scanf("%d",&n);
    while(n--){
        int x;
        scanf("%d", &x);
        check(x);
    }
    int ok = 0;
    for(int i= 0;i<3;i++){
        if(b[i][0]+b[i][1]+b[i][2] == -3) ok=1;
        if(b[0][i]+b[1][i]+b[2][i] == -3) ok=1;
    }
    if(b[0][0] + b[1][1] + b[2][2] == -3) ok=1;
    if(b[0][2] + b[1][1] + b[2][0] == -3) ok=1;
    if(ok) printf("Yes\n");
    else printf("No\n");

}

Measured memory_bytes: 128
//#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<utility>
#include<cstdlib>
#include<iterator>
#include<queue>
#include<stack>
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
typedef unsigned int uint;
#define int long long
const int INF = 9223372036854775807;


namespace G {
}

int h, w;
vector< vector<int> > map;

int check(int, int);

signed main() {
	cin >> h >> w;
	h += 2;
	w += 2;
	map = vector< vector<int> >(h, vector<int>(w, -2));
	for (int i = 1; i < h-1; ++i) {
		string str;
		cin >> str;
		for (int j = 1; j < w-1; ++j) {
			if (str[j - 1] != '#') {
				map[i][j] = 0;
			}
			else {
				map[i][j] = -1;
			}
		}
	}

	for (int i = 1; i < h - 1; ++i) {
		for (int j = 1; j < w - 1; ++j) {
			if (map[i][j] != -1) {
				cout << check(i, j);
			}
			else {
				cout << "#";
			}
		}	 cout << endl;
	}

	return 0;
}

int check(int ii, int jj) {
	int count = 0;
	for (int i = ii - 1; i <= ii + 1; ++i) {
		for (int j = jj - 1; j <= jj + 1; ++j) {
			if (map[i][j] == -1)count += 1;
		}
	}
	return count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll N;
    cin >> N;
    
    ll ans;
    for(int i=1;;i++){
        if(i*i <= N)
            ans = i*i;
        else
            break;
    }

    cout << ans << endl;

}

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

using namespace std;
using llint = long long;
using pint = pair<int,int>;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

const int INF = 1<<28;
const llint LLINF = 1LL<<60;

int p, q, r, ans;

int main() {
    // Input
    cin >> p >> q >> r;

    // Output
    ans = min({p+q, q+r, r+p});
    cout << ans << endl;
    return 0;
}

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

int main(){
    string s;
    int K,i,j,n;
    cin>>s;
    cin>>K;
    n=s.size();
    set<string>subs;
    
    for(i=0;i<n;i++)
        for(j=1;j<=K;j++)
            subs.insert(s.substr(i,j));

    
    set<string>::iterator t=subs.begin();
    for(i=1;i<K;i++)t++;
    cout<<*t<<endl;
    
    return 0;

}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  if(n==1) cout<<"Hello World"<<endl;
  else{
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
  }

  return 0;
}


Measured memory_bytes: 764
def from_mcxi(s):
	n = 0
	t = 1
	for c in s:
		if c == 'm':
			n += t*1000
		elif c == 'c':
			n += t*100
		elif c == 'x':
			n += t*10
		elif c == 'i':
			n += t*1
		else:
			t = int(c)
		if c in 'mcxi':
			t = 1
	return n

def to_mcxi(n):
	s = ''
	if (n // 1000) > 0:
		if (n // 1000) > 1:
			s += str(n // 1000)
		s += 'm'
	if (n % 1000 // 100) > 0:
		if (n % 1000 // 100) > 1:
			s += str(n % 1000 // 100)
		s += 'c'
	if (n % 100 // 10) > 0:
		if (n % 100 // 10) > 1:
			s += str(n % 100 // 10)
		s += 'x'
	if (n % 10) > 0:
		if (n % 10) > 1:
			s += str(n % 10)
		s += 'i'
	return s

n = int(input())
for i in range(n):
	s = input().split()
	print(to_mcxi(from_mcxi(s[0]) + from_mcxi(s[1])))

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    	return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll n,ll mod){
    return pow1(n,mod-2,mod);
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}
ll ans1;
void find(vll &c,vllv &a,vll &sum,ll n,ll m,ll x,ll i,ll ans){
	if(i>=n)return ;
	int j;
	ll fl=0;
	for(j=0;j<m;j++){
		sum[j]=sum[j]+a[i][j];
		if(sum[j]<x)fl=1;
	}
	if(fl==0){
		ans1=min(ans1,ans+c[i]);
	}
	find(c,a,sum,n,m,x,i+1,ans+c[i]);
	fl=0;
	for(j=0;j<m;j++){
		sum[j]-=a[i][j];
		if(sum[j]<x)fl=1;
		
	}
	if(fl==0){
	ans1=min(ans1,ans);	
	}
	find(c,a,sum,n,m,x,i+1,ans);
	
	

	
}
void solve(){
	
    ll i,j,k,l,n,m,x,y,z,r;
	cin>>n>>m>>x;
	vll c(n);
	vllv a(n,vll(m));
	vll sum(m);
	for(i=0;i<n;i++){
		cin>>c[i];
		for(j=0;j<m;j++){
			cin>>a[i][j];
			sum[j]+=a[i][j];
		}
	}
	for(i=0;i<m;i++){
		if(sum[i]<x){
			cout<<-1<<endl;
			return;
		}
	}
	vll s(m,0);
	ans1=1e11;
	find(c,a,s,n,m,x,0,0);
	cout<<ans1<<endl;
	
	
	
}
int main(){
    FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
    // cin>>q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
namespace IO
{
	template <typename T> inline void read(T &x)
	{
		int f = 1; x = 0; char c = getchar();
		for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
		for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
		x *= f;
	}

	template <typename T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }
	template <typename T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }

	template <typename T> inline void write(T x)
	{
		if (x < 0) putchar('-'), x = -x;

		char num[20]; int len = 0;
		while (x > 9) { num[++len] = char(x % 10 + '0'); x /= 10; }

		num[++len] = char(x + '0');

		while (len) putchar(num[len--]);
	}
	template <typename T> inline void writeln(T x) { write(x); puts(""); }
}
using namespace IO;
const int N = 2e5 + 5;
int n, a[N];
map <ll, int> h;
inline ll C(ll num) { return num * (num - 1) / 2; }
int main(){
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	ll now = 0; h[0] = 1;
	
	for (int i = 1; i <= n; i++)
	{
		now += a[i];
		h[now]++;
	}
	
	ll ans = 0;
	for (map <ll, int> :: iterator it = h.begin(); it != h.end(); it++) ans += C(it -> second);
	writeln(ans);
  return 0;
}

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

void solve() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << a[n - 1] << endl;
}	
int main() {
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	solve();
 	return 0;
}

Measured memory_bytes: 256
def main():
    N, K = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    K_bi = str(bin(K))[2:]
    M = len(K_bi)
    posi = []
    for i in range(M-1):
        if K_bi[i] == "1":
            posi.append(i)
    ans = 0
    for i in posi:
        cur_bit = int(K_bi[:i] + "0" + "1" * (M - (i + 1)), 2)
        cur_s = 0
        for a, b in AB:
            if a | cur_bit == cur_bit:
                cur_s += b
        ans = max(ans, cur_s)
    cur_s = 0
    for a, b in AB:
        if a | K == K:
            cur_s += b
    ans = max(ans, cur_s)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61016
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC123A
int main(void) {
  int n, k, i, cou=0, tmp, a, e;
  scanf(" %d %d %d %d %d %d", &a, &k, &k, &k, &e, &k);
  if(e-a>k) printf(":(");
  else printf("Yay!");
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	ll n;
	cin>>n;
	vector<PII>a(n);
	for(int i=0;i<n;i++)cin>>a[i].se>>a[i].fi;
	sort(a.begin(),a.end());
	ll cnt = 0;
	for(int i=0;i<n;i++){
		//cout<<cnt<<endl;
		if(cnt+a[i].se > a[i].fi){
			cout<<"No";
			return 0;
		}
		cnt+=a[i].se;
	}
	cout<<"Yes";	
}


Measured memory_bytes: 6428
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#define FI first
#define SE second
using namespace std;
const double EPS = 1e-8;
const int MAXN = 500005;
const int INF = 1111111111;
struct Node{
    string str;
    int id;
    bool operator<(const Node &a)const {
        return str<a.str;
    }
}node[MAXN];
long long tree[MAXN];
int n;
long long ans[MAXN];
int a,b,MOD;
int lowbit(int x) {
    return x&(-x);
}
void update (int x,long long add) {
    while (x<=n) {
        tree[x] = (tree[x]+add)%MOD;
        x += lowbit(x);
    }
}
long  query(int x) {
    long ret = 0;
    while (x > 0) {
        ret = (ret +tree[x])%MOD;
        x -= lowbit(x);
    }
    return ret;
}
int main() {
    //freopen("/home/qitaishui/in.txt","r",stdin);

    while (scanf("%d%d%d",&a,&b,&MOD)&&(MOD)) {
        n = 1;
        for (int i = a; i <= b; ++i) {
            node[n].id = n;
            //int tmp = i;
            stringstream st;
            st<<i;
            st>>node[n].str;

            ++n;
            //cout<<node[n++].str<<endl;
        }
        --n;
        memset(tree,0,sizeof(tree));
        sort (node+1,node+n+1);
        long long su = 0;
        memset(ans,0,sizeof(ans));
        for (int i = 1; i <= n; ++i) {

            ans[i] = (su+query(node[i].id) + 1)%MOD;
            //su =  (su+ans[i])%MOD;
            update(node[i].id,ans[i]);
            //cout<<i<<endl;
        }
        long long ret = 0;
        for (int i = 1; i <= n; ++i) {
            ret = (ret+ans[i])%MOD;
        }
        cout<<ret<<"\n";
    }
    return 0;
}

Measured memory_bytes: 21576
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string s[3];
	REP(i,3) cin >> s[i];
	REP(i,3) reverse(ALL(s[i]));
	int p = 0;
	while(!s[p].empty()){
		int ne = s[p][SZ(s[p])-1]-'a';
		s[p].pop_back();
		p = ne;
	}
	cout << char('A'+p) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

namespace AIDU {
    class AIDU0018
    {
        public static void Main(){
            string[] ss= Console.ReadLine().Split();
            int[] x=new int[5];
            string[] xs= new string[5];
            for(int i=0;i<5;i++) x[i]=int.Parse(ss[i]);
            Sort(ref x);
            for(int i=0;i<5;i++)
                xs[i]=x[i].ToString();
            Console.WriteLine(string.Join(" ",xs));
        }

        static void Swap(ref int[] x,int i) {
            int y;
            y=x[i];x[i]=x[i+1];x[i+1]=y;
        }

        static void Sort(ref int[] x) {
            for(int j=0;j<x.Length;j++) {
                for(int i=0;i<x.Length-j-1;i++) {
                    while(x[i]<x[i+1])Swap(ref x, i);
                }
            }
        }

    }
}

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

int main() {
  int e, y, ans;

  cin >> e >> y;
  if (e == 0) {
    ans = y - 1867;
    if (ans <= 44) {
      cout << "M" << ans << endl;
    }
    else if (ans <= 58) {
      ans -= 44;
      cout << "T" << ans << endl;
    }
    else if (ans <= 121) {
      ans -= 58;
      cout << "S" << ans << endl;
    }
    else {
      ans -= 121;
      cout << "H" << ans << endl;
    }
  }
  else if (e == 1) {
    ans = 1867 + y;
    cout << ans << endl;
  }
  else if (e == 2) {
    ans = 1911 + y;
    cout << ans << endl;
  }
  else if (e == 3) {
    ans = 1925 + y;
    cout << ans << endl;
  }
  else if (e == 4) {
    ans = 1988 + y;
    cout << ans << endl;
  }
}

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


int main() 
{
	int i, k = 0;
	char buf[3];
	int arr[4] = {0};

	while (scanf("%d,%s", &i,buf) != EOF)
	{
		if (strcmp(buf, "A") == 0)
		{
			++arr[0];
		}
		if (strcmp(buf, "B") == 0)
		{
			++arr[1];
		}
		if (strcmp(buf, "AB") == 0)
		{
			++arr[2];
		}
		if (strcmp(buf, "O") == 0)
		{
			++arr[3];
		}
	}
		

	for (i = 0; i < 4; i++)
	{
		printf("%d\n",arr[i]);
	}

	return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_S = 100;
string S;
bool changed[MAX_S];
ll K;

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

  cin >> S;
  cin >> K;
  
  if (len(S) == 1) {
    cout << K/2 << endl;
    return 0;
  }

  bool isAllSame = true;
  for (int i = 1; i < len(S); ++i) {
    if (S[i-1] != S[i]) {
      isAllSame = false; break;
    }
  }

  if (isAllSame) {
    cout << (K*len(S))/2 << endl;
    return 0;
  }

  ll ans = 0;
  for (int i = 1; i < len(S); ++i) {
    if (!changed[i-1] && S[i-1] == S[i]) {
      ++ans;
      changed[i] = true;
    }
  }

  if (!changed[len(S)-1] && S[0] == S[len(S)-1]) {
    int sequence = 1;
    for (int i = 1; i < len(S); ++i) {
      if (S[i-1] == S[i]) ++sequence;
      else break;
    }
    if (sequence%2 == 0) ans = ans * K;
    else ans = ans + (ans+1) * (K-1);
  } else {
    ans = ans * K;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int x;
  cin>>x;
  int ans=0;
  rep(i,1,40){
    int cnt=0;
    rep(j,2,12){
      if(pow(i,j)<=x){
        cnt=pow(i,j); 
         ans=max(ans,cnt); 
      }
      else{
       ans=max(ans,cnt); 
        
      }
    }
  }
 // cout<<pow(1,2)<<endl;
  cout<<ans<<endl;
}

Measured memory_bytes: 4228
S = gets.chomp
 
s1 = S[0..1].to_i
s2 = S[2..3].to_i
 
YY = (0..99)
MM = (1..12)
 
if YY.member?(s1) && MM.member?(s2)
  if MM.member?(s1) && YY.member?(s2)
    puts 'AMBIGUOUS'
  else
    puts 'YYMM'
  end
elsif MM.member?(s1) && YY.member?(s2)
  puts 'MMYY'
else
  puts 'NA'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i, a[n], b[n];
    
    for(i=0;i<n;i++) cin>>a[i]>>b[i];
    
    for(i=0;i<n - 2;i++)
    {
        if(a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2]) 
            return cout<<"Yes", 0;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3636
def f(n):
    return len(list(filter(lambda x: x >= n - 1, l)))
n = int(input())
l = [0] * (n + 1)
for i in range(2, n+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            l[j] += 1
            cur //= j
print(f(75) + f(25) * (f(3) - 1) + f(15) * (f(5) - 1) + f(5) * (f(5) - 1) * (f(3) - 2) // 2)

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

int a[4][4];
map<int,int>mp;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        mp[x]++;
    }
    int flag=0;
    if(mp[a[1][1]]&&mp[a[2][2]]&&mp[a[3][3]]) //duijiao
    {
        flag=1;
    }
    if(mp[a[1][1]]&&mp[a[1][2]]&&mp[a[1][3]])
    {
        flag=1;
    }
    if(mp[a[2][1]]&&mp[a[2][2]]&&mp[a[2][3]])
    {
        flag=1;
    }
    if(mp[a[3][1]]&&mp[a[3][2]]&&mp[a[3][3]])
    {
        flag=1;
    }
    if(mp[a[1][1]]&&mp[a[2][1]]&&mp[a[3][1]])
    {
        flag=1;
    }
    if(mp[a[1][2]]&&mp[a[2][2]]&&mp[a[3][2]])
    {
        flag=1;
    }
    if(mp[a[1][3]]&&mp[a[2][3]]&&mp[a[3][3]])
    {
        flag=1;
    }
    if(mp[a[1][3]]&&mp[a[2][2]]&&mp[a[3][1]])
    {
        flag=1;
    }
    if(flag)
        cout<<"Yes"<<'\n';
    else
        cout<<"No"<<'\n';





}


Measured memory_bytes: 256
def check(num):
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                return False
                break
        else:
            return True
    else:
        return False


a = int(input())

for i in range(a, 100500):
    if check(i):
        print(i)
        break

Measured memory_bytes: 6028
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    string S; cin >> S;
    ll ret = 0; char cur_c = S[0];
    REP(i, S.size()){
        if(S[i] != cur_c){
            ret++; cur_c = S[i];
        }
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
int main(){
    int n; std::cin >> n;
    std::string s; std::cin >> s;
    int cnt=0;
    int idx=0;
    while(idx<s.size()){
        while(idx < s.size() && s[idx] != 'A') ++idx;
        if(idx >= s.size()) break;
        if(s.substr(idx,3) == "ABC") ++cnt;
        ++idx;
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<math.h>
int main(void){
 int N,i,sum1=0,sum2=0;
  scanf("%d",&N);
  int W[N];
  for(i=0;i<N;i++){
    scanf("%d",&W[i]);
  }
  for(i=0;i<N;i++){
    sum1=sum1+W[i];
  }
  sum2=sum1;
  for(i=0;i<N;i++){
    if(sum1*2>W[i]){
      sum1=sum1-W[i]*2;
    }
    else{
      break;
    }
  }
  for(i=N-1;i>=0;i--){
    if(sum2*2>W[i]){
      sum2=sum2-W[i]*2;
    }
    else{
      break;
    }
  }
  sum1=abs(sum1);
  sum2=abs(sum2);
  if(sum1<=sum2){
    printf("%d",sum1);
  }
  else{
    printf("%d",sum2);
  }
  return 0;
}
    


Measured memory_bytes: 128
N = gets.to_i
a = []
a = gets.split.map(&:to_i)
# a中での登場回数を数える
# keyがaの要素で，valが登場回数
hash = {}
# ついでに和も数える
sum = 0
N.times do |i|
  if hash[a[i]].nil?
    hash[a[i]] = 1
  else 
    hash[a[i]] += 1
  end
  sum += a[i]
end

Q = gets.to_i
b, c = [], []
tmp = 0
ans = []
Q.times do |i|
  b[i], c[i] = gets.split.map(&:to_i)
  if not hash[b[i]].nil?
    tmp = hash[b[i]]
    hash[b[i]] = 0
    sum -= b[i]*tmp
    if hash[c[i]].nil?
      hash[c[i]] = tmp
    else
      hash[c[i]] += tmp
    end
    sum += c[i]*tmp
  end
  ans[i] = sum
  # puts "#{hash}"
  # puts "sum=#{sum}"
end

ans.each do |t|
  puts t
end

Measured memory_bytes: 30796
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 2019
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 2019;

int main(){
    int a,b;
    cin>>a>>b;
    if(a<=b){
        OUT("unsafe");
    }else{
        OUT("safe");
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,M,r,q;
int cum[10010][1300];

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

  while (cin >> N >> M, N) {
    ZERO(cum);
    cin >> r;
    REP(i,r) {
      int t,n,m,s;
      cin >> t >> n >> m >> s;
      m--;
      if (s == 1) cum[m][t]++;
      else cum[m][t]--;
    }
    REP(i,M) {
      for (int j = 0; j+1 < 1300; j++) {
        cum[i][j+1] += cum[i][j];
      }
    }
    cin >> q;
    REP(i,q) {
      int ts,te,m;
      cin >> ts >> te >> m;
      m--;
      int ans = 0;
      for (int j = ts; j < te; j++) {
        if (cum[m][j] > 0) ans++;
      }
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 104768
open Printf
open Scanf

let solve n =
  let l = String.length n in
  let rec loop r i =
    if i = l then r
    else let t = (Char.code n.[i] - 48 + r) mod 9
         in loop t (i + 1) in
  let r = loop 0 0 in
  if r = 0 then "Yes" else "No"

let () =
  scanf "%s " solve |> printf "%s\n"


Measured memory_bytes: 4420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i =1;i <=5;i++) {
			if(sc.nextInt() ==0) {
				System.out.println(i);
				return;
			}
		}

	}
}

Measured memory_bytes: 35852
#include<iostream>
#include<cstdio>
#define mod 998244353
using namespace std;
long long n,a,b,k,ans=0,anss[300005][3],fac[300005],cnt=0;
inline long long inv(long long b){  
    return b==1?1:(mod-mod/b)*inv(mod%b)%mod;
}
inline long long C(long long n,long long m){  
    long long t=(fac[m]*fac[n-m])%mod;
    return (fac[n]*inv(t))%mod;
}
inline void init(){
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	fac[0]=1,fac[1]=1;
	for(int i=2;i<300005;i++) fac[i]=(fac[i-1]*i)%mod;
}
int main(){
	init();
	for(int i=0;i<=n;i++)
		if(k>=(i*a)&&(k-a*i)%b==0&&(k-a*i)/b<=n){
			anss[cnt][0]=i;
			anss[cnt++][1]=(k-a*i)/b;
		}
	for(int i=0;i<cnt;i++) ans=(ans+C(n,anss[i][0])*C(n,anss[i][1])%mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8448
#include<iostream>
#include<string>
using namespace std;
int S=0,T=0,sum=0;
string c;
int main()
{
	std::ios::sync_with_stdio(false);
	cin>>c;
	for(int i=0;i<c.size();i++){
		if(c[i] == 'S'){
			S++;
			sum+=T;
			T=0;
		}
		else{
			if(S==0){
				T++;
			}else{
				S--;
			}
		}
	}
	sum+=S;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>

using namespace std;

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

    unsigned long long q = N % 11;
    unsigned long long p = N/11;
    if(q == 0){
        cout << 2 * p << endl;
    }else if(1 <= q && q <= 6){
        cout << 2 * p + 1 << endl;
    }else if(q >= 7){
        cout << 2 * p + 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m;
	int city[51]={0},rode[51][2];
	scanf("%d%d",&n,&m);
	int i,j;
	for(i=1;i<=m;i++)
	{
	   scanf("%d%d",&rode[i][0],&rode[i][1]);
	   city[rode[i][0]]++;
	   city[rode[i][1]]++;
    }
    for(j=1;j<=n;j++)
       printf("%d\n",city[j]);
    return 0;   
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) {
				break;
			}
			int y = stdIn.nextInt();
			int[] b = new int[n];
			int[] r = new int[n];
			int[] t = new int[n];
			double[] ans = new double[100];
			for(int i = 0; i < n; i++) {
				b[i] = stdIn.nextInt();
				r[i] = stdIn.nextInt();
				t[i] = stdIn.nextInt();
			}
			for(int i = 0; i < n; i++) {
				if(t[i] == 1) {
					ans[b[i]-1] = 10000.0*(1.0 + (double)y * (double)r[i] * 0.01);
				}
				else {
					double tmp = 1.0;
					for(int j = 0; j < y; j++) {
						tmp *= 1.0 + (double)r[i]*0.01;
					}
					ans[b[i]-1] = 10000*tmp;
				}
			}
			double max = 0;
			int id = 0;
			for(int i = 0; i < 100; i++) {
				if(ans[i] > max) {
					max = ans[i];
					id = i+1;
				}
			}
			System.out.println(id);
		}
		
	}
}

Measured memory_bytes: 39072
#include<stdio.h>
int main(void){
    int H,W,i,d;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0){
            break;
        }
        for(i=0;i<H;i++){
            for(d=0;d<W;d++){
                printf("#");
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2128
// liner search alg
// input integers S[] and T[], count T[] numbers at S[]
#include<iostream>
int linersearch(int*,int,int);
int main(){
  int count=0, n, q;
  std::cin >> n;
  int S[n], T[n];
  for(int i=0; i<n; i++) std::cin >> S[i];
  std::cin >> q;
  for(int i=0; i<q; i++) std::cin >> T[i];
  for(int i=0; i<q; i++) if(linersearch(S,n,T[i])) count++;
  std::cout << count <<std::endl;
  return 0;
}
int linersearch(int A[],int len,int key){
  int i;
  for(i=0; i<len; i++)
    if(A[i] == key)
      return 1;
  return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 233;
int n,a[maxn],b[maxn];
int sr,sc,x;
char s[maxn],t[maxn];
bool check(int l,int r,int maxi){
	for(int i=n;i;i--){
		if(b[i]==1)l--;
		if(b[i]==-1)r++;
		if(l<1)l = 1;
		if(r>maxi)r = maxi;
		if(a[i]==1)r--;
		if(a[i]==-1)l++;
		if(l>r)return 0;
	}
	if(l<=x&&x<=r)return 1;
	return 0;
}
int main()
{
	int h,w;cin>>h>>w>>n;
	cin>>sr>>sc;
	scanf("%s %s",s+1,t+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='L')a[i] = -1;
		else if(s[i]=='R')a[i] = 1;
		else a[i] = 0;
		if(t[i]=='L')b[i] = -1;
		else if(t[i]=='R')b[i] = 1;
		else b[i] = 0;
	}
	x = sc;
	if(!check(1,w,w)){
		puts("NO");
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(s[i]=='D')a[i] = 1;
		else if(s[i]=='U')a[i] = -1;
		else a[i] = 0;
		if(t[i]=='D')b[i] = 1;
		else if(t[i]=='U')b[i] = -1;
		else b[i] = 0;
		x = sr;
	}
	if(!check(1,h,h)){
		puts("NO");
		return 0;
	}
	cout << "YES" << endl;
	return 0;
} 

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

using namespace std;

typedef long long ll;

const int maxn = 100010;

int n, m;
ll q[maxn<<1], dp[maxn<<1], ans[maxn];
vector<int> ed[maxn<<1];
vector<ll> edw[maxn<<1];
int sta[maxn<<1], top;

void adde(int s, int t, ll len) {
	if (q[sta[1]] > len) {
		ed[s].push_back(len);
		edw[s].push_back(1);
		return;
	}
	int L = 1, R = t, res = -1;
	while (L <= R) {
		int mid = (L + R) >> 1;
		if (q[sta[mid]] <= len) {
			res = mid;
			L = mid + 1;
		} else R = mid - 1;
	}
	ll x = q[sta[res]];
	ed[s].push_back(sta[res]);
	edw[s].push_back(len / x);
	if (len % x) adde(s, res - 1, len % x);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) scanf("%lld", &q[n+i]);
	q[n] = n;
	sta[++ top] = n;
	for (int i = n+1; i <= n+m; i++) {
		adde(i, top, q[i]);
		while (top && q[sta[top]] >= q[i]) -- top;
		sta[++ top] = i;
	}
	dp[n + m] = 1;
	for (int i = n + m; i > n; i--) {
		for (int j = 0; j < ed[i].size(); j++) {
			int v = ed[i][j];
			dp[v] += edw[i][j] * dp[i];
		}
	}
	for (int i = n; i >= 1; i--) ans[i] = ans[i + 1] + dp[i];
	for (int i = 1; i <= n; i++) printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 28288
from math import sqrt;

count = int(input());
data = [];
for n in range(count):
    data.append(int(input()));

def prime_number(data):
    max_divisor = get_max_divisor(data);
    divisor_primes = get_prime(max_divisor);
    count = 0;
    for n in data:
        ok = 1;
        for p in divisor_primes:
            if n < p:
                ok = 0;
                break;
            elif n == p:
                break;
            elif n % p == 0:
                ok = 0;
                break;
        count += ok;
    return count;

def get_max_divisor(data):
    maxN = data[0];
    for n in data[1:]:
        if n > maxN:
            maxN = n;
    return int(sqrt(maxN)) + 1;

def get_prime(max_divisor):
    primes = [];
    for n in range(2, max_divisor + 1):
        is_prime = True;
        for p in primes:
            if n % p == 0:
                is_prime = False;
        if is_prime:
            primes.append(n);
    return primes;

print(prime_number(data));


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

int main() {
	int a,b,c;
	cin >> a;
	c = a % 10 ;
  	a = (a - c) / 10;
  	b = a % 10;
    a=(a-b)/10;
    cout<< a+b+c << endl;
	return 0;
}


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

int main(){
    int n,q;
    cin >> n;
    int S[n];
    for ( int i = 0;i < n;i++)cin >> S[i];
    cin >> q;
    int T[q];
    for ( int i = 0;i < q;i++)cin >> T[i];
    
    int x = 0;
    int mid;
    int left = 0;
    int right = n;
    for ( int j = 0;j<q;j++){
        left = 0;
        right = n;
        while(left<right){
        mid = (left+right) / 2;
            if (S[mid]==T[j]){
                x++;
                break;
            }else if(T[j] < S[mid]){
                right = mid;
            }else if(T[j] > S[mid]){
                left = mid + 1;
            }
        }
    }
    cout << x << endl;
    
    
    return 0;
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,m;
    cin>>h>>w>>m;
    set<pair<int,int>> grid;
    for(int i=0;i<m;i++)
    {
        int k,q;
        cin>>k>>q;
        grid.insert({k,q});
    }
    int row[h+1]={0},col[w+1]={0};
    for(auto x:grid)
    {
        row[x.first]++;
        col[x.second]++;
    }
    int rm=0,cm=0;
    int mr=-1,mc=-1;
    for(int i=1;i<=h;i++)
    {
        if(row[i]>rm)
        {
            mr=i;
            rm=row[i];
        }
    }
    for(int i=1;i<=w;i++) 
    {
        if(col[i]>cm)
        {
            mc=i;
            cm=col[i];
        }
    }
    if(rm>cm)
    {
        for(int i=1;i<=w;i++)
        {
            if(grid.find({mr,i})!=grid.end())
            {
                col[i]--;
            }
        }
        int ans=rm;
        ans+=*max_element(col,col+w+1);
        cout<<ans;
    }
    else
    {
        for(int i=1;i<=h;i++)
        {
            if(grid.find({i,mc})!=grid.end())
            {
                row[i]--;
            }
        }
        int ans=cm;
        ans+=*max_element(row,row+h+1);
        cout<<ans;
    }
    
    return 0;
}

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

int main ()
{
    int n;
    int sum=0;
    cin >> n;
    int cnt=0;

    for (int i=0;i<n;i++)
    {
        int input;
        cin >> input;
        cnt=max(cnt,input);
        sum+=input;
    }
    cout << sum-(cnt/2)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

void solve() {
    int n;
    string a, b;
    cin >> n >> a >> b;

    for (int i = 0; i < n; i++) {
        cout << a[i] << b[i];
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int MOD = 1000000007;
	static int N, total;
	static long[] pow10 = new long[801];
	static long[] fact = new long[201];
	static long[][] binom = new long[201][201];

	public static void main(String[] args) {
		pow10[0] = fact[0] = 1;
		for (int i = 1; i < pow10.length; ++i) {
			pow10[i] = pow10[i - 1] * 10 % MOD;
		}
		for (int i = 1; i < fact.length; ++i) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		for (int i = 0; i <= 200; ++i) {
			binom[i][i] = binom[i][0] = 1;
		}
		for (int i = 0; i <= 200; ++i) {
			for (int j = 1; j < i; ++j) {
				binom[i][j] = (binom[i - 1][j] + binom[i - 1][j - 1]) % MOD;
			}
		}
		N = sc.nextInt();
		int[] A = new int[N];
		int zi = -1;
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
			if (A[i] == 0) zi = i;
		}
		int ans = solve(A);
		if (zi != -1) {
			int[] B = new int[N - 1];
			int idx = 0;
			for (int i = 0; i < N; ++i) {
				if (i == zi) continue;
				B[idx++] = A[i];
			}
			ans += MOD - solve(B);
			ans %= MOD;
		}
		System.out.println(ans);
	}

	static int solve(int[] A) {
		int[] digits = new int[5];
		for (int i = 0; i < A.length; ++i) {
			digits[(A[i] + "").length()]++;
		}
		total = digits[1] + digits[2] * 2 + digits[3] * 3 + digits[4] * 4;
		int[][][] comb = new int[5][][];
		for (int i = 1; i <= 4; ++i) {
			if (digits[i] > 0) {
				comb[i] = calcComb(digits, i);
			}
		}
		long ret = 0;
		for (int i = 0; i < A.length; ++i) {
			int len = (A[i] + "").length();
			for (int j = 0; j < A.length; ++j) {
				long add = 0;
				for (int k = 0; k <= A.length - 1 - j; ++k) {
					add += binom[A.length - 1 - j][k] * fact[k];
					add %= MOD;
				}
				add *= A[i];
				add %= MOD;
				add *= fact[j];
				add %= MOD;
				for (int k = 0; k < total; ++k) {
					long addElem = add * pow10[k] % MOD;
					addElem *= comb[len][j][k];
					addElem %= MOD;
					ret += addElem;
					ret %= MOD;
				}
			}
		}
		return (int) ret;
	}

	static int[][] calcComb(int[] digits, int cur) {
		digits[cur]--;
		int[][] dp = new int[N][total + 1]; // dp[i][j] : j digits with i cards
		dp[0][0] = 1;
		for (int i = 1; i <= 4; ++i) {
			for (int j = 0; j < digits[i]; ++j) {
				for (int k = N - 1; k > 0; --k) {
					for (int l = total; l >= i; --l) {
						dp[k][l] += dp[k - 1][l - i];
						if (dp[k][l] >= MOD) dp[k][l] -= MOD;
					}
				}
			}
		}
		digits[cur]++;
		return dp;
	}
}

Measured memory_bytes: 26772
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define ll long long int
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};

int gcd(int a, int b)
{
   while ( b ) {
      int t = a % b;
      a = b;
      b = t;
   }
   return a;
}
int main() {
	int n;
	cin>>n;
	int num[n];
	rep(i,0,n)cin>>num[i];
	int ans=num[0];
	rep(i,1,n){
		ans=gcd(ans,num[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s[0] != 'A')return cout << "WA" << endl, 0;
	if (count(s.begin() + 2, s.end() - 1, 'C')==0)return cout << "WA" << endl,0;
	for (int i = 0; i < s.length(); i++) {
		for (int j = 65; j <= 90; j++) {
			if (j == 65 || j == 67) {
				if(count(s.begin(), s.end(), (char)j) >= 2)return cout << "WA" << endl, 0;
			}
			else if (count(s.begin(), s.end(), (char)j) >= 1)return cout << "WA" << endl,0;
		}
	}
	cout << "AC" << endl;
}


Measured memory_bytes: 256