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

int main() {
    int a, b;
    cin >> a >> b;
    int sum_of_palindrome = 0;
    for (int i=a; i<=b; ++i){
        int i1 = i%10, i5 = i/10000%10;
        int i2 = i/10%10, i4 = i/1000%10;
        if(i1==i5 && i2==i4) sum_of_palindrome++;
    }
    cout << sum_of_palindrome << endl;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int a, b, c, x, y;
  scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

  if (x > y) {
    swap(a, b);
    swap(x, y);
  }

  LL ans = 0;
  ans += x * min(a + b, 2 * c);
  ans += (y - x) * min(b, 2 * c);

  cout << ans << endl;
}


Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int n; cin >> n;
        vll a(n), b(n), c(n),d(n);
        rep(i,n)cin >> a[i], c[i] = a[i];
        rep(i,n)cin >> b[i];
        sort(all(a));
        ll acnt = 0;
        ll bcnt = 0;
        ll cnt = 0;
        do{
            if(a==c){
                acnt = cnt;
            }
            if(a==b){
                bcnt = cnt;
            }
            cnt++;
        }while(next_permutation(all(a)));
        cout<<abs(acnt-bcnt)<<endl;

return 0;
}




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

class Dice {
	array<int, 6> m_faces;

public:
	Dice():
		m_faces( { 1,2,3,4,5,6 } )
	{}

	explicit Dice( const array<int, 6>& f ):
		m_faces( f )
	{}

	int top() const { return m_faces.at( 0 ); }
	int front() const { return m_faces.at( 1 ); }
	int right() const { return m_faces.at( 2 ); }
	int left() const { return m_faces.at( 3 ); }
	int back() const { return m_faces.at( 4 ); }
	int bottom() const { return m_faces.at( 5 ); }

	void roll( char dir ) {
		if( dir == 'N' ) {
			swapFace( 1, 5, 2, 3, 0, 4 );
		}
		else if( dir == 'S' ) {
			swapFace( 4, 0, 2, 3, 5, 1 );
		}
		else if( dir == 'W' ) {
			swapFace( 2, 1, 5, 0, 4, 3 );
		}
		else if( dir == 'E' ) {
			swapFace( 3, 1, 0, 5, 4, 2 );
		}
	}

	void swapFace( int i0, int i1, int i2, int i3, int i4, int i5 ) {
		array<int, 6> f = m_faces;

		m_faces.at( 0 ) = f.at( i0 );
		m_faces.at( 1 ) = f.at( i1 );
		m_faces.at( 2 ) = f.at( i2 );
		m_faces.at( 3 ) = f.at( i3 );
		m_faces.at( 4 ) = f.at( i4 );
		m_faces.at( 5 ) = f.at( i5 );
	}

	bool same( const Dice& d2 ) const {
		Dice d1 = *this;

		for( int i = 0; i < 4; ++i ) {
			for( int j = 0; j < 4; ++j ) {
				for( int k = 0; k < 4; ++k ) {
					if( d1.m_faces == d2.m_faces ) {
						return true;
					}
					d1.roll( 'N' );
				}
				d1.roll( 'W' );
			}
			d1.roll( 'N' );
		}

		return false;
	}
};

