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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

char G[15][1005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w,k; cin>>h>>w>>k;
  rep(i,h) rep(j,w) cin>>G[i][j];
  
  ll ans=INF;
  for(ll bit=0; bit<(1<<h-1); bit++){
    ll g=0;
    vll id(h);
    rep(i,h){
      id[i]=g;
      if(bit>>i&1) g++;
    }
    g++;
    
    vvll c(g, vll(w));
    rep(i,h) rep(j,w) c[id[i]][j] += (G[i][j]-'0');
    ll num=g-1;
    vll now(g);
    auto add=[&](ll j){
      rep(i,g) now[i]+=c[i][j];
      rep(i,g) if(now[i]>k) return false;
      return true;
    };
    rep(j,w){
      if(!add(j)){
        num++;
        now=vll(g);
        if(!add(j)){
          num=INF;
          break;
        }
      }
    }
    chmin(ans,num);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

int main(){
	int n;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			int gx,gy,p;
			bool stage[16][16][16][16];
			memset(stage,-1,sizeof(stage));
			scanf("%d %d",&gx,&gy);
			scanf("%d",&p);
			for(int j=0;j<p;j++){
				int x1,y1,x2,y2;
				scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
				stage[x1][y1][x2][y2] = false;
				stage[x2][y2][x1][y1] = false;
			}

			int dp[17][17];
			
			memset(dp,0,sizeof(dp));

			dp[0][0] = 1;
			dp[1][1] = 1;

			for(int y=0;y<=gy;y++){
				for(int x=0;x<=gx;x++){
					if(x==0 && y==0) continue;

					if(x > 0 && stage[x-1][y][x][y]){
						dp[y+1][x+1] += dp[y+1][x];
					}

					if(y > 0 && stage[x][y-1][x][y]){
						dp[y+1][x+1] += dp[y][x+1];
					}
				}
			}

			if(dp[gy+1][gx+1]==0){
				printf("Miserable Hokusai!\n");
			}
			else{
				printf("%d\n",dp[gy+1][gx+1]);
			}
		}
	}

}

Measured memory_bytes: 1268
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

#define pi  3.141592653589793238462643

int main(){
  double a, b, h, m;
  double atheta, btheta, abtheta;
  double ans;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  btheta = (m/60)*360;
  atheta = (h/12+m/(12*60))*360;
  //printf("%lf %lf\n",atheta,btheta);
  
  if(fabs(atheta - btheta) > 180) {
    abtheta = 360 - fabs(atheta - btheta);
  }else {
    abtheta = fabs(atheta - btheta);
  }
  
  //printf("%lf\n",abtheta);
  
  ans = sqrt( a*a + b*b - 2*a*b*cosl(abtheta*pi/180));
  printf("%.15lf\n",ans);
  
  return 0;
}

Measured memory_bytes: 2528
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if(x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();
    }
}



Measured memory_bytes: 26392
#coding:utf-8

N,M = map(int,input().split())

Observ = [1 for i in range(N)]

h = input().split()
H = [int(i) for i in h]

for i in range(M):
    A,B = map(int,input().split())
    HA = H[A-1]
    HB = H[B-1]
    if HA > HB:
        Observ[B-1] = 0
    elif HA < HB:
        Observ[A-1] = 0
    elif HA == HB:
        Observ[A-1] = 0
        Observ[B-1] = 0

ans = 0
for i in Observ:
    ans += i
    
print("{}".format(ans))

Measured memory_bytes: 20908
N = int(input())
sect = []
sect_l = []
sect_r = []

for i in range(N):
	l,r = map(int,input().split())
	sect_l.append((l,r,i))
	sect_r.append((r,l,i))
	sect.append((l,r))

sect_l.sort()
sect_r.sort()
sect_r.reverse()

ans_l,ans_r = 0,0
if sect_r[N-1][0] < 0:
	used = [False for i in range(N)]
	L = [x for x in sect_l]
	R = [x for x in sect_r]
	next = 'L'
	cur = 0
	cnt = 0
	while cnt < N:
		if next == 'R':
			while True:
				l,r,i = L.pop()
				if not used[i]:
					used[i] = True
					break
			if not (l <= cur and cur <= r):
				ans_l += abs(cur - l)
				cur = l
			next = 'L'
			cnt += 1
		else:
			while True:
				r,l,i = R.pop()
				if not used[i]:
					used[i] = True
					break
			if not (l <= cur and cur <= r):
				ans_l += abs(cur - r)
				cur = r
			next = 'R'
			cnt += 1
	ans_l += abs(cur)

