akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
S = []
for _ in range(H):
    s1 = input()
    S.append(s1)

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
for i in range(W):
    if S[0][i] == ".":
        U[0][i] = 1
    if S[H-1][i] == ".":
        D[H-1][i] = 1

for i in range(H):
    if S[i][0] == ".":
        L[i][0] = 1
    if S[i][W-1] == ".":
        R[i][W-1] = 1
     
for i in range(1,H):
    for j in range(W):
        if S[i][j] == "#":
            continue
        U[i][j] = U[i-1][j] + 1
for i in range(H-1)[::-1]:
    for j in range(W):
        if S[i][j] == "#":
            continue
        D[i][j] = D[i+1][j] + 1
for i in range(H):
    for j in range(1,W):
        if S[i][j] == "#":
            continue
        L[i][j] = L[i][j-1] + 1
for i in range(H):
    for j in range(W-1)[::-1]:
        if S[i][j] == "#":
            continue
        R[i][j] = R[i][j+1] + 1
        
ans = 0

for i in range(H):
    for j in range(W):
        ans = max(ans, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)
print(ans)
        

Measured memory_bytes: 179844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    
    set<int> s;
    int a,n;
    cin>>n;
    rep(i,n){
        cin>>a;
        s.insert(a);
    }
    if(n==(int)s.size())fin("YES");
    else fin("NO");
}

Measured memory_bytes: 9600
import java.util.Scanner;

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

        int n = sc.nextInt();

        int[] nums = new int[n];

        int numNeg = 0;
        long sum = 0;
        int minMag = Integer.MAX_VALUE;

        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();

            sum += Math.abs(nums[i]);

            if (nums[i] < 0) {
                numNeg++;
            }

            minMag = Math.min(minMag, Math.abs(nums[i]));
        }

        if (numNeg % 2 == 0) {
            System.out.println(sum);
        } else {
            System.out.println(sum - 2 * minMag);
        }
    }
}

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	char a,b;
	cin >> a >> b;
	if(a == b)cout << 'H' << endl;
	else cout << 'D' << endl;
	return 0; 
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        boolean[] primeList = createPrimeList();
        
        while (sc.hasNext()) {
            int n = Integer.parseInt(sc.next());
            int sum = 0;
            for (int i = 2; i <= n; i++) {
                if (primeList[i]) sum++;
            }
            System.out.println(sum);
        }
    }

    private static boolean[] createPrimeList() {
        int N = 1000000;

        boolean[] primeList = new boolean[N+1];
        Arrays.fill(primeList, true);

        for (int i = 2; i < Math.sqrt(N); i++) {
            if (!primeList[i]) continue;

            for (int j = 2; i * j <= N; j++) {
                primeList[i * j] = false;
            }
        }
        return primeList;
    }
}

