akhauriyash/Code-Regression huggingface dataset:
s1 = input()
s2 = input()

def check(s1,s2):
    if len(s1)+1 != len(s2):
        print('No')
        return 
    
    for i in range(len(s1)):
        if s1[i] != s2[i]:
            print('No')  
            # print(s1[i],s2[i])  
            return
    print('Yes')    

check(s1,s2)

Measured memory_bytes: 9048
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const output = () => {
  if (Number(input) === 1) {
    console.log('Hello World');
    return;
  }
  const list = input.split('\n');
  console.log(Number(list[1]) + Number(list[2]));
  return;
}

output();


Measured memory_bytes: 7372
#include<stdio.h>
#include<stdlib.h>

typedef struct splaNodee{
  int t;
  int color;
  int vertex;
  int rad;
} node;

int cmp(const node *a,const node *b){
  return a->t>=b->t;
}

typedef struct binaryHeap{
  node *h;
  int heapSize;
  int (*cmp)(const node *,const node *);
} heap;

heap* newHeap(int maxSize,int (*cmpF)(const node *,const node *)){
  heap *res=(heap *)malloc(sizeof(heap));
  res->h=(node *)malloc(sizeof(node)*(maxSize+1));
  res->heapSize=0;
  res->cmp=cmpF;
  return res;
}

void push(heap *q,node *p){
  //printf("push : %d %d %d %d\n",p->vertex,p->rad,p->color,p->t);
  q->heapSize+=1;
  node *h=q->h;
  int k=q->heapSize;
  int (*cmp)(const node *,const node *)=q->cmp;
  h[k]=*p;
  while(k>1){
    if(cmp(h+k/2,h+k)) return;
    node swap=h[k];
    h[k]=h[k/2];
    h[k/2]=swap;
    k/=2;
  }
  return;
}

void pop(heap *q,node *res){
  node *h=q->h;
  *res=h[1];
  h[1]=h[q->heapSize];
  q->heapSize-=1;
  int n=q->heapSize;
  int k=1;
  while(2*k+1<=n){
    int next=cmp(h+2*k,h+2*k+1)?2*k:2*k+1;
    if(cmp(h+k,h+next)) return;
    node swap=h[k];
    h[k]=h[next];
    h[next]=swap;
    k=next;
  }
  if(2*k<=n && cmp(h+2*k,h+k)){
    node swap=h[k];
    h[k]=h[2*k];
    h[2*k]=swap;
  }
  //node *p=res;printf("pop : %d %d %d %d\n",p->vertex,p->rad,p->color,p->t);
  return;
}

void assign(int a,int b,int *vertex,int *next,int *start,int index){
  vertex[index]=b;
  next[index]=start[a];
  start[a]=index;
  return;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *vertex=(int *)malloc(sizeof(int)*2*m);
  int *next=(int *)malloc(sizeof(int)*2*m);
  int *start=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) start[i]=-1;
  for(i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;b--;
    assign(a,b,vertex,next,start,2*i);
    assign(b,a,vertex,next,start,2*i+1);
  }
  int q;
  scanf("%d",&q);
  heap *h=newHeap(11*(n+m+q),cmp);
  for(i=1;i<=q;i++){
    int v,d,c;
    scanf("%d%d%d",&v,&d,&c);
    v--;
    node t={i,c,v,d};
    push(h,&t);
  }
  int *rad=(int *)malloc(sizeof(int)*n);
  int *ans=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    rad[i]=-1;
    ans[i]=0;
  }
  while(h->heapSize>0){
    node t;
    pop(h,&t);
    int r=t.rad;
    int v=t.vertex;
    if(r<rad[v]) continue;
    rad[v]=r;
    if(ans[v]==0) ans[v]=t.color;
    r--;
    t.rad=r;
    if(r<0) continue;
    int p;
    for(p=start[v];p!=-1;p=next[p]){
      int u=vertex[p];
      if(r<=rad[u]) continue;
      rad[u]=r;
      t.vertex=u;
      push(h,&t);
    }
  }
  for(i=0;i<n;i++) printf("%d\n",ans[i]);
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int INF=1e9;

int main(){
	int N;
	cin>>N;
	lli T[1000],A[1000];
	rep(i,N)cin>>T[i]>>A[i];
	lli t=1,a=1;
	rep(i,N){
		lli x=(t-1)/T[i]+1,y=(a-1)/A[i]+1;
		lli z=max(x,y);
		t=T[i]*z,a=A[i]*z;
	}
	cout<<t+a;
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
A = [0] + A + [0]
s = sum(abs(b-c) for b, c in zip(A, A[1:]))
s += abs(A[2]) - abs(A[1]) - abs(A[2] - A[1])
B = [s]
for i in range(N-1):
    s += (abs(A[i+3] - A[i+1]) + abs(A[i+1] - A[i])) - (abs(A[i+3] - A[i+2]) + abs(A[i+2] - A[i]))
    B.append(s)
print(*B, sep='\n')

Measured memory_bytes: 14644
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <climits>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)

typedef long long ll;