int main() {
	Dice d1, d2;

	array<int, 6> f;
	for( auto& v: f ) { cin >> v; }
	d1 = Dice( f );
	for( auto& v: f ) { cin >> v; }
	d2 = Dice( f );

	cout << (d1.same( d2 ) ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3112
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int K;
	cin >> K;
	queue<ll>q;
	for (int i = 1; i <= 9; i++)q.push(i);

	for (int i = 0; i < K-1; i++) {
		ll cur = q.front();
		ll btm = cur % 10;
		q.pop();
		if(btm != 0)q.push(10 * cur + (btm-1));
		q.push(10 * cur + btm);
		if(btm != 9)q.push(10 * cur + (btm+1));
	}
	puts(q.front());
	

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string a,b;
    cin>>a>>b;
    vs vec;
    int n=a.size();
    int m=b.size();
    REP(i,n-m+1){
        bool f=true;
        REP(j,m){
            if(a[i+j]!=b[j]&&a[i+j]!='?'){
                f=false;
                break;
            }
        }
        if(f){
            string temp=a;
            REP(j,m){
                temp[i+j]=b[j];
            }
            REP(j,n){
                if(temp[j]=='?'){
                    temp[j]='a';
                }
            }
            vec.pb(temp);
        }
    }
    if(!vec.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    sort(all(vec));
    cout<<vec[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n,k; R(n,k);
    string s;
    R(s);
    s[k-1]+='a'-'A';
    W(s);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
        int n,a,b;
        scanf("%d %d %d", &n,&a,&b);
        int m = a<b ? b : a;
        int l = a<b ? a : b;
 
        if((m-l)%2==0) printf("Alice\n");
        else printf("Borys\n");
        return 0;
 
}

Measured memory_bytes: 128
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        d: usize,
        x: usize,
        a_s: [usize; n],
    }
    let eat = a_s.iter().fold(0, |sum, a| {
        sum + {
            let mut count = 0;
            for i in 0..101 {
                if a * i + 1 <= d {
                    count += 1;
                }
            }
            count
        }
    });
    let ans = x + eat;
    println!("{}", ans);
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for(int i=0; i<10; i++){
        ans = i*100+i*10+i;
        if(ans>=N){
            cout << ans << endl;
            break;
        }
    }
    return 0;
}

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

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

    double k = 0.5 * (a + b);
    long long ans = k;

    bool check = (ans==k) ? true : false;

    if(check)
        cout << ans << endl;
    else
        cout << "IMPOSSIBLE" << endl;    

    return 0;
}

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

typedef long long ll;



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

ll h,w;
char a[10][10];


void dfs(int x,int y){
  a[x][y]='.';
  for(int i=0;i<2;i++){
    if(a[x+dx[i]][y+dy[i]]=='#'){
      dfs(x+dx[i],y+dy[i]);
      return;
    }

  }

}
int main(){

  cin>>h>>w;

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }


  dfs(0,0);

  bool flag=true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#')flag=false;
    }
  }
  if(flag)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;

  // for(int i=0;i<h;i++){
  //   for(int j=0;j<w;j++){
  //     cout<<a[i][j];
  //   }
  //   cout<<endl;
  // }

  return 0;
}


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

#define MAX_LEN (2 * 100000 + 1)

using namespace std;

long Max = 0;
long Now = 0;

long count(char *str, long len)
{      
    long i;
    long count_D = 0;
    long count_PD = 0;
    for (i = 0; i < len - 1; i++) {
        if (str[i] == 'D') count_D++;
        if (str[i] == 'P' && str[i + 1] == 'D') count_PD++;
    }
    if (str[len - 1] == 'D') count_D++;

    return count_D + count_PD;
}


int main()
{
    char str[MAX_LEN];
    cin >> str;

    long len = strlen(str);

    long i;
    for (i = 0; i < len; i++) {
        if (str[i] == '?') {
            str[i] = 'D';
        }
    }

    cout << str;
    
    return 0;
}

Measured memory_bytes: 3788
[N, M] = list(map(int, input().split()))
[s, e] = [ [], [] ]
for _ in range(M):
  input_line = list(map(int, input().split()))
  s.append(input_line[0])
  e.append(input_line[1])
bucket = {}
for i in range(1, N+1):
  bucket[i] = []

for i in range(M):
  if s[i] in bucket and e[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]].append(e[i])
  elif s[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]] = [e[i]]
  elif e[i] in bucket:
    bucket[s[i]] = [s[i]]
    bucket[e[i]].append(e[i])
  else:
    bucket[s[i]] = [s[i]]
    bucket[e[i]] = [e[i]]

for i in range(1, N+1):
  print(len(bucket[i]))