Measured memory_bytes: 27532
"use strict"
function main(arg) {
    let X = Number(arg.trim().split("\n")[0])
    let sum = 100
    let i = 1
    for (i = 1; ; i++) {
        sum = Math.floor(sum + sum * 0.01)
        if (sum >= X) {
            break
        }
    }
    console.log(i)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29776
// https://atcoder.jp/contests/abc087/tasks/abc087_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << ((a * b) % 2 == 0 ? "Even\n" : "Odd\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,k;
    int count=0;
    scanf("%d %d",&n,&k);
    int h[n];
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
        if(h[i]>=k) count++;
    }
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        int a,b,c;
        cin>>a>>b>>c;
        int n;
        cin>>n;
        while(n--){
            if(b<c and a<b){
                c=c*2;
            }
            else if(b<=a){
                b*=2;
            }
            else if(b>=c){
                c=c*2;
            }
        }
        if(a<b and c>b){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
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 c = sc.nextInt();
    int x = sc.nextInt();
    int ans = 0;

    for (int i = 0; i <= a; i++) {
      for (int j = 0; j <= b; j++) {
        int cAns = (x -  (500 * i + 100 * j))/ 50;
        if(0 <= cAns && cAns <= c){
          ans++;
        }
      }
    }
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 35740
#include <iostream>
#include <cstring>
#include <string>
 
using namespace std;
 
int main(){
    string s;
    int n;
    int c_pos;
    cin>>n;
    cin.ignore();
    while(n--){
        getline(cin,s);
        while((c_pos=s.find("Hoshino"))!=string::npos){
            s.replace(c_pos,7,"Hoshina");
        }
        cout<<s<<endl;
    }
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string n;
    cin>>n;
    if(n[0]==n[1] && n[1]==n[2]){
        cout<<"Yes"<<endl;
        return 0;
    }else if(n[1]==n[2] && n[2]==n[3]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}

#define ll long long int
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(vv,it) for(auto &it : vv)
#define prep(vv,it) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{

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

    int a; cin >> a;
    cout << a + a*a + a*a*a << endll;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,K;
    cin >> N >> K;
    int now = (N-1)*(N-2)/2;
    vector<pair<int,int>> ans;
    vector<pair<int,int>> e;
    if(K>now){
        cout << -1 << endl;
        return 0;
    }
    for(int i=1;i<N;i++){
        for(int j=i+1;j<N;j++){
            e.push_back({i+1,j+1});
        }
    }
    for(int i=1;i<N;i++){
        ans.push_back({1,i+1});
    }
    for(int i=0;i<now-K;i++){
        ans.push_back(e[i]);
    }
    cout << ans.size() << endl;
    for(auto x:ans)cout << x.first << " " << x.second << endl;
}

Measured memory_bytes: 384
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort()
y.sort()

if X < x[N - 1] and y[0] <= Y and x[N - 1] < y[0]:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll a,b,c,d; cin >> a >> b >> c >> d;
  cout << max(max(a*c,a*d),max(b*c,b*d));
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int h, w, k; cin >> h >> w >> k;
    VS s(h); cin >> s;

    int ans = 0;
    FOR(i, 0, 1 << h)FOR(j, 0, 1 << w) {
        int cnt = 0;
        FOR(y, 0, h)FOR(x, 0, w) {
            if (i & (1 << y) || j & (1 << x))continue;
            if (s[y][x] == '#')++cnt;
        }
        if (cnt == k)++ans;
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
  int n,r;
  cin>>n>>r;
  if(n>=10)
     cout<<r<<"\n";
  else
  {
    int d=r+100*(10-n);
    cout<<d<<"\n";
  }
  return 0;
}
           
           

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	int b;
	int ata;
	int bta;
	scanf("%d",&a);
	scanf("%d",&ata);
	scanf("%d",&b);
	scanf("%d",&bta);
	int timesa=b/ata;
	if(b%ata!=0)timesa+=1;
	int timesb=a/bta;
	if(a%bta!=0)timesb+=1;
	if(timesa<=timesb)printf("Yes");
	else printf("No");
	return 0; 
}

Measured memory_bytes: 3864
// AOJ Volume 0 Problem 0037

#include <stdio.h>
#include <string.h>