int main(){
    ll n;
    ll ans = LLONG_MAX;
    cin >> n;
    for(ll i = 1;i*i <= n;i++){
        if( n%i == 0 ){
            ll divisor = n/i;
            ans = min(ans, divisor + i);
        }
    }
    cout << ans - 2 << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	string str;
	cin>>str;
	int answer=n;
	int red=0,white=0;
	for(char x:str)
	{
		if(x=='R')
		   red++;
		else
		   white++;
	}
	answer=min(red,white);
	int totalred=0,totalwhite=0;
	int j;
	for(j=0;j<n;j++)
	{
		if(str[j]=='R')
		   totalred++;
		else
		    totalwhite++;
		int val1=totalwhite;
		int val2=red-totalred;
		int here=max(val1,val2);
		answer=min(answer,here);
	}
	cout<<answer<<endl;
}


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

int main(){
	int N,K; cin>>N>>K;
	vector<int> P(N); rep(i, N) cin>>P[i];
	sort(P.begin(), P.end());
	int ans = 0;
	rep(i, K) ans += P[i];
	cout<< ans <<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2

using namespace std;

int n;
ll f[ 800040 ];
ll lazy[ 800040 ];
pair< ll, ll > a[ 200001 ];

void build( int, int, int );
void push_down( int, int, int );
void modify( int, int, int, int, int, ll );
ll query( int, int, int, int, int );

int find( ll );

int main() {
	ll d, dec, ans = 0, tmp, rt, t;
	scanf( "%d%lld%lld", &n, &d, &dec );
	for( int i = 1; i <= n; ++i )
		scanf( "%lld%lld", &a[ i ].first, &a[ i ].second );
	sort( a + 1, a + 1 + n );
	build( 1, 1, n );
	for( int i = 1; i <= n; ++i ) {
		tmp = query( 1, 1, n, i, i );
		if( tmp > 0 ) {
			t = tmp / dec;
			if( tmp % dec )
				++t;
			rt = find( a[ i ].first + 2 * d );
			modify( 1, 1, n, i, rt, -t * dec );
			ans += t;
		}
	}
	printf( "%lld", ans );
	return 0;
}

int find( ll x ) {
	int l = 1, r = n, mid;
	while( l <= r ) {
		mid = ( l + r ) >> 1;
		if( a[ mid ].first > x )
			r = mid - 1;
		else
			l = mid + 1;
	}
	return l - 1;
}

void build( int cur, int l, int r ) {
	int mid, t;
	if( l == r ) {
		f[ cur ] = a[ l ].second;
		return;
	}
	mid = ( l + r ) >> 1;
	t = cur << 1;
	build( t, l, mid );
	build( t + 1, mid + 1, r );
	f[ cur ] = f[ t ] + f[ t + 1 ];
}

void push_down( int cur, int lenL, int lenR ) {
	int t = cur << 1;
	f[ t ] += lazy[ cur ] * lenL;
	f[ t + 1 ] += lazy[ cur ] * lenR;
	lazy[ t ] += lazy[ cur ];
	lazy[ t + 1 ] += lazy[ cur ];
	lazy[ cur ] = 0;
}

void modify( int cur, int l, int r, int x, int y, ll k ) {
	int mid, t, len;
	if( x == l && y == r ) {
		len = r - l + 1;
		f[ cur ] += k * len;
		lazy[ cur ] += k;
		return;
	}
	mid = ( l + r ) >> 1;
	t = cur << 1;
	push_down( cur, mid - l + 1, r - mid );
	if( x <= mid ) {
		modify( t, l, mid, x, min( y, mid ), k );
	}
	if( mid + 1 <= y ) {
		modify( t + 1, mid + 1, r, max( x, mid + 1 ), y, k );
	}
	f[ cur ] = f[ t ] + f[ t + 1 ];
}

ll query( int cur, int l, int r, int x, int y ) {
	int mid, t;
	ll retl, retr;
	if( x == l && y == r )
		return f[ cur ];
	mid = ( l + r ) >> 1;
	t = cur << 1;
	retl = retr = 0;
	push_down( cur, mid - l + 1, r - mid );
	if( x <= mid ) {
		retl = query( t, l, mid, x, min( y, mid ) );
	}
	if( mid + 1 <= y ) {
		retr = query( t + 1, mid + 1, r, max( x, mid + 1 ), y );
	}
	return retl + retr;
}

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

void Bubble(string s[], int n){
    rep(i,n){
        for(int j=n-1;j>i;j--){
            if((int)s[j][1]<(int)s[j-1][1]) swap(s[j],s[j-1]);
        }
    }
    rep(i,n-1){
        cout << s[i]<<" ";
    }
    cout <<s[n-1]<<endl<<"Stable"<<endl;
}

void Select(string s[], int n){
    int minij;
    rep(i,n){
        minij=i;
        for(int j=i;j<n;j++){
            if((int)s[j][1]<(int)s[minij][1]) minij=j;
        }
        swap(s[i],s[minij]);
    }
    rep(i,n-1) {
        cout << s[i] << " ";
    }
    cout <<s[n-1]<<endl;
}

int main(){
    int n;
    cin >>n;
    string s[n],ss[n];
    rep(i,n){
        cin >>s[i];
        ss[i]=s[i];
    }
    Bubble(ss,n);
    Select(s,n);
    rep(i,n){
        if(ss[i]!=s[i]){
            cout << "Not stable" <<endl;
            return 0;
        }
    }
    cout << "Stable" <<endl;
    
    return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;

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

        long count = 0;
        for(long i = k;i <= n + 1;i++) {
            count += (i * (n - i + 1) + 1);
        }
        
        count %= (10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7);
        System.out.println(count);
    }
}