if sect_l[N-1][0] > 0:
	used = [False for i in range(N)]
	L = [x for x in sect_l]
	R = [x for x in sect_r]
	next = 'R'
	cur = 0
	cnt = 0
	while cnt < N:
		if next == 'R':
			while True:
				l,r,i = L.pop()
				if not used[i]:
					used[i] = True
					break
			if not (l <= cur and cur <= r):
				ans_r += abs(cur - l)
				cur = l
			next = 'L'
			cnt += 1
		else:
			while True:
				r,l,i = R.pop()
				if not used[i]:
					used[i] = True
					break
			if not (l <= cur and cur <= r):
				ans_r += abs(cur - r)
				cur = r
			next = 'R'
			cnt += 1
	ans_r += abs(cur)
print(max(ans_l,ans_r))

Measured memory_bytes: 39868
/*
lakshaygpt28
Lakshay Gupta
*/

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

const double PI = acos(-1);
const long long LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

long long power(long long a, long long b) {
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a, b - 1) * a) % MOD;
	long long q = power(a, b/2);
	return (q * q) % MOD;
}

int main() {
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    long long n;
    cin >> n;
    cout << (power(10, n) - ((2 * power(9, n) - power(8, n) + MOD) % MOD) + MOD) % MOD << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define in(a) cin >> a;
#define out(a) cout << a << endl;
#define inV(A) REP(i,A.size()) in(A[i]);
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-----------------------------------
int main(){
    init();
    ll n,m;
    in(n);in(m);
    vl s(m);
    vl c(m);
    map<int,int> A;
    map<int,int> B;
    REP(i,m){
        cin >> s[i] >> c[i];
        A[s[i]]=1;
        if(A[s[i]]!=1) B[s[i]]=c[i];
    }
    if(n==1){
        FOR(i,0,10){
            int f=1;
            REP(j,m){
                if(i!=c[j]) f=0;  
            }
            if(f){
                cout << i << endl;
                return 0;
            }
        }
        cout << -1 << endl;
    }else if(n==2){
        FOR(i,10,100){
            int f=1;
            REP(j,m){
                ll x;
                if(s[j]==1) x= i/10;
                else x= i%10;
                if(x!=c[j]) f=0;  
            }
            if(f){
                cout << i << endl;
                return 0;
            }
        }
        cout << -1 << endl;
    }else{
        FOR(i,100,1000){
            int f=1;
            REP(j,m){
                ll x;
                if(s[j]==1) x= i/100;
                else if(s[j]==2) x= (i/10)%10;
                else x= i%10;
                if(x!=c[j]) f=0;  
            }
            if(f){
                cout << i << endl;
                return 0;
            }
        }
        cout << -1 << endl;
    }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

lli aa[100][100];
lli bb[100][100];

int main(){

	lli n,m;
	cin>>n>>m;

	REP(i,0,n)REP(j,0,n){
		char tmp;
		cin>>tmp;
		if(tmp=='#')aa[i][j]=1;
		else aa[i][j]=0;
	}
	REP(i,0,m)REP(j,0,m){
		char tmp;
		cin>>tmp;
		
		if(tmp=='#')bb[i][j]=1;
		else bb[i][j]=0;
	}

	REP(i,0,n-m+1)REP(j,0,n-m+1){
		bool ok=true;
		REP(k,0,m){
			REP(l,0,m){
					if(aa[i+k][j+l] != bb[k][l]){
						ok=false;
						break;
					}
			}
		}
		if(ok){
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	cout<<"No"<<endl;
 
    return 0;
}

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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int count=0;
  for(int i=0;i<N-2;i++){
  	if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C')
      count++;
  }
  cout<<count<<endl;
}

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

int main() {
	int A, B,C,D;
	cin >> A >> B >> C >> D;
	if (abs(A-C)<=D) {
		cout << "Yes"<< endl;
		return 0;
	}
	if ((abs(A-B)<=D)&&(abs(B-C)<=D)) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No"<<endl;
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	bool rev = false;
	deque<int> dq;
	for(int i = 0;i < n;i++){
		if(rev){
			dq.push_front(a[i]);
		}
		else{
			dq.push_back(a[i]);
		}
		rev ^= true;
	}
	for(int i = 0;i < n;i++){
		cout << dq[!rev ? i : n - 1 - i] << " \n"[i + 1 == n];
	}
	return 0;
}


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

int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	
	if (a==b and b==c and a==c){
		cout << "Yes";
	}
	
	else {
		cout << "No";
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double th = 30*h - 5.5*m;
    th = min(th, 360-th);
    th = th/180*3.14159265358979;
    double c = sqrt(a*a +b*b - 2*a*b*cos(th));
    cout<<fixed<<setprecision(10);
    cout << c << endl;
}

Measured memory_bytes: 4196
#include <iostream>
#include <ios>
#include <algorithm>
using namespace std;
int n, A[20] = {};

bool check(int i, int v){
	if (i == n)					return false;
	if (v == A[i])				return true;
	if (v < A[i])				return false;
	if (check(i + 1, v))		return true;
	if (check(i + 1, v - A[i]))	return true;
	return false;
}

int main()
{
	int m, i, k;
	cin >> n;
	for (i = 0; i < n; ++i)
		cin >> A[i];
	sort(A, A + n);
	cin >> m;
	for (i = 0; i < m; ++i){
		cin >> k;
		cout << (check(0, k) ? "yes\n" : "no\n");
	}

	return 0;
}

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

int main() {
	int D, target;
	int p[12],c[12];
	cin>>D>>target;
	for (int i=0; i<D; i++) {
		cin>>p[i]>>c[i];
		c[i] += p[i]*(i+1)*100;
	}
	int ans=99999999;
	for (int i=0; i<(1<<D); i++) {
		int score=0, tmp=0;
		for (int k=0; k<D; k++)
			if ( (1<<k)&i )
				score+=c[k], tmp+=p[k];
		// cout<<"tmp="<<tmp<<" score="<<score<<endl;
		if (score < target) {
			int fill_pos;
			for (fill_pos = D-1; fill_pos>=0; fill_pos--)
				if ( ((1<<fill_pos)&i) == 0)
					break;
			int delta = (target - score - 1)/((fill_pos+1)*100) + 1;
			if (delta > p[fill_pos])
				continue;
			tmp += delta;
		}
		// cout<<"\ttmp="<<tmp<<" score="<<score<<endl;
		ans = min(ans, tmp);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main( ){

    string s ;

    cin >> s ;

    int ans = 0 , u = 0;

    for( int i =0 ; i < 3 ; i ++ ){


        if( s[i] == 'R' ){

            u  = 0 ;

            for( int j = i ; j < 3 ; j ++ ){

                if( s[j] == 'R' ){

                    u ++ ;

                }else if( s[j] == 'S' || j == 2 ){

                    ans = max( ans , u ) ;

                    break ;

                }

            }

        }

    }

    int h = 0 ;

    for( int i = 2 ; i >= 0 ; i -- ){

        if( s[i] == 'R' ){

            h ++ ;

        }else{

            break ;

        }

    }

    if( h > ans ){

        cout << h << endl ;

    }else{

        cout << ans << endl ;

    }

}


Measured memory_bytes: 3632
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll powmod(ll m, ll p) {
    if (p == 0) return 1;
    ll tmp = powmod(m, p / 2);
    if (p & 1) return (tmp * tmp % MOD) * m % MOD;
    else return tmp * tmp % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vll memo(k + 1, 0);
    for (ll i = k; i >= 1; i--) {
        ll div = k / i;
        memo[i] = powmod(div, n);
        for (ll j = i + i; j <= k; j += i) {
            ((memo[i] -= memo[j]) += MOD) %= MOD;
        }
    }

    ll ans = 0;
    for (ll i = 1; i <= k; i++) {
        (ans += i * memo[i] % MOD) %= MOD;
    }
    cout << ans << '\n';
    return 0;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    string s;
    cin >> s;

    // 処理
    string ans = "";
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B') {
            if (ans != "") {
                ans.pop_back();
            }
        } else {
            ans.push_back(s[i]);
        }
    }

    // 出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

next_small = [N]*N
G = []
heapq.heapify(G)
heapq.heappush(G, (-P[0], 0))
for i in range(1, N):
	judge = 0
	while judge == 0 and len(G) > 0:
		num = heapq.heappop(G)
		if -num[0] < P[i]:
			heapq.heappush(G, num)
			judge = 1
		else:
			next_small[num[1]] = i
	heapq.heappush(G, (-P[i], i))

before_large = [-1]*N
G = []
heapq.heapify(G)
heapq.heappush(G, (P[N - 1], N - 1))
for i in range(N - 2, -1, -1):
	judge = 0
	while judge == 0 and len(G) > 0:
		num = heapq.heappop(G)
		if num[0] > P[i]:
			heapq.heappush(G, num)
			judge = 1
		else:
			before_large[num[1]] = i
	heapq.heappush(G, (P[i], i))

inc = [1]*N
for i in range(1, N):
	if P[i] > P[i - 1]:
		inc[i] = inc[i - 1] + 1

num = 0
zero = 0
if inc[K - 1] >= K:
	zero += 1

for i in range(1, N - K + 1):
	#print(i + K - 1)
	if inc[i + K - 1] >= K:
		zero += 1
	elif next_small[i - 1] >= i - 1 + K and before_large[i + K - 1] <= i - 1:
		num += 1

#print(inc, next_small, before_large)
print(N - K + 1 - num - max(0, (zero - 1)))

Measured memory_bytes: 125400
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int a,b,c,counter1=0,counter2=0;
cin>>a>>b>>c;
if(a==5){
    counter1++;
}
if(b==5)
    counter1++;
if(c==5){
    counter1++;
}
if(a==7){
    counter2++;
}
if(b==7)
    counter2++;
if(c==7){
    counter2++;
}
if(counter1==2&&counter2==1){
    printf("YES\n");
}
else{
    printf("NO\n");
}
 
 
 
 
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<algorithm>

using namespace std;

int main()
{	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

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


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

  int x[5];
  rep(i,5) cin >> x[i];
  rep(i,5){
    if(i+1 != x[i]) {
      cout << i+1 << endl;
      return 0;
    }
  }
  
  return 0;
    

}


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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 6;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

ll n, k, arr[maxn], col[maxn];

bool solve(ll x) { 
	for (int i = 0; i < k; i++) {
		if (arr[i] > x)
			col[i] = 1;
		else
			col[i] = 0;
	}
	for (int i = 1; i < n; i++) {
		if (col[n - i - 1] == col[n - i]) 
			return col[n - i];
		if (col[n + i - 1] == col[n + i - 2]) 
			return col[n + i - 1];
	}
	return col[0];
}

int main() {
	fio();
	cin >> n;
	k = 2 * n - 1;
	for (int i = 0; i < k; i++) 
		cin >> arr[i];	
	ll L = 0, R = k - 1, M;
	while (L < R) {
		M = (L + R) / 2;
		if (solve(M)) 
			L = M + 1;
		else
			R = M;
	}
	cout << L << endl;
	return 0;
}


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

ans=1
d={}
for i in range(N+1):
	d[i]=0

d[0]=3

for a in A:
	ans*=d[a]
	d[a]-=1
	d[a+1]+=1
	if ans>=10**9+7:
		ans=ans%(10**9+7)


print(ans)


# 2darray [[0] * 4 for i in range(3)]

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << '\n';
	return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repm(i, a, b) for (int i = (a); i > (b); i--)

using namespace std;
using ll = long long;




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

  int a = x/500;
  int b = x%500/5;

  cout << a*1000 + b*5 << endl;


  return 0;
}

Measured memory_bytes: 256
from itertools import combinations
import numpy as np
N, M, X = map(int, input().split())
CA = [np.array(list(map(int, input().split()))) for _ in range(N)]

ans = None

for i in range(1, N+1):
    for comb_list in combinations(CA, i):
        comb_list = np.array(comb_list)
        sum_list = comb_list.sum(axis=0)
        if np.all(sum_list[1:] >= X):
            if not ans or (ans > sum_list[0]):
                ans = sum_list[0]
print(-1 if ans is None else ans)



Measured memory_bytes: 27392
dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()

    for i in range(4):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] == -1 or d < dst[nh][nw]:
            dq.appendleft((nh, nw, d))
            dst[nh][nw] = d

    for i in range(4, 24):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        dq.append((nh, nw, d + 1))
        dst[nh][nw] = d + 1

print(dst[eh][ew])


Measured memory_bytes: 93104
#include <stdio.h>

int choose_integers(int A, int B, int C)
{
  int i,flag;
  flag = 0;
  for(i = 0; i < B; i++){
    if((i * A)%B == C){
      flag = 1;
      break;
    }
  }
  return flag;
}

int check_input(int A, int B, int C)
{
  if((1 <= A && A <= 100) && (1 <= B && B <= 100) && (0 <= C && C < B)){
    return 1;
  }
  else{
    puts("Error: 制約条件を満たしていません");
    return -1;
  }
}

int main()
{
  int A,B,C;
  scanf("%d %d %d", &A, &B, &C);
  if (check_input(A,B,C) == 1){
    choose_integers(A,B,C) ? puts("YES") : puts("NO");
    return 0;
  }
  else{
    return -1;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ds(N, -1);
  bool failure = false;
  int s, c;
  for(int i = 0; i < M; ++i) {
    cin >> s >> c;
    auto idx = s - 1;
    if(ds[idx] != -1) {
      failure = ds[idx] != c;
    } else {
      ds[idx] = c;
    }
  }
  if(failure) {
    cout << -1 << endl;
    return 0;
  }
  for(int i = 0; i < ds.size(); ++i) {
    if(i == 0 && ds[i] == 0 && ds.size() != 1) {
      cout << -1 << endl;
      return 0;
    }
    if(ds[i] == -1) {
      if(ds.size() == 1) {
        cout << 0;
      } else {
        cout << (i == 0 ? 1 : 0);
      }
    } else {
      cout << ds[i];
    }
  }
  cout << endl;
  return 0;
}

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

int recur(int*arr,int n,int k,int*dp){
dp[1]=0;
if(dp[n]!=0){
	return dp[n];
}
	for(int i=2;i<=n;i++){
		dp[i]=INT_MAX;
		for(int j=i-1;j>=1 && (i-j)<=k;j--){
			dp[i]=min(dp[i],abs(arr[i]-arr[j])+dp[j]);
		}
	}
	return dp[n];
}
int main(){
int n;
cin>>n;
int k;
cin>>k;
int arr[100005];
arr[0]=0;
for(int i=1;i<=n;i++){
	cin>>arr[i];
}
int dp[100004]={0};
cout<<recur(arr,n,k,dp)<<endl;

return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;

    int n = s.length();
    int m = t.length();

    int dp[n+1][m+1];

    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
            if(i==0||j==0)
                dp[i][j] =0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    
    int i=n,j=m;
    string ans;
    while(i>0 && j>0){

        if(s[i-1]==t[j-1]){
            ans+=s[i-1];
            i--;j--;
        }
        else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
            
            

    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

ll n;

int main() {
    cin >> n;
    if (n & 1)
        cout << n * 2 << endl;
    else
        cout << n << endl;
    return 0;
}


Measured memory_bytes: 3608
while True:
    m,f,r=map(int,input().split())
    if(m==-1 and f==-1 and r==-1):
        break
    elif(m==-1 or f==-1):
        print("F")
    elif(m+f>=80):
        print("A")
    elif(m+f>=65):
        print("B")
    elif(m+f>=50):
        print("C")
    elif(m+f>=30):
        if(r>=50):
            print("C")
        else:
            print("D")
    elif(30>=m+f):
        print("F")


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll find(ll x)
{
	ll lb=0,ub=2e9;
	while(ub>lb+1)
	{
		ll mid=(lb+ub)>>1;
		//printf("lb=%lld,ub=%lld,mid=%lld\n",lb,ub,mid);
		if(mid*mid<=x) lb=mid;
		else ub=mid;
	}
	//puts("gg");
	return lb;
}
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		ll A,B;
		scanf("%lld%lld",&A,&B);
		if(A==1&&B==1)
		{
			puts("0");
			continue;
		}
		if(A>B) swap(A,B);
		if(A==1&&B==2)
		{
			puts("0");
			continue;
		}
		ll ans=A-1;
		ll s=find(A*B-1);
		//printf("ans=%lld,t=%lld\n",ans,t);
		ans+=s; ll t=(A*B-1)/s;
		if(t==A) --ans;
		//printf("ans=%lld,s=%lld,t=%lld\n",ans,s,t);
		ans+=max(0LL,min(s-A,B-t)-(s==t?1:0));
		printf("%lld\n",ans);
	}		
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min(a: &i64, b: &i64) -> i64 {
    if *a <= 0i64 {
        *b
    } else if *b <= 0i64 {
        *a
    } else if *a < *b {
        *a
    } else {
        *b
    }
}

fn max(a: &i64, b: &i64) -> i64 {
    if *a < *b {
        *b
    } else {
        *a
    }
}

fn abs(a: &i64, b: &i64) -> i64 {
    if *a - *b <= 0 {
        *b - *a
    } else {
        *a - *b
    }
}

fn main() {
    input! {
        n: i64
    }
    println!("{}",n*(n+1)/2 - 3*(n/3)*(n/3+1)/2 - 5*(n/5)*(n/5+1)/2 + 15*(n/15)*(n/15+1)/2 );
}


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

using namespace std;

int main(void) {
    long N, ans = 1;
    vector<long> A;

    cin >> N;
    for (int i = 0; i < N; i++) {
        long a;
        cin >> a;
        A.push_back(a);
    }

    int flag = 0;
    for (int i = 0; i < N-1; i++) {
        if (A[i] < A[i+1]) flag |= 1;
        if (A[i] > A[i+1]) flag |= 2;
        if (flag == 3) {
            ans++;
            flag = 0;
        }
    }

    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 1400
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if B[i] >= A[i]:
        ans += A[i]
        B[i] -= A[i]
        if B[i] >= A[i + 1]:
            ans += A[i + 1]
            A[i + 1] = 0
        else:
            ans += B[i]
            A[i + 1] -= B[i]
    else:
        ans += B[i]
        B[i] = 0
print(ans)


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
string S;
vector<string> T{"dream","dreamer","erase","eraser"};

bool dfs(int pos)
{
	if(pos == N) return true;
	bool res = false;
	FOR(i,0,4){
		if(S.substr(pos,T [i].size()) == T [i]){
			res |= dfs(pos + T [i].size());
		}
	}
	return res;
}

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

	cin >> S;
	N = S.size();

	printf("%s\n",dfs(0) ? "YES" : "NO");

	return 0;
}


Measured memory_bytes: 2384
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
m = c.most_common()
judge = 0
ans = 1
if n%2 == 0:
    for i in range(len(m)):
        if m[i][0]%2==0 or m[i][1]!=2 or m[i][0]>n-1:
            judge = 1
    num=n//2
else:
    for i in range(len(m)):
        if (m[i][0]==0 and m[i][1]!=1) or m[i][0]%2==1 or (m[i][1]!=2 and m[i][0]!=0)or m[i][0]>n-1:
            judge = 1
    num=(n-1)//2
if judge ==1:
    print('0')
else:
    for i in range(num):
        ans=ans*2%1000000007
    print(ans)


Measured memory_bytes: 16096
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int H = scanner.nextInt();
		int a[] = new int[N + 1];
		int b[] = new int[N + 1];
		for (int i = 0; i < N; i++) {
			a[i] = scanner.nextInt();
			b[i] = scanner.nextInt();
		}
		scanner.close();
		
		int aMax = 0;
		List<Integer> bOver = new ArrayList<>();
		int turn = 0;
		
		for (int i = 0; i < N; i++) {
			aMax = Math.max(aMax, a[i]);
		}
		
		for (int i = 0; i < N; i++) {
			if (aMax < b[i]) {
				bOver.add(b[i]);
			}
		}
		
		Collections.sort(bOver, Collections.reverseOrder());
		
		for (int i = 0; i < bOver.size(); i++) {
			if (H <= 0) {
				System.out.println(turn);
				return;
			}
			turn++;
			H = H - bOver.get(i).intValue();
		}
		
		while (H > 0) {
			turn++;
			H = H - aMax;
		}
		System.out.println(turn);
		
	}
	
}

Measured memory_bytes: 73456
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);

int main(){
	int n;
	int ans=0;
	cin >>n;
	Vi a(n);
	Vi o, e;
	rep(i,n){
		cin>>a[i];
		if(i%2){
			e.pb(a[i]);
		}else{
			o.pb(a[i]);
		}
	}
	if(n==1){
		cout<<0<<endl;
		return 0;
	}else if(n==2 or n==3){
		sort(all(a));
		if(e[0]==a[1]){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
		return 0;
	}
	sort(all(a));
	sort(all(e));
	repi(i,e){
		clog<<*i<<" ";
	}
	clog<<endl;
	auto ter=e.begin();
	for(int i=0;i<n/2;i++){
		clog<<a[1+i*2]<<endl;
		ter = lower_bound(all(e), a[1+i * 2]);
		if(ter==e.end()){
			ans++;
		}else if(a[1+i * 2] !=( *ter)){
			ans++;
		}
	}
	cout<<ans<<endl;
}
/*
5 4 3 2 1
3 4 5 2 1
3 4 1 2 5
3 2 1 4 5
1 2 3 4 5

2 4 3 1
2 1 3 4

2 3 1
1 3 2 -> 1

6 5 4 3 2 1
6 4 2
5 3 1
1 2 3 4 5 6
2 1 4 3 6 5
4 1 2 5 6 3
4 1 6 5 2 3
6 1 4 5 2 3
6 5 4 1 2 3

1 5 3 4 2 6
1 5 2 4 3 6
1 4 2 5 3 6
1 4 5 2 3 6
1 2 5 4 3 6
11 2 3 4 5
1 6 3 4 5 2
1 4 3 6 5 2
1 4 3 2 5 6
1 2 3 4
*/

Measured memory_bytes: 1276
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 100000 ;
//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

/*void BFS(vvc &g,vvll &cnt,int i,int j,deque<ll> &q){
	ll n = cnt.at(i).at(j) ;
	char c = g.at(i).at(j) ;
	if(g.at(i+1).at(j)=='.'&&cnt.at(i+1).at(j)>n){
		cnt.at(i+1).at(j) = n ;
		q.push_front(j) ; q.push_front(i+1) ;
	}
	if(g.at(i+1).at(j)=='#'&&cnt.at(i+1).at(j)>n+1){
		cnt.at(i+1).at(j) = n+1 ;
		if(c=='#') cnt.at(i+1).at(j) = n ;
		q.push_back(i+1) ; q.push_back(j) ;
	}
	if(g.at(i).at(j+1)=='.'&&cnt.at(i).at(j+1)>n){
		cnt.at(i).at(j+1) = n ;
		q.push_front(j+1) ; q.push_front(i) ;
	}
	if(g.at(i).at(j+1)=='#'&&cnt.at(i).at(j+1)>n+1){
		cnt.at(i).at(j+1) = n+1 ;
		if(c=='#') cnt.at(i+1).at(j) = n ;
		q.push_back(i) ; q.push_back(j+1) ;
	}
	if(q.empty()) return ;
	i = q.front() ; q.pop_front() ;
	j = q.front() ; q.pop_front() ;
	BFS(g,cnt,i,j,q) ;
} */

int main(){
	ll h,w ;
	cin >> h >> w ;
	vvc g(h+2,vc(w+2,'x')) ;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin >> g.at(i).at(j) ;
		}
	}
	vvll cnt(h+2,vll(w+2,INF)) ;
	cnt.at(1).at(1) = (g.at(1).at(1)=='#') ;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i==1&&j==1) continue ;
			ll sub1,sub2 ;
			if(g.at(i).at(j)=='#'&&g.at(i-1).at(j)=='.') sub1 = cnt.at(i-1).at(j)+1 ;
			else sub1 = cnt.at(i-1).at(j) ;
			if(g.at(i).at(j)=='#'&&g.at(i).at(j-1)=='.') sub2 = cnt.at(i).at(j-1)+1 ;
			else sub2 = cnt.at(i).at(j-1) ;
			cnt.at(i).at(j) = min(sub1,sub2) ;
		}
	}
	cout << cnt.at(h).at(w) << endl ;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