int main(void)
{
	int map[13][13];
	int i, j;
	char in[6];
	int x, y;
	char direc_table1[] = "URDLURD";
	int direc; 	// 0:ツ右ツ古シツつォ 1:ツ可コツ古シツつォツ　2:ツ債カツ古シツつォ 3:ツ湘」ツ古シツつォ

	memset(map, 0, sizeof(map));
	
	for (i = 0; i < 9; i++){
		scanf("%s", in);
		if (i % 2 == 0){
			for (j = 0; j < 4; j++){
				if (in[j] == '1'){
					y = ((i / 2) + 1) * 2;
					map[y][(j + 1) * 2    ] =
					map[y][(j + 1) * 2 + 1] =
					map[y][(j + 1) * 2 + 2] = 1;
				}
			}
		}
		else {
			for (j = 0; j < 5; j++){
				if (in[j] == '1'){
					y = ((i / 2) + 1) * 2;
					x = (j + 1) * 2;
					map[y    ][x] =
					map[y + 1][x] =
					map[y + 2][x] = 1;
				}
			}
		}
	}
	
//	for (i = 0; i < 13; i++){
//		for (j = 0; j < 13; j++){
//			if (map[i][j] == 0){
//				printf(".");
//			}
//			else {
//				printf("*");
//			}
//		}
//		printf("\n");
//	}
	
	x = y = 2;
	direc = 0;
	
	while (1){
		
//		printf("(%d,%d)", x, y);
		
		for (i = direc; i < direc + 4; i++){

//			printf("[%c]", direc_table1[i]);

			if (direc_table1[i] == 'U'){
				if (map[y - 1][x] != 0){
					map[y][x] = map[y - 1][x] = 2;
					y -= 2;
					direc = 3;
					printf("U");
					break;
				}
			}
			else if (direc_table1[i] == 'R'){
				if (map[y][x + 1] != 0){
					map[y][x] = map[y][x + 1] = 2;
					x += 2;
					direc = 0;
					printf("R");
					break;
				}
			}
			else if (direc_table1[i] == 'D'){
				if (map[y + 1][x] != 0){
					map[y][x] = map[y + 1][x] = 2;
					y += 2;
					direc = 1;
					printf("D");
					break;
				}
			}
			else if (direc_table1[i] == 'L'){
				if (map[y][x - 1] != 0){
					map[y][x] = map[y][x - 1] = 2;
					x -= 2;
					direc = 2;
					printf("L");
					break;
				}
			}
		}
		if (x == 2 && y == 2){
			break;
		}
	}
	
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e3+2;
int n,m;
int dp[(1LL<<12)+20];

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cin>>n>>m;
      vector<int> v[m];
      int a[m],b[m];
      for(int i=0;i<m;i++)
      {
            cin>>a[i]>>b[i];
            for(int j=0;j<b[i];j++){
                  int x;
                  cin>>x;
                  v[i].pb(x);
            }
      }
      for(int i=0;i<(1<<n);i++)
      {
            dp[i]=1e18;
      }
      dp[0]=0;
      for(int i=0;i<m;i++)
      {
            int b=0;
            for(auto x:v[i]) b|=(1<<(x-1));
            // cout<<b<<" ";
            for(int j=0;j<(1<<n);j++)
            {
                  dp[(j|b)]=min(dp[(j|b)],dp[j]+a[i]);
            }
            // for(int j=0;j<(1<<n);j++) cout<<dp[j]<<" ";
            // cout<<"\n";
      }
      if(dp[(1<<n)-1]==1e18) cout<<"-1";
      else cout<<dp[(1<<n)-1];
}
// I never lose. I either win or I learn

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	string s;
	cin>>s;
	int l = 0;
	while(s[l] != 'A') l++;
	int r = s.size();
	r--;
	while(s[r] != 'Z') r--;
	cout<<r-l+1<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 720
//https://atcoder.jp/contests/dp/tasks/dp_f
#include<bits/stdc++.h>
#define forz(i,n) for(int i=0;i<n;i++)
#define foro(i,n) for(int i=1;i<=n;i++)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define lli long long int
using namespace std;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
     faster
     string s,t;
     cin>>s;
     cin>>t;
     int n1=s.length();
     int n2=t.length();
     int dp[n1+1][n2+1];
     for(int i=0;i<=n1;i++)
     {
          dp[i][0]=0;
     }
     for(int i=0;i<=n2;i++)
     {
          dp[0][i]=0;
     }
     for(int i=1;i<=n1;i++)
     {
          for(int j=1;j<=n2;j++)
          {
               if(s[i-1]==t[j-1])
               {
                    dp[i][j]=1+dp[i-1][j-1];
               }
               else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
               }
          }
     }
     string ans="";
  int i=n1,j=n2;
  while(i>0 && j>0)
  {
    if(s[i-1]==t[j-1])
    {
          ans.pb(s[i-1]);
          i--;
          j--;
    }   
    else if(dp[i-1][j]>dp[i][j-1])
    {
          i--;
    }       
    else{
          j--;
    }

       
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<'\n';
 

return 0;
}

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

class idnum{
public:
  int num;
  int id;
  bool operator<(const idnum &another) const{
    return num < another.num;
  };
};

