akhauriyash/Code-Regression huggingface dataset:
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
	fwrite(buf, 1, _bl, stdout);
	_bl = 0;
}
__inline void _putchar(char c) {
	if(_bl == _B) flush();
	buf[_bl++] = c;
}
inline void print(LL x, char c) {
	static char tmp[20];
	int l = 0;
	if(!x) tmp[l++] = '0';
	else {
		while(x) {
			tmp[l++] = x % 10 + '0';
			x /= 10;
		}
	}
	for(int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
	_putchar(c);
}
const int N = 303;
const int LOG = 20;
const int mod = 998244353;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[N][N][N];
int cnt[N], sufsum[N];
__inline void add(int & a, int b) {
	if((a += b) >= mod) a -= mod;
}
int main() {
	string s;
	int k;
	cin >> s >> k;
	k = min(k, 300);
//s.clear();
//for(int i = 0; i < 300; i++) s.pb(gene() % 2 + '0');
	n = 1;
	for(char c : s) {
		if(c == '0') {
			n++;
		}else {
			cnt[n]++;
		}
	}
	for(int i = n; i >= 1; i--) {
		sufsum[i] = sufsum[i + 1] + cnt[i];
	}
	dp[0][0][0] = 1;
	for(int i = 1; i <= n + 1; i++) {
		for(int j = 0; j <= sufsum[i]; j++) {
			for(int l = 0; l <= 300; l++) {
				if(dp[i - 1][j][l] == 0) continue;
				for(int k = max(0, cnt[i] - j); k <= 300 && l + k - cnt[i] <= 300 && j + k - cnt[i] <= 300; k++) {
					add(dp[i][j + k - cnt[i]][l + max(0, k - cnt[i])], dp[i - 1][j][l]);
				}
			//	printf("dp[%d][%d][%d] = %d\n", i - 1, j, l, dp[i - 1][j][l]);
			}
		}
	}
	int ans = 0;
	for(int l = 0; l <= k; l++) {
		ans = (ans + dp[n][0][l]) % mod;
	}
	cout << ans << endl;
}






Measured memory_bytes: 111560
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007


int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(2000, vector<char>(2000));
  rep(i, H) {
    rep(j, W) {
      cin >> S[i][j];
    }
  }

  vvi a(2000, vi(2000, 0)), hashx(2000, vi(2000, 0));
  rep(i, H) {
    int res = 0;
    rep(j, W) {
      if (S[i][j] == '#') {
        res++;
      }
      else {
        a[i][j] = res;
        hashx[i][res]++;
      }
    }
  }

  vvi b(2000, vi(2000, 0)), hashy(2000, vi(2000, 0));
  rep(j, W) {
    int res = 0;
    rep(i, H) {
      if (S[i][j] == '#') {
        res++;
      }
      else {
        b[i][j] = res;
        hashy[res][j]++;
      }
    }
  }
  int ans = 1;
  rep(i, H) {
    rep(j, W) {
      if (S[i][j] == '.') {
        int tmp = hashx[i][a[i][j]] + hashy[b[i][j]][j] - 1;
        ans = max(tmp, ans);
      }
    }
  }
  cout << ans << endl;

}





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

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    ll sum = 0;
    for (int i = 0; i < N - K; ++i) sum += v[i];
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const int imax = ~(1 << 31);
const long long linf = 1ll << 61;
const long long lmax = ~(1ll << 63);

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int par[200000];
int level[200000];

void init(int n)
{
    for (int i = 0; i < n; i++) {
        par[i] = i;
        level[i] = 0;
    }
}