Measured memory_bytes: 3064
A, B, C, D, E, F = map(int, input().split())
# 100(Ax + By) + Cz + Dw <= F
# 100(Cz + Dw) / (100(Ax + By) + Cz + Dw) <= E
SD = {}
WD = {}
MS = (E * F) // (100 + E)
for i in range(MS // C + 1):
  for j in range((MS - i * C) // D + 1):
    SD[i*C+j*D] = 1
Sup = F // (100 * A)
wans, sans = 0, 0
for i in range(Sup+1):
  SUp = (F - 100 * A * i) // (100 * B)
  for j in range(SUp+1):
    W = 100 * (A * i + B * j)
    if i != 0 or j != 0:
      for S in SD:
        if W + S <= F and 100 * S <= W * E:
          if wans == 0 and sans == 0:
            wans, sans = W + S, S
          else:
            if sans * (S + W) < S * wans:
              wans, sans = W + S, S
print(wans, sans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
int main()
{
    using namespace std;
    int D, N;
    cin >> D >> N;
    int sum = static_cast<int>(pow(100, D)), result(sum);
    for (int i = 1; i < N; i++)
    {
        result += sum;
        if ((result / sum) % 100 == 0)
        {
            result += sum;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <map>
using namespace std;

int main()
{
	long long H, W;
	cin >> H >> W;
	if (H % 3 == 0 || W % 3 == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		//try1 H/3
		long long firstcut_H = H / 3;
		long long residue_H = H - H / 3;
		long long area1 = firstcut_H * W;
		long long area2, area3;
		if (residue_H * W % 2 == 0)
		{
			area2 = residue_H * W / 2;
			area3 = area2;
		}
		else
		{
			if (residue_H >= W)
			{
				area2 = (residue_H / 2) * W;
				area3 = (residue_H - residue_H / 2) * W;
			}
			else
			{
				area2 = residue_H  * (W/2);
				area3 = residue_H * (W - W / 2);
			}
		}
		long long minimumoutput1 = max(area1, max(area2, area3)) - min(area1, min(area2, area3));
		
		//try2 H/3+1で切る
		firstcut_H = H / 3 + 1;
		residue_H = H - firstcut_H;
		area1 = firstcut_H * W;
		if (residue_H * W % 2 == 0)
		{
			area2 = residue_H * W / 2;
			area3 = area2;
		}
		else
		{
			if (residue_H >= W)
			{
				area2 = (residue_H / 2) * W;
				area3 = (residue_H - residue_H / 2) * W;
			}
			else
			{
				area2 = residue_H * (W/2);
				area3 = residue_H * (W - W / 2);
			}
		}
		long long minimumoutput2 = max(area1, max(area2, area3)) - min(area1, min(area2, area3));

		//try3 W/3で切る
		long long firstcut_W = W / 3;
		long long residue_W = W - W / 3;
		area1 = firstcut_W * H;
		if (residue_W * H % 2 == 0)
		{
			area2 = residue_W * H / 2;
			area3 = area2;
		}
		else
		{
			if (residue_W >= H)
			{
				area2 = (residue_W/2) * H;
				area3 = (residue_W - residue_W / 2) *H;
			}
			else
			{
				area2 = (H / 2)*residue_W;
				area3 = (H - H / 2)*residue_W;
			}
		}
		long long minimumoutput3 = max(area1, max(area2, area3)) - min(area1, min(area2, area3));
		//try4
		firstcut_W = W / 3 + 1;
		residue_W = W - firstcut_W;
		area1 = firstcut_W * H;
		if (residue_W * H % 2 == 0)
		{
			area2 = residue_W * H / 2;
			area3 = area2;
		}
		else
		{
			if (residue_W >= H)
			{
				area2 = (residue_W / 2) * H;
				area3 = (residue_W - residue_W / 2) *H;
			}
			else
			{
				area2 = (H / 2)*residue_W;
				area3 = (H - H / 2)*residue_W;
			}
		}
		long long minimumoutput4 = max(area1, max(area2, area3)) - min(area1, min(area2, area3));
		
		long long output = min(min(minimumoutput1, minimumoutput2), min(minimumoutput3, minimumoutput4));
		cout << output << endl;
	}


	return 0;
}


Measured memory_bytes: 256
s = input()
c = []
cnt = 0

for i, e in enumerate(s):
    if e == "A" or e == "C" or e == "G" or e == "T":
        cnt += 1
    else:
        c.append(cnt)
        cnt = 0
if s[-1] == "A" or s[-1] == "C" or s[-1] == "G" or s[-1] == "T":
    c.append(cnt)
print(max(c))


Measured memory_bytes: 3060
x, y = map(int, input().split())

lst1 = [1, 3, 5, 7, 8, 10, 12]
lst2 = [4, 6, 9, 11]

if x in lst1 and y in lst1:
    print ('Yes')
    exit()
if x in lst2 and y in lst2:
    print ('Yes')
    exit()

print ('No')

Measured memory_bytes: 3060
ary = gets.split(" ").map {|i| i.to_i}
A = ary[0]
B = ary[1]
K = ary[2]

if K < A
  A -= K
else
  K -= A
  A = 0
  if K < B
    B -= K
  else
    B = 0
  end
end

puts "#{A} #{B}"

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if (U == S){
    A -= 1;
  }
  else if (U == T){
  	B -= 1;
  }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


#define int long long
vector<pair<int, int>> vertexs[300];
int dp[300][300];
void solve() {
    while (true) {
        int n, m, c;
        cin >> n >> m >> c;
        if (n == 0) return;
        REP(i, n+1) {
            vertexs[i].clear();
            REP(q, n+1) {
                dp[i][q] = 1e9;
            }
        }
        REP(i, m) {
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            vertexs[a].push_back(mp(b, c));
            //vertexs[b].push_back(mp(a, c));
        }
        priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> next;
        next.push(make_tuple(0, 0, 0));
        dp[0][0] = 0;
        while (next.empty() == false) {
            tuple<int, int, int> now = next.top();
            next.pop();
            if (get<2>(now) > n) continue;
            if (dp[get<1>(now)][get<2>(now)] != get<0>(now)) continue;
            for (auto x : vertexs[get<1>(now)]) {
                if (dp[x.first][get<2>(now)] > x.second + get<0>(now)) {
                    dp[x.first][get<2>(now)] = x.second + get<0>(now);
                    next.push(make_tuple(x.second + get<0>(now), x.first, get<2>(now)));
                }
                if (dp[x.first][get<2>(now) + 1] > get<0>(now)) {
                    dp[x.first][get<2>(now) + 1] = get<0>(now);
                    next.push(make_tuple(get<0>(now), x.first, get<2>(now) + 1));
                }
            }
        }
        for (int q = 0;; ++q) {
            if (dp[n - 1][q] <= c) {
                cout << q << endl;
                break;
            }
        }
    }
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 3760
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
public static void Ans() {

			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S= inputArray[0].Select(x=>x).ToArray();
			var T = retreiveStringArray()[0].Select(x => x).ToArray(); ;

			var N = S.Length - T.Length;

			var min = int.MaxValue;
			for (int i = 0; i <= N; i++) {

				var count = 0;
				for (int k = 0; k < T.Length; k++) {
					if (T[k]!=S[i+k]) {
						count++;
					}
				}
				min = Math.Min(min, count);

			}


			//答えの出力
			var ans = min;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


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


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 1000; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    priority_queue<int> que1, que2, que3, que4, que5, que6, que7, que8;
    rep(i,N){
        int a, b, c;
        cin >> a >> b >> c;
        que1.push(a+b+c);
        que2.push(a+b-c);
        que3.push(a-b+c);
        que4.push(a-b-c);
        que5.push(-a+b+c);
        que6.push(-a+b-c);
        que7.push(-a-b+c);
        que8.push(-a-b-c);
    }
    int c1{}, c2{}, c3{}, c4{}, c5{}, c6{},c7{},c8{};
    rep(i,M){
        c1 += que1.top();
        que1.pop();
        c2 += que2.top();
        que2.pop();
        c3 += que3.top();
        que3.pop();
        c4 += que4.top();
        que4.pop();
        c5 += que5.top();
        que5.pop();
        c6 += que6.top();
        que6.pop();
        c7 += que7.top();
        que7.pop();
        c8 += que8.top();
        que8.pop();
    }
    cout << max({c1,c2,c3,c4,c5,c6,c7,c8}) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n,m;
    cin>>n>>m;
    if(m==n)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace tubosuu.cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            decimal a = ab[0];
            decimal b = ab[1];
            Console.WriteLine(a * b / 3.305785m);
        }
    }
}

Measured memory_bytes: 9752
import java.util.*;
public class Main {

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

		while(true) {
			int W=in.nextInt(),H=in.nextInt(),n=in.nextInt(),m=in.nextInt();
			if(m==0)break;
			List<List<Integer>> kami=new ArrayList<>();

			for(int i=0;i<H;i++) {
				List<Integer> ls=new ArrayList<>();
				for(int j=0;j<W;j++) {
					ls.add(1);
				}
				kami.add(ls);
			}

			for(int i=0;i<n;i++) {
				int d=in.nextInt(),c=in.nextInt();

				if(d==1) {
					if(c*2>kami.get(0).size()) {
//						System.out.println("escape Overflow X");
						c=kami.get(0).size()-c;
						for(int p=0;p<kami.size();p++) {
							Collections.reverse(kami.get(p));
						}
					}


					for(int p=0;p<kami.size();p++) {
						for(int q=0;q<c;q++) {
							int a=kami.get(p).get(c+q),b=kami.get(p).get(c-1-q);
							kami.get(p).set(c+q, a+b);
						}

						for(int q=0;q<c;q++)kami.get(p).remove(0);
					}
				}
				else {
					if(c*2>kami.size()) {
//						System.out.println("escape Overflow Y");
						c=kami.size()-c;
						Collections.reverse(kami);
					}

					for(int p=0;p<c;p++) {
						for(int q=0;q<kami.get(0).size();q++) {
							int a=kami.get(kami.size()-1-c-p).get(q),
									b=kami.get(kami.size()-c+p).get(q);
							kami.get(kami.size()-1-c-p).set(q, a+b);
						}
					}
					for(int p=0;p<c;p++)kami.remove(kami.size()-1);
				}
				/*System.out.println();
				for(int k=0;k<kami.size();k++) {
					for(int l=0;l<kami.get(k).size();l++) {
						System.out.print(kami.get(k).get(l)+" ");
					}
					System.out.println();
				}*/
			}

			for(int i=0;i<m;i++) {
				int x=in.nextInt(),y=in.nextInt();
				System.out.println(kami.get(kami.size()-1-y).get(x));
			}
			/*System.out.println();
			for(int i=0;i<kami.size();i++) {
				for(int j=0;j<kami.get(i).size();j++) {
					System.out.print(kami.get(i).get(j)+" ");
				}
				System.out.println();
			}*/
		}
		/*System.out.println();
		for(int i=0;i<kami.size();i++) {
			for(int j=0;j<kami.get(i).size();j++) {
				System.out.print(kami.get(i).get(j)+" ");
			}
			System.out.println();
		}*/
	}

}



Measured memory_bytes: 43904
#include<iostream>
#include<string.h>
using namespace std;
#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)
long long mp[20][20],mat[20][20];
int main() {
  int n,gx,gy,p,px,py,qx,qy,i,j;
  cin>>n;
  while(n--) {
    memset(mp, 0, sizeof(mp));
    memset(mat, 0, sizeof(mat));
    cin>>gx>>gy>>p;
    rep(i,p) {
      cin>>qx>>qy>>px>>py;
      if(qx == px) mat[qx][min(qy,py)] += 2;
      else mat[min(qx,px)][qy] += 1;
    }

    **mp = 1;
    rep(i,gy+1) {
      rep(j,gx+1) {
	if(i == 0) {
	  if(j > 0 && mat[j-1][i]%2 == 0) mp[j][i] += mp[j-1][i];
	} else if(j == 0) {
	  if(mat[j][i-1]/2 == 0) mp[j][i] += mp[j][i-1];
	} else {
	  if(mat[j][i-1]/2 == 0) mp[j][i] += mp[j][i-1];
	  if(mat[j-1][i]%2 == 0) mp[j][i] += mp[j-1][i];
	}
      }
    }

    if(mp[gx][gy] == 0)
      cout<<"Miserable Hokusai!"<<endl;
    else
      cout<<mp[gx][gy]<<endl;
  }
}

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

int main(){

  int A, B, C, X, ans=0;
  cin >> A >> B >> C;
  cin >> X;

  for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
      for(int k=0; k<=C; k++){
        if(X - i*500 - j*100 - k*50 == 0) ans++;
      }
    }
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int k,s;
  cin>>k>>s;
  ll ans=0;
  rep(i,k+1)rep(j,k+1)
    if(i+j+k>=s && i+j<=s)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 384
//==========//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {

ll n;
cin>>n;
ll ans=0;
ll sum=0;
for (int i = 1; i <=n; ++ i)
ans+=i;

for (int i = 1;  i<= n; ++i)
{
if(i%3==0||i%5==0)
	sum+=i;
}
cout<<ans-sum<<endl;
return 0;
}







Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, L;
	cin >> N >> L;
	//vector<int> apple(N);
	int pie = 0;

	//for (int i = 0; i < N; i++) {
		//apple[i] = L + i;
	//}

	for (int i = 0; i < N; i++) {
		pie = pie + L + i;
	}

	if (L < 0) {
		if (N + L <= 0) {
			cout << pie - (L + N - 1) << endl;
		}
		else {
			cout << pie << endl;
		}
	}
	else {
		cout << pie - L << endl;
	}
	return 0;
}

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    int64_t money = 1000;
    for (int64_t i = 1; i < N; i++) {
        int64_t pre_max_num = money / A[i - 1];
        int64_t price = pre_max_num * A[i - 1];
        int64_t change = (money - price) + pre_max_num * A[i];

        money = max(money, change);
    }

    cout << money << endl;
}

Measured memory_bytes: 3624
#import numpy as np

n = int(input())
a_s = list(map(int, input().split()))

m = 0
ans = [0]*(n+1)
#ans = np.zeros(n+1).astype(int)


i=1
for i in range(n,0,-1):
    sum_num = 0
    for j in range(i,n+1,i):
        sum_num += ans[j]

    if((sum_num & 1) != a_s[i-1]):
        m += 1
        ans[i] = 1

ans2 = []
for i in range(1,n+1):
    if ans[i]==1:
        ans2.append(i)

print(m)
print(' '.join(map(str,ans2)))


Measured memory_bytes: 19772
#include <bits/stdc++.h>
using namespace std;
#define FASTIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define MOD 1000000007
int main()
{
    int n,x;
    cin>>n;
    n = (1<<n);
    multiset<int>arr;
    for(int i=0; i<n; i++) cin>>x,arr.insert(x);
    multiset<int>done,temp;
    done.insert(*arr.rbegin());
    arr.erase(arr.find(*arr.rbegin()));

    for(int i=1; i<n; i=i<<1)
    {
        for(auto it=done.begin(); it!=done.end(); it++)
        {
            auto bt = arr.lower_bound(*it);
            if(bt == arr.begin())
            {
                cout<<"No";
                exit(0);
            }

            bt--;
            temp.insert(*bt);
            arr.erase(bt);
        }
        for(auto x:temp) done.insert(x);
        temp.clear();
    }
    cout<<"Yes";
}

Measured memory_bytes: 18688
H,W = map(int,input().split())
g = [input() for i in range(H)]
 
c = [[0 for w in range(W)] for h in range(H)]
 
hs = [0 for i in range(W)]
 
for h in range(H):
    ws = 0
    for w in range(W):
        if g[h][w] == '#':
            for i in range(ws,w):
                c[h][i] += w-ws-1
            ws = w+1
            for j in range(hs[w],h):
                c[j][w] += h-hs[w]
            hs[w] = h+1
    w2 = w+1
    for i in range(ws,w2):
        c[h][i] += w2-ws-1
h2 = h+1
for w in range(W):
    for j in range(hs[w],h2):
        c[j][w] += h2-hs[w]
 
#print(c)
 
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,c[h][w])
 