void solve(){
  int n, m; cin >> n >> m;
  vector<int> x(m);
  for(int i = 0; i < m; i++) cin >> x[i];
  sort(x.begin(), x.end());
  vector<idnum> y(m - 1);
  for(int i = 1; i < m; i++){
    y[i - 1].num = x[i] - x[i - 1];
    y[i - 1].id = i;
  }
  sort(y.begin(), y.end());

  /*for(int i = 0; i < y.size(); i++){
    cout << y[i].id << " " << y[i].num << endl;
  }*/
  vector<int> z;
  for(int i = y.size() - 1; i >= max((int)y.size() - n + 1, 0); --i){
    z.push_back(y[i].id);
  }
  sort(z.begin(), z.end());
  //for(int i = 0; i < z.size(); i++) cout << z[i] <<" "; cout << endl;
  long long ans = 0, prev = x[0];
  for(int i = 0; i < z.size(); i++){
    ans += x[z[i] - 1] - prev;
    prev = x[z[i]];
  }
  ans += x[m - 1] - prev;
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 2044
import sys

n, *towns = map(int, sys.stdin.buffer.read().split())
xxx = towns[0::3]
yyy = towns[1::3]
ppp = towns[2::3]

INF = 10 ** 18
ans = [INF] * (n + 1)

precalc_dist_x = []
precalc_dist_y = []
for bit in range(1 << n):
    dists_x = []
    dists_y = []
    for i in range(n):
        x = xxx[i]
        y = yyy[i]
        dist_x = abs(x)
        dist_y = abs(y)

        t = bit
        j = 0
        while t:
            if t & 1:
                dist_x = min(dist_x, abs(xxx[j] - x))
                dist_y = min(dist_y, abs(yyy[j] - y))
            t >>= 1
            j += 1
        dists_x.append(dist_x * ppp[i])
        dists_y.append(dist_y * ppp[i])
    precalc_dist_x.append(dists_x)
    precalc_dist_y.append(dists_y)

for bit in range(1 << n):
    k = (bit & 0x5555) + (bit >> 1 & 0x5555)
    k = (k & 0x3333) + (k >> 2 & 0x3333)
    k = (k & 0x0f0f) + (k >> 4 & 0x0f0f)
    k = (k & 0x00ff) + (k >> 8 & 0x00ff)
    vertical = bit
    while vertical:
        cost = 0
        pcx = precalc_dist_x[vertical]
        pcy = precalc_dist_y[vertical ^ bit]
        for i in range(n):
            cost += min(pcx[i], pcy[i])
        ans[k] = min(ans[k], cost)
        vertical = (vertical - 1) & bit
    cost = 0
    pcx = precalc_dist_x[0]
    pcy = precalc_dist_y[bit]
    for i in range(n):
        cost += min(pcx[i], pcy[i])
    ans[k] = min(ans[k], cost)

print('\n'.join(map(str, ans)))


Measured memory_bytes: 89928
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    string s, t;
    int ans = 0;
    cin >> s >> t;
    FOR (i, 0, sz(s)) {
        ans += (s[i] != t[i]);
    }
    cout << ans << "\n";
}

