akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetNum(int num) {
	int N=0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

int main() {
	int N;
	int min = 1000000;
	cin >> N;

	for (int i = 1; i < N; i++)
	{
		int A = i;
		int B = N - i;
		int tmp = GetNum(A) + GetNum(B);
		if (tmp < min) {
			min = tmp;
		}
	}

	cout << min << endl;
	return 0;
}


Measured memory_bytes: 256
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
#define MAXN 100
short a[MAXN+10][MAXN+10],s[MAXN+10][MAXN+10];
int h,w;
short query(int x1,int y1,int x2,int y2)
{
	if (x1>x2 || y1>y2  || x1<0 || y1<0 || x2>h || y2>w) return -10000;
	return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
}
short f[MAXN+5][MAXN+5][MAXN+5][MAXN+5];
short max(short a,int b) {
	return max(int(a),b);
}
int main(){	
#ifdef WAAUTOMATON
	freopen("in.txt","r",stdin);
#endif
	
	cin>>h>>w;
	int sx,sy;
	for(int i=1; i<=h; ++i) {
		for(int j=1; j<=w; ++j) {
			char t;
			cin>>t;
			if (t=='E') {
				sx=i; sy=j;
			} else if (t=='o') {
				a[i][j]=1;
			}
		}
	}
	for(int i=1; i<=h; ++i) {
		for(int j=1; j<=w; ++j) {
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
			//debug(s[i][j]);
		}
	}
	for(int l=0; l<w; ++l) {
		for(int u=0; u<h; ++u) {
			for(int r=0; r<w-l; ++r) {
				for(int d=0; d<h-u; ++d) {
					//debug(l,u,r,d,f[l][u][r][d]);
					if (sy-(l+1)>r)
					f[l+1][u][r][d]=max(f[l+1][u][r][d],f[l][u][r][d]
						+query(max(sx-u,d+1),sy-(l+1),min(sx+d,h-u),sy-(l+1)));
					if (sx-(u+1)>d)
					f[l][u+1][r][d]=max(f[l][u+1][r][d],f[l][u][r][d]
						+query(sx-(u+1),max(r+1,sy-l),sx-(u+1),min(w-l,sy+r)));
					if (sy+(r+1)<=w-l)
					f[l][u][r+1][d]=max(f[l][u][r+1][d],f[l][u][r][d]
						+query(max(sx-u,d+1),sy+(r+1),min(sx+d,h-u),sy+(r+1)));
					if (sx+(d+1)<=h-u)
					f[l][u][r][d+1]=max(f[l][u][r][d+1],f[l][u][r][d]
						+query(sx+(d+1),max(r+1,sy-l),sx+(d+1),min(w-l,sy+r)));
				}
			}
		}
	}

	//debug(4,0,0,1,f[4][0][0][1]);
	//debug(5,0,0,0,f[5][0][0][0]);
	int ans=*max_element(&f[0][0][0][0],&f[w][h][w][h]+1);
	cout<<ans<<endl;		
	return 0;
}

Measured memory_bytes: 227584
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int main(){
    int H, W;
    while(cin >> H >> W){
        vector<string> str(H);
        REP(i, H) cin >> str[i];

        const int MAXS = 1 << W;
        vector<int> dp(MAXS, -INF);
        dp[0] = 0;
        for(int y = 0; y < H; y++){
            for(int x = 0; x < W; x++){
                vector<int> next(MAXS, -INF);
                for(int s = 0; s < MAXS; s++) if(dp[s] >= 0){
                    int cu = __builtin_popcount(s >> x); // count of upper
                    int cl = __builtin_popcount(s & ((1 << x) - 1)); // count of lower
                    assert(cu + cl == __builtin_popcount(s));

                    if(cl + (W - 1 - x) >= str[y].size())
                        next[s & ~(1 << x)] = max(next[s & ~(1 << x)], dp[s]); // path through

                    if(cl == str[y].size()) continue;

                    int add = 0;
                    if(cl > 0 && str[y][cl] == str[y][cl - 1] && (s >> (x - 1) & 1)){
                        add += 2;
                    }
                    if(y > 0 && (s >> x & 1) && str[y - 1][str[y - 1].size() - cu] == str[y][cl]){
                        add += 2;
                    }
                    next[s | (1 << x)] = max(next[s | (1 << x)], dp[s] + add);
                }
                dp.swap(next);
            }
        }
        int ans = 0;
        for(int s = 0; s < MAXS; s++) ans = max(ans, dp[s]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1684
PROGRAM-ID.                      ABC_103_C.
ENVIRONMENT                      DIVISION.
INPUT-OUTPUT                     SECTION.
FILE-CONTROL.
    SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA                             DIVISION.
FILE                             SECTION.
    FD  SYSIN.
        01 INDATA PIC X(21000).

WORKING-STORAGE                  SECTION.
    01 N       PIC 9(4).
    01 INP     PIC X(21000).

    01 maxlen  PIC 9(4) VALUE 3000.
    01 cur     PIC 9(5) VALUE 1.
    01 i       PIC 9(18) VALUE 1.
    01 j       PIC 9(18).
    01 len     PIC 9(5).
    01 ans     PIC X(9).

    01 a       PIC 9(6).
    01 sm      PIC 9(9).

    01 ZS      PIC Z(10).
    01 DUMMY   PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT N.

    OPEN INPUT SYSIN.

    READ SYSIN INTO INP.

    CLOSE SYSIN.

    MOVE ZERO TO sm.

    MOVE N TO maxlen.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO a

        SUBTRACT 1 FROM a

        ADD a TO sm

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    MOVE sm TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 384
#include <stdio.h>
#define N 200002
typedef long long LL;

int a[N];
LL s[N][2];

int read()
{
	char c, f = 0;
	while((c = getchar()) < 48 || c > 57){
		if(c == '-') f = 1;
	}
	int x;
	if(!f){
		x = c - 48;
		while((c = getchar()) > 47 && c < 58) x = x * 10 + (c - 48);
	}
	else{
		x = 48 - c;
		while((c = getchar()) > 47 && c < 58) x = x * 10 - (c - 48);
	}
	return x;
}

int main()
{		
	int n, i;
	LL s1 = 0, s2 = 0, t, x;
	
	scanf("%d", &n);
	for(i = 1; i <= n; i++){
		a[i] = read();
	}
	if(n % 2 == 0){
		s[1][0] = (LL)a[1], s[2][0] = (LL)a[2];
		for(i = 3; i <= n; i++){
			if(i & 1){
				s[i][0] = s[i - 2][0] + (LL)a[i];
			}
			else{
				t = s[i - 2][0];
				if((x = s[i - 3][0]) > t) t = x;
				s[i][0] = t + (LL)a[i];
			}
		}
		t = s[n][0];
		if((x = s[n - 1][0]) > t) t = x;
		printf("%lld\n", t);
		return 0;
	}
	
	s[1][0] = (LL)a[1], s[2][0] = (LL)a[2];
	s[3][1] = (LL)a[3], s[3][0] = (LL)(a[1] + a[3]);
	for(i = 4; i <= n; i++){
		if(i & 1){
			s[i][0] = s[i - 2][0] + (LL)a[i];
			t = s[i - 2][1];
			if((x = s[i - 3][0]) > t) t = x;
			if((x = s[i - 4][0]) > t) t = x;
			s[i][1] = t + (LL)a[i];
		}
		else{
			t = s[i - 2][0];
			if((x = s[i - 3][0]) > t) t = x;
			s[i][0] = t + (LL)a[i];
		}
	}
	t = s[n][1];
	if((x = s[n - 1][0]) > t) t = x;
	if((x = s[n - 2][0]) > t) t = x;
	printf("%lld\n", t);
			
	return 0;
}

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

int i, h, w;

long long solve(int h, int w) {
  if(h % 3 == 0 || w % 3 == 0) return 0;

  long long ans = w;
  long long aux = 1LL * h * w / 3;
  long long fst = 0;

  while(fst <= h) {
    long long z = 1LL * fst * w;
    long long x = 1LL * (w / 2) * (h - fst);
    long long c = 1LL * h * w - z - x;
    ans = min(ans, max({c, x, z}) - min({c, x, z}));
    ++fst;
  }

  return ans;
}

int main() {
  ios_base::sync_with_stdio(0);

  cin >> h >> w;

  cout << min(solve(h, w), solve(w, h)) << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    long long q, h, s, d; cin >> q >> h >> s >> d;

    int n; cin >> n;

    long long a_2l[] = {8*q, 4*h, 2*s, d};

    long long minv = 1e10;
    int i_2l = 0;
    int i_1l = 0;
    for(int i=0; i<4; i++){
        if(minv > a_2l[i]){
            minv = a_2l[i];
            i_2l = i;
            if(i < 3){
                i_1l = i;
            }
        }
    }

    long long ans = (n / 2) * a_2l[i_2l];
    if(n % 2 == 1){
        ans += a_2l[i_1l]/2;
    }
       
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a = []
for _ in range(3):
    a += list(map(int, input().split()))
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a:
        i = a.index(b)
        a[i] = 0
if sum(a[0:3]) == 0 or sum(a[3:6]) == 0 or sum(a[6:]) == 0 \
    or sum(a[0::3]) == 0 or sum(a[1::3]) == 0 or sum(a[2::3]) == 0 \
    or sum(a[0::4]) == 0 or sum(a[2:7:2]) == 0:
    print("Yes")
else:
    print("No")


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

int main(){
  int N,i;
  bool B = true;
  cin >>N;
  vector<int> A(N);

  for(i=0;i<N;i++)
  cin >> A.at(i);

  for(i=0;i<N;i++){
    if(A.at(i)%2 == 0){
      if(A.at(i)%3!=0&&A.at(i)%5!=0){
        B = false;
        break;
      }
    }
  }
  if(B)
  cout << "APPROVED";
  else
  cout << "DENIED";
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = INPUT()

    if S == "hi" or S == "hihi" or S == "hihihi" or S == "hihihihi" or S == "hihihihihi": print("Yes")
    else: print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a), greater<ll>());
  ll ans = 0;
  REP(i, n){
    if(i%2 == 0) ans += a[i];
    else ans -= a[i];
  }
  cout << ans << endl;
}

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

typedef struct node{
    char s[11];
    int p;
    int id;
}node;

int cmp(const void* a, const void* b){
    if(strcmp(((node*)a)->s, ((node*)b)->s) == 0){
        return ((node*)b)->p - ((node*)a)->p;
    }else{
        return strcmp(((node*)a)->s, ((node*)b)->s);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    node a[n];
    for(int i=0; i<n; i++){
        a[i].id = i+1;
        scanf("%s%d", a[i].s, &a[i].p);
    }
    qsort(a, n, sizeof(node), cmp);
    for(int i=0; i<n; i++){
        printf("%d\n", a[i].id);
    }

    return 0;
}

Measured memory_bytes: 128
k = gets.to_s.to_i

if k.even? || (k % 5).zero?
  puts -1
  exit
end

s = 0
(1 .. 10**6).each do |i|
  s = (s * 10 + 7) % k
  if s == 0
    puts i
    exit
  end
end

puts -1

Measured memory_bytes: 14324
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int x, y;
        cin >> x >> y;
        if(x % y){
            cout << x << '\n';
        }else{
            cout << "-1\n";
        }
    }
}

Measured memory_bytes: 31488
#include<stdio.h>

int  main(void){
	int x,y,n;
	int i=0;
	scanf("%d", &x);
	scanf("%d", &y);
	while(y!=0){
	if(x<y){
		n =y;
		y =x;
		x =n;
	}
	n = x%y;
	x = y;
	y =n;
	}
	printf("%d\n", x);
	return 0;

}


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

int main()
{
    int a,b;

    cin>>a>>b;

    if(a<10 && b<10)
    {
        cout<<a*b<<endl;
    }
    else
    {
        cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  int n;
  cin >> n;
  vecint ans(n, 0);
  // map<int, int> g;
  REP(i, n - 1) {
    int tmp;
    cin >> tmp;
    tmp--;
    ans[tmp]++;
  }
  REP(i, n) { cout << ans[i] << endl; }
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    int ans = 700;
    REP(i,s.size()) {
        if(s[i] == 'o') ans += 100;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, i, j, k, x, ans = 0;
    
    while(1){
        scanf("%d %d", &n, &x);
        
        if(n==0 && x==0){
            break;
        }
        
        ans = 0;
        
        for(i=1; i<=n; i++){
            for(j=2; j<=n; j++){
                for(k=3; k<=n; k++){
                    if((i+j+k)==x && i<j && j<k){
                        ans = ans + 1;
                    }
                }
            }
        }
        
        printf("%d\n", ans);
    }
    
    return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  string t;cin>>t;
  int sn=s.length();
  int tn=t.length();
  vector<vector<int>> dp(sn,vector<int>(tn,0));
  int flag=0;
  rep(i,sn){
      if(s[i]==t[0])flag=1;
      dp[i][0]=flag;
  }
  flag=0;
  rep(i,tn){
      if(s[0]==t[i])flag=1;
      dp[0][i]=flag;
  }
  rep1(i,sn-1){
      rep1(j,tn-1){
          dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
          if(s[i]==t[j])dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
      }
  }
  string res;
  int i=sn-1;int j=tn-1;
  while(true){
      while(j>0&&dp[i][j]==dp[i][j-1])--j;
      while(i>0&&dp[i][j]==dp[i-1][j])--i;
      //if(j==0&&i==0)break;
      if(s[i]==t[j])res+=s[i];
      if(i>0)--i;else break;
      if(j>0)--j;else break;
  }
  reverse(ALL(res));
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 38552
#include<stdio.h>

int main(void)
{
	int W, H, x, y, r, i;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	i = 0;
	if (x + r>W)i = 1;
	if (y + r>H)i= 1;
	if (r>x)i = 1;
	if (r>y)i= 1;

	if (i == 0)printf("Yes\n");
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll arr[n][3];
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < 3; j++)
            cin>>arr[i][j];
    }
    vector<vector<ll> >ans(n,vector<ll>(3));
    for(ll i = 0; i < 3; i++)
        ans[0][i] = arr[0][i];
    for(ll i = 1; i < n; i++)
    {
        ans[i][0] = arr[i][0] + max(ans[i-1][1], ans[i-1][2]);
        ans[i][1] = arr[i][1] + max(ans[i-1][0], ans[i-1][2]);
        ans[i][2] = arr[i][2] + max(ans[i-1][0], ans[i-1][1]);
    }
    cout<<max(ans[n-1][0], max(ans[n-1][1], ans[n-1][2]));
}

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

int main(){
  const int H500= 1000;
  const int H5= 5;
  int X;
  cin >> X;

  int N500= X/500;
  int N5= (X- 500*N500)/5;
  int ans= H500*N500+ H5*N5;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int H, A;

int main () {
  cin >> H >> A;

  int ans = (H % A == 0) ? (H / A) : (H / A + 1);
  cout << ans << "\n";
}

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

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

    vector<vector<long long int>> work(n,vector<long long int>(2));// (deadline, time)
    for(int i=0; i<n; i++){
        long long int a, b;
        cin >> a >> b;
        work[i][0] = b;
        work[i][1] = a;
    }

    sort(work.begin(),work.end());

    int current_time = 0;
    for(int i=0; i<n; i++){
        current_time += work[i][1];
        if(current_time > work[i][0]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 11136
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
int N;
vector<int> A;

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

    cin >> N;
    A.resize(N);

    vector<int> cnt(2);

    map<int, int> cache;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        cache[A[i]]++;
    }

    int buffer = 0;

    for (auto entry : cache) {
        cnt[entry.second % 2]++;
    }

    if (cnt[0] & 1) {
        cout << cache.size() - 1 << "\n";
    } else {
        cout << cache.size() << "\n";
    }

    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
// #define inf 1e15
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	int n;
	cin>>n;
	int a[n];
	int f=0;
	f(i,0,n-1)
	{
		cin>>a[i];
		if(a[i]==0)
		f=1;
	}
	if(f)
	{
		cout<<0;
		return;
	}
	int tot=a[0];
	int inf=1e18;
	f(i,1,n-1)
	{
		int cap=inf/tot;
		if(a[i]>cap)
		{
			cout<<-1;
			return;
		}
		tot*=a[i];
	}
	cout<<tot;

}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


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

int main()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  int a = N%10;

  if(a==2||a==4||a==5||a==7||a==9){
    cout<<"hon"<<endl;
  }
  else if(a==3){
    cout<<"bon"<<endl;
  }
  else{
    cout<<"pon"<<endl;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h> 
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(long long int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
signed main() 
{
    fast
   
        ll x1,x2,x3,x4,x5;
        cin>>x1>>x2>>x3>>x4>>x5;
        if(x1==0) cout<<"1\n";
        if(x2==0) cout<<"2\n";
        if(x3==0) cout<<"3\n";
        if(x4==0) cout<<"4\n";
        if(x5==0) cout<<"5\n";
       
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, std::vector<long long> A){

    vector<lli> v;

    REP(i,0,N){
        lli num = A[i];
        auto itr = upper_bound(v.begin(),v.end(),num);
        if(itr == v.end()){
            v.push_back(num);
        }
        else{
            *itr = num;
        }
    }

    cout<<v.size()<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        A[i] *= -1;
    }
    func(N, std::move(A));
    return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> ID(N + 1);
	for (int i = 0; i < M; i++) {
		int L, R;
		cin >> L >> R;
		ID.at(L - 1)++;
		ID.at(R)--;
	}
	for (int i = 0; i < N; i++) {
		if (i != 0) {
			ID.at(i) += ID.at(i - 1);
		}
	}

	/*for (int i = 0; i < N; i++) {
		cout << ID.at(i) << " ";
	}
	cout << endl;*/

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (ID.at(i) == M) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int dp[N];
vi adj[N];
int dfs(int id){
    if(dp[id]!=-1) return dp[id];
    dp[id]=0;
    for(auto i:adj[id]) dp[id] = max(dp[id], 1+dfs(i));
    return dp[id];
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n>>k;
    rep(i, 1, n+1) adj[0].pb(i);
    rep(i, 0, k){
        cin>>a>>b;
        adj[a].pb(b);
    }
    memset(dp, -1, sizeof dp);
    cout<<dfs(0)-1;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string s;
    cin >> s;

    if(s.size()%2){ //奇数
        if(s[0]==s[s.size()-1]){
            P("Second");
        }else{
            P("First");
        }
    }else{ //偶数
        if(s[0]==s[s.size()-1]){
            P("First");
        }else{
            P("Second");
        }
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int N;
double ans,t[202],v[202],m1[202],m2[202];
const double EPS{10e-9};
int main(){
    cin>>N;
    for(int i{1};i<=N;++i)cin>>t[i];
    for(int i{};i<N;++i)cin>>v[i];
    for(int i{};i<N;++i){
        m1[i+1]=min(m1[i]+t[i+1],v[i]);
        m2[N-i]=min(m2[N+1-i]+t[N+1-i],v[N-i]);
    }
/*    for(int i{};i<N+2;++i)
        cout<<m1[i]<<' ';
    cout<<endl;
    for(int i{};i<N+2;++i)
        cout<<m2[i]<<' ';
        cout<<endl;*/
    double vp{};
    for(int i{};i<N;++i){
        double m{min(m1[i+1],m2[i+1])};
        double d{t[i+1]};
        double s{v[i]-m};
        double ss{v[i]-vp};
        if(d-s-ss<EPS){
            double x{(vp+m+d)/2.0};
            ans+=vp*(x-vp)+pow(x-vp,2)/2.0;
            double y{d-x+vp};
            vp=x;
            ans+=vp*y-pow(y,2)/2.0;
            vp=m;
        }
        else{
            ans+=vp*ss+pow(ss,2)/2.0;
            double y{d-s-ss};
            ans+=y*v[i];
            ans+=v[i]*s-pow(s,2)/2.0;
            vp=m;
        }
    }
    cout.precision(4);
    cout<<fixed<<ans<<endl;
}


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

int main(){
    int x,y,ans=0;
    cin>>x>>y;
    if(x==1)ans+=300000;
    if(y==1)ans+=300000;
    if(x==2)ans+=200000;
    if(y==2)ans+=200000;
    if(x==3)ans+=100000;
    if(y==3)ans+=100000;
    if(x==1&&y==1)ans+=400000;
    cout<<ans<<endl;
    return 0;

}

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

int main(){
    int n,m;
    cin >> n >> m;
    if(n<=m){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3656
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int H, W;
    cin >> H >> W;
    string a[H];
    rep(i,H) cin >> a[i];

    rep(i,W+2) cout << "#";
    cout << endl;
    for(int i=0; i<H; i++){
        cout << "#" << a[i] << "#" << endl;
    }
    rep(i,W+2) cout << "#";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,m,i,maxl,minr;
    scanf("%d %d",&n,&m);
    int l[m],r[m];
    for(i=0;i<m;i++){
        scanf("%d %d",&l[i],&r[i]);
    }
    maxl = l[0];
    minr = r[0];
    for(i=0;i<m-1;i++){
        if(maxl<l[i+1]) maxl = l[i+1];
        if(minr>r[i+1]) minr = r[i+1];
    }
    if(maxl>minr) printf("0");
    else
    {
        printf("%d",minr-maxl+1);
    }
    
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


struct UnionFind{
	std::vector<int> data;
	// dataの各要素について
	// 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
	// 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

	//初期化 size:最大要素数
	UnionFind(int size): data(size, -1) {}
	
	// 集合を併合する
	// すでに同じ集合だった場合は、falseが返る
	bool unite(int x, int y){
		x=root(x);
		y=root(y);
		if( x != y ){
			// 要素数の大きな方へ合併するためのswap
			if( data[y] < data[x] ) std::swap(x, y);
			// 要素数を加算する
			data[x] += data[y];
			// yの属する集合のルートをxに変更
			data[y] = x;
		}
		return x!=y;
	}

	// 同じ集合かどうか判定
	bool find(int x, int y){
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	int root(int x){
		// 負の値を持つものがその集合のルート
		// 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}

	// 集合の要素数を返す
	int size(int x){
		return -data[ root(x) ];
	}
};

int main(){
	//ios_base::sync_with_stdio(0);
	ll N, ans=0;
	ll A[305][305];
	ll B[305][305];
	vector<pair<ll,pii>> v;

	cin >> N;
	rep(i,N) rep(j,N){
		cin >> A[i][j];
		B[i][j] = A[i][j];
		v.emplace_back(A[i][j], pii(i,j) );
	}

	sort(all(v));

	rep(k,N) rep(i,N) rep(j,N){
		chmin(B[i][j], B[i][k] + B[k][j]);
	}
	bool f=true;
	rep(i,N) rep(j,N){
		if( A[i][j] != B[i][j] ) f = false;
	}
	if(!f){
		cout << -1 << endl;
		return 0;
	}

	ll C[305][305];
	Fill(C, INF);
	rep(i,305) C[i][i] = 0;
	UnionFind uf(305);
	for(auto p: v){
		int len = p.X;
		int i = p.Y.X;
		int j = p.Y.Y;
		//if( !uf.find(i,j) ){
		//	ans += len;
		//	uf.unite(i,j);
		//}
		if(C[i][j] > len){
			ans += len;
			rep(a,N) rep(b,N){
				chmin(C[a][b], C[a][i] + C[j][b] + len);
				chmin(C[a][b], C[a][j] + C[i][b] + len);
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4468
/*
title:D - Islands War

url:https://abc103.contest.atcoder.jp/tasks/abc103_d

方針
断行したい島の組み合わせai, biにたいして、二次元座標を作って考えてみる
入力が
5 2 
1 4 
2 5
なら
g/s 1 2 3 4 5
1 
2
3
4     1
5   1
ここで、2番目の橋を破壊するということは
g/s 1 2 | 3 4 5
1       |
2       |
- - - - - - - - 
3       |
4     1 |
5   1   |
上のように区切ることと同義。左下の区間が、断行に成功した島。
必ずai<biなのだから、bi=ai+1の数が答えになる
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    int g_min[N + 1];
    for (int i = 0; i < N + 1; i++)
    {
        g_min[i] = N + 1;
    }

    int a, b;
    for (int i = 0; i < M; i++)
    {
        cin >> a >> b;
        if (g_min[a] > b)
        {
            g_min[a] = b;
        }
    }
    int ans = 0;
    int min = g_min[1];
    for (int i = 1; i <= N - 1; i++)
    {
        if ((min == i + 1) || g_min[i] == i + 1)
        {
            ans++;
            min = g_min[i + 1];
            continue;
        }
        else if (min > g_min[i])
            min = g_min[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
N,M = list(map(int,input().split()))
lst1 = []
for i in range(M):
  lst2 = list(map(int,input().split()))
  lst1.append(lst2)

for j in range(1,N+1):
  ans = 0
  for k in range(M):
    a = lst1[k].count(j)
    #print(j,k,a)
    ans += a
  print(ans)
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
long long ans;
int n;
char s[N];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1); 
	int cnt=0;
	for (int i=n;i;i--)
		if (s[i]=='W')cnt++;
		else ans+=cnt;
	printf("%lld\n",ans);
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll a, b;
    cin >> a >> b;
    if(a>=1&&a<=9&&b>=1&&b<=9) cout << a*b << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.zeros(N+2, np.int32)
A[1:-1] = np.array([ir() for _ in range(N)])

left_max = np.maximum.accumulate(A[:-2])
right_max = np.maximum.accumulate(A[::-1])[::-1][2:]
answer = np.maximum(left_max, right_max)
print('\n'.join(map(str, answer)))


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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    int l;
    cin >> l;

    int j = 32 - __builtin_clz(l) - 1;

    if (l == (1 << j)) {
        cout << j + 1 << ' ' << 2 * j << '\n';
        for (int i = 2; i <= j; i++) {
            cout << i - 1 << ' ' << i << ' ' << 0 << '\n';
            cout << i - 1 << ' ' << i << ' ' << (1 << (j - i + 1)) << '\n';
        }
        cout << j << ' ' << j + 1 << ' ' << 0 << '\n';
        cout << j << ' ' << j + 1 << ' ' << 1 << '\n';
        return 0;
    }

    --l;
    j = 32 - __builtin_clz(l) - 1;
    int sum = (1 << j);

    cout << j + 1 << ' ' << 2 * j + __builtin_popcount(l) << '\n';

    for (int i = j - 1; i >= 0; i--) {
        if (l & (1 << i)) {
            cout << 1 << ' ' << j - i + 1 << ' ' << sum << '\n';
            sum |= (1 << i);
        }
    }
    cout << 1 << ' ' << j + 1 << ' ' << sum << '\n';

    for (int i = 2; i <= j; i++) {
        cout << i - 1 << ' ' << i << ' ' << 0 << '\n';
        cout << i - 1 << ' ' << i << ' ' << (1 << (j - i + 1)) << '\n';
    }
    cout << j << ' ' << j + 1 << ' ' << 0 << '\n';
    cout << j << ' ' << j + 1 << ' ' << 1 << '\n';
    return 0;
}


Measured memory_bytes: 3652
/*
      author  : nishi5451
      created : 15.08.2020 10:47:42
*/

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


int main(){
    int n,l;
    cin >> n >> l;
    int sum = n*(2*l+n-1)/2; 

    if(l+n-1 < 0) cout << sum-(l+n-1) << endl;
    else if(l > 0) cout << sum-l << endl;
    else cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const int WALL = -1;
const int ROAD = 1;
const int MOD = 1000000007;

int f(vector<vector<int>>& dp, int H, int W, int vi, int vj){
    if(dp[vi][vj] != -1)return dp[vi][vj];
    
    int a = vi+1 < H ? f(dp, H, W, vi+1, vj) : 0;
    int b = vj+1 < W ?  f(dp, H, W, vi, vj+1) : 0;
    dp[vi][vj] =  (a + b) % MOD;
    return dp[vi][vj];
}

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<int>> grid(H, vector<int>(W));
    vector<vector<int>> dp(H,vector<int>(W,-1));
    for(int i = 0;i < H;i++){
        string s;cin>>s;
        for(int j = 0;j < W;j++){
            grid[i][j] = (s[j] == '.') ? ROAD : WALL;
            if(grid[i][j] == WALL)dp[i][j] = 0;
        }
    }
    dp[H-1][W-1] = 1;
    cout<<f(dp, H, W, 0, 0)<<endl;

}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const double EPS = 1e-4;

struct Coor {
	double x, y;
};

double pw(double x) { return x * x; };
int max(int n, int m) { return n > m ? n : m; };

int main()
{
	double n;
	vector<Coor> v(300);

	while (cin >> n) {
		if (n == 0) break;

		

		for (int i = 0; i < n; i++) {
			cin >> v.at(i).x >> v.at(i).y;
		}

		double x1, y1, x2, y2;
		int _max = 1;

		Coor mid;

		for (int i = 0; i < n-1; i++) {
			x1 = v.at(i).x; y1 = v.at(i).y;

			for (int j = i + 1; j < n; j++) {
				x2 = v.at(j).x; y2 = v.at(j).y;
				mid.x = (x1 + x2) / 2;
				mid.y = (y1 + y2) / 2;

				double d = sqrt(pw(x1 - x2) + pw(y1 - y2));
				double dx = sqrt(1 - pw(d / 2)) * (y1 - y2) / d;
				double dy = sqrt(1 - pw(d / 2)) * (x2 - x1) / d;

				int ct1 = 0, ct2 = 0;

				for (int k = 0; k < n; k++) {
					double tmp = pw(v.at(k).x - (mid.x + dx)) + pw(v.at(k).y - (mid.y + dy));
					if (sqrt(tmp) <= 1.0 + EPS) ct1++;

					tmp = pw(v.at(k).x - (mid.x - dx)) + pw(v.at(k).y - (mid.y - dy));
					if (sqrt(tmp) <= 1.0 + EPS) ct2++;
				}

				_max = max(_max, ct1);
				_max = max(_max, ct2);
			}
		}

		cout << _max << endl;
	}
}


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

int dp[100005], h[100005], n;

int main() {
	scanf("%d", &n);
	for(int i = 1;i <= n; i++) scanf("%d", &h[i]);
	dp[1] = 0; 
	dp[2] = dp[1]+abs(h[2]-h[1]);
	for(int i = 3;i <= n; i++) {
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	
	printf("%d\n", dp[n]);
}

Measured memory_bytes: 4516
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a, b, c;
  cin >> a >> b >> c;
  // cout << SQRT(a) << endl;
  // cout << SQRT(b) << endl;
  // cout << SQRT(c) << endl;
  //
  if (c - a - b <= 0) {
    cout << "No" << endl;
  } else {
    ll po = POW(c, 2) + POW(a, 2) + POW(b, 2) - (2 * a * c) - (2 * a * b) -
            (2 * c * b);
    if (po > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N;
	cin >> N;
	vector <ll> C(N-1, 0);
	vector <ll> S(N-1, 0);
	vector <ll> F(N-1, 0);
	for (int ii = 0; ii < N-1; ++ii){
		cin >> C[ii] >> S[ii] >> F[ii];
	}

	vector <ll> ans(N, 0);
	for (int ii = 0; ii < N-1; ++ii){
		for (int jj = ii; jj < N-1; ++jj){
			if (ans[ii] < S[jj]){
				ans[ii] = S[jj] + C[jj];
			} else {
				ll mul = (ans[ii] - S[jj] + F[jj] - 1) / F[jj];
				ans[ii] = S[jj] + mul * F[jj] + C[jj];
			}
		}
	}
	

	for (int ii = 0; ii < N; ++ii){
		cout << ans[ii] << "\n";
	}

	

	return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<pii>a(N); rep(i, 0, N) { cin >> a[i].first; a[i].second = i; }
	sort(all(a));
	reverse(all(a));
	a.eb(0, -1);
	dump(a);
	int j = a[0].second;
	vector<int>ans(N);
	rep(i, 0, N) {
		chmin(j, a[i].second);
		ans[j] += (a[i].first - a[i+1].first)*(i + 1);
	}
	rep(i, 0, N) { cout << ans[i] << endl; }


	return 0;
}


Measured memory_bytes: 4864
/* 
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    int n, k;
    cin >> n >> k;
    vector<int> h(n+5);
    for(int i = 0; i < n; ++i) cin >> h[i];

    vector<int> dp(n+5, 2e9);
    dp[0] = 0;
    for(int i = 1; i < n; ++i)
    {
        for(int j = 1; j <= k; ++j)
        {
            if(i-j < 0) break;
            dp[i] = min(dp[i], abs(h[i]-h[i-j]) + dp[i-j]);
        }
    }
    cout << dp[n-1] << "\n";
    return 0; 
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main()
{
	bool A = false;
	bool AC = false;
	char x[6] = { 0 };
	scanf("%s", x);
	int c = strlen(x);
	for (int i = 0;i < c;i++)
	{
		if (A)
		{
			if (x[i] == 'C')
			{
				AC = true;
			}
			else
			{
				A = false;
			}
		}
		if (x[i] == 'A')
		{
			A = true;
		}

	}
	if (AC)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
    return 0;
}


Measured memory_bytes: 128