print(ans)
'''
横方向と縦方向に分けてプログラムを作成してまとめた
横方向
for h in range(H):
    ws = 0
    for w in range(W):
        if g[h][w] == '#':
            for i in range(ws,w):
                c[h][i] += w-ws-1
            ws = w+1
    w2 = w+1
    for i in range(ws,w2):
        c[h][i] += w2-ws-1
 
縦方向
hs = [0 for i in range(W)]
for h in range(H):
    for w in range(W):
        if g[h][w] == '#':
            for j in range(hs[w],h):
                c[j][w] += h-hs[w]
            hs[w] = h+1
h2 = h+1
for w in range(W):
    for j in range(hs[w],h2):
        c[j][w] += h2-hs[w]
'''

Measured memory_bytes: 103384
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import numpy as np

d = ni()
c = na()
s = []

for i in range(d):
    ss = na()
    s.append(ss)

c = np.array(c) # 満足度の下がりやすさ
s = np.array(s) # i日目jコン
s_t = s.T # iコンj日目
last = np.zeros(26)

# 評価関数
# 得になった分+その日の満足度
# n: 日数, 
def eva(n, cc, ss):
    return (d-n)*cc + 50*ss

score = 0

for i in range(d): # i日目(0-indexed)
    last += 1 # 一日分追加
    tow = c * last # 満足下がる値 
    sc = -100000
    M = -1
    for j in range(26):
        k = eva(i, tow[j], s[i][j])
        if sc < k:
            sc = k
            M = j
    last[M] = 0
    score -= np.dot(c,last)
    score += s[i][M]
    print(M+1)