int main() {
    io;
    int t = 1;
    tc(t) {
        solve();
    }
}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 3832
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int n,k,cnt,i;
int main()
{
	cin>>n>>k;
	int cnt=1;
	for(i=1;i<=n;i++)
	{
		if(cnt>k)
		{
			cnt+=k;
		}
		else
		{
			cnt*=2;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

//小数点以下を切り上げる割り算
int updivide(int a,int b){
    if(b==1) return a;
    else if(a%b==0) return a/b;
    else return (a/b)+1;
}

int main(){
    LL(n,x,t);
    out(updivide(n,x)*t);
}

Measured memory_bytes: 3828
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
c = 0
rx = x
for i in range(N):
  if a[i] > rx or (i == N-1 and rx != a[i]):
    print(c)
    exit()
  c += 1
  rx -= a[i]
print(N)

Measured memory_bytes: 8964
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <cstdlib>
#include <cstring>

const int mod = 998244353;
const int max_N = 100010;

int cnt[max_N];

int powmod(int a, int b) {
    int ret = 1;
    for (; b; b >>= 1) {
        if (b & 1) {
            ret = 1ll * ret * a % mod;
        }
        a = 1ll * a * a % mod;
    }
    return ret;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        int d;
        scanf("%d", &d);
        if ((d == 0 && i != 1) || (i == 1 && d != 0)) {
            printf("0\n");
            return 0;
        }
        ++cnt[d];
    }
    int ans = 1;
    for (int i = 1; i <= n; ++i) {
        if (cnt[i] == 0) continue;
        ans = 1ll * ans * powmod(cnt[i - 1], cnt[i]) % mod;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n;
	int h[21];
	int m=0,t=0;

	cin>>n;
	rep(i,n){
		cin>>h[i];
		if(m<=h[i]){
			t++;
			m=h[i];
		}
	}
	cout<<t<<endl;
	return 0;

}


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

main()
{
	char a[1000],b[1000];
	int lena,lenb;
	int i,j,flag=0;
	
	scanf("%s %s",a,b);
	lena=strlen(a);
	lenb=strlen(b);
	
	if(lena>lenb)
	{
		flag=1;
		printf("GREATER");
	}
	
	else if(lena<lenb)
	{
		flag=1;
		printf("LESS");
	}
	
	else if(lena==lenb)
	for(i=0;i<lena;i++)
	{
		if(a[i]>b[i])
		{
			printf("GREATER");
			flag=1;
			break;
		}
		else if(a[i]<b[i])
		{
			printf("LESS");
			flag=1;
			break;
		}
	}
	if(flag==0)
	printf("EQUAL");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    ll a, b;
    cin >> a >> b;
    map<ll,int> ad, bd;
    ll na = a, nb = b;
    for (ll i = 2; i*i <= a; i++) {
        while (na%i == 0) {
            ad[i]++;
            na /= i;
        }
    }
    if (na > 1) ad[na] ++;
    for (ll i = 2; i*i <= b; i++) {
        while (nb%i == 0) {
            bd[i]++;
            nb /= i;
        }
    }
    if (nb > 1) bd[nb] ++;
    ll ans = 1;
    for (auto ea : ad) {
        if (bd[ea.first] > 0) ans++;
    }
    cout << ans << "\n";
    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vi h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (h[i] >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(1000000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K):
    m = N % K
    return min(m, K-m)


def main():
    N, K = read_int_n()
    print(slv(N, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5448
#include <iostream>
#include <string>
#include <queue>
#include <cmath>
using namespace std;

int cnt[11][11];
long long int ans;

#define MAX 20
bool is_wall[MAX][MAX];
int is_dirty[MAX][MAX];

#define BIT_MAX (1 << 10)
bool visited[MAX][MAX][BIT_MAX];

#define DIRS 4
int dx[DIRS] = {-1, 0, 0, 1};
int dy[DIRS] = { 0,-1, 1, 0};

bool is_ok(int x, int y, int w, int h){
  return 0 <= x && x < w && 0 <= y && y < h;
}
 
int main() {
  
  int w, h;
  
  while(cin >> w >> h, w || h ) {
    int start_x = -1, start_y = -1;
    int dirtys = 0;

    for(int i = 0; i < h; i++){
      string line;
      cin >> line;
    
      for(int j = 0; j < w; j++){
	is_wall[i][j] = false;
	is_dirty[i][j] = -1;
	for(int k = 0; k < BIT_MAX; k++){
	  visited[i][j][k] = false;
	}

	if(line[j] == 'x'){
	  is_wall[i][j] = true;
	}else if(line[j] == '*'){
	  is_dirty[i][j] = dirtys++;
	}else if(line[j] == 'o'){
	  start_x = j;
	  start_y = i;
	}
      }
    }
    
    queue<int> xq, yq, tq, bq;
    xq.push(start_x);
    yq.push(start_y);
    tq.push(0);
    bq.push(0);
    visited[start_y][start_x][0] = true;

    bool answered = false;
    while(!tq.empty()){
      const int x    = xq.front(); xq.pop();
      const int y    = yq.front(); yq.pop();
      const int time = tq.front(); tq.pop();
      const int bit  = bq.front(); bq.pop();
      
      if(bit == (1 << dirtys) - 1){
	answered = true;
	cout << time << endl;
	break;
      }
 
      for(int dir = 0; dir < DIRS; dir++){
	const int nx = x + dx[dir];
	const int ny = y + dy[dir];
	const int n_time = time + 1;
	
	if(!is_ok(nx, ny, w, h)){
	  continue;
	}else if(is_wall[ny][nx]){
	  continue;
	}

	const int n_bit = bit | (is_dirty[ny][nx] < 0 ? 0 : (1 << is_dirty[ny][nx]));
	
	if(visited[ny][nx][n_bit]){
	  continue;
	}
	
	visited[ny][nx][n_bit] = true;
	xq.push(nx);
	yq.push(ny);
	tq.push(n_time);
	bq.push(n_bit);
      }
    }

    if(!answered){
      cout << -1 << endl;
    }
  }
  
  return 0;
  
}

Measured memory_bytes: 1752
N = gets.to_i
S = gets.chomp

min = 10**6
w_sum = e_sum = 0
from_left = []
from_right = []
S.size.times do |i|
  from_left << w_sum
  from_right << e_sum

  w_sum += 1 if S[i] == 'W'
  e_sum += 1 if S[-(i + 1)] == 'E'
end

S.size.times do |i|
  min = [min, from_left[i] + from_right[-(i + 1)]].min
end

puts min

Measured memory_bytes: 7180
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;   
int a[4];
int main(){
	fastIO;       
	int k,s,ans=0;
	cin>>k>>s;
	for(int x=0;x<=k;x++){
		for(int y=0;y<=k;y++){
			int z=s-x-y;
			if(z >=0 && z <=k)ans++;
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {

  val Array(r, c) = readLine().split(" ").map { _.toInt }

  val lines = Array.fill(r)(readLine())

  val xss = for {
    line <- lines
    xs    = line.split(" ").map { _.toInt }
  } yield xs

  val colSum = xss.transpose.map { _.sum }

  for (xs <- xss) {
    println(display(xs))
  }
  println(display(colSum))

  def display(xs: Seq[Int]): String = xs.mkString("", " ", " " + xs.sum)
}



Measured memory_bytes: 48000
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;



void solve() {
	int a, b, p, q, r; cin >> a >> b >> p >> q >> r;
	ld ans = b;
	ld dif = b * p - (b-a) * q;
	ans += dif / (ld)(q + r);
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(4);
	//init();
	solve();
	stop
		return 0;
}



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

const ll inf = 10000000000;

int main() {
  ll N;
  cin >> N;
  vector<ll> H(N+1);
  for (int i = 0; i < N; i++) cin >> H[i];
  H[N] = inf;

  ll ans = 0;
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    if (H[i+1] <= H[i]) {
      cnt++;
    }
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
N,K=map(int,input().split(' '))
P=list(map(int,input().split(' ')))
tmp = sum([(i+1)/2 for i in P[:K]])
ans = tmp
for i,j in zip(P,P[K:]):
    tmp +=(j+1)/2-(i+1)/2
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 80992
def main():
    N, K = map(int, input().split())
    ans = 0
    for b in range(1, N+1):
        p = N//b
        r = N%b
        ans += p * max(0, b-K) + max(0, r+1-K) - (K==0)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9064
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int W, a, b;
    cin >> W >> a >> b;
    if (a > b) swap(a, b);
    
    if (a + W > b) {
        cout << 0 << endl;
        return 0;
    }
    cout << b - (a + W) << endl;
    return 0;
}


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

using namespace std;

int H, W;
vector<vector<char>> S(50, vector<char>(50, '#'));

const pair<int, int> points[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int compute_dist(pair<int, int> s)
{
    vector<vector<int>> dist(H, vector<int>(W, 0));
    int dmax = 0;
    queue<pair<int, int>> q;
    q.push(s);

    while(!q.empty()) {
        pair<int, int> cur = q.front();
        q.pop();
        for (int i=0; i<4; ++i) {
            pair<int, int> next = make_pair(cur.first+points[i].first, cur.second+points[i].second);
            if (next.first>=0 && next.first<W && next.second>=0 && next.second<H && S[next.second][next.first]=='.') {
                if (dist[next.second][next.first] == 0 && !(next.first==s.first && next.second==s.second)) {
                    q.push(next);
                    dmax = dist[next.second][next.first] = dist[cur.second][cur.first] + 1;
                }
            }
        }
    }

    return dmax;
}

int main()
{
    cin >> H >> W;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) cin >> S[i][j];
    }

    int dmax=0;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (S[i][j] == '.') {
                int d = compute_dist(make_pair(j, i));
                dmax = max(d, dmax);
            }
        }
    }
    cout << dmax << endl;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

const int MAX = 1e5+1;
vector<bool> primes(MAX,true);
vector<int> rescnt(MAX);

void init() {
  primes[0] = primes[1] = false;
  FOR(i,2,(int)sqrt(MAX)+1) {
    if (primes[i]) {
      for (int j=i*2;j<MAX;j+=i) {
        primes[j] = false;
      }
    }
  }

  for (int i=MAX-1;i>=3;i--) {
    if (!primes[i] || primes[(i+1)/2]) continue;
    primes[i] = false;
  }
  // 今回はfalse
  primes[2] = false;

  // 累積和
  rescnt[0] = 0;
  FOR(i,1,MAX) {
    rescnt[i] = rescnt[i-1]+primes[i];
  }
}

int main() {
  init();
  int Q;cin>>Q;
  REP(i,Q) {
    int l,r;cin>>l>>r;
    OUT(rescnt[r]-rescnt[l-1]);
  }

  return 0;
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {

            Solve();

            //Console.WriteLine(ans);
            Console.ReadKey();
        }

        static void Solve()
        {

            var ans = "";
            for(int i = 0; i < 3; i++)
            {
                ans += GetStr().Substring(i, 1);
            }
            Console.WriteLine(ans);
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll a = 0,b = 0;
  cin >> a >> b;
  REP(i,n-1){
    ll t,ta;
    cin >> t >> ta;
    if(a <= t && b <= ta){
      a = t;
      b = ta;
    }
    else{
      ll q,w;
      q = a/t;
      w = b/ta;
      if(a%t != 0)
	q++;
      if(b%ta != 0)
	w++;
      ll seki = max(q,w);
      a = t*seki;
      b = ta*seki;
    }

    
  }
  cout << a+b << endl;
  return 0;
}


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

int main(){
    int n, a, b;

    cin >> n >> a >> b;

    int maxn = min(a, b);
    int minv;

    if(a + b - n < 0){
        minv = 0;
    }
    else{
        minv = a + b - n;
    }

    printf("%d\n", maxn);
    printf("%d\n", minv);

    return 0;
}

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

//??????????????????????????????????????????
char key[10][6] = {
  {}, //0
  {5, '.', ',', '!', '?', ' '},
  {3, 'a', 'b', 'c'},
  {3, 'd', 'e', 'f'},
  {3, 'g', 'h', 'i'},
  {3, 'j', 'k', 'l'},
  {3, 'm', 'n', 'o'},
  {4, 'p', 'q', 'r', 's'},
  {3, 't', 'u', 'v'},
  {4, 'w', 'x', 'y', 'z'}
};
		 

int main(){

  int N;

  std::cin >> N;

  //??\????????\???????????°??????????????????????????¨???????????¨???????????????
  while(N){
    int row = 0;
    int count = -1;
  
    std::string str;
    std::cin >> str;

    for(int i = 0; i < (int)str.size(); i++){
      int num = str[i] - '0'; //???'??°???' - '0'??? ??§????????¨???????????°?????????int ?????????(ex: '1'-'0' = 1)

      if(num != 0){
	row = num;
	count++;
      }else{

	if(row != 0) //?????????0?????´???????°?????????????
	  std::cout << key[row][ (count % key[row][0]) + 1 ]; 
	
	row = 0;
	count = -1;
	/*??????????????§???????????????count???0????????????????????????key??????????????????cout%key[row][0]????????????????????¨
	  5550???????????????????????\?????¨???????????????0????????£?????????????????¬??????3????????£????????????????????¨????????????????????????*/
      }

    }

    std::cout << std::endl;

    N--;
    
  }
  return 0;
}

Measured memory_bytes: 3000