Measured memory_bytes: 35776
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

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

  vector<vector<int>> dp(n, vector<int>(n));
  rep(i, n){
    int add = 0;
    if(s.at(n-1) == s.at(i)) add = 1;
    dp.at(i).at(n-1) = dp.at(n-1).at(i) = add;
  }

  rrep(i, n-1){
    rrep(j, n-1){
      int add = 0;
      if(s.at(i) == s.at(j)) add = dp.at(i+1).at(j+1) + 1;
      dp.at(i).at(j) = add;
    }
  }

  int ans = 0;
  rep(i, n){
    rep(j, n){
      int add = min(abs(i-j), dp.at(i).at(j));
      ans = max(ans, add);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		string a, b;
		cin >> a >> b;
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		while(a.size() < 110) a += "0";
		while(b.size() < 110) b += "0";
		int carry = 0;
		string res = "";
		for(int i = 0; i< a.size(); i++) {
			res   += ((a[i] - '0') + (b[i] - '0') + carry) % 10 + '0';
			carry  = ((a[i] - '0') + (b[i] - '0') + carry) / 10;
		}
		while(res.size() > 1 && *(res.end()-1) == '0') res.erase(res.end()-1);
		reverse(res.begin(), res.end());
		if(res.size() > 80)
			cout << "overflow" << endl;
		else
			cout << res << endl;
	}
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

bool isprime(int x){
  if (x == 2)
    return true;

  if (x < 2 || x % 2 == 0)
    return false;

  int i = 3;
  while (i <= sqrt(x)) { 
    if (x % i == 0){
      return false;
    }
    i = i + 2;
  }

  return true;
}

#define MAX 10000

long long int num[MAX];

int main() {
  int n;
  int count = 0;
  cin >> n;

  for (int i = 0; i < n; i++) {
    long long int num;
    cin >> num;
    if(isprime(num)) count++;
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 3088
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var di = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var sum = 0;
            for (var i = 0; i < di.Length - 1; i++)
            {
                for (var j = i + 1; j < di.Length; j++)
                {
                    sum += di[i] * di[j];
                }
            }
            Console.WriteLine(sum);
        }
    }
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, h);
    int yui = 0;
    vector<i_i> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i].sec >> data[i].fir;
        yui = max(yui, data[i].sec);
    }

    sort(all(data));
    reverse(all(data));

    int sum = 0, cnt = 0;
    rep(i, n) {
        if (yui <= data[i].fir) {
            sum += data[i].fir;
            cnt++;
        }
        if (sum >= h) {
            cout << i+1 << endl;
            return 0;
        }
    }
    h -= sum;

    cout << cnt + (h / yui) + !!(h % yui) << endl;
    
    return 0;
}





Measured memory_bytes: 1792
#include<bits/stdc++.h>
 
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

const int N = 17;

LL computedVal[(1 << N)];

LL dp[(1 << N)];
bool vis[(1 << N)];

LL arr[N][N];

LL solve(LL mask)
{
	if (mask == 0) return 0;
	if (vis[mask]) return dp[mask];
	vis[mask] = true;
	for (int i = mask; i > 0; i = (i - 1) & mask){
		dp[mask] = max(dp[mask], computedVal[i] + solve(mask ^ i));
	}
	return dp[mask];
}

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

    int n; cin >> n;
    for (int i = 0; i < n; i++){
    	for (int j = 0; j < n; j++){
    		cin >> arr[i][j];
    	}
    }

    for (int i = 1; i < (1 << n); i++){
    	for (int j = 0; j < n; j++){
    		if (i & (1 << j)){
    			for (int k = j; k < n; k++){
    				if (i & (1 << k)){
    					computedVal[i] += arr[j][k];
    				}
    			}
    		}
    	}
    }

    cout << solve((1 << n) - 1) << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1e9;
const int mod=1e9+7;



void solve()
{
   ll n,i;
    cin>>n;
    vector<ll>a(n+1,i);
    for(i=1;i<=n;i++)
    {
     for(ll j=i;j<=n;j+=i)
         a[j]++;
    }
    ll ans=0;
    for(i=1;i<=n;i++)
      ans+=(i*a[i]);
    
    cout<<ans<<endl;
    
    
}


int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
        solve();
}
    
    
    
    


Measured memory_bytes: 81324
#include<iostream>
using namespace std;
long long int m,s;
long long int t[55][2];