char a[100010];
int main()
{
	int n,i;
	while(~scanf("%d",&n))
	{
		scanf("%s",a);
		int p=1;
		for(i=1;i<strlen(a);i++)
			if(a[i]!=a[i-1])p++;
		printf("%d\n",p);
	}
}
 

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int X; cin >> X;
  cout << (30 <= X ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3616
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


bool DEBUG = 0;
#define debug(x) if (DEBUG) {cerr << #x << " = " << x << "\n";}
#define debug_vec(x) if (DEBUG) {cerr << #x << " = {"; for(auto a : x) cerr << a << ","; cerr << "}" << endl;}

//#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m, a[88][88], b[88][88];
bitset <13000> dp[88][88];
main() {
    file("atlarge");
    ios;
    cin >> n >> m;
    fo(i, 1, n, 1) fo(j, 1, m, 1) cin >> a[i][j];
    fo(i, 1, n, 1) fo(j, 1, m, 1) cin >> b[i][j];
    dp[1][1][abs(a[1][1] - b[1][1])] = 1;
    fo(i, 1, n, 1) {
        fo(j, 1, m, 1) {
            if (i == 1 and j == 1) continue;
            int diff = abs(a[i][j] - b[i][j]);
            fo(k, 0, 13000, 1) {
                if (dp[i - 1][j][k] || dp[i][j - 1][k]) {
                    int val = abs(k - diff);
                    dp[i][j][val] = 1;
                    val = k + diff;
                    dp[i][j][val] = 1;
                }
            }
        }
    }
    fo(i, 0, 13000, 1) if (dp[n][m][i]) return !(cout << i);
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**
-2 + 1 + 3
2
*/


Measured memory_bytes: 12288
#include <iostream>

int main() {
  int A, B, C, X;
  std::cin >> A >> B >> C >> X;

  int answer = 0;
  
  for (int a = 0; a <= A; a++) {
    for (int b = 0; b <= B; b++) {
      for (int c = 0; c <= C; c++) {
        answer += (X == 500 * a + 100 * b + 50 * c);
      }
    }
  }

  std::cout << answer << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    cout<<t+s;
    return 0;
}

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

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

	for(i = 0; i < n; i++){
		ans[i] = 0;
	}
	for(i = 0; i < q; i++){
		ans[a[i]-1]++;
	}
	for(i = 0; i < n; i++){
		if(k - q + ans[i] > 0){
			cout << "Yes" << "\n";
		}
		else if(k - q + ans[i] <= 0){
			cout << "No" << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 1408
//
//  main.cpp
//  ABC173C
#include <iostream>
#include <cmath> // powを使う
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using P=pair<int,int>;

int main(int argc, const char * argv[]) {
    int h,w,k;
    cin >>h>>w>>k;
    int c[6][6]={};
    char cs;
    rep(i,h)rep(j,w){
        cin>>cs;
        if(cs=='#'){
            c[i][j]=1;
        }
    }
    int ans=0;
    rep(is,1<<h){
        rep(js,1<<w){
            int count=0;
            rep(i,h) rep(j,w){
                if(is>>i&1) continue;
                if(js>>j&1) continue;
                count+=c[i][j];
            }
            if(count==k) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdio>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<iomanip>
#include<list>
#include<set>
#include<utility>
using namespace std;

//repetition
//------------------------------------------

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
//#define INF (1 << 30)
#define pii pair<int, int>

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, -1, 0, 1, -1, -1, 1, 1};

static const int INF = 1000000010;
int d[510][510];
string s[510];
int l[110];

int main() {
  int n, a, tmp;
  cin >> n;
  int lis[n];
  rep(i,n){
    cin >> lis[i];
  }
  int alice = 0;
  int bob = 0;
  rep(i,n){
    rep(j,n){
      if(lis[i] > lis[j]){
        tmp = lis[i];
        lis[i] = lis[j];
        lis[j] = tmp;
      }
    }
  }
  rep(i,n){
    if((i+1)%2==1){
      alice += lis[i];
    } else {
      bob += lis[i];
    }
  }

  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int compare_ints(const void* a, const void* b)
{
    int arg1 = *(const int*)a;
    int arg2 = *(const int*)b;
 
    if (arg1 < arg2) return -1;
    if (arg1 > arg2) return 1;
    return 0;
}

int	main(void)
{
  	int	n;
  	int	*a;
  	int	num;
  	int	i;
  
  	num = scanf("%d", &n);
  	if (num != 1)
      	return (0);
  
  	a = (int *)malloc(sizeof(int) * n);
  	for (i = 0; i < n; i++)
    {
      	num = scanf("%d", &a[i]);
      	if (num != 1)
          	return (0);
    }
  
  	qsort(a, n, sizeof(int), compare_ints);
  
  	for (i = 0; i < n - 1; i++)
    {
          	if (a[i] == a[i + 1])
            {
              	printf("NO");
          		return (0);
            }
    }
  	printf("YES");
  	return (0);
}

Measured memory_bytes: 1788
n, m = [int(i) for i in input().split()]

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

vector = []
for mi in range(m):
    vector.append(int(input()))

for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)

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

const int maxn = 1e5 + 100;

char str[maxn];
int data[50];

int main()
{
    memset(data, 0, sizeof(data));
    scanf("%s", str);
    int len = strlen(str);
    if(str[0] != str[len - 1])
    {
        if((len - 2) & 1) printf("First\n");
        else printf("Second\n");
    }
    else {
        if(!((len - 2) & 1)) printf("First\n");
        else printf("Second\n");
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
using namespace std;
using ll = long long;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i, h) cin >> c[i];

  int ans = 0;
  rep(ih, 1 << h) rep(jw, 1 << w) {
    int cnt = 0;
    rep(i, h) rep(j, w) {
      if (ih >> i & 1) continue;
      if (jw >> j & 1) continue;
      if (c[i][j] == '#') cnt++;
    }
    if (cnt == k) ans++;
  }

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


Measured memory_bytes: 3572
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	s := strconv.Itoa(n)
	slice := strings.Split(s, "")
	len := len(slice)
	for i := 0; i < len; i++ {
		if slice[i] == "7" {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

int main() {
    vector<int> dp(31, 0);
    dp[0] = 1;
    for (int i = 1; i <= 30; i++) {
        dp[i] = dp[i - 1];
        if (i >= 2) dp[i] += dp[i - 2];
        if (i >= 3) dp[i] += dp[i - 3];
    }
    int N;
    while (cin >> N, N) {
        cout << ((dp[N] + 10 - 1) / 10 + 365 - 1) / 365 << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    ll ans;
    if(A%2 == 0 || B%2 == 0 || C%2 == 0) ans=0;
    else{
        int m = max(A,max(B,C));
        if(m == A) ans = B*C;
        else if(m == B) ans = A*C;
        else ans = A*B;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

N,Y = map(int,input().split())

cnt = [0,0,0]
money = [1,5,10]

Y = Y // 1000

for i in range(N+1):
    for j in range(N+1):
        k = N - i - j
        if k < 0: continue
        if (10 * i + 5 * j + k) == Y:
            print(i,j,k)
            sys.exit()
        
print(-1,-1,-1)

Measured memory_bytes: 3064