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

using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k; i++) {
        ans += p[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>

int compare(const void *a, const void *b){
  return (*(int *)a)- (*(int *)b);
}
 
int main(){
  int a,b,m,sum,tmp,tmpa=INT_MAX,tmpb=INT_MAX;
  scanf("%d%d%d",&a,&b,&m);
  int A[a],B[b],ans;
  for(int i=0;i<a;i++){
    scanf("%d",&A[i]);
    if(A[i]<tmpa){
      tmpa=A[i];
    }
  }
  for(int i=0;i<b;i++){
    scanf("%d",&B[i]);
    if(B[i]<tmpb){
      tmpb=B[i];
    }
  }
  int x[m],y[m],C[m];
  for(int i=0;i<m;i++){
    scanf("%d%d%d",&x[i],&y[i],&C[i]);
  }
  
  ans=tmpa+tmpb;
  
  for(int i=0;i<m;i++){
    sum = A[x[i]-1]+B[y[i]-1]-C[i];  
    if(sum<ans){
      ans=sum;
    }
  }
  printf("%d",ans);
  
  return 0;
}

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


int main()
{
    string a,b;
    cin >> a >> b ;
    int n = a.size();
    int m = b.size();
    int dp[n + 1][m + 1];
    for(int i = 0; i <= n; i++)
        dp[i][0] = 0;
    for(int i = 0; i <= m; i++)
        dp[0][i] = 0;

    string ans;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            dp[i][j] = max(dp[i - 1][j],dp[i][j - 1]);
            if(a[i - 1] == b[j - 1]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
        }
    }
    int i = n;

    for(int j = m; j >= 1 && i >= 1;)
    {
        if(dp[i][j] == dp[i][j - 1])
        {
            j--;
        }
        else if(dp[i][j] == dp[i - 1][j])
        {
            i--;
        }
        else if(dp[i][j] == dp[i - 1][j - 1] + 1 && a[i - 1] == b[j - 1])
        {
            ans += b[j - 1];
            i--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans << '\n' ; 
    return 0;
}

Measured memory_bytes: 35584
s=int(input())

a=s//100
b=s%100

notYYMM = b < 1 or 12 < b

notMMYY = a < 1 or 12 < a

if notYYMM and notMMYY:
    print("NA")
elif not notYYMM and not notMMYY:
    print("AMBIGUOUS ")
elif not notYYMM and notMMYY:
    print("YYMM")
elif notYYMM and not notMMYY:
    print("MMYY")

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  string a;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      a += "0";
    } else if (s[i] == '1') {
      a += "1";
    } else {
      if (a.size() != 0) {
	int k = a.size();
	a = a.substr(0, k-1);
      }
    }
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define flb(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define mp make_pair
#define pb push_back
#define inf (long long)(1e18+1e15)
typedef pair<int,int> ii;
typedef vector <ll> vi;
typedef vector <pair<int,int> > vii;
typedef vector <vector <int> > vvi;
vector <int> v(101);
vector <int> w(101);
int n,weig;
ll calculated[101][100001];
ll solve(int i,int wt)
{
    if(wt<0)
        return (-inf);
    if(i==n)
        return 0;
    if(calculated[i][wt]!=-1)
        return calculated[i][wt];
    if(wt-w[i]<0)
        calculated[i][wt]=solve(i+1,wt);
    else
    {
        calculated[i][wt]=max(v[i]+solve(i+1,wt-w[i]),solve(i+1,wt));
    }
    return calculated[i][wt];
}
int main()
{
    cin>>n>>weig;
    memset(calculated,-1,sizeof(calculated));
    ll ans=(-inf);
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    ans=max(v[0]+solve(1,weig-w[0]),solve(1,weig));
    cout<<ans;
}


Measured memory_bytes: 79104
# -*- encoding: Shift_JIS -*-
class Node
  attr_accessor :key, :left, :right
  def initialize key
    @key = key
  end

  def inorder
    left.inorder if left
    print " ", key
    right.inorder if right
  end

  def preorder
    print " ", key
    left.preorder if left
    right.preorder if right
  end
end

def insert
  z = Node.new $key.to_i
  x = $root
  while x
    y = x  #???????¨????
    x = z.key < x.key ? x.left : x.right  #?????????????§????/?????????????§????
  end

  unless y  #y???nil?????´???
    $root  = z
  else
    z.key < y.key ? y.left = z : y.right = z  #z???y?????????????????????/z???y?????????????????????
  end
end

n = gets.to_i
n.times do
  command, $key = gets.split
  if command == "insert"
    insert
  else
    $root.inorder
    puts 
    $root.preorder
    puts
  end
end

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    ll n;
    int m;
    ll sum=0;
    cin >> n >> m;
    rep(i, m)
    {
        int a;
        cin >> a;
        sum += a;
    }
    ll res = n - sum;
    if (res < 0)
        res = -1;
    c(res);
}


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

int D[31][31], convert[3][31];

int main() {
    int N, C;
    scanf("%d%d", &N, &C);
    for (int i = 1; i<=C; i++){
        for (int j = 1; j<=C; j++){
            scanf("%d", &D[i][j]);
        }
    }
    for (int i = 1; i<=N; i++){
        for (int j = 1; j<=N; j++){
            int x;
            scanf("%d", &x);
            for (int k = 1; k<=C; k++){
                convert[(i+j)%3][k] += D[x][k];
            }
        }
    }
    int best = 1e9;
    for (int i = 1; i<=C; i++){
        for (int j = 1; j<=C; j++){
            for (int k = 1; k<=C; k++){
                if (i==j || j==k || k==i)
                    continue;
                best = min(best, convert[0][i] + convert[1][j] + convert[2][k]);
            }
        }
    }
    printf("%d", best);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
ll gcd(ll a, ll b){
    if(!b) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int main(){
    ll a,b;
    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;cin >> h >> w;
    char a[h][w];
    queue<pair<int,int>> q;
    vector<vector<int>> d(h,vector<int>(w,inf));
    REP(i,h){
        REP(j,w){
            cin >> a[i][j];
            if(a[i][j]=='#'){
                q.push({i,j});
                d[i][j]=0;
            }
        }
    }
    while(!q.empty()){
        int u=q.front().first,v=q.front().second;
        q.pop();
        REP(i,4){
            int x=u+dx[i],y=v+dy[i];
            if(x>=0&&x<h&&y>=0&&y<w){
                if(chmin(d[x][y],d[u][v]+1)){
                    q.push({x,y});
                }
            }
        }
    }
    int ans=0;
    REP(i,h) REP(j,w) chmax(ans,d[i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 16324
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;

LL N, M;

int X[55], Y[55];
int main() {
    //cout << fixed << setprecision(15);

    int n; cin >> n;
    for(int i=0; i<n; ++i) cin >> X[i] >> Y[i];

    map<pair<int, int>, int> dxy;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            if(i==j) continue;
            dxy[{X[i]-X[j], Y[i]-Y[j]}]++;
        }
    }

    int ans = n;
    for(auto e: dxy){
        ans = min(ans, n-e.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
    public static void main(String args[]){
	try{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String str;
	    boolean s[] = new boolean[1000000];
	    int maxnum = 1000000;
	    int count = 0;
	    int sc[] = new int[1000000];
	    s[0] = false;//?´???°??§?????????
	    s[1] = false;
	    for (int i = 2; i < maxnum; i++) {
		s[i] = true;  //?´???°
	    }
	    for (int i = 1; i < maxnum; i++) {
		if(s[i] == true){
		    count++;
		    for (int j = i+i; j < maxnum; j+=i) {
			s[j]=false;
		    }
		}
		sc[i] = count;
	    }
	    while(null != (str = br.readLine())){
		int n = Integer.parseInt(str);
		System.out.println(sc[n]);
	    }
	}
	catch(Exception e){
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 26180
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

int main() {
  double L; cin >> L;
  cout << setprecision(10);
  cout << fixed << L*L*L/27. << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let mut ret = 0;
    let d: i64 = read();

    for _ in 0..n {
        let x: i64 = read();
        let y: i64 = read();

        if x * x + y * y <= d * d {
            ret += 1;
        }
    }
    println!("{}", ret);
}


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

typedef long long int ll;

int main()
{
	ll n,w;
	cin>>n>>w;
	std::vector<pair<ll,ll> > val(n);
	ll sm = 0;
	for (int i = 0; i < n; ++i)
	{
		cin>>val[i].first>>val[i].second;
		sm += val[i].second;
	}
	std::vector<std::vector<ll> > v(n);
	for (int i = 0; i < n; ++i)
	{
		v[i].resize(sm+1);
	}
	for (int i = 0; i <= sm; ++i)
	{
		v[0][i] = -1;
	}
	v[0][val[0].second] = val[0].first;
	v[0][0] = 0;
	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j <= sm; j++)
		{
			if(val[i].second <= j)
			{
				if(v[i-1][j-val[i].second] != -1)
				{
					if(v[i-1][j] != -1)
					{
						v[i][j] = min(v[i-1][j-val[i].second]+val[i].first, v[i-1][j]);
					}
					else
						v[i][j] = v[i-1][j-val[i].second]+val[i].first;
				}
				else
				{
					v[i][j] = v[i-1][j];
				}
			}
			else
			{
				v[i][j] = v[i-1][j];
			}
		}
	}
	for(int i = sm; i >= 0; i--)
	{
		if(v[n-1][i] != -1 && v[n-1][i] <= w)
		{
			cout<<i<<'\n';
			break;
		}
	}
}

Measured memory_bytes: 78592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int a[505][505];

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;

    for (int i = 0; i < M; i++) {
        int l, r; cin >> l >> r;
        a[r][l] += 1;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            a[i][j] += a[i][j-1];
        }
    }
    for (int i = 0; i < Q; i++) {
        int p, q; cin >> p >> q;
        int sum = 0;
        for (int j = p; j <= q; j++) {
            sum += a[j][q] - a[j][p-1];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
/* nichijou */
template<class T,class U>
bool cmax(T & a, const U & b) {return a < b ? a = b, 1 : 0;}
template<class T,class U>
bool cmin(T & a, const U & b) {return b < a ? a = b, 1 : 0;}
/* data type */
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second
/* STL container */
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back
/* I gave you my heart and then you turned around. */
void _BG(const char * s) {cerr<<s<<endl;}
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
    for (size_t c = 0; *s && (c || *s != ','); cerr << *s++)
        c += count(ALL("([{"),*s) - count(ALL(")]}"),*s);
    cerr << " = " << a;
    if (*s) {
        cerr << ", ";
        ++s;
    }
    _BG(s,b...);
}
#ifdef PR3PONY
#define BG(...) do { \
    cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
    _BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)
#else
#define BG(...)
#endif
/* Good Luck && Have Fun ! */
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    double l;
    cin >> l;
    cout << fixed << setprecision(16) << pow(l / 3, 3) << endl;
}


Measured memory_bytes: 512
from sys import stdin 
n = int(stdin.readline())
a = [0] + map(int,stdin.readline().split())
ans = 0 
for i in xrange(1,n+1):
    ans += abs(a[i] - a[i-1])
ans += abs(a[n])
b = []
cur = abs(a[2])
for i in xrange(3,n+1):
    cur += abs(a[i] - a[i-1])
cur += abs(a[n])
b.append(cur)

for i in xrange(2,n):
    cur = ans - abs(a[i]-a[i-1]) - abs(a[i] - a[i+1]) + abs(a[i-1]-a[i+1])
    b.append(cur)
cur = 0
for i in xrange(1,n):
    cur += abs(a[i]-a[i-1])
cur += abs(a[n-1])
b.append(cur)
for i in b:
    print i
    
    

Measured memory_bytes: 11108
n = int(input())

h = list(map(int,input().split()))

if n == 1:
    print(0)
else:
    b = 0
    c = 0
    for i in range(n-1):
        if h[i] >= h[i + 1]:
            b += 1
            c = max(c,b)
        else:
            c = max(c,b)
            b = 0
    print(c)


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, h, w);
    Cins(string, h, s);
    
    Vec2(int, h, w, ci);
    Vec2(int, h, w, cj);
    For(i, h){
        int l = 0;
        while(l < w){
            while(l < w && s[i][l] == '#') l ++;
            if(l == w) break;
            int r = l+1;
            while(r < w && s[i][r] == '.') r ++;
            for(int t = l; t < r; t ++) cj[i][t] = r-l;
            l = r+1;
        }
    }
    For(j, w){
        int l = 0;
        while(l < h){
            while(l < h && s[l][j] == '#') l ++;
            if(l == h) break;
            int r = l+1;
            while(r < h && s[r][j] == '.') r ++;
            for(int t = l; t < r; t ++) ci[t][j] = r-l;
            l = r+1;
        }
    }
    
    int ans = 0;
    For(i, h) For(j, w){
        ans = max(ans, ci[i][j] + cj[i][j]);
    }
    Cout(ans - 1);
}


Measured memory_bytes: 35712
#dp[i][j][k]=(i,j)にアイテムをk個以下使って移動するときの最大値
#入力
r,c,k=list(map(int,input().split()))

rck=[[0 for i in range(c+1)] for j in range(r+1)]
for i in range(k):
     r_num,c_num,k_num=list(map(int,input().split()))
     rck[r_num][c_num]=k_num

#dpテーブルと初期条件
dp_0=[[0 for j in range(c+1)] for k in range(r+1)]
dp_1=[[0 for j in range(c+1)] for k in range(r+1)]
dp_2=[[0 for j in range(c+1)] for k in range(r+1)]
dp_3=[[0 for j in range(c+1)] for k in range(r+1)]
#dp
for i in range(1,r+1):
  for j in range(1,c+1):
    dp_1[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_0[i][j-1]+rck[i][j],dp_0[i][j],dp_1[i][j-1])
    dp_2[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_1[i][j-1]+rck[i][j],dp_1[i][j],dp_2[i][j-1])
    dp_3[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_2[i][j-1]+rck[i][j],dp_2[i][j],dp_3[i][j-1])
    
    
    
    
    #dp[i][j][k]=max(dp[i-1][j][3]+rck[i][j],dp[i][j-1][k-1]+rck[i][j],dp[i][j][k-1],dp[i][j-1][k])
    #print(dp[i][j])
print(dp_3[r][c])

     
      


  

Measured memory_bytes: 463780
#include <iostream>

using namespace std;

int main() {
	char c;
	cin >> c;
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	} else {
		cout << "consonant" << endl;
	}

	return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool ok = true;
    REP (i, 0, 3) {
        if (s[i] == s[i + 1]) {
            ok = false;
        }
    }
    cout << (ok ? "Good" : "Bad") << endl;
    return 0;
}


Measured memory_bytes: 256
X = int(input())

def isprime(n):
    if n < 2:
    # 2未満は素数でない
        return False
    if n == 2:
    # 2は素数
        return True
    for p in range(2, n):
        if n % p == 0:
            break
    else:
        return True  #nまでの数で割り切れなかったら素数

while True:
    isprime(X)
    if isprime(X) == True:
        break
    else:
        X = X + 1

print(X)

Measured memory_bytes: 2940
// Package main provides
//
// File:  main.go
// Author:ymiyamoto
//
// Created on Fri Feb  8 08:59:10 2019
//
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println((a + b + 1) / 2)
}


Measured memory_bytes: 512
n = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    exit()
A.sort(reverse=True)
cnt = A[0]
for a in A[1:]:
    cnt *= a
    if cnt > 10 ** 18:
        cnt = -1
        break
print(cnt)

Measured memory_bytes: 21792
H, W = list(map(int, input().split()))
A = []

for i in range(H):
	A.append(list(input()))

judge = "Possible"
x = 0
y = 0
for i in range(H + W - 2):
	if x == W - 1:
		if A[y + 1][x] == "#":
			y += 1
		else:
			judge = "Impossible"
			break
	elif y == H - 1:
		if A[y][x + 1] == "#":
			x += 1
		else:
			judge = "Impossible"
			break

	else:
		if A[y + 1][x] == "#":
			if A[y][x + 1] == "#":
				judge = "Impossible"
				break
			else:
				y += 1
		else:
			if A[y][x + 1] == "#":
				x += 1
			else:
				judge = "Impossible"
				break

s = 0
for i in range(H):
	s += A[i].count("#")

if s != H + W - 1:
	judge = "Impossible"

if A[0][0] != "#":
	judge = "Impossible"

if A[H - 1][W - 1] != "#":
	judge = "Impossible"

print(judge)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int a,b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int main() {
    ll k,n;
    cin >> k >> n;
    ll a[n];
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll dis[n]; //a[n]からa[n+1]までの距離
    for (ll i = 0; i < n - 1; i++){
        dis[i] = a[i + 1] - a[i];
    }
    dis[n - 1] = k - a[n - 1] + a[0];
    ll max = 0;
    for (ll i = 0; i < n; i++) {
        if (max < dis[i]) {
            max = dis[i];
        }
    }
    cout << k - max;
    return 0;
}

Measured memory_bytes: 3328
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = pow(10, 5) + 1;//+1しないとREになる(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

int main(void) {
	ll N;
	cin >> N;
	vector<ll> X(N), L(N), right_end(N), left_end(N);
	typedef pair<ll, ll> P_ll;
	vector<P_ll> p(N);
	for (ll i = 0; i < N; i++) {
		cin >> X[i] >> L[i];
		right_end[i] = X[i] + L[i];
		left_end[i] = X[i] - L[i];
		p[i] = P_ll(right_end[i], left_end[i]);
	}
	sort(p.begin(), p.end());

	ll ans = N;
	ll delete_count = 0;
	for (ll i = 1; i < N; i++) {
		if (p[i - 1 - delete_count].first > p[i].second) {
			delete_count++;
			ans--;
		}
		else delete_count = 0;
	}
	cout << ans << endl;


	/* WA解法
	ll N;
	cin >> N;
	vector<ll> X(N), L(N);
	typedef pair<ll, ll> P_ll;
	vector<P_ll> p(N);
	for (ll i = 0; i < N; i++) {
		cin >> X[i] >> L[i];
		p[i] = P_ll(X[i], L[i]);
	}
	sort(p.begin(), p.end());
	//for (ll i = 0; i < N; i++) cout << i << ": " << p[i].first << ", " << p[i].second << endl;
	
	ll ans = N;
	ll delete_count = 0;
	for (ll i = 1; i < N; i++) {
		ll left_robot = p[i - 1 - delete_count].first + p[i - 1 - delete_count].second;
		ll now_robot = p[i].first - p[i].second;
		if (left_robot > now_robot) {
			delete_count++;
			ans--;
		}
		else delete_count = 0;
	}
	
	cout << ans << endl;
	*/
	
}


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

int main() {
  string S;
  map<char,int> m;
  cin >> S;
  
  for(char c : S)
    if(m.count(c))
      m[c]++;
    else
      m[c]=0;
  
  if(m.size()==2 && m[S[0]]==1)
    cout << "Yes";
  else
    cout << "No";
  cout << endl;
}

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

int main(){
  vector<int> side(3);
  for(int i = 0; i < 3; i++){
    cin >> side.at(i);
  }

  sort(side.begin(), side.end());
  cout << side.at(0) * side.at(1)/2<< endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] A =new int[N];
        int[] differ=new int[N];
        for(int i=0;i<N;i++)
            A[i] = sc.nextInt();
        Arrays.sort(A);
        for(int i=0;i<N;i++){
            if(i==(N-1))
            differ[i]=K-(A[i]-A[0]);
            else
            differ[i]=A[i+1]-A[i];
        }
        Arrays.sort(differ);
        System.out.println(K-differ[N-1]);
    }
}