void check(int n){
	if(m==0)return;
	if(m>=t[n][0]){
		m-=t[n][0],s+=t[n][1];
		return;
	}
	m--;
	if(n==0){
		s++;
		return;
	}
	check(n-1);
	if(m==0)return;
	m--,s++;
	check(n-1);
	if(m==0)return;
	m--;
	return;
}	

int main(){
	int n;
	cin>>n>>m;
	t[0][0]=1,t[0][1]=1;
	for(int i=1;i<=n;i++){
		t[i][0]=t[i-1][0]*2+3;
		t[i][1]=t[i-1][1]*2+1;
	}
	check(n);
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	
	int passed = 0;
	int passed_b = 0;
	for(int i = 0; i < n; ++i) {
		if( s[i] == 'a' ) {
			if( passed < a + b ) { 
				cout << "Yes" << endl;
				passed++;
			} else {
				cout << "No" << endl;
			}
		} else if( s[i] == 'b' ) {
			if( passed < a + b && passed_b < b ) { 
				cout << "Yes" << endl;
				passed++;
				passed_b++;
			} else {
				cout << "No" << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=2e5+10;
const ll mod=20180623;
int main(){
    string s;
    cin>>s;
    ll sum=0;
    for(auto it:s){
        sum+=it-'0';
    }
    if(sum%9==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a+b==c || b+c==a || c+a==b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int w,h,x,y,r;
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  if(x>=r && x<=w-r && y<=h-r && y>=r){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}



Measured memory_bytes: 2132
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}aaa;

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

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


int main (){
    int n;
    cin >> n;
    vector<int> h(n);
    int ma = 0;
    Rep(i,n){
        cin >> h[i];
        ma = max(ma,h[i]);
    }
    int ans = 0;
    Rep(i,ma){
        int tmp = 1;
        Rep(j,n){
            if(h[j] > i && tmp == 1){
                ans++;
                tmp = 0;
            }else if(h[j] <= i){
                tmp = 1;
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = "";    
        str = sc.nextLine();
        int i;
        String result = "";
        char c;
        for(i=0;i<str.length();i++){
            c = str.charAt(i);
            if(Character.isUpperCase(c)== true) {
                c += 32;
                result += c;
            }else if(Character.isLowerCase(c)== true){
                c -= 32;
                result += c;
            }else{
                result += c;
            }
        }
        
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 31612
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
ps=LI()
compare=[]
count=0
for i in range(1,n-1):
    compare=[]
    compare.append(ps[i-1])
    compare.append(ps[i])
    compare.append(ps[i+1])
    s=sorted(compare)
    if ps[i]==s[1]:
        count+=1
print(count)

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
using namespace std;
char  ta[50][50],tb[50][50];
	int n,h,w;
	bool used[50][50],can[50][50];
	bool ok(){

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
			tb[i][j]=ta[i][j];
			}
		}
		
		int cnt=0;
		char tmp;
		bool endf=0;
		for(int cc=0;cc<300;cc++){
			endf=0;
			for(int i=0;i<50;i++)for(int j=0;j<50;j++)used[i][j]=0,can[i][j]=0;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(tb[i][j]!='.')can[i][j]=1;
				//???????????????
			for(int i=h-1;i>=0;i--){
				for(int j=w-1;j>=0;j--){
					int ni=i;
					if(tb[i][j]!='.'){
						while(1){
							if(ni+1>=h||tb[ni+1][j]!='.'||can[i][j]==0)break;
							tb[ni+1][j]=tb[ni][j];
							tb[ni][j]='.';
							ni++;
						}
					}
				}
			}
			//if(cc==0)for(int i=0;i<h;i++){for(int j=0;j<w;j++){cout<<tb[i][j];}cout<<endl;}
		
		
		

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cnt=0;
				tmp=tb[i][j];
					while(j<w&&tb[i][j+cnt]==tmp&&tmp!='.')cnt++;
				if(cnt>=n){
					for(int nj=j;nj<j+cnt;nj++)used[i][nj]=1,endf=1;
				}
			}
		}
		
			for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cnt=0;
				tmp=tb[i][j];
					while(i<h&&tb[i+cnt][j]==tmp&&tmp!='.')cnt++;
				if(cnt>=n){
					for(int ni=i;ni<i+cnt;ni++)used[ni][j]=1,endf=1;
				}
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(used[i][j])tb[i][j]='.';
			}
		}
			if(endf==0)break;
		}
		bool nf=1;
		//for(int i=0;i<h;i++){for(int j=0;j<w;j++){cout<<tb[i][j];}cout<<endl;}
		//cout<<endl;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(tb[i][j]!='.')nf=0;
		return nf;
	}
int main(){

	cin>>h>>w>>n;
	
	bool f=0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>ta[i][j];

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			for(int ii=0;ii<h;ii++)for(int jj=0;jj<w;jj++)can[ii][jj]=0;
			//cout<<i<<" "<<j<<endl;
			/*if(i+1<h){
				swap(ta[i][j],ta[i+1][j]);
				can[i][j]=can[i+1][j]=1;
				if(ok())f=1;
				swap(ta[i][j],ta[i+1][j]);
			}*/
			for(int ii=0;ii<h;ii++)for(int jj=0;jj<w;jj++)can[ii][jj]=0;
			if(j+1<w){
				swap(ta[i][j],ta[i][j+1]);
				if(ok())f=1;
				swap(ta[i][j],ta[i][j+1]);
			}
		}
	}
	if(f)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    vi ans(12);
    cin >> s;
    int ind = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '0') {
            ans[ind++] = 0;
        } else if (s[i] == '1') {
            ans[ind++] = 1;
        } else {
            ind--;
            if (ind < 0) ind = 0;
        }
    }
    for (int i = 0; i < ind; ++i) {
        cout << ans[i];
    }
    cout << "\n";
    return 0;
}

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