int find(int x)
{
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (level[x] < level[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if(level[x] == level[y]) level[x]++;
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}

int N, M;
int pos[200000];

int main(int argc, char* argv[])
{
    scanf("%d%d", &N, &M);
    init(N);
    for (int i = 0; i < N; i++) {
        int p;
        scanf("%d", &p);
        p--;
        pos[p] = i;
    }
    for (int i = 0; i < M; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        x--; y--;
        unite(x, y);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (same(pos[i], i)) {
            ans++;
        }
    }
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1408
N=int(input())
H=list(map(int,input().split()))
count2=0
C=0
for i in range(0,N):
  C=max(C,H[i])
  if C-H[i]>1:
    print("No")
    count2 +=1
    exit()
if count2==0:
  print("Yes")
  

Measured memory_bytes: 14396
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    T = input()
    print(T.replace('?', 'D'))
    # N = int(input())
    # QUERYS = [input().split() for _ in range(Q)]
    # N, Q = [int(a) for a in input().split()]
    # A = [int(a) for a in input().split()]
    # T1, T2, T3 = [int(a) for a in input().split()]


if __name__ == "__main__":
    main()


Measured memory_bytes: 69452
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n; cin >> n;
  long maxa=0, maxb=0;
  for(int i=0;i<n;i++){
    long a,b;
    cin >> a >> b;
    if(a>maxa){
      maxa = a;
      maxb = b;
    }
  }
  cout << maxa + maxb << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<w;k++){
        cout << s[i][k];
      }
      cout << endl;
    }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb push_back


int main(){
    int N,A,B;
    cin >> N >> A >> B;
    cout << ((A-B)%2?"Borys":"Alice") << '\n';
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (c >= a && c <= b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e12
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
    ll n,d;
    
    cin>>n>>d;
    
    ll ans=0;
    
    
    for(ll i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        
        ll p=x*x+y*y;
        
        if(p<=d*d)
        ans++;
    }
    cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

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


int main() {
  double A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  double tm = 0;
  double ts = 0;
  double tc = 0;
  double m = 0;
  double s = 0;
  double c = 0;


  for(int i=0; 100*A*i<=F; i++){
    tm = 0;
    ts = 0;
    tc = 0;
    for(int j=0; 100*A*i+100*B*j<=F; j++){
      for(int k=0; 100*A*i+100*B*j+C*k<=F; k++){
        for(int l=0; 100*A*i+100*B*j+C*k+D*l<=F; l++){
          ts = C*k+D*l;
          tm = ts + 100*A*i+100*B*j;
          tc = ts*100 / tm;

          if(C*k+D*l<=E*(A*i+B*j) && tc > c){
            s = ts;
            m = tm;
            c = tc;
          }
        }
      }
    }
  }

  if(m == 0 && s == 0) cout << 100*A << " " << 0 << endl;
  else cout << m << " " << s << endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=0; cin>>n;
    for(ll i=1;i<=n;i++){
        ll k=n/i;
        ans+=i*(k+1)*k/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
N, T = gets.strip.split.map(&:to_i)
c = []
t = []
min = 1001
N.times do |i|
  c[i], t[i] = gets.chomp.split.map(&:to_i)
  if t[i] <= T
    if c[i] < min
      min = c[i]
    end
  end
end
if min == 1001
  puts "TLE"
else
puts min
end



Measured memory_bytes: 1788
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	static int w;
	static int h;
	static String[][] map;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			w = stdIn.nextInt();
			h = stdIn.nextInt();
			if(w == 0 && h == 0) break;
			map = new String[h][w];
			for(int i = 0; i < h; i++) {
				String tmp = stdIn.next();
				for(int j = 0; j < w; j++) {
					map[i][j] = String.valueOf(tmp.charAt(j));
				}
			}
			
			String ans = dp();
			
			System.out.println(ans);
		}
	}
	
	public static String dp() {
		String ret = "0";
		for(int i = h-1; i >= 0; i--) {
			for(int j = w-1; j >= 0; j--) {
				int cx1 = j;
				int cy1 = i+1;
				int cx2 = j+1;
				int cy2 = i;
				if(!fC(map[i][j])) continue;
				String a = map[i][j];
				String b = map[i][j];
				if(cx1 < w && cy1 < h &&fC(map[cy1][cx1])) {
					a = map[i][j] + map[cy1][cx1];
				}
				if(cx2 < w && cy2 < h && fC(map[cy2][cx2])) {
					b = map[i][j] + map[cy2][cx2];
				}
				if(StComp(a,b)) {
					map[i][j] = a;
				}
				else {
					map[i][j] = b;
				}
				if(!StComp(ret,LV(map[i][j]))) {
					ret = map[i][j];
				}
			}
			
		}
		
		return LV(ret);
	}
	public static String LV(String a) {
		String cp = a;
		for(int i = 0; i < a.length(); i++) {
			if(cp.charAt(0) == '0') {
				cp = cp.substring(1, cp.length());
			}
		}
		return cp;
	}
	// 数字の文字列比較　aがbより大きいか等しい場合trueを返す
	public static boolean fC(String a) {
		if(a.length() >= 2) {
			return true;
		}
		for(int i = 0; i < 10; i++) {
			if(a.charAt(0) == String.valueOf(i).charAt(0)) {
				return true;
			}
		}
		return false;
	}
	public static boolean StComp(String a, String b) {

		if(a.length() > b.length()) return true;
		if(a.length() == b.length()) {
			if(a.compareTo(b) < 0) return false;
			else return true;
		}
		return false;
	}
}
	

Measured memory_bytes: 64540
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
  int N, M; cin >> N >> M;
  vector<int> L(M); vector<int> R(M); 
  for(int i = 0; i < M ; i++){
    cin >> L[i] >> R[i];}
  
  int minimum = 1e5; int maximum = -1e5;
  
 for(int i = 0; i < M ; i++){
   
   int c = R[i]; int d = L[i];
 minimum = min(minimum,c);
   maximum = max(maximum,d);}
  
   if(minimum >= maximum){cout << minimum - maximum + 1;}
  else{cout << 0;}
  
  return 0;
}
 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	if(a>b || (n==1 && a!=b)){
		cout << 0 << endl;
		return 0;
	}
	ll va = (n-1)*a + b;
	ll vb = (n-1)*b + a;
	cout << max(vb - va + 1, 0LL) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
double dMAX(double a,double b){return a+1e-8<b?b:a;}
int main(){
  int n,m,i,j,k;
  double d[110][110],r[110][110],max;
  for(i=0;i<110;i++)d[0][i]=1;
  while(scanf("%d %d",&n,&m),n||m){
    for(i=1;i<m;i++){
      for(j=0;j<n;j++)d[i][j]=0;
    }
    for(i=0;i<n*n;i++)scanf("%lf",&r[i/n][i%n]);
    for(i=0;i<m;i++){
      for(j=0;j<n;j++){
	for(k=0;k<n;k++)d[i+1][k]=dMAX(d[i+1][k],d[i][j]*r[j][k]);
      }
    }
    for(i=max=0;i<n;i++)max=dMAX(max,d[m-1][i]);
    printf("%.2f\n",max);
  }
  return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 8272
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	int A, B, C, D, E;
	std::cin >> A >> B >> C >> D >> E;

	std::vector<int> v = { A, B, C, D, E };

	// 1の位の値が大きい順にソートする
	std::sort( v.begin(), v.end(), []( int a, int b ) {
			return ( a % 10 > b % 10 );
		} );

	// さらに1の位が0のものを前に持ってくる
	std::sort( v.begin(), v.end(), []( int a, int b ) {
			return ( a % 10 == 0 );
		} );

	int total = 0;
	for ( int i = 0; i < 5; i++ )
	{
		total += v[i];
		int mod = total % 10;

		if ( ( mod != 0 ) && ( i != 4 ) )	//	最後の要素は除外する
		{
			total += 10 - mod;
		}
	}

	std::cout << total << std::endl;

	return ( 0 );
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

prev = []
ans = 0
for _t in t:
    _p = ""
    if len(prev) >= k:
        _p = prev.pop(0)

    if _t == "r" and _p != "p":
        ans += p
        prev.append("p")
    elif _t == "s" and _p != "r":
        ans += r
        prev.append("r")
    elif _t == "p" and _p != "s":
        ans += s
        prev.append("s")
    else:
        prev.append("")

print(ans)


Measured memory_bytes: 3956
/*
  * author: said_v15
  * created with web_programmer
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
	char s;
	cin>>a>>s>>b;
	s=='+'? cout<<a+b: cout<<a-b;
	cout<<endl;
	return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
    using lint = long long int;
    int sz;
    lint mod;
    vector<lint> fac;
    vector<lint> finv;
    combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
        fac.assign(sz + 1, 1);
        finv.assign(sz + 1, 1);
        vector<lint> inv(sz + 1, 1);
        for (int i = 2; i <= sz; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint query(int n, int r) {
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
};

int main() {
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int n = (x + y) / 3;
    x -= n, y -= n;
    if (x < 0 || y < 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << combination_mod(n, 1e+9 + 7).query(n, x) << endl;
}

Measured memory_bytes: 15872
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(long long int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
int main() {
    int n, m, x; ll ans = INF; cin >> n >> m >> x;
    vector<int> c(n); int a[15][15];
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    rep(i, (1 << n)) {
        vector<int> un(m, 0); ll cnt = 0;
        rep(j, n) {
            if (i & (1 << j)) {
                rep(k, m) {
                    un[k] += a[j][k];
                }
                cnt += c[j];
            }
        }
        rep(j, m) {
            if (un[j] < x) break;
            if (j == m - 1) ans = min(ans, cnt);
        }
    }cout << (ans == INF ? -1:ans) << endl;
}

Measured memory_bytes: 3632
//The Doc

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d){
        cout<<"Yes"<<"\n";
    }
    else{
        cout<<"No"<<"\n";
    }
    return 0;
}


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


struct Node
{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

typedef struct Node Node;

Node *root;
Node *NIL;

void insert(int k);
void inorder(Node *u);
void preorder(Node *u);


int main(void)
{
  int n,x;
  int i;
  char com[20];

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%s",com);
	 
      if(com[0]=='i')
	{
	  scanf("%d",&x);
      
	  insert(x);
	}
    
      else if(com[0]=='p')
	{
	  inorder(root);
      
	  putchar('\n');
      
	  preorder(root);
      
	  putchar('\n');
      
	}
  
    }
  
  return 0;  
}

void insert(int k)
{
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL)
    {
      y=x;

      if(z->key<x->key)
	{
	  x=x->left;
	}
      
      else
	{
	  x=x->right;
	}
    }

  z->parent=y;

  if(y==NIL)
    {
      root=z;
    }

  else
    {
      if(z->key<y->key)
	{
	  y->left=z;
	}

      else
	{
	  y->right=z;
	}
    }
}

void inorder(Node *u)
{
  if(u==NIL)
    {
      return;
    }
  
  inorder(u->left);
  
  printf(" %d",u->key);
  
  inorder(u->right);  
}

void preorder(Node *u)
{
  if(u==NIL)
    {
      return;
    }
  
  printf(" %d",u->key);
  
  preorder(u->left);
  
  preorder(u->right);
}



Measured memory_bytes: 25180
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
  
long long int bit[300001];
const int N=3e+5; 

void update(int pos, long long int x)
{
    for (int i = pos; i <= 300001; i += (i & (-i)))
        bit[i] += x;
}

long long int qsum(int pos)
{
    long long int ans = 0;
    for (int i = pos; i > 0; i -= (i & (-i)))
        ans += bit[i];
    return ans;
}

void rupdate(int l, int r, long long int val)
{
    update(l, val);
    update(r + 1, -val);
}

long long int querry(int idx)
{
    return qsum(idx);
}
pair<long long int,long long int> v[N];

int main()
{
    long long int n,d,a;
    cin>>n>>d>>a;
    for(int i=1;i<=n;i++)
    {
        int x,h;
        cin>>x>>h;
        v[i]=make_pair(x,h);
    }
    sort(v+1,v+n+1);
    for(int i=1;i<=n;i++)
        rupdate(i,i,v[i].second);
    long long int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(querry(i)<=0)
            continue;
        int j=lower_bound(v+1,v+n+1,make_pair(v[i].first+2*d+1,0LL))-(v);
        j--;
        // cout<<j<<endl;
        long long int g=(querry(i)+a-1)/a;
        rupdate(i,j,-g*a);
        ans+=g;
    }
    cout<<ans;
}

Measured memory_bytes: 6528
n,m,k = map(int,input().split())

a=list(map(int,input().split()))
b=list(map(int,input().split()))

A=[0]
B=[0]
for i in a:
  A.append(i+A[-1])
for i in b:
  B.append(i+B[-1])
  
ans,j = 0,m
for i in range(n+1):
  if A[i] > k:
    break
  while B[j] + A[i] > k:
    j -= 1
  ans=max(ans,i+j)
print(ans)
  

Measured memory_bytes: 47352
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

struct edge{
  int to,cost;
  edge(){}
  edge(int to,int cost):to(to),cost(cost){}
};
typedef pair<int,int> P;

int d[101];
const int INF=(int)1e9;

int main(void){
  int n,k;
  while(cin>>n>>k,!(n==0&&k==0)){
    vector<edge> G[1000];
    for(int i=0;i<k;i++){
      int r,a,b,cost;
      cin>>r;
      if(r==1){
	cin>>a>>b>>cost;
	G[a].push_back(edge(b,cost));
	G[b].push_back(edge(a,cost));
      }
      if(r==0){
	cin>>a>>b;
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+101,INF);
	d[a]=0;
	que.push(P(0,a));
	while(!que.empty()){
	  P p=que.top();
	  que.pop();
	  if(d[p.second]<p.first)continue;
	  for(int j=0;j<G[p.second].size();j++){
	    edge e=G[p.second][j];
	    if(d[e.to]>d[p.second]+e.cost){
	      d[e.to]=d[p.second]+e.cost;
	      que.push(P(d[e.to],e.to));
	    }
	  }
	}
	if(d[b]==(int)INF){
	  cout<<"-1"<<endl;
	}else{
	  cout<<d[b]<<endl;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1248
#include <stdlib.h>

int main(void);
int chk(char str[]);

int chk(char str[]){
   if(str[2]==str[3] && str[4]==str[5])
      return 1;
   else
      return 2;
}

int main(void){
   char str[7];
   int flag;
   scanf("%s", str);
   flag = chk(str);
   if(flag==1)
     printf("Yes");
   else if(flag==2)
     printf("No");
   else
     printf("Error");
   return 0;
}

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

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

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

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

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

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

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

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

int main(){
    ll n;
    cin >> n;
    ll a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    ll m = min({ a, b, c, d, e });
    ll ans = (n + m - 1) / m + 4;
    cout << ans << endl;
    return 0;
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
ll dp[100007][3];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double pi= 3.14159265358979323846;
    ll n,k;
    cin>>n;
    ll a,b,c;
    cin>>a>>b>>c;
    dp[1][0]=a;
    dp[1][1]=b;
    dp[1][2]=c;
    for(ll i=2;i<=n;i++)
    {
        cin>>a>>b>>c;
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X,A,B,C,count=0;
    scanf("%d %d %d %d",&A,&B,&C,&X);
    for(int i=0;i<=A;i++)
        for(int j=0;j<=B;j++)
            for(int k=0;k<=C;k++)
                if(i*500+j*100+k*50==X)
                    count++;
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SUM(v) accumulate(ALL(v), 0)
#define AVE(v) SUM(v) / (v).size()
// 入力eと同じ値の要素の数
#define COUNT(v, e) count(ALL(v), e)

using namespace std;


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

  int a, b, c;
  cin >> a >> b >> c;

  if(a < b) { // a > b
    int swap = a;
    a = b;
    b = swap;
  }

  if(b <= c and c <= a)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
/*
* @Author: Nazrul Islam
* @Date:   2020-09-19 13:36:18
* @Last Modified by:   Nazrul Islam
* @Last Modified time: 2020-09-19 13:39:15
*/

#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll; 
typedef double dd;
typedef vector<int> vi;
typedef vector<char> vc;
typedef list<int> li;
typedef set<int> si;
typedef map<int,int> mp;
#define pb push_back
#define pf push_front
#define mk make_pair
#define sc scanf
#define pr printf
#define pi acos(-1.0)
#define endl '\n'
// char s[200009];
// char st[200009];
// int a[600][600];
// int b[29][10];
// int a[200009];
// int c[200009];
void solve()
{
	ll n, m, i, j, k, l; 
	cin >> n; m = n; ll sm = 0;
	while(n) {
		ll p = n%10;
		n = n/10;
		sm = sm + p;
	}
	if(m % sm == 0) cout << "Yes" << endl;
	else cout << "No" << endl; 
}
int main()
{
	IO;
	int t; 
	t = 1;
	// cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3508
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9+8
#define OO 1e18
#define EPS 1e-6
#define Endl '\n'
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=200005;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    vector<pair<ll,int> >a(n);
    for(int i=0;i<n;++i)
        scanf("%lld%d",&a[i].f,&a[i].s);
    sort(a.begin(),a.end());
    ll ans=0;
    for(auto i:a){
        if(!m)break;
        int Min=min(m,i.s);
        ans+=(Min*i.f);
        m-=Min;
    }
    printf("%lld\n",ans);
    re 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1000000007;
const int N = 100005;
const int M = 1000005;
 
#define ll                      long long int
#define loop(i,a,b)             for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)            for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)            for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)            for(int i=(int)a;i>=(int)b;--i)
#define pb                      push_back
#define F                       first
#define S                       second
#define mp                      make_pair
#define RALL(x)                 x.rbegin(),x.rend()
#define ALL(x)                     x.begin(),x.end()
#define MAX                     1e9
#define MIN                     -1e9
#define max(x,y)                (x>y)?x:y
#define min(x,y)                (x<y)?x:y
#define mid(l,r)                (l+(r-l)>>1)
#define mina(a)                    *min_element(a.begin(), a.end())
#define maxa(a)                    *max_element(a.begin(), a.end())
#define PI                      acos(-1.0)

typedef  map<string,int>         msi;
typedef  map<int,int>             mii;
typedef  map<ll, ll>             mll;
typedef  map<char,int>           mci;
typedef  map<int,string>         mis;
typedef  pair<int,int>              pii;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef  vector<int>              vi;
typedef  vector<string>          vs;
typedef  vector<char>             vc;
typedef  vector<bool>            vb;
typedef  vector< pii >           vii;

int dp[1000005];
vector<vi> adj;

int maxl(int x)
{
    if(dp[x]>=0) return dp[x];
    int maxx = -1;
    for(auto i : adj[x])
    {
        maxx = max(maxx, maxl(i)+1);
    }
    return dp[x]=maxx;

}

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    memset(dp,-1,sizeof(dp));
    int n, m;
    cin>>n>>m;
    int maxx=0;

    adj.resize(n+1);

    loop(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        adj[x-1].pb(y-1);
    }

    loop(i,0,n)
        maxx = max(maxx, maxl(i));

    cout<<maxx+1<<endl;


    return 0;
}

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

const int MAXN = 2000 + 200 + 20 + 2;
int arr[MAXN];
int tmp[MAXN];
int N, K, Q;

bool ok(int I, int dif) {
  memset(tmp, -1, sizeof tmp);
  for(int i = 0; i < N; i++)
    if(arr[i] >= arr[I] && arr[i] - arr[I] <= dif) tmp[i] = arr[i];
    else if(arr[i] >= arr[I]) tmp[i] = 0;
  int len = 0, tl = 0;
  long long ques = 0;
  for(int i = 0; i < N + 1; i++)
    if(tmp[i] == -1) {
      ques += max(min(len, tl - K + 1), 0);
      len = 0;
      tl = 0;
    } else len += (tmp[i] > 0), tl++;
  return ques >= Q;
}

int main() {
  scanf("%d %d %d", &N, &K, &Q);
  for(int i = 0; i < N; i++) scanf("%d", arr + i);
  int ans = 2e9 + 7;
  for(int i = 0; i < N; i++) {
    int l = 0, r = 2e9 + 7;
    while(l < r) {
      int mid = l + (r - l) / 2;
      if(ok(i, mid)) r = mid;
      else l = mid + 1;
    }
    ans = min(ans, l);
  }
  printf("%d\n", ans);
  return 0;
}


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

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

    bool Y = false;

    rep(i, N) {
        string S;
        cin >> S;

        if (S == "Y") {
            Y = true;
        }
    }

    if (Y) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s, p;
signed main() {
	int n;
	cin >> n;
	int a = 0, b = 0;
	for (int i = 0; i < n; i++) {
		cin >> s >> p;
		if (s == p) a++, b++;
		else if (s > p) a += 3;
		else b += 3;
	}
	cout << a << " " << b << endl;
}


Measured memory_bytes: 3204
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  vector<pair<ll, ll>> v;
  for (int i = 0; i < N; i++)
  {
    ll X, L;
    scanf("%lld", &X);
    scanf("%lld", &L);
    v.emplace_back(X + L, X - L);
  }
  sort(v.begin(), v.end());
  ll t = -INF, ans = 0;
  for (int i = 0; i < N; ++i)
  {
    if (t <= v[i].second)
    {
      ans++;
      t = v[i].first;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

double W,H,x,y;

int main(){
    cin>>W>>H>>x>>y;

    double ans=(W*H)/2;

    int ans2;
    if(x==W/2 && y==H/2){
        ans2=1;
    }else{
        ans2=0;
    }

    cout<<setprecision(10)<<ans<<' '<<ans2<<endl;
}

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

#define ll long long
#define all(it) it.begin(), it.end()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPU(i, a, b, s) for(int i = a; i < b; i += s)
#define REPD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k, t;

int f(int x) {
    if(x % 2 == 0) {
        return x / 2;
    } else {
        return 3 * x + 1;
    }
}
int main() {

    int N = 1000001;
    int s;
    cin >> s;

    int now, next;
    vector<int> m(N, 0);
    now = s;
    m[s] = 1;

    REPU(i, 2, 1000001, 1) {
        next = f(now);
        if(m[next] == 0) {
            m[next] = 1;
        } else {
            cout << i << endl;
            exit(0);
        }
        now = next;
    }
}

Measured memory_bytes: 7496
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

long long MOD = 1000000007;

int main(){
    double n, m, d;
    cin >> n >> m >> d;
    double ans=0.0;
    if(d==0){
        ans=n;
    }else{
        ans=min(n,2*d)+max(0.0,(n-2*d))*2;
    }
    ans=ans*(m-1)/n/n;
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#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 count = 0;
    for(int i = 1; i < n - 1; i++) if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) count++;

    cout << count << endl;

    return 0;
}

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

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=530005;
//i_am_noob
int n,m;
vector<int> a,b,c;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> m;
  	a.resize(n),b.resize(m);
	rep(n) cin >> a[i];
  	rep(m) cin >> b[i];
  	c=convolution(a,b);
  	rep(n+m-1) print0(c[i]);
  	cout << "\n";
    return 0;
}


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

int main() {
  // cin, coutが速くなる？
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< pair<int, int> > a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  // begin(), end() : 昇順
  // rbegin(), rend() : 降順
  sort(a.rbegin(), a.rend());
  for(int i = 0; i < n; i++) {
    // 降順にしたときに最大値をとるindexのみ2番目の値を出力
    if(i == a[0].second) cout << a[1].first << endl;
    else                 cout << a[0].first << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
n, m = map(int, input().split())
wa = [0]*(n+1)
ac = [0]*(n+1)
for i in range(m):
    p, s = input().split()
    p = int(p)
    if ac[p]:
        continue
    if s == 'WA':
        wa[p] += 1
    else:
        ac[p] = 1

a, b = 0, 0
for c, w in zip(ac, wa):
    if c == 0:
        continue
    a += 1
    b += w
print(a, b)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int a,int b,int c){
    int d;
    int k;
    k=min(a,b);
    d=min(k,c);
    while(1){
        if((a%d==0)&&(b%d==0)&&(c%d==0))return d;
        d--;
    }
}

int main(){ 
    int k;
    cin>>k;
    int ans=0;
    for(int i=1;i<k+1;i++){
        for(int j=1;j<k+1;j++){
            for(int l=1;l<k+1;l++){
                ans=ans+gcd(i,j,l);
            }
        }
    }

    cout<<ans<<endl;
    
 
    return 0;
}

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

char s[510];
int f(int i){
	if(s[i]!='m')return i;
	i=f(i+1);
	if(s[i]!='e')puts("Rabbit"),exit(0);
	i=f(i+1);
	if(s[i]!='w')puts("Rabbit"),exit(0);
	return i+1;
}

int main(){
	scanf("%s",s);
	puts(s[f(0)]?"Rabbit":"Cat");
}


Measured memory_bytes: 2108
S = '1 1 1 2 1 2 1 5 2 2 1 5 1 2 1 14 1 5 1 5 2 2 1 15 2 2 5 4 1 4 1 51'

S_list = S.split()

K = int(input())

print(S_list[K-1])


Measured memory_bytes: 2940
import sys
from time import time
from random import randint
input = lambda: sys.stdin.buffer.readline()

st = time()
def get_time():
    return time() - st

L = 26
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

ans = [randint(1, L) for _ in range(D)]

class BinaryIndexedTree:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (self.n+1)
    
    def sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res
    
    def add(self, i, x):
        if i <= 0: raise IndexError
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    def lower_bound(self, x):
        if x <= 0: return 0
        cur, s, k = 0, 0, 1 << (self.n.bit_length()-1)
        while k:
            nxt = cur + k 
            if nxt <= self.n and s + self.data[nxt] < x:
                s += self.data[nxt]
                cur = nxt
            k >>= 1
        return cur + 1

def rsum(x):
    return x*(x+1)//2

b = [BinaryIndexedTree(D) for _ in range(L)]

score = 0
for d, cont in enumerate(ans):
    cont -= 1
    b[cont].add(d+1, 1)
    score += S[d][cont]

for i in range(L):
    m = b[i].sum(D)
    tmp = 0
    s = [0]
    for j in range(1, m+1):
        s.append(b[i].lower_bound(j))
    s.append(D+1)

    for j in range(len(s)-1):
        x = s[j+1] - s[j] - 1
        tmp += rsum(x)
    
    score -= tmp*C[i]

def chg(d, p, q):
    diff = 0
    d += 1

    o = b[p].sum(d)
    d1 = b[p].lower_bound(o-1)
    d2 = b[p].lower_bound(o+1)

    diff += rsum(d-d1) * C[p]
    diff += rsum(d2-d) * C[p]
    diff -= rsum(d2-d1) * C[p]

    o = b[q].sum(d)
    d1 = b[q].lower_bound(o)
    d2 = b[q].lower_bound(o+1)

    diff += rsum(d2-d1) * C[q]
    diff -= rsum(d-d1) * C[q]
    diff -= rsum(d2-d) * C[q]

    d -= 1
    diff -= S[d][p]
    diff += S[d][q] 

    return diff

while True:
    d, q = randint(1, D), randint(1, L)
    p = ans[d-1]
    diff = chg(d-1, p-1, q-1)
    if diff > 0:
        ans[d-1] = q
        b[p-1].add(d, -1)
        b[q-1].add(d, 1)
        score += diff

    if get_time() >= 1.7: break

for x in ans:
    print(x)


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

lst = [list(map(int,input().split())) for _ in range(N)]

x = 0
y = 0
t = 0
ans = 'Yes'

for i in lst:
  diff_t = i[0] - t
  dis = abs(i[1] - x) + abs(i[2] - y)
  if (diff_t < dis):
    ans = 'No'
    break
  if ((dis - diff_t) % 2 != 0):
    ans = 'No'
    break
  x = i[1]
  y = i[2]
  t = i[0]
print(ans)

Measured memory_bytes: 61400
H,W = map(int,input().split())
ss=[]
for s in range(H):
    ss.append(input().strip())
flg=True
for i in range(H):
    for j in range(W):
        if ss[i][j]== "#":
            if not (j>0 and ss[i][j-1] == "#"or j<W-1 and ss[i][j+1] == "#" or i>0 and ss[i-1][j]=="#" or i< H-1 and ss[i+1][j]=="#"):
                flg=False
                break
    if not flg:
        break
print("No Yes".split()[int(flg)])  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n, a[100000], dp[100000];
int f(int i)
{
    if( i == n-1 )
        return 0;
    if( dp[i] != -1 )
        return dp[i];
    dp[i]= f(i+1)+abs(a[i]-a[i+1]);
    if( i < n-2 )
        dp[i] = min( dp[i], f(i+2)+abs(a[i]-a[i+2]) );
    return dp[i];
}
int main()
{
    scanf("%d", &n);
    for(int i=0; i<n; ++i)
        scanf("%d", a+i);
    memset(dp, -1, sizeof dp);
    cout << f(0);
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    if (N <= K){
        cout << N * X << endl;
    }
    else{
        cout << K * X + (N - K) * Y << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;



int main()
{
	fastio
  string s, t;
  cin >> s >> t;
  if(s.size()+1==t.size() && s==t.substr(0,s.size())) cout << "Yes\n";
  else cout << "No\n";
	return 0;
}






Measured memory_bytes: 3652