akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
    int N, f, d[100], i, j, count=0;

    scanf("%d", &N);
    for (i = 0; i < N; i++){
        f = 0;
        scanf("%d", &d[i]);
        for (j = 0; j < i; j++){
            if(d[i]==d[j]){
                f = 1;
            }
        }
        if(f==0){
            count++;
        }
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int INF = 2*1e9;
// int recur(vector<int>&A,vector<int>&dp,int i){
//   if(i>=A.size())
//     return 0;
  
// //   if(dp[i]!=INF)
// //     return dp[i];
    
// //   if(i+1<A.size()){
// //     int cost1 = abs(A[i]-A[i+1]) + recur(A,dp,i+1);
// //     dp[i]=min(dp[i],cost1);
// // 	}
// //   if(i+2<A.size()){
// //     int cost2 = abs(A[i]-A[i+2]) + recur(A,dp,i+2);
// //     dp[i]=min(dp[i],cost2);
// //   }
  
//   return min(abs(A[i]-A[i+1]) + recur(A,dp,i+1),abs(A[i]-A[i+2]) + recur(A,dp,i+2)) ;
// }
int main(){
  int n;
  cin>>n;
  vector<int> A(n);
  int a;
  for(int i=0;i<n;i++){
    cin>>a;
    A[i]=a;
  }
  
  vector<int> dp(n,INF);
  dp[0]=0;
  for(int i=0;i<n;i++){
      for(auto j:{i+1,i+2}){
          if(j<n)
          dp[j] = min(dp[j],dp[i]+abs(A[i]-A[j]));
          
      }
    //   if(i+1<n)
    //     dp[i+1] = min(dp[i+1],dp[i]+abs(A[i]-A[i+1]));
    //   if(i+2<n)
    //     dp[i+2] = min(dp[i+2],dp[i]+abs(A[i]-A[i+2]));
  }
  
    cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;


vector<ll> have;
ll mx = 0;


int main()
{
	ios::sync_with_stdio(false);

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


	ll n, sum;

	cin >> n >> sum;

	for (int i = 0; i < n; ++i) {
		ll temp1, temp2;
		cin >> temp1 >> temp2;
		have.push_back(temp2);
		mx = max(temp1, mx);
	}

	sort(have.rbegin(), have.rend());

	for (int i = 0; i < n; ++i) {
		if (have[i] <= mx) {
			n = i;
		}
	}

	ll temp = 0;

	for (int i = 0; i < n; ++i) {
		temp += have[i];
		if (temp >= sum) {
			cout << i + 1;
			return 0;
		}
	}

	ll need = sum - temp;

	ll ans = n + need / mx + (bool)(need % mx);

	cout << ans;

	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 _main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << 1 + (X - (Y + Z * 2)) / (Y + Z) << endl;
}


Measured memory_bytes: 256
type ElementId = usize;

///
/// To read numbers from each lines
///
/// ```
/// (0..n)
///   .map(|_| read_number())
///   .collect::<Result<Vec<_>, _>>()
/// ```
///
fn read_number() -> Result<usize, String> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    line.trim()
        .parse::<usize>()
        .map_err(|err| format!("Error at read_number(): {}", err.to_string()))
}

fn read_numbers() -> Result<Vec<usize>, String> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    line.split_whitespace()
        .map(|x| {
            x.parse::<usize>()
                .map_err(|err| format!("Error at read_numbers(): {}", err.to_string()))
        })
        .collect::<Result<Vec<_>, _>>()
}

#[derive(Debug)]
struct DisjointSet {
    n: usize,
    pointers: Vec<ElementId>,
    ranks: Vec<u32>,
}

impl DisjointSet {
    fn make_set(x: ElementId) -> () {
        unimplemented!();
    }

    fn find_set(&mut self, x: ElementId) -> ElementId {
        let mut current = x;
        let mut path = vec![current];
        while current != self.pointers[current] {
            current = self.pointers[current];
            path.push(current);
        }

        let root = current;
        for p in path {
            self.pointers[p] = root;
        }

        root
    }

    fn unite(&mut self, x: ElementId, y: ElementId) -> () {
        let root_x = self.find_set(x);
        let root_y = self.find_set(y);
        let rank_x = self.ranks[root_x];
        let rank_y = self.ranks[root_y];

        // Swap if the rank of the tree which contains x is smaller.
        let (x, y, root_x, root_y) = if rank_x < rank_y {
            (y, x, root_y, root_x)
        } else {
            (x, y, root_x, root_y)
        };

        self.pointers[root_y] = root_x;

        if rank_x == rank_y {
            self.ranks[x] += 1;
        };
    }
}