const int maxn = 1e5 + 5;
int dp[3][maxn], a[3][maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int j = 0; j < n; j ++){
		for (int i = 0; i < 3; i ++)
			cin >> a[i][j];
	}
	dp[0][n - 1] = a[0][n - 1];
	dp[1][n - 1] = a[1][n - 1];
	dp[2][n - 1] = a[2][n - 1];
	for (int i = n - 2; i >= 0; i --){
		dp[0][i] = a[0][i] + max(dp[1][i + 1], dp[2][i + 1]);
		dp[1][i] = a[1][i] + max(dp[0][i + 1], dp[2][i + 1]);
		dp[2][i] = a[2][i] + max(dp[0][i + 1], dp[1][i + 1]);
	}
	cout << max(max(dp[0][0], dp[1][0]), dp[2][0]);
}


Measured memory_bytes: 2560
/// @pSaurabh

#include <bits/stdc++.h>

using namespace std;

#define read(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define print(a, n) for(int i = 0; i < n; i++) if(i < n - 1){ cout << a[i] << " "; } else cout << a[i] << "\n";

typedef long long ll;
typedef long double ld;

const ll mod = 1e9 + 7;

void fast(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout .tie(0);
}

int main(){
	// fast();

	int n;
	cin >> n;

	int a[n + 1][3];
	for(int i = 1; i <= n; ++i){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}

	int dp[n + 1][3];
	dp[0][0] = dp[0][1] = dp[0][2] = 0;

	for(int i = 1; i <= n; ++i){
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + a[i][2];
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));

	return 0;
}


Measured memory_bytes: 5932
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var K = sc.nextInt();
        var h = sc.ArrayInt(N).OrderBy(val => val).ToArray();
        var abs = new int[N - 1];
        for (int i = 1; i < N; i++) {
            abs[i - 1] = Math.Abs(h[i] - h[i - 1]);
        }
        var ans = int.MaxValue;
        var sum = abs.Take(K-1).Sum();
        for (int i = 0; i <= N-K; i++) {
            ans = Math.Min(ans, sum);
            if (i == N - K) break;
            sum = sum + abs[(K - 1) + i] - abs[i];
        }
        WriteLine(ans);
    }


}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 18772
n,m = (int(i)for i in input().split())
l = [int(i)for i in input().split()]
lim = (sum(l))/(4*m)
# ~ print("lim ",lim)
cnt=0
for i in range(n):
	if l[i]>=lim:
		cnt+=1
# ~ print("cnt = ",cnt)
if cnt>=m:print("Yes")
else:print("No")


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,m,l; cin>>n>>m>>l;
    ll a[n][m],b[m][l];
    vector<vector<ll>> c(n,vector<ll>(l,0));
    rep(i,n)rep(j,m) cin>>a[i][j];
    rep(i,m)rep(j,l) cin>>b[i][j];
    rep(i,n)rep(j,m)rep(k,l){
        c[i][k]+=a[i][j]*b[j][k];
    }
    rep(i,n)rep(j,l){
        cout<<c[i][j];
        if(j==l-1) cout<<endl;
        else cout<<" ";
    }
    return 0;
}


Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    ll ans = 0;
    ll now=-1, beg;
    rep(i,n){
        ll a;cin>>a;
        if(now==-1||(now-beg)*(a-now)<0){
            now=a;
            ans++;
            beg=a;
        }
        else now=a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
if y>10000*n:
  print('-1 -1 -1')
else:
  for p in range(n+1):
    for q in range(n-p+1):
      if 10000*p+5000*q+1000*(n-p-q)==y:
        print(p,q,n-p-q)
        exit()
  print('-1 -1 -1')
        



Measured memory_bytes: 9076
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

var maxDiff int
var diffs []int
var sumNum int

func main() {
	log.SetFlags(log.Lshortfile)
	// 入力値を取得
	nextReader = NewScanner()
	line1 := nextInt()
	line2 := nextInt()
	sort.Ints(line2)

	koma_count := line1[0]
	place_count := line1[1]
	x := line2

	// コマの数と地点の数が同じなら移動回数は0になる
	if len(x) <= koma_count {
		fmt.Println(0)
		return
	}

	// それぞれの地点の差を取得
	// x1-x2, x1-x3, x1-x4, ...
	for i := 0; i < len(x)-1; i++ {
		diffs = append(diffs, x[i+1]-x[i])
	}

	sort.Ints(diffs)

	var ans int
	for i := 0; i < place_count-koma_count; i++ {
		ans += diffs[i]
	}

	fmt.Println(ans)
}

// ------ Mathライブラリ ---------------------------------//
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func maxIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ------ Mathライブラリ ---------------------------------//

// ----- 標準入力用の関数 ----------------------------------//
var nextReader func() []string

func NewScanner() func() []string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	return func() []string {
		r.Scan()
		return strings.Fields(r.Text())
	}
}