Measured memory_bytes: 27548
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);

      String sb1 = sc.next();
      String sb2 = sc.next();
      int a = 0;
      
            for(int i = 0;i<3;i++){
          if(String.valueOf(sb1.charAt(i)).equals(String.valueOf(sb2.charAt(i)))){
              a++;
          }
      }
        System.out.println(a);
    }
}


Measured memory_bytes: 21972
program bt;

var s:ansistring;
    t,i:longint;
 
begin
   readln(s);
   t:=0;
   for i:=1 to length(s) do t:=t+(ord(s[i])-48);
   if (t mod 9=0) then write('Yes') else write('No');
   readln;
end.
       
       

Measured memory_bytes: 1384
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N, C;  cin >> N >> C;
	vector<vector<int>> D(C, vector<int>(C));
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}
	/*
	for (int k = 0; k < C; k++) {
		for (int i = 0; i < C; i++) {
			for (int j = 0; j < C; j++) {
				D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}
	*/
	//vector<vector<int>> c(N, vector<int>(N));
	vector<vector<ll>> cnt(3, vector<ll>(C));
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			int c; cin >> c;
			cnt[(i + j) % 3][c - 1]++;
		}
	}
	ll ans = 1e15;
	//cost[remaider][color]=cost
	vector<vector<ll>> cost(3, vector<ll>(C));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				cost[i][j] += cnt[i][k] * D[k][j];
			}
		}
	}
	
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				if (i == j || j == k || k == i) continue;
				ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k]);
				//printf("i=%d j=%d k=%d ans=%lld\n", i, j, k, ans);
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	string st;
	cin >> st;
	int n = 0;
	int w = 0;
	int s = 0;
	int e = 0;
	for (int i = 0; i < st.size(); i++) {
		if (st[i] == 'N') {
			n = 1;
		}
		if (st[i] == 'W') {
			w = 1;
		}
		if (st[i] == 'S') {
			s = 1;
		}
		if (st[i] == 'E') {
			e = 1;
		}
	}
	if (e - w == 0 && s - n == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
import numpy as np
N, M = map(int,input().split())
S = np.empty((N,2))
sum_buy = 0
sum_money = 0

for i in range(N):
    A, B = map(int,input().split())
    S[i,0] = A
    S[i,1] = B

S = S[S[:,0].argsort(),:]

j = 0

while True:
    if sum_buy + S[j,1] < M:
        sum_buy += S[j,1]
        sum_money += S[j,1] * S[j,0]
        j += 1
    else:
        break

sum_money = sum_money + (M - sum_buy) * S[j,0]

print(int(sum_money))

Measured memory_bytes: 16344
#include<bits/stdc++.h>
using namespace std;
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();


int main () { _read(); 

      int x;
      cin >> x;
      cout << !x << '\n';
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define printA(arr) for(int i = 0; i < SZ(arr); i++){cout << arr[i];if (i==SZ(arr)-1){cout<<endl;}else{cout << " ";}}
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vector<int> a;

  REP(i,N){
    int num;
    cin >> num;
    a.push_back(num);
  }

  int cnt = 0;
  // iより左はソート済み．
  // i+1より左を隣同士で入れ替えていく．
  for(int i=0;i<N;i++){
    for(int j=i-1;j>=0;j--){
      if (a[j]>a[j+1]){
        int tmp = a[j+1];
        a[j+1] = a[j];
        a[j] = tmp;
        cnt++;
      }
    }
  }
  printA(a);
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3144
H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    ans = min(H, W)
    for h in range(1, H):
        y = (H - h) * W
        x = h * (W // 2)
        z = h * W - x
        ans = min(ans, max(x, y, z) - min(x, y, z))
    t = H
    H = W
    W = t
    for h in range(1, H):
        y = (H - h) * W
        x = h * (W // 2)
        z = h * W - x
        ans = min(ans, max(x, y, z) - min(x, y, z))
    print(ans)


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

int N,M;
int A[301][301];

int main(){
	cin >> N >> M;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++){
			cin >> A[i][j];
		}
	}
	int ans = 1e9;
	int count = M;
	while(count>0){
		vector<int> v(M+1,0);
		for(int i=1;i<=N;i++){
			int j = 1;
			while(1){//iが参加する競技は？
				if(A[i][j]!=0){
					v[A[i][j]]++;
//					cout << A[i][j] << endl; 
					break;
				}
				j++;
			}
		}
		vector<int>::iterator maxit = max_element(v.begin(),v.end());
		int max_id = maxit - v.begin();
		ans = min(ans,*maxit);
//		cout << ans << " " << max_id << endl;
		for(int i=1;i<=N;i++){
			for(int j=1;j<=M;j++){
				if(A[i][j] == max_id) A[i][j] = 0;
			}
		}
		count--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

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

    int a[n] = {};
    int zero = 0;
    int one = 0;
    rep(i,n){
        scanf("%d",&a[i]);
        a[i] = a[i]%2;
        if(a[i]){
            one++;
        }else{
            zero++;
        }
    }


    ll ans = 0;

    if(p){
        if(one==0){
            cout << ans << endl;
            return 0;
        }
        ans = pow(2,zero);
        ans *= pow(2,one);
        ans = ans / 2;
    }else{
        if(n==1&&one==1){
            ans = 1;
           cout << ans << endl;
            return 0; 
        }
        ans = pow(2,zero);
        ans *= pow(2,one);
        if(one>0){
            ans = ans / 2;
        }
    }
    
    cout << ans << endl;
    return 0;
}
 
 


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    ll ans = 0;
    int id = 0;
    vll l(1, 0);
    for(int i = 0; i < N; i++) {
        if(S[i] == '0') {
            if(K == 0) {
                id++;
            } else {
                K--;
            }
        } else if(i > 0) {
            l.push_back(i);
        }
        // debug(id);
        // debug(l[id]);
        int j = i;
        while(S[i] == S[j])
            j++;
        // debug(j);
        ans = max(ans, j - l[id]);
        i = j - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1020