fn solve() -> Result<(), String> {
    let header = read_numbers()?;
    let n = header[0] as usize;
    let q = header[1];
    // println!("{:?}", (n, q));

    let mut dset = DisjointSet {
        n: n,
        pointers: (0..n).collect(),
        ranks: vec![0; n],
    };

    for i_line in 0..q {
        let line = read_numbers()?;

        if line[0] == 0 {
            dset.unite(line[1], line[2]);
        } else {
            if dset.find_set(line[1]) == dset.find_set(line[2]) {
                println!("1");
            } else {
                println!("0");
            }
        }
        //println!("{:?}", dset);
    }

    Ok(())
}

fn main() {
    match solve() {
        Err(err) => panic!("Error at solve: {}", err),
        _ => (),
    };
}



Measured memory_bytes: 5052
#include <stdio.h>
#include <ctype.h>

int main( void )
{
	int moji_cou;
	char string[1200] = {};
	char convert_str[1200] = {};

	while( gets( string ) != NULL)
	{
		for( moji_cou = 0; moji_cou < 1200; moji_cou++ )
		{
			if( string[moji_cou] >= 'a' && string[moji_cou] <= 'z' )
			{
				convert_str[moji_cou] = string[moji_cou] - 'a' + 'A';
			}else
			if( string[moji_cou] >= 'A' && string[moji_cou] <= 'Z' )
			{
				convert_str[moji_cou] = string[moji_cou] - 'A' + 'a';
			}else
			{
				convert_str[moji_cou] = string[moji_cou];
			}
			if( string[moji_cou] == '\0' )
			{
				break;
			}
		}
		printf( "%s\n", convert_str );
	}
	return 0;
}

Measured memory_bytes: 524
n , x = map(int , input().strip().split())
a  = list(map(int , input().strip().split()))
a.sort()
if sum(a) < x:
  count = -1
else:
  count = 0

for i in a:
  if x - i < 0:
    break
  x -= i
  count += 1

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#define Abs                           \
	ios_base::sync_with_stdio(false); \
	cout.tie(NULL);                   \
	cin.tie(NULL);