Measured memory_bytes: 67888
import sys
from math import atan2, pi

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
a, b, x = map(int, read().split())

s = x / a

if s > a*b/2:
    theta = atan2(2*(a*b-s), a**2)
else:
    theta = atan2(b**2, 2*s)

print(theta * 180 / pi)


Measured memory_bytes: 9432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;

    ll a1 = 1e9;
    ll b2 = n / a1;
    if (n % a1 != 0) b2++;
    ll a2 = 1;
    ll b1 = a1 * b2 - n;

    // cout << "menseki: " << endl;
    // cout << abs(a1 * b2 - a2 * b1) << endl;
    // cout << endl;

    // cout << "ans: " << endl;
    cout << "0 0 " << a1 << " " << b1 << " " << a2 << " " << b2 << endl;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
bool flg;

int main() {
	cin >> n;
	for(int i = 0; i <= n; i += 4) {
		if((n - i) % 7 == 0) {
			flg = 1; break;
		}
	}
	if(flg) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
def main():
    buf = input()
    buflist = buf.split()
    n = int(buflist[0])
    m = int(buflist[1])
    ab = []
    for i in range(m):
        buf = input()
        buflist = buf.split()
        ab.append(tuple(map(int, buflist)))

    ab.sort()
    dp = []
    for i in range(n+1):
        dp.append([False, False, False])
    dp[1][0] = True
    for i in range(m):
        if dp[ab[i][0]][0]:
            dp[ab[i][1]][1] = True
        if dp[ab[i][0]][1]:
            dp[ab[i][1]][2] = True
    if dp[n][2]:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()


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

struct book{
  string n,w,t;

  bool match(string a, string b, string c, string d){
    if(a!="*" && n.find(a)==string::npos)return false;
    if(b!="*" && w.find(b)==string::npos)return false;
    if(c!="*" && t<c)return false;
    if(d!="*" && d<t)return false;
    return true;
  }
};

int main(){
  int n; cin >> n;
  string a,b,c,d;

  book B[100];
  for(int i=0;i<n;i++){
    cin >> a >> b >> c;
    B[i].n = a; B[i].w = b; B[i].t = c;
  }

  int q; cin >> q;
  for(int i=0;i<q;i++){
    cin >> a >> b >> c >> d;
    for(int j=0;j<n;j++){
      if(B[j].match(a,b,c,d))cout << B[j].n << endl;
    }
    if(i<q-1)cout << endl;
  }
}

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


int main(void) {

  int n, m;
  cin >> n >> m;
  vector< vector<int> > a(n, vector<int>(m));
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin >> a[i][j];
    }
  }

  vector<int> b(m);
  for(int i=0; i<m; i++) cin >> b[i];

  for(int i=0; i<n; i++){
    int tmp = 0;
    for(int j=0; j<m; j++){
      tmp += b[j] * a[i][j];
    }
    cout << tmp << endl;
  }




  return 0;
}