func nextString() []string {
	return nextReader()
}

func nextInt() []int {
	var intArray []int
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.Atoi(v)
		intArray = append(intArray, i)
	}
	return intArray
}

func nextFloat64() []float64 {
	var floatArray []float64
	strArray := nextReader()
	for _, v := range strArray {
		f, _ := strconv.ParseFloat(v, 64)
		floatArray = append(floatArray, f)
	}
	return floatArray
}

// ------ 標準入力用の関数 ---------------------------------//

// ------ あまり使わない -----------------------------------//
func nextInt64() []int64 {
	var int64Array []int64
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.ParseInt(v, 10, 64)
		int64Array = append(int64Array, i)
	}
	return int64Array
}

// ------ あまり使わない -----------------------------------//


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

int main() {
	// your code goes here
	int n,i,j,k,p[500],x[500],used[500]={0};
	string s[500],t[500];
	cin >> n;
	for(i=0;i<n;i++){
		cin >> s[i] >> p[i];
		t[i]=s[i];
		x[p[i]]=i;
	}
	sort(t,t+n);
	for(i=0;i<n;i++){
		for(j=100;j>=0;j--){
			for(k=0;k<n;k++){
				if(equal(t[i].begin(),t[i].end(),s[k].begin(),s[k].end())&&p[k]==j&&used[k]==0){
					cout << k+1 << endl;
					used[k]=1;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int n, m;
	string s;
	cin >> n >> m >> s;
	reverse(all(s));
	vector<int> ans;
	int c = 0;
	bool ok;
	while (c != n) {
		ok = false;
		rep(i, 0, m) {
			if (m - i + c <= n && s[m - i + c] == '0') {
				c += m - i;
				ans.push_back(m - i);
				ok = true;
				break;
			}
		}
		if (!ok) {
			puts("-1");
			return 0;
		}
	}
	reverse(all(ans));
	rep(i, 0, ans.size()) {
		printf(i != ans.size() - 1 ? "%d " : "%d\n", ans[i]);
	}
	return 0;
}

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

int f[3005][3005];

int main() {
	string s, t; cin >> s >> t;
	int n = s.size(), m = t.size();
	s = '$' + s; t = '$' + t;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++) {
		if (s[i] == t[j]) f[i][j] = f[i - 1][j - 1] + 1;
		else f[i][j] = max(f[i - 1][j], f[i][j - 1]);
	}
	int i = n, j = m;
	string res;
	while (i && j) {
		if (s[i] == t[j]) {
			res += s[i];
			i--; j--;
		} else {
			if (f[i - 1][j] > f[i][j - 1]) i--;
			else j--;
		}
	}
	reverse(res.begin(), res.end());
	cout << res << '\n';
}


Measured memory_bytes: 38808
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll n;
    vector<ll> ans;
    cin>>n;
    vector<ll> b(n);
    rep(i, n){
        cin>>b[i];
    }
    bool a = true;
    rep(i, n){
        ll arg = 0;
        if(b[0] != 1) {a = false; break;}
        rep(j, b.size()){
            if( j + 1 == b[j]) arg = j;
        }
        ans.push_back(arg+1);
        vector<ll> newb;
        rep(j, b.size()){
            if(j != arg) newb.push_back(b[j]);
        }
        b=newb;
    }
    if(a) {
        rep(i,n)
        pr(ans[n-i-1]);
    } else{
        pr("-1");
    }
    return 0;
}



Measured memory_bytes: 888
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))
flag = 0
for i in range(n-1,1,-1):
  if h[i] - h[i-1] == -1:
    h[i-1] -= 1
  elif h[i] - h[i-1] >= 0:
    continue
  else:
    flag += 1
if flag == 0:
  print("Yes")
else:
  print("No")

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