#define FOR(i, b, a) for (ll i = b; i < a; i++)
#define FOR1(i, b, a) for (ll i = b; i <= a; i++)
#define FORd(i, b, a) for (ll i = (a)-1; i >= b; i--)
const double PI = acos(-1);
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define iq(v)   v.resize(unique(v.begin(), v.end()) - v.begin())
#define endl "\n"
#define sz(v) ((ll)((v).size()))
#define fx(n)           fixed << setprecision(n)
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
const int mod = 1e9 + 7;
int main()
{
	Abs;
	char x;
	cin>>x;
	if (x>='A' && x<='Z')
	cout<<'A';
	else
	cout<<'a';
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define PI acos(-1.0)
#define EPS 1e-9 //epsilon 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define go(i,a,n) for(int i=a;i<n;i++)
#define og(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(i,n) go(i,0,n)
#define per(i,n) og(i,0,n)
#define sz(x) (x.size())
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pr(x) cout<<(x)<<endl
#define exist(e,s) ((s).find(e)!=(s).end()) //Element e in structure s
#define existstr(c,s) ((s).find(c) !=string::npos) //Character in structure
#define fo(x,s) for(auto &x:s) //for all x in structure s
typedef vector<int> vi;typedef vector<ll> vll;typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvll;typedef pair<int,int> ii;typedef pair<int, pair<int,int> > iii;
typedef pair<ll,ll> pll;typedef vector<ii> vii;typedef vector<iii> viii;typedef map<int,int> mii;
const int inf=1e9+7; //10^9 +7
inline void rvi(vi& v, int n){int temp; go(i,0,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll& v, int n){ll temp;go(i,0,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prmii(map<int,int>& m){for(auto x:m){cout<<x.fi<<" "<<x.se<<endl;}}
inline vll prefixsum(vi& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
void solve();
int main(){ios;solve();return 0;}
//--------SOLVE---------------------------------------------------------------------
void solve()
{
 	string s;cin>>s;
 	int n=sz(s);
 	ll k;cin>>k;
 	ll t=k;
 	/*for(int i=0;i<n && t>0 ;i++)
 	{
 		if(s[i]=='1') t--,index=i;
 		else break;
 	}*/
 	int a[9];
 	a[0]=1;
 	for(int i=1;i<9;i++)
 	{
 		a[i]=18/log10(i+1);
 		//cout<<a[i]<<" ";
 	}
 	//cout<<"hello"<<endl;
 	int index=0;
 	int ans=s[index]-'0';
 	//cout<<"ans here= "<<ans<<endl;
 	while(t>0)
 	{
 		//cout<<"t="<<t<<endl;
 		//cout<<"s[index]-'0'="<<(s[index]-'0')<<endl;
 		if((s[index]-'0') ==1)
 		{
 			index++;
 			t--;
 			//cout<<"inside first if\n";
 			//cout<<"t now="<<t<<endl;
 		}
 		else
 		{
 			// cout<<"inside else\n";
 			// cout<<"t in else= "<<t<<endl;
 			// cout<<"index in else="<<index<<endl;
 			if(t<= (a[s[index]-'0']) )
			{	
				ans=s[index]-'0';
				//cout<<"this is ans now="<<ans<<endl;
				t-= (a[s[index]-'0']);
			}
			else
			{
				ans=s[index]-'0';
				break;
			}

 		}
 	}
 	cout<<ans<<endl;
}


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

int main() {
  int N;
  string S;
  int sum = 0;
  cin >> N >> S;
  for (int i = 0; i < N-2; i++) {
    if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
      sum++;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

ll gcd(ll a, ll b) {
    if(a < b) gcd(b, a);
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

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

int main() {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());

    ll n;
    cin >> n;
    vector <ll> v;
    for (ll i=0;i<n;i++){
        ll p;
        cin >> p;
        v.push_back(p);
    }
    ll g = v[0];
    for (ll i=1;i<n;i++){
        g = gcd(g, v[i]);
    }
    cout << g << endl;

}




Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
for(int i=0;;i++){
int a,s;
cin>>a>>s;
if(a==0) break;
for(int j=0;j<a;j++){
for(int e=0;e<s;e++){

if(j==0 || j==a-1){
cout<<'#';
}
else if(e==0 || e==s-1){
cout<<'#';
}
else{
cout<<'.';
}
}
cout<<endl;
}
  cout<<endl;
}
}


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

template <typename T>
std::vector<std::complex<T>> convex_hull(std::vector<std::complex<T>> points) {
  std::sort(points.begin(), points.end(), [](const std::complex<T>& a, const std::complex<T>& b) {
    return (std::real(a) < std::real(b)) || ((std::real(a) == std::real(b)) && std::imag(a) < std::imag(b));
  });
  points.erase(std::unique(points.begin(), points.end()), points.end());

  int n = points.size(), k = 0;
  if (n < 3) return points;
  else {
    auto cross = [](const std::complex<T>& a, const std::complex<T>& b) {
      return std::real(a) * std::imag(b) - std::imag(a) * std::real(b);
    };

    std::vector<std::complex<T>> ret(n << 1);
    for (int i = 0; i < n; ret[k++] = points[i++]) {
      while (k >= 2 && cross(ret[k - 1] - ret[k - 2], points[i] - ret[k - 1]) <= 0) --k;
    }
    for (int i = n - 2, t = k + 1; i >= 0; ret[k++] = points[i--]) {
      while (k >= t && cross(ret[k - 1] - ret[k - 2], points[i] - ret[k - 1]) <= 0) --k;
    }
    ret.resize(k - 1);
    return ret;
  }
}

using namespace std;

long long distance(const complex<long long>& a, const complex<long long>& b){
  complex<long long> c = a - b;
  return abs(real(c)) + abs(imag(c));
}

signed main(){
  int N;
  cin >> N;
  
  vector<complex<long long>> ps(N);
  for(int i = 0; i < N; i++){
    long long x, y;
    cin >> x >> y;
    ps[i] = complex<long long>(x, y);
  }
  
  vector ch = convex_hull(ps);
  
  int k = ch.size();
  
  long long max_dist = 0;
  for(int i = 0, r = 0; i < k; i++){
    while((r + 1) % k != i && distance(ch[i], ch[(r + 1) % k]) >= distance(ch[i], ch[r % k])) ++r;
    max_dist = max(distance(ch[i], ch[r % k]), max_dist);
    if(i == r) ++r;
  }
  
  cout << max_dist << endl;
  
  return 0;
}

Measured memory_bytes: 15648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
using namespace std;
int main(){   
   string s;
   cin>>s;
   int a=s.size();
   rep(i,a){
      cout<<'x';
   }
   
   return 0;
}

Measured memory_bytes: 256
n=int(input())
dp=[i for i in range(n+1)]
lw=[6,9]
for w in lw:
    k=1
    while w**k<=n:
        q=w**k
        for j in range(n+1-q):
            dp[j+q]=min(dp[j]+1,dp[j+q])
        k+=1
print(dp[n])

Measured memory_bytes: 7064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(b/a>c) System.out.println(c);
		else System.out.println(b/a);

	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int ans=1;
  int min=p[0];
  for(int i=1;i<n;i++){
    if(min>p[i]){
      ans++;
      min=p[i];
    }
  }  
  cout << ans << endl;
}

Measured memory_bytes: 1024
using System;

namespace _1_C {
    class Program {
        static void Main (string[] args) {
            var input = Console.ReadLine ().Split ();
            var a = Convert.ToInt32 (input[0]);
            var b = Convert.ToInt32 (input[1]);
            var area = a * b;
            var perimeter = a * 2 + b * 2;
            Console.WriteLine ($"{area} {perimeter}");
        }
    }
}


Measured memory_bytes: 18028
import itertools

n = int(input().strip())
p = int(''.join(input().strip().split()))
q = int(''.join(input().strip().split()))

cnt_l = 0
cnt_r = 0
for it in itertools.permutations(list(map(str,range(1, n+1)))):
  tmp = int(''.join(it))
  if tmp<=p:
    cnt_l += 1
  if tmp<=q:
    cnt_r += 1
print(abs(cnt_r-cnt_l))

Measured memory_bytes: 3064
n = int(input())
A = input().split(' ')
count = 0

flag = True
while flag:
    flag = False
    i = 0

    for j in reversed(range(i + 1, n)):
        if int(A[j]) < int(A[j-1]):
            (A[j-1], A[j]) = (A[j], A[j-1])
            count += 1
            flag = True

    i += 1


print(" ".join(A))
print(count)

Measured memory_bytes: 7672
#include <stdio.h>

int main(){
  int N, K, X, Y;
  scanf("%d %d %d %d", &N, &K, &X, &Y);
  if(N <= K){
    printf("%d\n", N*X);
  }else{
    printf("%d\n", K*X + (N - K)*Y);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#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 BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

int mday[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main(){
		
	int m, d;
	
	while(cin>>m>>d, (m||d)){
		
		int dsum = d+2;
		
		for(int i = 0; i < m; ++i){
			dsum += mday[i];
		}
		
		cout << week[dsum%7] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<pii,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//ruogu_alter
const int N=2e5+5;
int n,l;
ll res;
pii b[N];
vector<iiii >a;
//
inline ll calc(vector<pii >&v){
	ll ans=0,sum=0;
	for(int i=l-1,j=0;i<v.size();i++,j++){
		sum+=1ll*v[j].first;
		ans+=1ll*v[i].second*sum;
	}
	return ans;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=getint();l=getint();
	rep(i,n){
		int x=getint();
		b[i]=mp(x,i);
	}
	sort(b,b+n);
	int pos=0,val=0;res=1ll*n;
	while(1){
		if(a.empty()){
			if(pos==n)break;
			else val=b[pos].first;
		}
		else ++val;
		while(pos<n&&b[pos].first==val){
			a.emplace_back(pii(b[pos].second,b[pos].second),pii(1,1));
			++pos;
		}
		sort(a.begin(),a.end());
		vector<iiii >toa;
		for(int i=0,j;i<a.size();i=j+1){
			j=i;while(j<a.size()-1&&a[j].first.second+1==a[j+1].first.first)++j;
			int len=j-i+1,cnt=len/l;
			if(cnt){
				vector<pii >v,posx,posy;
				for(int k=i;k<=j;k++)v.push_back(a[k].second);
				res+=calc(v);
				rep(k,cnt){
					posx.emplace_back(a[i].first.first+k,a[i].first.first+k);
					posy.emplace_back(0,0);
					if(k==cnt-1)posx.back().second=a[j].first.second;
				}
				for(int k=i;k<=j;k++){
					int tx=k-i+1,ty=j-k+1;
					if(tx>=l)posy[tx/l-1].second+=a[k].second.second;
					if(ty>=l)posy[cnt-ty/l].first+=a[k].second.first;
				}
				res-=calc(posy);
				rep(k,posx.size())toa.emplace_back(posx[k],posy[k]);
			}
		}
		a=toa;
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 10860
#include<stdio.h>
int main(void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x>=r&&x<=W-r&&y>=r&&y<=H-r){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return(0);
}

Measured memory_bytes: 1824
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    

    class Program
    {

        static int N;
        static int K;

        static void Main(string[] args)
        {
            string[] strer = Console.ReadLine().Split(' ');
            N = int.Parse(strer[0]);
            K = int.Parse(strer[1]);

            int one = 0;
            int half = 0;

            for(int i = 1; i <= N; i++)
            {
                if(i % K == 0)
                {
                    one++;
                }
                else if(i % K == K / 2)
                {
                    half++;
                }
            }

            long ans = 0;

            if(K % 2 != 0)
            {
                ans += (long)Math.Pow(one, 3);
            }
            else
            {
                ans += (long)(Math.Pow(one, 3) + Math.Pow(half, 3));
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 100000000
using namespace std;
int main()
{
  int H,W;
  cin>>H>>W;
  int mod=1000000007;
  int dp[H][W];
  rep(y,H)rep(x,W){
     char tmp;
     cin>>tmp;
     if(tmp=='.')dp[y][x]=0;
     else dp[y][x]=-1;
  }
  rep(y,H)rep(x,W){
    if(dp[y][x]==-1)continue;
    else if(y==0){
      if(x==0)dp[y][x]=1;
      else dp[y][x]=dp[y][x-1];
    }
    else if(x==0)dp[y][x]=dp[y-1][x];
    else {
      dp[y][x]+=
        (dp[y-1][x]>0?dp[y-1][x]:0)+
        (dp[y][x-1]>0?dp[y][x-1]:0);
      if(dp[y][x]>mod)dp[y][x]-=mod;
    }
  }
  cout<<dp[H-1][W-1]<<"\n";
}
                          

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=1e5+5;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
struct data{int l,r;}a[N];
int n,L1,R1,L2,R2;
int work(int L1,int R1,int L2,int R2,int l,int r){
	L1=max(L1,L2);R1=min(R1,R2);
	return max(0,R1-L1+1)+max(0,r-l+1);
}
bool cmp(data a,data b){
    return a.l<b.l;
}
int main(){
	n=read();rep(i,1,n)a[i].l=read(),a[i].r=read();
    sort(a+1,a+n+1,cmp);
	L1=a[1].l;R1=a[1].r;
	L2=a[2].l;R2=a[2].r;
	rep(i,3,n){
		int l=a[i].l,r=a[i].r;
		int ans1=work(L1,R1,l,r,L2,R2);
		int ans2=work(L2,R2,l,r,L1,R1);
		int ans3=work(L1,R1,L2,R2,l,r);
		if(ans1>=ans2){
			if(ans1>ans3)L1=max(L1,l),R1=min(R1,r);
			else L1=max(L1,L2),R1=min(R1,R2),L2=l,R2=r;
		}
		else{
			if(ans2>=ans3)L2=max(L2,l),R2=min(R2,r);
			else L1=max(L1,L2),R1=min(R1,R2),L2=l,R2=r;
		}
	}
	printf("%d\n",max(0,R1-L1+1)+max(0,R2-L2+1));
	return 0;
}

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

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

    int h[n];
    rep(i, n)
        cin >> h[i];

    int max = 0;
    rep(i, n){
        if(h[i] > max){
            max = h[i];
        }
        if(h[i] < max - 1){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll INF = 1LL << 61;
const int MAX_N = 305;
const int MAX_K = 305;
ll H[MAX_N];
ll dp[MAX_N][MAX_K][MAX_N];

int main2() {
  CLR(dp, 0);
  REP(i, MAX_N) REP(j, MAX_K) REP(k, MAX_N) dp[i][j][k] = INF;
  REP(j, MAX_K) dp[0][j][0] = 0;

  int N = nextInt();
  int K = nextInt();
  REP(i, N) H[i+1] = nextLong();


  for (int i = 1; i <= N; i++) {
    for (int k = 0; k <= K; k++) {
      for (int l = 0; l < N; l++) {
        chmin(dp[i][k][i], dp[i-1][k][l] + max(0LL, H[i] - H[l]));
        chmin(dp[i][k+1][l], dp[i-1][k][l]);
      }
    }
  }
  ll ans = INF;
  for (int k = 0; k <= K; k++)
    for (int l = 0; l <= N; l++)
      chmin(ans, dp[N][k][l]);
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 221952
#include<stdio.h>
int main(){
  int A[101], n, i, j, tmp, cnt = 0, m;

  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  
  

  for ( i = 1; i <= n; i++ ){
    m = i;
    for ( j = i; j <= n; j++ ){
      if ( A[j] < A[m]) m = j;
    }
    tmp = A[i]; A[i] = A[m]; 
    A[m] = tmp;
    if ( i != m ) cnt++;
  }
  
  

  for ( i = 1; i <= n; i++ ){
    if (i>1) printf(" ");
    printf("%d", A[i]);
  }
  
  
  printf("\n");
  printf("%d\n",cnt);

  return 0;
}



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

char c[3][3];

void solve() {
  cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

int main() {
  for (int i = 0; i < 3; ++i) {
    string input;
    cin >> input;
    c[i][0] = input[0];
    c[i][1] = input[1];
    c[i][2] = input[2];
  }
  solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,ans;
  cin>>n;
  vector<int> a(n-1);
  rep(i,n-1)cin>>a[i];
  ans=a[0]+a[n-2];
  for(int i=1;i<n-1;i++){
    ans+=min(a[i-1],a[i]);
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        
        if(a < 3200) {
        	System.out.println("red");
        } else {
        	System.out.println(s);
        }
        
        sc.close();
    }
}

Measured memory_bytes: 21716
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  long A, B, K; readf("%d %d %d\n", &A, &B, &K);

  void solve() {
    if (A+K > B) {
      foreach(i; A..B+1) i.writeln;
      return;
    }

    auto left_max = A+K;
    auto right_min = B-K+1 > left_max? B-K+1 : left_max;
    
    foreach(i; A..left_max) writeln(i);
    foreach(i; right_min..B+1) writeln(i);
  }

  solve();
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ld, ll, ll>> vtll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

ll GetDigit(ll num)
{
  return log10(num) + 1;
}

void Main()
{
  ll a; ld b; cin >> a >> b;
  ll c = a * b;
  fin(c);
  return;
}

//前処理
int main()
{
  //int ti = clock();
  //srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl; // 実行時間計測
  return 0;
}

Measured memory_bytes: 3808
import java.util.Scanner;
public class Main{
	
	static int p = 100000;
	
	static boolean prime(int num) {
		if (num < 2) return false;
	    else if (num == 2) return true;
	    else if (num % 2 == 0) return false; 

	    double sqrtNum = Math.sqrt(num);
	    for (int i = 3; i <= sqrtNum; i += 2)
	    {
	        if (num % i == 0)
	        {
	            return false;
	        }
	    }
	    return true;

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int q = sc.nextInt();
		
		int []a = new int [p+1];
		
		for(int i = 0; i < p ; i++) {
			if(i % 2 == 0) {
				a[i+1] += a[i];
				continue;
			}
			if(prime(i)&&prime((i+1)/2)) {
				a[i]++;
			}
			a[i+1] += a[i];
		}
		int []ans = new int [q];
		for(int j = 0; j < q ; j++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			
			ans[j] = a[r] - a[l-1];
		}
		
		for(int i = 0 ; i < q ;i++) {
			System.out.println(ans[i]+" ");
		}
	

	}

}


Measured memory_bytes: 84352
#include <iostream>
    #include <string>
    #include <set>  
    #include <stack>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
    #include <ctime>
using namespace std;
#define for1(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,maxn) for1(i,0,maxn)
#define ford(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long ll;
typedef pair<int,int> pii;
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define dprintf(...) printf(__VA_ARGS__)
const int maxn=707;
const int maxm=maxn*(maxn-1)/2;
int n,m;
int col[maxn];
int cnt[2][maxn];
bool can[maxn][maxn];
bool board[maxn][maxn];
vector<int> g[maxn];
bool bad;
int ans=0x3f3f3f3f;
void dfs(int x,int co,int rt)
{
	col[x]=co;
	rep(i,g[x].size())
	{
	//	cout<<i<<" "<<g[x][i]<<endl;
	//	system("pause");
		if(~col[g[x][i]])
		{
			if(col[g[x][i]]==co)bad=1;
	//		cout<<bad<<endl;
		}
		else dfs(g[x][i],co^1,rt);
	}
	cnt[co][rt]++;
}
int main()
{
	scanf("%d %d",&n,&m);
	rep(i,m)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		x--,y--;
		board[x][y]=board[y][x]=1;
	}
	rep(i,n)
		rep(j,i)
			if(!board[i][j])
			{
				g[i].push_back(j);
				g[j].push_back(i);
			}
	memset(col,-1,sizeof(col));
	memset(cnt,0,sizeof(cnt));
	int all=0;
	rep(i,n)
	{
		if(~col[i])continue;
		dfs(i,0,all++);
		if(bad)
		{
			printf("-1\n");
			return 0;
		}
	}
	can[0][cnt[0][0]]=can[0][cnt[1][0]]=1;
	rep(i,all-1)
		rep(j,n)
			if(can[i][j])
			{
				can[i+1][j+cnt[0][i+1]]=1;
				can[i+1][j+cnt[1][i+1]]=1;
			//	cout<<j+cnt[0][i]<<" "<<j+cnt[1][i]<<endl;
			//	system("pause");
			}
	rep(j,n)
	{
		if(can[all-1][j])
		{
			ans=min(ans,j*(j-1)/2+(n-j)*(n-j-1)/2);
		//	cout<<j<<" "<<n-j<<endl;
		//	system("pause");
		} 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll K;
    string S;
    cin >> K >> S;

    if (SZ(S) <= K) {
        cout << S << endl;
    } else {
        rep(i, K) { cout << S[i]; }
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  cin >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) cin >> a[i];
  sort(p.begin(), p.end());
  sort(a.begin(), a.end());
  int i = 0;
  int j = 0;
  while (j < m) {
    if (p[i] < a[j]) i++;
    else if (p[i] == a[j]) i++,j++;
    else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string S; cin >> S;
  bool n = false, s = false, e = false, w = false;
 
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'N') n = true;
    else if (S[i] == 'S') s = true;
    else if (S[i] == 'E') e = true;
    else if (S[i] == 'W') w = true;
  }
 
  if (n^s || e^w) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

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

using ll = long long;
#define rep(i,n) for(int i = 0;i < n;i++)

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

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

    int n;cin >> n;

    vector<int64_t> a(n);
    int64_t tot = 0;
    rep(i,n){cin >> a[i]; tot ^= a[i];}

    rep(i,n)cout << (a[i] xor tot) << ' ';
    cout << '\n';

}


Measured memory_bytes: 4780
#include <stdio.h>

int main()
{
    int i, n, a, x, min, max;
    long sum;
    
    scanf("%d",&n);

    scanf(" %d",&a);
    min = max = sum = a;
   

    for(i = 1; i < n; i++){
    scanf(" %d",&x);
    
    if(x >= max){  
    max = x;
    }
    if(x <= min){  
    min = x;
    }
    sum = x + sum;
    }
     
    printf("%d %d %ld\n", min, max, sum);

    return 0;
}

Measured memory_bytes: 1848
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
    int n, q, t;
    string name;

    queue<pair<string, int>> Q;
    cin >> n >> q;

    for (int i = 0; i < n; i++)
    {
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }

    pair<string, int> u;
    int elaps = 0, a;
    while(!Q.empty()){
        u = Q.front();
        Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        
        if(u.second > 0){
            Q.push(u);
        }else{
            cout << u.first << " " << elaps << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6232
#include<stdio.h>

int main(void)
{
	int a,b,c,d;
	int n;
	int x=0; int y=0;
	int ans;
	while(scanf("%d",&n)!=EOF){
		ans=0;
		for(a=0;a<=9;a++){
			for(b=0;b<=9;b++){
				for(c=0;c<=9;c++){
					for(d=0;d<=9;d++){
						if((a+b+c+d)==n){
							ans++;
						}
					}
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<int> C[101010];
int A[101010],B[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) {
		cin>>A[i]>>B[i];
		C[A[i]].push_back(B[i]);
	}
	
	ll ret=0;
	priority_queue<ll> PQ;
	for(i=1;i<=M;i++) {
		FORR(c,C[i]) PQ.push(c);
		if(PQ.size()) {
			ret+=PQ.top();
			PQ.pop();
		}
		
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

using Graph = vector<vector<int>>;

vector<int> ans;
void dfs(const Graph &G,int v,int p){
    for(auto nv : G[v]){
        if(nv==p) continue;
        ans[nv]+=ans[v];
        dfs(G,nv,v);
    }
}

int main() {
    int n,q;
    cin>>n>>q;
    Graph G(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ans.assign(n,0);
    rep(i,q){
        int p,x;
        cin>>p>>x;
        p--;
        ans[p]+=x;
    }
    dfs(G,0,-1);

    rep(i,n) cout<<ans[i]<<" ";
    cout<<endl;
}

Measured memory_bytes: 26624
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = IR(n)
    a = [-i for i in a]
    dp = [float("inf")]*n
    for i in a:
        j = bisect.bisect_right(dp,i)
        dp[j] = i
    print(n-dp.count(float("inf")))
    return

#Solve
if __name__ == "__main__":
    solve()


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

using namespace std;

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  string s[h];
  for(int i=0; i<h; i++) cin >> s[i];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(s[i][j] == '#'){
        bool ok = false;
        for(int k=0; k<4; k++){
          int nx = dx[k] + i;
          int ny = dy[k] + j;
          if(nx >= 0 && nx < h && ny >= 0 && ny < w){
            if(s[nx][ny] == '#') ok = true;
          }
        }
        if(!ok){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    unsigned long int N = 0, M = 0;
    cin >> N >> M;
 
    if(N == M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
a= [0 for i in range(N+1)]
for i in range(M):
    a[int(input())]=1


if a[1]==0:
    S = [1,1]
else:
    S = [1,0]
for i in range(2,N+1):
    if a[i]==1:
        S.append(0)
    else:
        S.append((S[i-1]+S[i-2])%(10**9 + 7))

print(S[N])

Measured memory_bytes: 50976
"""
オーソドックスなDP
メモリ効率を考えるとdp部分は３要素だけで足りるか
"""
N = int(input())

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

dp = [0] * N
dp[1] = abs(H[0] - H[1])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))

print(dp[-1])


Measured memory_bytes: 13980
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  int n;
  cin >> n;
  a.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }

  int cur;
  
  long long int sum = 0;
  cur = a[0];
  
  for(ii=1;ii<n;ii++){

    if(cur > a[ii]){

      sum  += cur - a[ii];
      
      
    }
    if(cur < a[ii]){
      cur = a[ii];
    }
  }
  
  cout << sum << endl;

  return 0;
}


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

using namespace std;

struct Edge {
  int src, dst;
  Edge(int f, int t) {
    src = f;
    dst = t;
  }
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

vector<int> tarjan(const Graph &g) {
  int n = g.size(), idx = 0, k = 0, s = 0;
  vector<int> ord(n, -1), low(n), onS(n), cmp(n), stk(n);
  function<void(int)> dfs;
  dfs = [&](int v) {
    ord[v] = low[v] = idx++;
    stk[s++] = v;
    onS[v] = true;
    for (auto &e : g[v]) {
      int w = e.dst;
      if (ord[w] == -1) {
        dfs(w);
        low[v] = min(low[v], low[w]);
      } else if (onS[w]) {
        low[v] = min(low[v], ord[w]);
      }
    }
    if (low[v] == ord[v]) {
      while (1) {
        int w = stk[--s];
        onS[w] = false;
        cmp[w] = k;
        if (w == v)
          break;
      }
      ++k;
    }
  };
  for (int v = 0; v < n; ++v)
    if (ord[v] == -1)
      dfs(v);
  return cmp;
}

int main() {
  int n;
  while (cin >> n, n) {
    vector<double> p(n);
    Graph g(n);
    for (int i = 0; i < n; ++i) {
      int m;
      cin >> p[i] >> m;
      for (int j = 0; j < m; ++j) {
        int a;
        cin >> a;
        --a;
        g[i].emplace_back(i, a);
      }
    }
    vector<int> SCC = tarjan(g);
    set<int> se;
    for (auto s : SCC) {
      se.insert(s);
    }
    Graph gg(se.size());
    vector<double> pp(se.size(), 1.0);
    for (int i = 0; i < n; ++i) {
      for (auto e : g[i]) {
        if (SCC[e.src] == SCC[e.dst])
          continue;
        gg[SCC[e.src]].emplace_back(SCC[e.src], SCC[e.dst]);
        pp[SCC[e.dst]] = -1.0;
      }
      pp[SCC[i]] *= p[i];
    }
    double ans = 1.0;
    for (auto x : pp) {
      if (x > 0.0)
        ans *= 1 - x;
    }
    cout << fixed << setprecision(6) << ans << endl;
  }
}


Measured memory_bytes: 3376
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	int n, k; 
	cin>>n>>k;
	int g = 0, m = 0;
	for(int i = 0; i < n; i++) {
		int x; cin>>x; 
		g = __gcd(g, x); 
		m = max(m, x); 
	}
	if(k <= m && k % g == 0) cout<<"POSSIBLE\n";
	else cout<<"IMPOSSIBLE\n"; 
}

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

#define BUF_SIZE 20

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

#define PARTS_MAX 100000
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int main(void) {
    static uint64_t parts[PARTS_MAX*2];
    int ps = get_int();
    uint64_t sum3 = 0;
    static uint64_t cum[PARTS_MAX*2+1];
    uint64_t part_max = 0;
    int i;
    for(i = 0; i < ps; i++) {
        parts[i] = parts[i+ps] = get_int();
        part_max = max(part_max, parts[i]);
    }
    for(i = 1; i <= ps*2; i++) {
        cum[i] = parts[i-1] + cum[i-1];
    }
    // max in theory.
    uint64_t sum = cum[ps];
    sum3 = max(sum / 3, part_max);
#ifdef DEBUG
    printf("sum3: %llu\n", sum3);
#endif

    int start, end;
    uint64_t ans = 0;
    uint64_t s = 0;
    for(start = 0, end = 0; start < ps; start++) {
        // Shactory Method .. set end
        while(end < start+ps) {
            uint64_t ns = s + parts[end];
            if(ns > sum3) break;
            s = ns;
            end++;
        }
#ifdef DEBUG
        printf("[%d, %d)\n", start, end);
#endif
        // [start, end-1], [end, high), [high, start+ps)

        // search [end, start+ps) in [start, start+ps) using binary-search.
        int low = end-1;
        int high = start + ps;
        while(low + 1 < high) {
            int mid = (low + high)/2;
            uint64_t vs = cum[mid] - cum[end]; // [end, mid)
            // lower bound
            if(s <= vs) {
                high = mid;
            } else {
                low = mid;
            }
        }
        // update answer
        // [end, high)
        uint64_t s2 = cum[high] - cum[end];
        uint64_t rem = sum - s - s2;
        uint64_t res = min(s, rem);
#ifdef DEBUG
        printf("[%d, %d), [%d, %d+1) -> %llu ;;", start, end, end, high, s);
        printf("%llu %llu %llu\n", s, s2, rem);
#endif
        ans = max(ans, res);

        // update s
        s -= parts[start];
    }
    printf("%llu\n", ans);
    return 0;
}


Measured memory_bytes: 4928
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1400000;
char cn[CM], * ci = cn, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}
char* di = cn;
inline void putint(int X) {
	if (X < 10) {
		*di++ = '0' + X;
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	fread(cn, 1, CM, stdin);
	int N = getint();
	rep(i, N - 1) A[getint()]++;

	rep1(i, N) putint(A[i]);

	fwrite(cn, 1, di - cn, stdout);


	Would you please return 0;
}

Measured memory_bytes: 3508
n = gets.chomp.to_i
ary = gets.chomp.split.map(&:to_i)

# n = 100, h.length = 100だからとりあえずおーだーは木にしない
# 最初の０じゃない要素から０じゃない要素まで１引くを１とカウント
count = 0
while true
  if !(ary.find_index {|item| item != 0})
    puts count
    break
  end
  count += 1
  # 0-index
  first = ary.find_index {|item| item != 0}
  i = 0
  while true
    # p first
    # p i
    if ary[first+i] == nil
      # p "here"
      break
    elsif ary[first+i] == 0
      # p "there"
      break
    else
      ary[first+i] -= 1
    end
    i += 1
  end
  # p ary
end


Measured memory_bytes: 3836