akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#define SIZE 200005
#define INF 100000000000000000LL
#define MOD 1000000007
 
using namespace std;
typedef long long int ll;
typedef pair <ll,int> P;
 
struct edge
{
	int to,cost;
	edge(int to=0,int cost=0):to(to),cost(cost){}
};
vector <edge> vec[SIZE];
ll dist[SIZE];
ll ds[SIZE],dt[SIZE];
ll ws[SIZE],wt[SIZE];
ll way[SIZE];
int U[SIZE],V[SIZE];
ll L[SIZE];
int n,m;
 
void dijkstra(int v)
{
	for(int i=0;i<n;i++) dist[i]=INF;
	dist[v]=0;
	way[v]=1;
	priority_queue <P,vector <P>,greater <P> > que;
	que.push(P(0,v));
	while(!que.empty())
	{
		P p=que.top();que.pop();
		int u=p.second;
		if(dist[u]<p.first) continue;
		for(int i=0;i<vec[u].size();i++)
		{
			edge e=vec[u][i];
			if(dist[e.to]>dist[u]+e.cost)
			{
				dist[e.to]=dist[u]+e.cost;
				que.push(P(dist[e.to],e.to));
				way[e.to]=way[u];
			}
			else if(dist[e.to]==dist[u]+e.cost)
			{
				way[e.to]+=way[u];
				if(way[e.to]>=MOD) way[e.to]-=MOD;
			}
		}
	}
}
int main()
{
	scanf("%d %d",&n,&m);
	int s,t;
	scanf("%d %d",&s,&t);s--,t--;
	for(int i=0;i<m;i++)
	{
		int u,v,d;
		scanf("%d %d %d",&u,&v,&d);u--,v--;
		vec[u].push_back(edge(v,d));
		vec[v].push_back(edge(u,d));
		U[i]=u,V[i]=v;
		L[i]=d;
	}
	dijkstra(s);
	for(int i=0;i<n;i++) ds[i]=dist[i];
	for(int i=0;i<n;i++) ws[i]=way[i];
	dijkstra(t);
	for(int i=0;i<n;i++) dt[i]=dist[i];
	for(int i=0;i<n;i++) wt[i]=way[i];
	ll ret=ws[t]*ws[t]%MOD;
	ll mn=ds[t];
	for(int i=0;i<n;i++)
	{
		if(mn==ds[i]+dt[i]&&ds[i]==dt[i])
		{
			ret-=(ws[i]*ws[i]%MOD)*(wt[i]*wt[i]%MOD)%MOD;
			if(ret<0) ret+=MOD;
		}
	}
	//printf("%lld : %lld\n",mn,ret);
	for(int i=0;i<m;i++)
	{
		int u=U[i],v=V[i];
		if(ds[u]>ds[v]) swap(u,v);//ds[u]<ds[v]
		if(ds[u]+L[i]+dt[v]==mn)
		{
			ll a=ds[u],b=ds[u]+L[i];
			ll c=dt[v],d=dt[v]+L[i];
			if(max(a,c)<min(b,d))
			{
				ret-=(ws[u]*ws[u]%MOD)*(wt[v]*wt[v]%MOD)%MOD;
				if(ret<0) ret+=MOD;
			}
		}
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 23284
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1000000;
struct D{
	int tID;
	int p[10];	//the number of incorrect problems
	int c;		//the number of correct problems
	int x;		//penalty points
};

bool rank( const D &a, const D &b ){
	if( a.c == b.c ){
		return a.x == b.x ? a.tID < b.tID : a.x < b.x;
	}else{
		return a.c > b.c;
	}
}

int main(){
	int T, P, R;
	while( cin >> T >> P >> R && T ){
		vector< D > data(T);
		for( int i = 0; i < T; i++ ){
			data[i].tID = i + 1;
		}
		for( int i = 0; i < R; i++ ){
			int tID, pID, t;
			string m;
			cin >> tID >> pID >> t >> m;
			if( m == "CORRECT" ){
				if( data[tID-1].p[pID-1] != inf ){
					data[tID-1].c++;
					data[tID-1].x += t + data[tID-1].p[pID-1] * 1200;
					data[tID-1].p[pID-1] = inf;
				}
			}else{
				data[tID-1].p[pID-1]++;
			}
		}
		sort( data.begin(), data.end(), rank );
		for( int i = 0; i < T; i++ ){
			cout << data[i].tID << " " << data[i].c << " " << data[i].x << endl;
		}
	}
}

Measured memory_bytes: 1244
/* competitive programming circle traP */
/* template */
#include <stdio.h>

int main(){
  while(true){
    int n;
    scanf("%d",&n);
    if(n==0)break;
    int a[50];
    for(int i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    int begin = a[0];
    int cur = a[0];
    for(int i=1;i<n;i++){
      if(a[i] == cur+1){
        cur ++;
      }else{
        if(begin == cur){
          printf("%d ",begin);
        }else{
          printf("%d-%d ",begin,cur);
        }
        begin = cur = a[i];
      }
    }
    if(begin == cur){
      printf("%d\n",begin);
    }else{
      printf("%d-%d\n",begin,cur);
    }
  }
  return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
string s; cin>>s;
int co = 1;
int best = 0;
for(int i = 0; i+1 < s.size(); i++){
if(s[i] == s[i+1]) co++;
else {
best = max(co,best); 
co = 1;
}
}
best = max(co,best);
if(best >= 3) cout<<"Yes"<<"\n";
else cout<<"No"<<"\n";
}

Measured memory_bytes: 256
A,B,C,D = gets.chars.map(&:to_i)

['+','-'].each do |o1|
  ['+','-'].each do |o2|
    ['+','-'].each do |o3|
      if eval("A #{o1} B #{o2} C #{o3} D") == 7
        puts "#{A}#{o1}#{B}#{o2}#{C}#{o3}#{D}=7"
        exit
      end
    end
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
struct pt{
  int x,y,n;
};
vector<pt> dirs = { {0,1,1}, {0,-1,1}, {1,0,1}, {-1,0,1} };
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int h,w,nb = 0;
  cin >> h >> w;
  vector<string> vs(h);
  queue<pt> q;
  for(int i = 0; i < h; ++i){
    cin >> vs[i];
    for(int j = 0; j < w; ++j){
      if(vs[i][j] == '#'){
        vs[i][j] = true;
        q.emplace(pt{i,j,0});
      }
    }
  }
  while(!q.empty()){
    auto p = q.front();
    q.pop();
    for(auto& d : dirs){
      int x=p.x+d.x,y=p.y+d.y,n=p.n+d.n;
      if(0 <= x and x < h and 0 <= y and y < w){
        if(vs[x][y] == '.'){
          vs[x][y] = '#';
          nb = max(nb,n);
          q.emplace(pt{x,y,n});
        }
      }
    }
  }
  cout << nb;
  return 0;
}


Measured memory_bytes: 13456
from collections import Counter
N = int(input())
s = sorted([input() for _ in range(N)])
M = int(input())
t = sorted([input() for _ in range(M)])

d = {}
for val,cnt in Counter(s).items():
    d[val] = cnt

for val,cnt in Counter(t).items():
    if val in d:
        d[val] -= cnt
print(max(max(d.values()),0))

Measured memory_bytes: 3316
#include<stdio.h>

int main(void)


{


  int a,b;


  scanf("%d %d",&a,&b);


  if(a<b)


  {


    printf("a < b\n");


  }


  if(a>b)


  {


    printf("a > b\n");


  }


  if(a==b)


  {


    printf("a == b\n");


  }


  return 0;


}

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

int main(){
    int n;
    string s;
    cin>>n>>s;
    vector<int> r(n),l(n);
    for(int i=0;i<n-1;i++){
        if(s[i]=='W') l[i+1]=l[i]+1;
        else l[i+1]=l[i]; 
    }
    for(int i=n-1;i>0;i--){
        if(s[i]=='E') r[i-1]=r[i]+1;
        else r[i-1]=r[i];
    }
    int ans=1e9;
    for(int i=0;i<n;i++){
        ans=min(ans,r[i]+l[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6148
import itertools
H,W,K = map(int, input().split())
#print(H,W,K)
ln = []
for i in range(H):
    sam = []
    sam2 = input()
    for j in sam2:
      sam.append(j)
    ln.append(sam)
#print(ln)
line_H = list(itertools.product([0,1],repeat = H))
line_W = list(itertools.product([0,1],repeat = W))
counter = 0
total = 0
for h in line_H:
    for w in line_W:
        
        counter = 0
        for i,k in enumerate(h):
            for j,l in enumerate(w):
                
                if ln[i][j] == '#' and k == 1 and l == 1:
                    counter +=1
                
        if counter == K:
            total += 1
print(total)  


Measured memory_bytes: 9116
#include<stdio.h>
int main(){
int x,y,z;
scanf("%d %d",&x,&y);
while(!(x==0&&y==0)){
if(x>y){
z=x;
x=y;
y=z;
}
printf("%d %d\n",x,y);
scanf("%d %d",&x,&y);
};

return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int test;

int len, n;
int inp[200005], x[200005];
LL sum[200005];

LL calc() {
    LL res = 0;
    sum[0] = 0;
    forn(i, n) {
        sum[i + 1] = sum[i] + x[i];
    }
    forn(i, n) {
        LL cur = x[i];
        if (i != n - 1) {
            cur += x[i];
            int mid = (i + n + 1) / 2;
            cur += ((LL)len * (n - mid) - sum[n] + sum[mid]) * 2;
            cur += (sum[mid] - sum[i + 1]) * 2;
            if ((n - i - 1) % 2 == 0) {
                cur -= x[mid - 1];
            } else {
                cur -= len - x[mid];
            }
        }
        res = max(res, cur);
    }
    return res;
}

LL solve() {
    forn(i, n) {
        x[i] = inp[i];
    }
    LL ans = calc();
    forn(i, n) {
        x[i] = len - inp[i];
    }
    reverse(x, x + n);
    ans = max(ans, calc());
    return ans;
}

void readInput() {
    scanf("%d%d", &len, &n);
    forn(i, n) {
        scanf("%d", inp + i);
    }
}

mt19937 mt(123);

bool used[30000];

void genTest() {
    len = mt() % 6000 + 4000;
    n = mt() % 15 + 1;
    forn(i, n) {
        while (true) {
            int ind = mt() % (len - 1) + 1;
            if (!used[ind]) {
                used[ind] = true;
                inp[i] = ind;
                break;
            }
        }
    }
    sort(inp, inp + n);
    forn(i, n) {
        used[inp[i]] = false;
    }
}

LL brute() {
    forn(i, n) {
        x[i] = inp[i];
    }
    LL res = 0;
    forn(mask, 1 << n) {
        LL cur = 0;
        int lo = 0, hi = n - 1;
        int pos = 0;
        forn(i, n) {
            if (mask & (1 << i)) {
                cur += x[lo] - pos;
                if (x[lo] < pos) {
                    cur += len;
                }
                pos = x[lo];
                ++lo;
            } else {
                cur += pos - x[hi];
                if (pos < x[hi]) {
                    cur += len;
                }
                pos = x[hi];
                --hi;
            }
        }
        res = max(res, cur);
    }
    return res;
}

int main() {
//    freopen("input.txt", "r", stdin);
    readInput();
    cout << solve() << endl;
//    cout << brute() << endl;
//    for (test = 0; test < 12341234; ++test) {
//        genTest();
//        auto sol = solve();
//        auto br = brute();
//        if (sol != br) {
//            printf("WA %d\n", test);
//            printf("%d %d\n", len, n);
//            forn(i, n) printf("%d ", inp[i]);
//            puts("");
//            puts("");
//            cout << "sol " << sol << " br " << br << endl;
//            return 0;
//        }
//        if (!(test & 1023)) {
//            printf("OK %d\n", test);
//        }
//    }
    return 0;
}


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

int main() {
  
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  
  int price = a * x + b * y,Tprice;
  
  for ( int i = 1; i <= 100000; i++){
    Tprice = i * 2 * c + max(0,x-i) * a + max(0,y-i) * b;
    price = min(price,Tprice);
  }
  
  cout << price << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int max = Math.max(a + b, a - b);
		max = Math.max(max, a * b);
		System.out.print(max);

	}
}

Measured memory_bytes: 21844
# coding: utf-8
# Your code here!
import collections
A,B = map(int,input().split())

#最大公約数を求める
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
    
G = gcd(A, B)

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


#print(factorize(G))
print(len(factorize(G)) + 1)


Measured memory_bytes: 38512
#include "bits/stdc++.h"

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  REP(i,a,b) for(int i=a;i<b;i++)
typedef long long int lld;
typedef vector<lld> vl;
typedef vector<int> vi;
typedef vector<string> vs;



//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());

int main() {
	int h, w, tmp = 0;

	string ans;
	cin >> h >> w;
	vi flag_y(w, 0), flag_x(h, 0);
	vs a(h);
	rep(i, h) {
		cin >> a[i];
	}

	rep(i, h) {
		tmp = 0;
		rep(k, w) {
			if (a[i][k] == '.')
				tmp++;
		}
		if (tmp == w) {
			flag_x[i] = 1;
		}

	}
	rep(i, w) {
		tmp = 0;
		rep(k, h) {
			if (a[k][i] == '.')
				tmp++;
		}
		if (tmp == h) {
			flag_y[i] = 1;
		}
	}

	rep(i, h) {
		if (flag_x[i]) continue;
		rep(k, w) {
			if (!flag_y[k]) {
				cout << a[i][k];
			}

		}
		cout << endl;

	}

	/*
	rep(i,w) {
		rep(k, h) {
			cout << flag_x[i] + flag_y[k];
		}
		cout << "\n";
	}
	 */
	return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
using namespace std;

#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair

int solve()
{
  ll n;
  cin>>n;
  
  ll arr[n][3];
  
  for(ll i=0;i<n;i++)
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  
  ll dp[n][3];
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];
  
  for(ll i=1;i<n;i++)
  {
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+arr[i][2];
  }
  
  cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
  

    return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    /*ll t;
    cin>>t;
    while(t--)*/
        solve();

    return 0;
}

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

int main(){
  
  string S;
  cin >> S;
  int i, hug = 0;
  
  for(i = 0; i < S.size()/2; i++){
    
    if (S.at(i) != S.at(S.size() - 1 - i)){
      hug++;
    }
  }
  cout << hug << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    for(int i =1 ; i <=5 ; i++ ) {
        int tmp;
        cin>>tmp;
        if(tmp == 0) cout<<i<<'\n';
    }
    return 0;
    
}

Measured memory_bytes: 3612
N = int(input())
X = list(map(int,input().split()))
X0 = X.copy()
X.sort()

for i in range(N):
  if(X0[i] < X[N//2]):
   B = X[N//2]
  else:
   B = X[N//2 - 1]
  print(B)

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

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////
unsigned int rnd(){
    static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned int t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}
#include <chrono>
//auto end=chrono::system_clock::now();
//double time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000000.0);//多分これで秒
//cerr<<"loop: "<<loopcount<<endl;

#define N 30
#define D 400
vector<ll> c(N);
vector<vector<ll>>s(D);
ll d;
ll n=26;

vector<ll> calhappy(vector<ll>ans){
    vector<ll>v;
    ll res=0;
    ll last[N];memset(last,0,sizeof(last));
    rep(i,1,d){
        res+=s[i][ans[i]];
        last[ans[i]]=i;
        rep(j,1,n){
            res-=c[j]*(i-last[j]);
        }
        v.pb(res);
    }
    return v;
}
int main(){fastio
    auto start=chrono::system_clock::now();ll loopcount=0;
    
    
    cin>>d;
    rep(i,1,n)cin>>c[i];
    rep(i,1,d){
        s[i].resize(n+1);
        rep(j,1,n)cin>>s[i][j];
    }
    
    vector<ll>ans(d+1);
    rep(i,1,d)cin>>ans[i];
    vector<ll>ret=calhappy(ans);
    for(auto x:ret)cout<<x<<endl;
    
    
    
    
    
    /*
    while(1){
        auto end=chrono::system_clock::now();
        double time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()/ 1000000.0);
        if(time>0.3)break;
        
        
        loopcount++;
    }
    cerr<<loopcount<<endl;
    */
    
    return 0;
}







Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define rep(i,n) for(int i=0,i##_len=n;i<i##_len;i++)
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;
using namespace std;

signed main(){
  int w, h; cin >> w >> h;
  vector<int> cx(w), cy(h);
  vector<tuple<int,int>> cxy(w+h);
  rep(i,w){
    cin >> cx[i];
    cxy[i] = make_tuple(cx[i], 0);
  }
  rep(i,h){
    cin >> cy[i];
    cxy[w+i] = make_tuple(cy[i], 1);
  }

  sort(all(cxy));

  int mx = 0, my = 0;

  int res = 0;
  rep(i,w+h){
    int cs, d; tie(cs, d) = cxy[i];
    if(d == 0){
      res += cs * (h + 1 - my);
      mx++;
    }else{
      res += cs * (w + 1 - mx);
      my++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

const long long mod = 1e9 + 7;

struct points {
	int x;
	int y;
	int point;
};

int main() {
	int h, w;
	char** s;
	int** north, **south, **east, **west;
	cin >> h >> w;

	s = new char*[h];

	north = new int*[h];
	south = new int*[h];
	east = new int*[h];
	west = new int*[h];

	for (int i = 0; i < h; i++) {
		char* sins;
		sins = new char[w];
		s[i] = sins;

		int* Ninnorth, *Sinsouth, *Eineast, *Winwest;

		Ninnorth = new int[w];
		Sinsouth = new int[w];
		Eineast = new int[w];
		Winwest = new int[w];

		north[i] = Ninnorth;
		south[i] = Sinsouth;
		east[i] = Eineast;
		west[i] = Winwest;
	}

	for (int i = 0; i < w; i++) {
		north[0][i] = 1;
		south[h - 1][i] = 1;
	}
	for (int i = 0; i < h; i++) {
		east[i][w - 1] = 1;
		west[i][0] = 1;
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
			if (s[i][j] == '#') {
				north[i][j] = 0;
				west[i][j] = 0;
			}
			if (i != h - 1) {
				north[i + 1][j] = north[i][j] + 1;
			}
			if (j != w - 1) {
				west[i][j + 1] = west[i][j] + 1;
			}
		}
	}

	points pon;
	pon.point = 0;
	for (int i = h - 1; i >= 0; i--) {
		for (int j = w - 1; j >= 0; j--) {
			if (s[i][j] == '#') {
				south[i][j] = 0;
				east[i][j] = 0;
			}
			if (i != 0) {
				south[i - 1][j] = south[i][j] + 1;
			}
			if (j != 0) {
				east[i][j - 1] = east[i][j] + 1;
			}

			if (pon.point < north[i][j] + south[i][j] + east[i][j] + west[i][j] - 3) {
				pon.x = i;
				pon.y = j;
				pon.point = north[i][j] + south[i][j] + east[i][j] + west[i][j] - 3;
			}
		}
	}

	cout << pon.point << endl;
}

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

void U(int &x,int y){
    x=(x+y)%mod;
}

ll K(ll x,ll y=mod-2){
    ll t=1;
    for (;y;y>>=1,x=x*x%mod)
        if (y&1) t=t*x%mod;
    return t;
}

int n, N=400, a[404], b[404], f[404][404], g[404][404];
ll jc[404], inv[404];

void trans(int a,int b){
    memset(g,0,sizeof g);
    for (int i=0;i<=N;++i)
        for (int j=0;j<=N;++j)
            if (f[i][j]){
                U(g[i][j],f[i][j]);
                ll pw=1;
                for (int k=0;k<b;++k){
                    U(g[i+a][j+k],mod-f[i][j]*pw%mod*inv[k]%mod);
                    pw=pw*a%mod;
                }
            }
    memcpy(f,g,sizeof f);
}

int main(){
    cin>>n;
    for (int i=0;i<=N;++i){
        jc[i]= i? jc[i-1]*i%mod: 1;
        inv[i]=K(jc[i]);
    }
    for (int i=1;i<=n;++i) cin>>a[i]>>b[i];
    f[0][0]=mod-1;
    int sum=0;
    for (int i=1;i<=n;++i){
        trans(a[i],b[i]);
        sum+=a[i];
    }
    ll ans=0;
    for (int i=1;i<=N;++i){
        ll ivi=K(i), pw=sum*ivi%mod;
        for (int j=0;j<=N;++j){
            ans=(ans+f[i][j]*pw%mod*jc[j])%mod;
            pw=pw*ivi%mod;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1536
input()
X = [int(x) for x in input().split()]
input()
Y = [int(x) for x in input().split()]

flag = [False]*2000
for j in range(1 << len(X)):
    n = 0
    for i in range(len(X)):
        if 1 & (j >> i) == 1:
            n += X[i]
    flag[n] = True

for m in Y:
    print("yes" if flag[m] else "no")




Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    BeatMeScanf;
    //freopen("G:/C++/in.txt", "r", stdin);
    //freopen("G:/C++/out.txt", "w", stdout);
    int a, b;
    cin>>a>>b;
    if(a<b)
    {
        for(int i = 0; i<b; i++)
            cout<<a;
    }
    else
    {
        for(int i = 0; i<a; i++)
            cout<<b;
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
//Solution for aoj:0212 Highway Express Bus
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
typedef pair<int, int>P;


struct S {
	int cost, to, num;
	S(int c, int t, int n) : cost(c), to(t), num(n){}
	bool operator>(const S &s) const {
		return cost > s.cost;
	}
};

const int INF = 1 << 30;
int c, n, m, s, d, ans;
int tocost[101][11];
vector<P> town[101];
priority_queue<S, vector<S>, greater<S> > pq;


void dijkstra(){
	while (!pq.empty()){
		S a = pq.top();
		pq.pop();
		for (int i = 0; i < town[a.to].size(); i++){
			int tt = town[a.to][i].first, cc = town[a.to][i].second;
			if (tocost[tt][a.num] > cc + a.cost){
				tocost[tt][a.num] = cc + a.cost;
				pq.push({ cc + a.cost, tt, a.num });
			}
			if (a.num>0&&tocost[tt][a.num-1] > cc/2 + a.cost){
				tocost[tt][a.num-1] = cc/2 + a.cost;
				pq.push({ cc/2 + a.cost, tt, a.num-1 });
			}
		}
	}
}
	int main(){
		while (cin >> c >> n >> m >> s >> d&&c&&n&&m&&s){
			for (int i = 0; i < 101; i++)
				fill(tocost[i], tocost[i] + 11, INF);
			tocost[s][c] = 0;
			ans = INF;
			while (pq.size())
				pq.pop();
			for (int i = 0; i < 101; i++)
				town[i].clear();
			for (int i = 0; i < m; i++){
				int a, b, c;
				cin >> a >> b >> c;
				town[a].push_back({ b, c });
				town[b].push_back({ a, c });
			}
			pq.push({ 0, s, c });
			dijkstra();
			for (int i = 0; i <= c; i++)
				ans = min(ans, tocost[d][i]);
			cout << ans << endl;
		}
		return 0;
	}

Measured memory_bytes: 1240
#include<stdio.h>
int main()
{
	char s[15];
	int len,i,ans=0;
	scanf("%s", &s);
	len = strlen(s);
	if(s[0]=='A'){
		for(i=1;i<len;i++){
			if('A'<=s[i] && s[i]<='Z'){
				if(1<i && i<len-1 && s[i]=='C')ans++;
				else ans+=2;
			}
		}
	}
	puts(ans==1?"AC":"WA");
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 25 20:54:45 2020

@author: naoki
"""

import sys
A, B, C = map(int, input().split())
K = int(input())

for i in range(0,8):
    for j in range(0,8):
        for k in range(0,8):
            Aa = A * 2**i
            Ba = B * 2**j
            Ca = C * 2**k
            
            if i+j+k <= K and Aa < Ba and Ba < Ca:
                print("Yes")
                sys.exit()
print("No")

Measured memory_bytes: 62252
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long N = S.length;
    auto dp = new long[][](13, N + 1);
    dp[0][0] = 1;
    foreach (i; 0 .. N)
    {
        if (S[i] == '?')
        {
            foreach (j; 0 .. 10)
                foreach (k; 0 .. 13)
                {
                    dp[(k * 10 + j) % 13][i + 1] += dp[k][i];
                    dp[(k * 10 + j) % 13][i + 1] %= MOD;
                }
            continue;
        }
        foreach (j; 0 .. 13)
        {
            dp[(j * 10 + (S[i] - '0')) % 13][i + 1] += dp[j][i];
            dp[(j * 10 + (S[i] - '0')) % 13][i + 1] %= MOD;
        }
    }
    writeln(dp[5][N]);
}


Measured memory_bytes: 11544
#include <iostream>
#include <cmath>
using namespace std;
int main()
{int n,l,a[200];
while(cin>>n>>l)
{for(int i=0;i<n;i++)
{a[i]=l+i;
}
int key=abs(a[0]);
int number=0;
for(int j=0;j<n;j++)
{if(abs(a[j])<key)
{key=abs(a[j]);
 number=j;
} 
}
int s=0;
for(int k=0;k<n;k++)
{if(k==number)
 {continue;
 }
 else s+=a[k];
}
cout<<s;
}
return 0;
}

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

int main(){
  int n;
  cin >> n;
  int ac=0,wa=0,tle=0,re=0;
  rep(i,n){
    string x;
    cin >> x;
    if(x=="AC") ac++;
    if(x=="WA") wa++;
    if(x=="TLE") tle++;
    if(x=="RE") re++;
  }
  cout << "AC x " << ac << "\n";
  cout << "WA x " << wa << "\n";
  cout << "TLE x " << tle << "\n";
  cout << "RE x " << re << "\n";

  return 0;
}

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

class CMaze {
public:
  CMaze(uint h, uint w, vector<string> maze) : m_h(h), m_w(w), m_maze(maze) {}
  uint max_range(uint h_f, uint w_f) {
    if((h_f >= m_h) || (w_f >= m_w) || m_maze[h_f][w_f] == '#') return 0;
    vector<vector<int>> ranges(m_h, vector<int>(m_w, -1));
    ranges[h_f][w_f] = 0;

    int r = 0;
    while(true) {
      bool isSetNextRange = false;
      for(uint h = 0; h < m_h; ++h) {
        for(uint w = 0; w < m_w; ++w) {
          if(ranges[h][w] == r) {
            if((h>0)       && (m_maze[h-1][w] == '.') && (ranges[h-1][w] == -1)) {ranges[h-1][w] = r + 1; isSetNextRange=true;}
            if(((h+1)<m_h) && (m_maze[h+1][w] == '.') && (ranges[h+1][w] == -1)) {ranges[h+1][w] = r + 1; isSetNextRange=true;}
            if((w>0)       && (m_maze[h][w-1] == '.') && (ranges[h][w-1] == -1)) {ranges[h][w-1] = r + 1; isSetNextRange=true;}
            if(((w+1)<m_w) && (m_maze[h][w+1] == '.') && (ranges[h][w+1] == -1)) {ranges[h][w+1] = r + 1; isSetNextRange=true;}
          }
        }
      }
      if(isSetNextRange) r++;
      else break;
    }

    return r;
  }

private:
  uint m_h;
  uint m_w;
  vector<string> m_maze;
};

int main() {
  uint h, w;
  cin >> h >> w;
  vector<string> m(h);
  for(uint i = 0; i < h; ++i) {
    cin >> m[i];
  }
  CMaze maze(h, w, m);
  uint max_range = 0;
  for(uint h_g = 0; h_g < h; ++h_g) {
    for(uint w_g = 0; w_g < w; ++w_g) {
      max_range = max(max_range, maze.max_range(h_g, w_g));
    }
  }

  cout << max_range << endl;
  return 0;
}

Measured memory_bytes: 256
# from scipy.special import comb
from scipy.misc import comb

n, p = map(int, input().strip().split())
as_ = list(map(int, input().strip().split()))

num_evens = len([a for a in as_ if a % 2 == 0])
num_odds = len([a for a in as_ if a % 2 == 1])

counts = 0
if p == 0:
    # 全部で偶数枚食べる = 偶数枚の袋 a 個 + 奇数枚の袋 b = 2k 個
    # 0袋食べる場合も OK.
    counts += 1
    # 1袋以上食べる場合
    for i in range(1, n + 1):
        # 全部で i 袋食べるとする i = 1 〜 n
        for a in range(i + 1):
            # そのうち偶数枚の袋を a 個食べる方法
            even_ways = comb(num_evens, a, exact=True)
            # 奇数枚の袋は (i - a) 個食べるが、それは偶数でなければならない
            b = (i - a)
            if b % 2 == 1 or b < 0:
                continue
            else:
                odd_ways = comb(num_odds, b, exact=True)

            counts += even_ways * odd_ways

else:
    # 全部で奇数枚食べる = 偶数枚の袋 a 個 + 奇数枚の袋 b = 2k + 1個 (k >= 0)
    # 奇数の袋は0ではいけない (k >= 0)
    # 0袋食べるのはダメ
    # 1袋以上食べる場合
    for i in range(1, n + 1):
        # 全部で i 袋食べるとする
        for b in range(0, i + 1):
            # 奇数枚の袋を b = 2k + 1 個食べる
            if b % 2 == 0:
                continue
            # すると偶数枚の袋は a = i - b 個食べる
            a = i - b
            if a < 0:
                continue

            odd_ways = comb(num_odds, b, exact=True)
            even_ways = comb(num_evens, a, exact=True)
            counts += even_ways * odd_ways

print(counts)


Measured memory_bytes: 13536
n, k = gets.split.map &:to_i
h = gets.split.map &:to_i

dp = [0]
(1...n).each do |j|
  dp[j] = ([j-k, 0].max..j-1).map do |i|
    dp[i] + (h[j] - h[i]).abs
  end.min
end

p dp[n-1]


Measured memory_bytes: 78524
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int D, G;
	cin >> D >> G;

	G /= 100;
	vector<int> p(D);
	vector<int> c(D);
	for (auto i = 0; i < D; ++i)
	{
		cin >> p[i] >> c[i];
		c[i] /= 100;
	}

	auto limit = 1;
	for (auto i = 0; i < D; ++i)
	{
		limit *= 2;
	}

	auto result = INT_MAX;
	for (auto i = 0; i < limit; ++i)
	{
		auto sum = 0;
		auto num = 0;
		for (auto j = 0; j < D; ++j)
		{
			if ((i & (1 << j)) != 0)
			{
				sum += p[j] * (j + 1) + c[j];
				num += p[j];
			}
		}
		if (sum >= G)
		{
			result = min(result, num);
			continue;
		}

		auto remain = G - sum;
		for (auto j = 0; j < D; ++j)
		{
			if ((i & (1 << j)) == 0)
			{
				auto n = remain / (j + 1);
				if (remain % (j + 1) > 0)
				{
					++n;
				}
				if (n < p[j])
				{
					result = min(result, num + n);
				}
			}
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <map>
#include <set>
#include <ctime>
#include <cstring>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
 
#define mod 1000000007
#define INF 1000000000

#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define contains(a, x) (a.find(x) != end(a))
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)
#define RF(i,a,b)for(int i = (int)(a); i >= (int)(b); --i)

typedef double dbl;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

#define fast() {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define log(x) cout << (x) << endl;


#define exp(x) dbl((6*x)+(5*x))


int main() {
	fast();

	ll a, x = 1, r;
	cin >> x;

	r = x/11;
	a = r * 2;
	x %= 11;

	a += (x > 6)?2:(x > 0)?1:0;
	log(a)

	return 0;
}





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

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d.at(i);
	}
	sort(d.begin(), d.end(),greater<int>());

	int tmp = 0;
	for (int i = 1; i < N; i++) {
		if (d.at(i - 1) == d.at(i))tmp++;
	}
	cout << N - tmp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  inl(a,b,c);
  if( (a+b)+1 >= c ) out(b + c);
  else out( (a + b + 1) + b );

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int n,y,m,d,res,j;
    cin >> n;
    for(int i = 0;i < n;i++){
        res = 0;
        cin >> y >> m >> d;
        for(j = 1;j < y;j++){
            if(j % 3 == 0)res += 200;
            else res +=195;
        }
        for(j = 1;j < m;j++){
            if(y % 3 == 0)res += 20;
            else if(j % 2 == 0)res += 19;
            else res += 20;
        }
        res += d;
        res = 196471 - res;
        cout << res <<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
int main(void){
    int n;
    int a;
    int b;
    int max;
    int min;
    scanf("%d %d %d",&n,&a,&b);
    if(a>b){
        max=b;
    }
    else{
        max=a;
    };
    if((a+b-n)>0){
        min=a+b-n;
    }
    else{
        min=0;
    }
    printf("%d %d",max,min);
}

Measured memory_bytes: 128
W, H, N = map(int, input().split())
max_x = W
min_x = 0
max_y = H
min_y = 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        min_x = max(min_x, x)
    elif a == 2:
        max_x = min(max_x, x)
    elif a == 3:
        min_y = max(min_y, y)
    else:
        max_y = min(max_y, y)
if min_x >= max_x or min_y >= max_y:
    print(0)
else:
    print((max_x-min_x) * (max_y-min_y))


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

int main()
{
    int n;
    cin >> n;
    int a[n];
    vector<int> b(n);
    bool flag = 0;
    rep(i, n) {
        cin >> a[i];
        if (a[i] >= 0) {
            b[i] = a[i];
        }
        else {
            b[i] = -a[i];
            flag = !flag;
        }
    }

    sort(b.begin(), b.end());
    ll sum = 0;
    if (flag == 1) sum -= b[0];
  	else sum += b[0];
    rep(i, n-1) sum += b[i+1];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] N = new int[3];
    for(int i=0;i<3;i++){
      N[i] = sc.nextInt();
    }
    Arrays.sort(N);
    if(N[0]==5 && N[1]==5 && N[2]==7){        
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 35652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll rwpw(ll a, ll p){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

ll fc[225816],nv[225816];

ll comb(ll n, ll k){
	ll ret;
	ret = fc[n];
	mul_mod(ret,nv[k]);
	mul_mod(ret,nv[n-k]);
	return ret;
}

int main(void){
	ll n,i,t,a,an,b,bn,c,p,bs,ans=0ll;
	p = rwpw(100ll,MOD-2);
	cin >> n >> a >> b >> c;
	fc[0] = 1ll; nv[0] = 1ll;
	for(i=0; i<2*n; ++i){
		fc[i+1] = fc[i];
		mul_mod(fc[i+1],i+1);
		nv[i+1] = nv[i];
		mul_mod(nv[i+1],rwpw(i+1,MOD-2));
	}
	mul_mod(a,p); mul_mod(b,p); mul_mod(c,p);
	t = rwpw((a+b)%MOD,MOD-2);
	mul_mod(a,t); mul_mod(b,t);
	an = rwpw(a,n); bn = rwpw(b,n);
	for(i=n; i<n*2; ++i){
		bs = (t*i)%MOD;
		p = an; mul_mod(p,rwpw(b,i-n));
		mul_mod(p,comb(i-1,i-n));
		mul_mod(p,bs);
		add_mod(ans,p);
		p = bn; mul_mod(p,rwpw(a,i-n));
		mul_mod(p,comb(i-1,i-n));
		mul_mod(p,bs);
		add_mod(ans,p);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    int max_h = H[0];
    int ans = 1;
    for (int i = 1; i < N; i++) {
        if (H[i] >= max_h) {
            max_h = H[i];
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]

def solve(H, W, S):
    S = [s + "." for s in S] + ["." * (W + 1)]
    for y in range(H):
        for x in range(W):
            if (S[y][x] == "#" and
                S[y][x + 1] == "." and S[y][x - 1] == "." and
                S[y + 1][x] == "." and S[y - 1][x] == "."
            ):
                return False
    return True

if solve(H, W, S):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<bits/stdc++.h>            
#include<cmath>                  
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define pb push_back 
#define mkp make_pair    
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define rall(v )  reverse(v.begin(), v.end())      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define ee cout<<endl
#define pr pair<ll,ll>
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
/*ll vis[100023];
ll a[100023];
vl v0[100023];
vl v1[100023];
vl V[100023];
ll col[100023];
ll ans=0;
vl L[100023];
ll mx=0;
void dfs(ll node,ll f)
{
	if(vis[node]==1)
	return;
	vis[node]=1;
	mx=max(mx,f);
	L[f].pb(node);
	for(i=0;i<V[node].size();i++)
	{
		dfs(V[node][i],f+1);
	}
}
*/
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
	   //cin>>t;
	      while(t--)
{
/*
5
4 4 9 7 5*/
ll n,j,k,l,i,m;
cin>>n;
ll a[n];
fo(i,n)
cin>>a[i];
//sort(a,a+n);
ll ans=0;
for(i=0;i<n-2;i++)
{
	for(j=i+1;j<n-1;j++)
	{
		for(k=j+1;k<n;k++)
		{
			if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[k]+a[j]>a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
			ans++;
		}
	}
}
cout<<ans;
ee;

	/*
string a;
ll c=0,i;
ll mx=0;
cin>>a;
fo(i,a.length())
{
	if(a[i]=='R')
	c++;
	else
	c=0;
	mx=max(mx,c);
}
cout<<mx;
ee;*/
/*ll n,m,j,k,l,i;
cin>>n;
ll a[n],b[n];
string s;
fo(i,n-1)
{
	cin>>a[i]>>b[i];
	V[a[i]].pb(b[i]);
	V[b[i]].pb(a[i]);
}
cin>>s;
ans=0;
mx=0;
fo(i,n)
vis[i+1]=0;
dfs(1,1);
ll h=2;
ans=0;
for(i=mx;i>=1;i--)
{
	if(L[i].size()>=h)
	{
		ans=-1;
		break;
	}
}
*/

/*
1  
7  
1 2  
1 3  
2 4  
2 5  
3 6  
3 7  
0010010*/
}
return 0;
}
















Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/errno.h>
#include <limits.h>

#define READ_BUF_SIZE 1024
#define ASIZE(a) (sizeof (a) / sizeof (a[0]))

static int
read_str (char **out, int out_size, int max)
{
  char *p;
  char buf[READ_BUF_SIZE];
  int i = 0;
  char format[128];

  sprintf (format, "%%%d[^\n]%%*[^\n]", READ_BUF_SIZE);
  if (scanf (format, buf) == EOF)
    {
      printf ("EOF\n");
      fseek (stdin, 0L, SEEK_SET);
      return -1;
    }
  getchar ();

  for (p = strtok (buf, " "); p; p = strtok (NULL, " "))
    {
      strncpy ((char *) out, p, out_size);
      out = (char **) ((char *) out + out_size - 1); 
      *(char *) out = '\0';
      out = (char **) ((char *) out + 1); 
      i++;
      if (i >= max)
	break;
      
    }
  return i;
}

static int
read_num (int *out, int max)
{
  char *p;
  char buf[READ_BUF_SIZE];
  int i = 0;
  char format[128];

  sprintf (format, "%%%d[^\n]%%*[^\n]", READ_BUF_SIZE);
  if (scanf (format, buf) == EOF)
    {
      printf ("EOF\n");
      fseek (stdin, 0L, SEEK_SET);
      return -1;
    }
  getchar ();

  for (p = strtok (buf, " "); p; p = strtok (NULL, " "))
    {
      char *endptr = NULL;
      long num = strtol (p, &endptr, 10);
      if (*endptr != '\0' || errno == ERANGE)
	continue;
      else
	out[i++] = num;
      if (i >= max)
	break;
    }
  return i;
}


#define MAX(a, b) ((a) > (b) ? (a) : (b)) 
#define MIN(a, b) ((a) < (b) ? (a) : (b)) 

int
main (int argc, char *argv[])
{
  int input[5];
  read_num (input, 5);
  int i;
 
  int A = input[0], B = input[1], C = input[2];
  int X = input[3], Y = input[4];
  long sum = LONG_MAX;
    
  for (i = 0; i <= MAX (X, Y) ; i++)
    sum = MIN (sum, 2 * C * i + A * MAX (0, (X - i)) + B * MAX (0, (Y - i)));

  printf ("%ld\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll n;
    cin>>n;
    vector<pair<ll,ll>>a(n);
    rep(0,i,n){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(a.begin(),a.end());
    rep(0,i,n){
        if(i==a[n-1].second){
            cout<<a[n-2].first<<endl;
        }else{
            cout<<a[n-1].first<<endl;
        }
    }
}

Measured memory_bytes: 6424
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll A,B;
    cin >> A >> B;
    A=max(A-1,0LL);
    
    int i=0;
    ll factor=1;
    ll ans=0;
    while(B>>i){
        ll cnt=0;
        cnt+=(ll) (B>>(i+1))*factor+((B>>i)&1)*(B%factor+1);
        //cout << (ll) (B>>(i+1))*factor << ' ' << ((B>>i)&1)*(B%factor+1) << endl;
        cnt-=(ll) (A>>(i+1))*factor+((A>>i)&1)*(A%factor+1);
        //cout << cnt << endl;
        cnt%=2LL;
        i++;
        ans+=cnt*factor;
        factor*=2LL;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> nd(n, 0);
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        while(a % 2 == 0){
            nd.at(i)++;
            a /= 2;
        }
    }
    cout << accumulate(nd.begin(), nd.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.HashMap;
 
public class Main {
	private	static			BufferedReader	br  = null;
	private	static	final	String			INI = "01234567";
	private	static	final	int[]			SV = { 1, -1, 0, 0  };
	private	static	final	int[]			SH = { 0, 0,  1, -1 };

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StepTbl	stp = new StepTbl();
		String	arr = null;

		swap(stp);

		while ((arr = parseArray()) != null) {
			System.out.println(stp.get(arr));
		}
	}

	private static void swap(StepTbl tbl) {
		// 0 1 2 3
		// 4 5 6 7
		Queue	que = new Queue();
		Stat	fst = new Stat();
		int		cnt = 0;

		tbl.put(INI, cnt);
		fst.stt = INI;
		fst.stp = 0;
		que.add(fst);

		while (que.size() > 0) {
			Stat	cst = que.pollFirst();
			int		cp  = cst.stt.indexOf("0");
			int		cy = cp / 4;
			int		cx = cp % 4;

			for (int l = 0; l < 4; l++) {
				int		ny = cy + SV[l];
				int		nx = cx + SH[l];

				if (0 <= nx && nx < 4 && 0 <= ny && ny < 2) {
					boolean	fin = false;
					Stat	nst = new Stat();
					char[]	na  = cst.stt.toCharArray();
					char	sc  = na[ny*4+nx];

					na[ny*4+nx] = na[cy*4+cx];
					na[cy*4+cx] = sc;

					nst.stt = String.valueOf(na);
					nst.stp = cst.stp+1;

					if (tbl.containsKey(nst.stt)) {
						if (nst.stp >= tbl.get(nst.stt)) {
							fin = true;
						}
					}

					if (!fin) {
						tbl.put(nst.stt, nst.stp);
						que.add(nst);
					}
				}			
			}
		}
	}

	private static String parseArray() {
		String  arr = null;

		if ((arr = parseStdin()) != null) {
			arr = arr.replaceAll(" ", "");
		}

		return arr;
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

class Stat {
	String	stt = null;
	Integer	stp = 0;
}

class Queue extends ArrayDeque<Stat> {
}

class StepTbl extends HashMap<String, Integer> {
}

Measured memory_bytes: 37712
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    int cnt[501][501] = {};
    rep(i,0,M){
        int l,r;
        cin >> l >> r;
        l--,r--;
        rep(j,0,l+1){
            cnt[j][r]++;
        }
    }
    int accu[501][501] = {};
    rep(i,0,500){
        rep(j,0,500){
            accu[i][j+1] = accu[i][j] + cnt[i][j];
        }
    }
    rep(i,0,N+1)rep(j,0,N+1){
        //cout << accu[i][j] << " \n"[j==N];
    }
    rep(i,0,Q){
        int l,r;
        cin >> l >> r;
        int c = 0;
        rep(j,0,N+1){

        }
        cout << accu[l-1][r] << endl;
    }
}

Measured memory_bytes: 2944