int  main()
{
	string s; cin >> s;
	string t; cin >> t;
	int len = s.size();
	
	for (int i = 0; i < len; i++)
	{
		string ans;
		for (int j = i; i < len; j++)
		{
			ans += s[j];
			if (j == len - 1 && ans.size() < len)
				j = -1;
			if (ans.size() == len)
				break;
		}
		if (ans == t)
		{
			cout << "Yes" << endl; return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

const int inf = 2147483647;
int n, h[MAX], dp[MAX];

int main()
{
    memset(dp, -1, sizeof(dp));
    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>h[i];
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    
    for(int i = 2; i < n; i++){
        dp[i] = min((dp[i-1] + abs(h[i] - h[i-1])), (dp[i-2] + abs(h[i] - h[i-2])));
    }

    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

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

	int n;
	cin >> n;
	int a=0,b=0,c=0,d=0;
	string s;
	for(int i=0; i<n; i++){
		cin >> s;
		if(s=="AC")
			a++;
		else if(s=="WA")
			b++;
		else if(s=="TLE")
			c++;
		else
			d++;
	}

	cout << "AC x " << a;
	cout << "\nWA x " << b;
	cout << "\nTLE x " << c;
	cout << "\nRE x " << d;


	
	

	return 0;
}

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

#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define repi(i,a,b) for(int i=a; i<=b; i++) 
#define repd(i,a,b) for(int i=a; i>=b; i--)

const int INF = ~(1<<31);
typedef long long int ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	cin>>N;
	ll H[N];
	repi(i, 0, N-1){
		cin>>H[i];
	}
	ll minHeight = 0;
	bool yess = true;
	repi(i, 0, N-1){
		if(H[i] > minHeight){
			H[i]--;
		}
		if(H[i] < minHeight){
			yess = false;
			break;
		}
		minHeight = H[i];
	}
	if(yess){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
	return 0;
}

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

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


Measured memory_bytes: 256
N, D = map(int, input().split())
X = [[int(x) for x in input().split()] for _ in range(N)]

ans = 0

for i in range(N):
	for j in range(i + 1, N):
		dist = 0
		for k in range(D):
			dist += (X[i][k] - X[j][k])**2
		if int(dist**0.5)**2 == dist: ans += 1

print(ans)


Measured memory_bytes: 3060
#coding: utf-8
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
li = list(combinations_with_replacement([i for i in range(1, M+1)], N))
eq = []
for i in range(Q):
    eq.append(list(map(int, input().split())))
# print(list(combinations_with_replacement([i for i in range(1, M+1)], N)))
ans = 0
for l in li:
    tmp = 0
    for i in range(Q):
        a, b, c, d = eq[i]
        if l[b-1] - l[a-1] == c:
            tmp += d
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 84736
#include<stdio.h>
#include<string.h>

int main(){
    int A, B, count=0;
    scanf("%d%d", &A,&B);
    char add [A + B + 2];
    scanf("%s", add);
    
    for(int i = 0; i < A+B+1 ; i++){
        if(i != A){
            if( add[i] >= 48 && add[i] <= 57){
                count++;
            } 
        } else {if(add[i] == '-'){
                count++;
            }
        }
    }
    count == A+B+1 ? printf("Yes"):printf("No");
    return 0;
}

Measured memory_bytes: 1704
#include <stdio.h>
#include <stdlib.h>

int main(){
    char s, t;
    int y, m, d;
    scanf("%d%c%d%c%d", &y, &s, &m, &t, &d);
    if(m<=4){
        printf("Heisei\n");
    }
    else{
        printf("TBD\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>

void printArray(int A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i != N-1) {
            printf("%d ", A[i]);
        } else {
            printf("%d", A[i]);
        }
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    for (int i = 0; i < N; i++) {
        int j = i - 1;
        int insertNum = A[i];
        while (j >= 0 && insertNum < A[j]) {
            A[j+1] = A[j]; // move to right
            j--;
        }
        A[j+1] = insertNum;
        printArray(A, N);
    }
}

int main() {
    int N;
    scanf("%d", &N);

    int A[N];
    for (int i = 0; i < N; i++) {
        int in;
        scanf("%d", &in);
        A[i] = in;
    }
    insertionSort(A, N);
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 7;

ll q, h, s, d, n;

int main(){
  cin >> q >> h >> s >> d >> n;
  n = n * 4;

  vector < pair < ll, ll > > perm = {{1, q}, {2, h}, {4, s}, {8, d}};
  ll ans = ll(1e18);
  do{
    ll now = 0;
    ll nn = n;
    for(auto i : perm){
      now += (nn / i.first) * i.second;
      nn %= i.first;
    }
    ans = min(ans, now);
  }while(next_permutation(perm.begin(), perm.end()));
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
lcm = a[0]
for i in range(1, N):
    lcm =(lcm * a[i]) // gcd(lcm, a[i])
ans = 0
for i in a:
    ans += (lcm-1) % i
print(ans)

Measured memory_bytes: 3316
function Main(input) {
  input = input.split("\n");
  nm = input[0].split(" ");
  n = parseInt(nm[0]);
  m = parseInt(nm[1]);
  t = [];
  for (var i = 0; i < m; i++) {
    r = [];
    // console.log(input[i+ n]);
    for (var j = 0; j < m; j++) {
      // console.log(input[i + 1 + n]);
      r.push(input[i + 1 + n][j]);
    }
    // console.log(r);
    t.push(r);
  }
  // console.log(t);
  yes = false;
  loop0: for (var i = 0; i < n - m + 1; i++) {
    for (var j = 0; j < n - m + 1; j++) {
      // console.log(input[i + 1][j]);
      loop1: for (var k = 0; k < m; k++) {
        for (var l = 0; l < m; l++) {
          if (input[i + 1 + k][j + l] != t[k][l]) {
            break loop1;
          }
        }
//        console.log(i, j);
        if (k == m - 1) {
          yes = true;
          break loop0;
        }
      }
      // console.log(input[i + 1][j]);
    }
  }
  if (yes) {
    console.log("Yes");
  } else {
    console.log("No");
  }
  // console.log(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
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

//ソートすればいいんですか？
//???
int dp[3000];

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


	int N, T;
	scanf("%d", &N);
	scanf("%d", &T);
	int AB[3000];
	rep(i, N) {
		int a, b;
		scanf("%d %d", &a, &b);
		AB[i] = (a << 12) + b;
	}
	sort(AB, AB + N);

	int saidai = 0;
	rep(i, N) {
		int a = AB[i] >> 12;
		int b = AB[i] & ((1 << 12) - 1);
		chmax(saidai, dp[0] + b);
		rep(j, T - a) {
			chmax(dp[j], dp[j + a] + b);
		}
	}
	printf("%d", saidai);

	Would you please return 0;
}

Measured memory_bytes: 128
n,k = gets.chomp.split.collect{ |item| item.to_i}
rn = n-k
result = 0
num = 1000000007
data = Hash.new(0)

def calc_c(cn,ck)
  ck = [ck, cn-ck].min
  val = 0
  if ck==0
    val = 1
  else
    val = calc_c(cn-1,ck-1)*cn/ck
  end
  return val
end

k.times do |i|
  ki = i+1
  red_set = rn - ki + 1
  if (rn < (ki-1))
    puts 0
  else
    blue_va = calc_c(k-1,ki-1)
    red_va  = calc_c(rn+1,ki)
    result = blue_va * red_va
    puts result%num
  end
end


Measured memory_bytes: 2044
import java.util.*;

public class Main {

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

		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			
			int count = 0;
			int rst = 1000-n;
			
			count += rst/500;
			rst %= 500;
			count += rst/100;
			rst %= 100;
			count += rst/50;
			rst %= 50;
			count += rst/10;
			rst %= 10;
			count += rst/5;
			rst %= 5;
			count += rst;
			
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 17164
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    //準備
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    //答の入れ物
    int max = 0;
    //ACGT文字列のカウンタ
    int cnt = 0;

    //ACGT文字列なら1、それ以外なら0に変換
    for(int i=0; i<s.length(); i++){
      char c = s.charAt(i);
      if(c == 'A' | c == 'C' | c == 'G' | c == 'T') ++cnt;
      else { max = Math.max(max, cnt); cnt=0; }
    }
    //ACGT文字列最大長の更新
    max = Math.max(max, cnt);

    //出力
    System.out.println(max);
  }
}

Measured memory_bytes: 23636
#coding:UTF-8
def Marge(A,left,mid,right):
    n1=mid-left
    n2=right-mid
    L=[]
    R=[]
    c=0
    for i in range(n1):
        L.append(A[left+i])
    for i in range(n2):
        R.append(A[mid+i])
    L.append(100000000000000000)
    R.append(100000000000000000)
    i=j=0
    for k in range(left,right):
        if L[i]<=R[j]:
            A[k]=L[i]
            i+=1
        else:
            A[k]=R[j]
            j+=1
            c+=n1-i
    return c
            
def MS(A,left,right,c):
    
    if left+1<right:
        mid=int((left+right)/2)
        c1=MS(A,left,mid,c)
        c2=MS(A,mid,right,c)
        c3=Marge(A,left,mid,right)
        return c1+c2+c3
    return 0
 
    
if __name__=="__main__":
    n=int(input())
    A=input().split(" ")
    cnt=0
    for i in range(n):
        A[i]=int(A[i])
    cnt=MS(A,0,n,0)
    print(cnt)

Measured memory_bytes: 24584
#include <cstdio>
#include <algorithm>

const int mod = 100000;
const int maxx = 128, maxy = 128;

int main()
{
int w1[maxx][maxy] = {0};
int w2[maxx][maxy] = {0};
int s1[maxx][maxy] = {0};
int s2[maxx][maxy] = {0};

for(int i = 0; i < maxx; ++i)
w2[i][0] = 1;
for(int i = 0; i < maxy; ++i)
s2[0][i] = 1;

for(int x = 1; x < maxx; ++x) {
for(int y = 1; y < maxy; ++y) {
w1[x][y] = (s2[x - 1][y]) % mod;
w2[x][y] = (w1[x - 1][y] + w2[x - 1][y]) % mod;
s1[x][y] = (w2[x][y - 1]) % mod;
s2[x][y] = (s1[x][y - 1] + s2[x][y - 1]) % mod;
}
}

while(true) {
int w, h;
scanf("%d%d", &w, &h);
if(w == 0)
break;
w -= 1, h -= 1;
int ans = (s1[w][h] + s2[w][h] + w1[w][h] + w2[w][h]) % mod; 
printf("%d\n", ans);
}
return 0;
}

Measured memory_bytes: 1292