Measured memory_bytes: 3160
#include <stdio.h>
#include <math.h>

int main(){
	int a,b,c;
	int i;
	int n = 0;
	scanf("%d %d %d", &a, &b, &c);

	for (i = a; i <= b; i++){
		if (c%i == 0)n++;
	}

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

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


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

  ll q,h,s,d;
  cin >> q >> h >> s >> d;
  
  h = min(h,q*2);
  s = min(s,h*2);
  d = min(d,s*2);

  ll n;
  cin >> n;
  ll ans =0;

  ans = (n/2 * d) +((n%2) * s);
  cout << ans << endl;
    
  
  return 0;
    

}


Measured memory_bytes: 256
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main() {
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++) {
		 int n;
		 string s;
		 cin >> n >> s;
		 for(int i = 0; i < (int) s.size(); i++){
			 if(s[i] + n > 'Z'){
				 int x = n;
				 x -= ('Z' - s[i]);
				 char c = 'A';
				 c += (x - 1);
				 s[i] = c;
			 }else{
				 s[i] += n;
			 }
		 }
		 cout << s << "\n";
	 }
}


Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll n;
    cin >> n;
    vector<ll> c(n-1),s(n-1),f(n-1);
    rep(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i,n-1){
        ll t=s[i]+c[i];
        for(int j=i+1;j<n-1;j++){
            ll a=(t-s[j])/f[j];
            if(t-s[j]<0){
                a=0;
            }
            else if(a*f[j]!=t-s[j]){
                a++;
            }
            t=s[j]+a*f[j]+c[j];
            //cout << t << " ";
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
} 

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;string s;
    cin>>n>>s;
    int cntr=0,cntb=0;
    rep(i,n){
        if(s[i]=='R') cntr ++;
        else cntb ++;
    }
    cntr>cntb?Yes:No;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define llint long long int
#define ldouble long double

//setprecision()<<

using namespace std;

int main() {
    int N,K;
    cin>>N>>K;
    int n=1;
    for(int i=0;i<N;i++){
        if(n*2<n+K){
            n*=2;
        }
        else{
            n+=K;
        }
    }
    cout<<n<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>

using namespace std;
int main()
{
	auto cmp = [](const vector<long long>& a, const vector<long long>& b) {return a[0] < b[0];};
	priority_queue<vector<long long>, vector<vector<long long>>, decltype(cmp) > heap(cmp);
	long long X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<long long> A(X, 0);
	vector<long long> B(Y, 0);
	vector<long long> C(Z, 0);

	for(int i = 0; i < X; i += 1) cin >> A[i];
	for(int i = 0; i < Y; i += 1) cin >> B[i];
	for(int i = 0; i < Z; i += 1) cin >> C[i];

	sort(A.begin(), A.end(), greater<long long>());
	sort(B.begin(), B.end(), greater<long long>());
	sort(C.begin(), C.end(), greater<long long>());

	vector<vector<vector<bool>>> flags(X, vector<vector<bool>>(Y, vector<bool>(Z, false)));

	int i, j, k;
	heap.emplace(vector<long long>({A[0] + B[0] + C[0], 0, 0, 0}));
	flags[0][0][0] = true;
	for(int t = 0; t < K; t += 1)
	{
		cout << heap.top()[0] << endl;
		i = heap.top()[1], j = heap.top()[2], k = heap.top()[3];
		heap.pop();
		if(i + 1 < X && !flags[i + 1][j][k])
		{
			heap.emplace(vector<long long>({A[i + 1] + B[j] + C[k], i + 1, j, k}));
			flags[i + 1][j][k] = true;
		}
		if(j + 1 < Y && !flags[i][j + 1][k])
		{
			heap.emplace(vector<long long>({A[i] + B[j + 1] + C[k], i, j + 1, k}));
			flags[i][j + 1][k] = true;
		}
		if(k + 1 < Z && !flags[i][j][k + 1])
		{
			heap.emplace(vector<long long>({A[i] + B[j] + C[k + 1], i, j, k + 1}));
			flags[i][j][k + 1] = true;
		}
	}
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const int MAX_N = 4000;
const int A = 1000;
int n;
vi ra, la;
map<int, int> hm;

int main()
{
  erep(i, 0, A) erep(j, 0, A) la.pb(i + j);
  sort(ALL(la));

  ra = la;
  ra.erase(unique(ALL(ra)), ra.end());
  vrep(v, la) hm[*v] = upper_bound(ALL(la), *v) - lower_bound(ALL(la), *v);

  while(cin >> n){
    int res = 0;
    vrep(v, ra) res += hm[*v] * hm[n - (*v)];
    cout << res << endl;
  }

  return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO  = "No";

int func(int n, vll s) {
    ll temp = s[0];
    // for (int i = 1; i < n; i++) {
    rep1(i, n - 1) {
        if (temp - 1 <= s[i]) {
            temp = max(temp, s[i]);
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

int main() {
    int n;
    cin >> n;
    vll s(n);
    rep(i, n) { cin >> s[i]; }
    func(n, move(s));
    return 0;
}


Measured memory_bytes: 1024
N = int(input())

s = []
for _ in range(N):
    s.append(int(input()))

all_sum = sum(s)
if all_sum % 10 != 0:
    print(all_sum)
else:
    s.sort()
    n = -1
    for i in s:
        if i % 10 != 0:
            n = i
            break
    if n != -1:
        print(all_sum - n)
    else:
        print(0)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
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


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


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


def read_float():
    return float(buff_readline())


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


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


def read_str_n():
    return readline().strip().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(S):
    ans = []
    for i, c in enumerate(S):
        if c == '?':
            ans.append('D')
        else:
            ans.append(c)
    return ''.join(ans)


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 92996
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
ll n, m, k = 0, l = 0,x,y;

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

set<int> mn;



int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	cout << max(max(n*m, m + n), n - m);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i, n) for (int i = 0, i##_cond = (n); i < i##_cond; ++i)
#define FOR(i, a, b) for (int i = (a), i##_cond = (b); i < i##_cond; ++i)
#define ROF(i, a, b)                                                           \
  for (int i = (a)-1, i##_cond = (b); i >= i##_cond; --i) // ROF(i,n,0)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend() // sortで降順
#define SUM(a) accumulate(all(a), int(0))
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
constexpr ll inf = 1ll << 61;
constexpr ll mod = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> T add(const T &a, const T &b) { return (a + b) % mod; }

signed main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  int ans = 1;
  rep(i, n) {
    int tmp = ans;
    ans *= a[i];
    dump(i, ans, tmp, a[i]);
    if (ans > 1000000000000000000 or ans < tmp) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4052
/**
*    created: 09.07.2020 01:24:41
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

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

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> a(N); rep(i, N) cin >> a[i];
    rep(i, N) {
        if (a[i] % 2) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 640
//https://cs.stackexchange.com/questions/84426/find-a-node-with-maximum-distance-from-given-node-in-a-tree
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
//#include <ext/rope> //header with rope
//using namespace __gnu_cxx;
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order tells index pr kon hai..
// order_by_key  tells ki us element se kitne strictly smaller element hai...
#define mod 1000000007
#define INF 1000000000000000000
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll fact[1000007];
ll mdpower(ll a,ll b)
{
    ll res =1;
    while(b)
    {
        if(b&1) res = (res%mod*a%mod)%mod;
        b/=2;
        a = (a%mod*a%mod)%mod;
    }
    return res;
}
void factorial()
{
    fact[0]=1;
    for(int i=1;i<1000007;i++)
        fact[i] = (fact[i-1]%mod*i%mod)%mod;
}
ll inverse(ll a,ll b)
{
    return mdpower(a,b-2);
}
ll power(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
int main()
{   
    Senky_Bansal
    IIIT_ALLAHABAD

        ll n;
        cin>>n;
        ll h[n];
        for(int i=0;i<n;i++)
        {
            cin>>h[i];
        }
        ll dp[n+1];
        for(int i=1;i<=n;i++){
            dp[i]=INF;
        }
        dp[0]=0;
        for(int i=0;i<n;i++)
        {
            if(i+1<n)
            dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
            if(i+2<n)
            dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
        }
        cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
ll N, M, K,H,W, ans, mi1,mi2,sum;
string s;
int main() {
	cin >> s;
	vector<LL> H(s.size());
	string ss;
	char a='R';
	LL con = 0;
	for (int i = 0; i < s.size(); i++) {
		H[i] = 0;
	}
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == a){
			con++;
	}else if (con>0) {

			H[i - 1] += (con / 2) + (con % 2);
			H[i] += (con / 2);
			con = 0;
		}
	}
	a = 'L';
	for (int i = s.size()-1; i >-1; i--) {
		if (s[i] == a) {
			con++;
		}
		else if(con>0){

			H[i+1] += (con / 2) + (con % 2);
			H[i] += (con / 2);
			con = 0;
		}
	}
	

	for (int i = 0; i < s.size(); i++) {
		cout<<H[i]<<" ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 1536