akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue,copy
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])
def graph():
    n,m=inpm()
    g=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=inpm()
        a-=1
        b-=1
        g[a].append(b)
        #g[b].append(a)
    return n,m,g

def main():
    n,m=inpm()
    py=[]
    num=[1 for _ in range(n)]
    for i in range(m):
        p,y=inpm()
        py.append([y,p,i])
    py.sort()
    ans=[]
    for i in range(m):
        ID_head=list(str(py[i][1]))
        ID_back=list(str(num[py[i][1]-1]))
        num[py[i][1]-1]+=1
        if len(ID_head)<6:
            ID_head=['0' for _ in range(6-len(ID_head))] + ID_head
        if len(ID_back)<6:
            ID_back=['0' for _ in range(6-len(ID_back))] + ID_back
        ID=ID_head+ID_back
        ans.append( [ py[i][2] , ID ] )
    ans.sort()
    for i in range(m):
        print(''.join(ans[i][1]))
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 124076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;
	vector<ll>arr(n);
	for(ll& x:arr){
		cin>>x;
	}
	ll sum=0;
	for(int i=1;i<n;i++){
		if(arr[i]<arr[i-1]){
			sum+=(arr[i-1]-arr[i]);
			arr[i]=arr[i-1];
		}
	}
	cout<<sum<<'\n';

	return 0;
}

Measured memory_bytes: 4780
class MaxHeap:
    def __init__(self):
        self.__pq = []
        self.__length = 0
    def length(self):
        return self.__length
    def push(self,item):
        self.__pq.append(item)
        self.__length += 1
        i = self.__length - 1
        while i > 0:
            p = (i-1)//2
            tmp = self.__pq[p]
            if tmp >= item:
                break
            self.__pq[p] = item
            self.__pq[i] = tmp
            i = p    
    def popMax(self):
        if self.__length == 0:
            return None
        ret = self.__pq[0]
        if self.__length == 1:
            self.__length -= 1
            return self.__pq.pop(0)
        self.__pq[0] = self.__pq.pop(self.__length-1)
        self.__length -= 1
        i = 0
        while 2*i+1 < self.__length:
            larger = 2*i+1
            if 2*i+2 < self.__length:
                if self.__pq[2*i+2] > self.__pq[larger]:
                    larger = 2*i+2
            tmp = self.__pq[larger]
            if tmp <= self.__pq[i]:
                break
            self.__pq[larger] = self.__pq[i]
            self.__pq[i] = tmp
            i = larger
        return ret
    
    def isempty(self):
        return self.__length == 0
from collections import defaultdict
N,M = map(int,input().split())
PQ = MaxHeap()
dic = defaultdict(list)
for i in range(N):
    a,b = map(int,input().split())
    dic[a].append(b)
keys = list(dic.keys())
keys.sort()
n = 1
ans = 0
i = 0
ln = len(keys)
while n <= M:
    if i < ln and keys[i] == n:
        for l in dic[keys[i]]:
            PQ.push(l)
        i  += 1
    if not PQ.isempty():
        ans += PQ.popMax()
    n += 1
print(ans)

Measured memory_bytes: 27644
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int a, b, n;
	char op;
	while (cin >> a >> op >> b && op != '?') {
		switch (op) {
		case '+':
			n = a + b; break;
		case '-':
			n = a - b; break;
		case '/':
			n = a / b; break;
		case '*':
			n = a * b; break;
		}
		cout << n << endl;
	}

	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  string S, T;
  cin >> S >> T;
  bool same = true;
  if ((S.length()+1) == T.length()) {
    for (int i = 0; i < S.length(); i++) {
      if (S[i] != T[i]) same = false;
    }
  } else {
    same = false;
  }
  if (same) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#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 pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#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 in(x, a, b) ((a) <= (x) && (x) < (b))
#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(a, p);
    p += a * 3;

    std::cout << p / 2 << std::endl;

    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

sq = []
for i in range(H):
    sq.append(list(input().rstrip()))

for i in range(H):
    r = ''
    for j in range(W):
        if sq[i][j] == '#':
            r += '#'
            continue
        cnt = 0
        for y in range(i-1, i+2):
            if y < 0 or y > H-1:
                continue
            for x in range(j-1, j+2):
                if x < 0 or x > W-1:
                    continue
                if sq[y][x] == '#':
                    cnt += 1
        r += str(cnt)
    print(r)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int C, D, E;
cin >> C;
E = C;
D = C;
int J = 0;

E /= 500;
J += E * 1000;
D = C % 500;
D /= 5;
J += D * 5;

cout << J << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

bool isprime[100010];
int a[100010];

void sieve(int n)
{
  for (int i=0; i<=n; i++) isprime[i] = true;
  isprime[0] = isprime[1] = false;
  for (int i=2; i<n; i++) {
    if (isprime[i]) {
      for (int j=2*i; j<=n; j+=i) isprime[j] = false;
    }
  }
}

int main()
{
  int q; cin>>q;
  vector<int> ans;

  sieve(100000);
  for (int i=1; i<=100000; i++) {
    if (i%2 && isprime[i] && isprime[(i+1)/2]) a[i]++;
    a[i+1] += a[i];
  }

  while (q--) {
    int l,r; cin>>l>>r;
    cout << a[r]-a[l-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 4088
# Thanks <3 https://qiita.com/derodero24/items/91b6468e66923a87f39f#%E7%95%AA%E5%A4%96%E7%B7%A8
def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  # 出力の制限
N = 10 ** 6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


x, y = map(int, input().split())
if (x + y) % 3 != 0:
    print(0)
    exit()

# n = (i + 1, j + 2) / m = (i + 2, j + 1)
n = int((2 * y - x) / 3)
m = int((2 * x - y) / 3)
print(cmb(n + m, m, mod))


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

string formula;
int not_[3] = {2,1,0};
int and_[3][3] = { {0,0,0},{0,1,1},{0,1,2}};
int or_[3][3] = { {0,1,2},{1,1,2},{2,2,2}};
int R,Q,P;

int parse(int &pos) {
    int ret;
    if(formula[pos] == 'R') ret = R;
    else if(formula[pos] == 'Q') ret = Q;
    else if(formula[pos] == 'P') ret = P;
    else if('0'<=formula[pos] && formula[pos] <= '9') ret = formula[pos] - '0'; 
    else if(formula[pos] == '(') {
        ret = parse(++pos);
        if(formula[pos] == '+') ret = or_[ret][parse(++pos)];
        else if(formula[pos] == '*') ret = and_[ret][parse(++pos)];
    }
    else if(formula[pos] == '-') return not_[parse(++pos)];

    pos++;

    return ret;

} 

void solve() {
    int pos = 0;
    int ans = 0;
    for(P=0;P<=2;P++) {
        for(Q=0;Q<=2;Q++) {
            for(R=0;R<=2;R++) {
                pos = 0;
                if(parse(pos) == 2) ans++;
            }
        }
    }

    cout<<ans<<endl;

}
int main() {
    while(cin>>formula) {
        if(formula==".") return 0;

        solve();
    }


    return 0;
}

Measured memory_bytes: 1192
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n

#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define FOR(i,m,n) for(int (i)=(m);(i)<(n); i++)
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
	ll N,K;cin>>N>>K;
	ll H[N];REP(i,N)cin>>H[i];
	sort(ALL(H,N),greater<int>());
	ll count=0;
	REP(i,N){
		if(K>0){
			H[i]=0;
			K--;
		}
		else{
			count+=H[i];
		}
	}
	cout<<count;
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

vector<int> f(int n) {
	ll p = 0;

	vector<int> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;

	for (int i = 2; i * i <= n; i++) {
		if (!isPrime[i]) {
			continue;
		}

		for (int j = 2 * i; j <= n; j += i) {
			isPrime[j] = false;
		}
	}

	vector<int> a(n);
	for (int i = 3; i < n; i++) {
		a[i] = isPrime[i] && isPrime[(i + 1) / 2];
	}

	vector<int> memo(n + 1);
	for (int i = 1; i <= n; i++) {
		memo[i] += memo[i - 1] + a[i - 1];
	}

	return memo;
}

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


	const int N_MAX = (int)1e5 + 30;
	vector<int> memo = f(N_MAX);

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;

		cout << memo[r + 1] - memo[l] << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int keta(int i) {
	int ret=0;
	while (i > 0) {
		i /= 10;
		ret++;
	}
	return ret;

}
void ita(int y, vector<int> *x) {
	int i = x->size()-1;
	while (y > 0) {
		x->at(i--) = y % 10;
		y /= 10;
	}
}
int main() {
	int a, b;
	cin >> a >> b;
	int count = 0;
	for (int i = a; i <= b; i++) {
		vector<int> x(keta(i));
		ita(i, &x);
		int l = 0, r = x.size() - 1;
		while (x.at(l++) == x.at(r--)&&x.at(0)!=0) {
			if (l > r) {
				count++;
				break;
			}
		}
	}
	cout << count << endl;
}

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

const int N = 1000010;

bool prime[N];
int number[N];
void init() {
  for (int i=0;i<N;i++) prime[i] = true;
  prime[0] = prime[1] = false;
  for (int i=0;i<=sqrt(N);i++) {
    if (prime[i]) {
      for (int j=i*2;j<N;j+=i) prime[j] = false;
    }
  }
  number[0] = 0;
  for (int i=0;i<N-1;i++) {
    number[i + 1] = number[i] + prime[i + 1];
  }
}

int main() {
  int n;
  init();
  while (cin >> n) {
    cout << number[n] << endl;
  }
}

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

using namespace std;

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

    int d;
    cin >> d;

    if(d == 22)
        cout << "Christmas Eve Eve Eve";
    else if(d == 23)
        cout << "Christmas Eve Eve";
    else if(d == 24)
        cout << "Christmas Eve";
    else
        cout << "Christmas";

    return 0;
}


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

int main() {
  int n,k;
  cin>>n>>k;
  int v[55],sort_lr[55];
  for (int i=0; i<n; i++) {
    cin>>v[i];
  }
  int ans=0;
  for (int left=0; left<=k; left++) {
    for (int right=0; right<=min(n-left,k-left); right++) {
      for (int i=0; i<=left-1; i++) {
	sort_lr[i]=v[i];
      }
      for (int i=0; i<=right-1; i++) {
	sort_lr[i+left]=v[n-1-i];
      }
      sort(sort_lr,sort_lr+(left+right));
      int have=0;
      for (int i=0; i<min(left+right,k-(left+right)); i++) {
	if (sort_lr[i]>0) have+=sort_lr[i];
      }
      for (int i=k-(left+right); i<=left+right-1; i++) {
	have+=sort_lr[i];
      }
      ans=max(ans,have);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;



const int N = (int) 1e6 + 100;
int a[3][N];

int getC(int n, int i)
{
    int j = 20;
    while (n >= 0)
    {
        while ((1 << j) > n)
            j--;
        if (i > n)
            return 0;
        //eprintf("(%d, %d) : -= %d\n", n, i, 1 << j);
        n -= (1 << j);
        if (i >= (1 << j))
            i -= (1 << j);
    }
    return 1;
}

char s[N];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    for (int i = 0; i < 20; i++)
    {
        for (int j = 0; j < 20; j++)
            eprintf("%d", getC(i, j));
        printf("\n");
    }

    int n;
    scanf("%d", &n);
    scanf("%s", s);
    for (int i = 0; i < n; i++)
        a[0][i] = s[i] - '0';

    for (int t = 0; t < 2; t++)
    {
        for (int i = 0; i < n; i++)
        {
            a[t + 1][i] = abs(a[t][i] - a[t][i + 1]);
        }
    }

    if (n <= 3)
    {
        printf("%d\n", a[n - 1][0]);
        return 0;
    }

    int ans = 0;
    n -= 2;
    //eprintf("n = %d\n", n);
    int x = 2;

    for (int i = 0; i < n; i++)
        if (a[2][i] == 1)
            x = 1;
    for (int i = 0; i < n; i++)
    {
        //eprintf("%d", a[2][i]);
        ans ^= getC(n - 1, i) * (a[2][i] == x) * x;
    }
    eprintf("\n");

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

	return 0;
}




Measured memory_bytes: 12928
#include<stdio.h>
#include<stdlib.h>
int main(){
  int a,b;
  if(scanf("%d%d",&a,&b)==-1){
    exit(1);
  }
  if(a>12){
    printf("0\n");
    return 0;
  }
  if(b>31){
    printf("0\n");
    return 0;
  }
  if(a==2 && b>28){
    printf("0\n");
    return 0;
  }
  if((a==4 || a==6 || a==9 ||a==11) && b>30){
    printf("0\n");
    return 0;
  }
  if(a>b){
    printf("%d\n",a-1);
  }
  else{
    printf("%d\n",a);
  }
  return 0;
}


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

int main(){
    int n,m;
    cin >> n;
    vector<string> s(n);
    vector<string> t(m);
    rep(i, n){
        cin >> s.at(i);
    }
    cin >> m;
    rep(i, m){
        cin >> t.at(i);
    }
    map<string,int> mp;
    rep(i, n){
        mp[s.at(i)]++;
    }
    rep(i, m){
        mp[t.at(i)]--;
    }

    int ans = 0;
    rep(i, n){
        if (ans < mp[s.at(i)]){
            ans = mp[s.at(i)];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
//shara's here
//私は大きな男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
#include <bits/stdc++.h>
using namespace std;
//fold
typedef double w;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
	ll x;
	cin>>x;
	ll ar[x];
	int cnt=0,cnt1=0;
	bool ok=false;
	for(ll i=0;i<x;i++){	
	cin>>ar[i];
	if(ar[i]%2==0)cnt++;
	}
	for(ll i=0;i<x;i++){
	if(ar[i]%2==0&&(ar[i]%3==0||ar[i]%5==0)){ok=true; cnt1++;}
	}
	if((cnt==cnt1)){cout<<"APPROVED"<<endl;}
	else cout<<"DENIED"<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	






return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/




Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    s: chars,
    t: chars,
  }
  for i in 0 .. n {
    puts!("{}{}", s[i], t[i]);
  }
  puts!("\n");
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int h,w;
    cin >> h >> w;
    vs s(h);
    rep(i,h) cin >> s[i];
    rep(i,h){
        rep(j,w)if(s[i][j] == '#')break;
        if(j == w){
            rep(j,w)s[i][j] = '*';
        }
    }
    rep(j,w){
        rep(i,h)if(s[i][j] == '#')break;
        if(i == h){
            rep(i,h)s[i][j] = '*';
        }
    }
    rep(i,h){
        bool t = false;
        rep(j,w)if(s[i][j]!='*')cout << s[i][j], t = true;
        if(t)cout << endl;
    }
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    int x;
    cin >> s >> x;
    int n = s.size();
    int dp[105][4][2] = {0};
    dp[0][0][0] = 1;
    rep (i, n) {
        rep (j, 4) {
            rep (k, 2) {
                int cur = s[i] - '0';
                rep (digit, 10) {
                    int ni, nj, nk;
                    ni = i + 1, nj = j, nk = k;
                    if (digit != 0) nj++;
                    if (nj > x) continue;
                    if (k == 0) {
                        if (digit > cur) continue;
                        if (digit < cur) nk = 1;
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    cout << dp[n][x][0] + dp[n][x][1] << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  int a, b;

  scanf("%d %d", &a, &b);

  int ans = a + b;

  if(ans < a - b)
    ans = a-b;

  if(ans < a * b)
    ans = a * b;

    printf("%d", ans);


  return 0;
}


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

int main() {
	int n,m,x,broken[100010]{0};
	long long ans=0LL,mod=1000000007LL,D[100010];
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		cin >> x;
		broken[x] = 1;
	}
	D[0] = 1;
	D[1] = !broken[1];
	for(int i=2;i<=n;i++){
		if(broken[i]){
			D[i] = 0;
		}else{
			D[i] = (D[i-1]+D[i-2])%mod;
		}
	}
	ans = D[n];
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1408
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int  a, b, c, x, y, ans=100000000000000LL ; 
    cin >> a >> b >> c >> x >> y ;  
    for (int i=0;i<=max(x,y);i++){
        int cur=i*2*c + max(x-i,0LL)*a+max(y-i,0LL)*b;
        ans = min(cur,ans);
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3616
gets
a = gets.split.map(&:to_i)
*lhs, rhs = *a
dp = Array.new(lhs.count).map{Array.new(21, 0)}
lhs.each_with_index do |n, i|
	if i == 0
		dp[i][lhs[i]] = 1
	else
		(0..20).each do |j|
			unless dp[i - 1][j] == 0
				l = j + lhs[i]
				m = j - lhs[i]
				dp[i][l] += dp[i - 1][j] if l <= 20
				dp[i][m] += dp[i - 1][j] if m >= 0
			end
		end
	end
end
p dp[lhs.count - 1][rhs]

Measured memory_bytes: 8672
import java.util.*;
public class Main{
	private static Scanner sc=new Scanner(System.in);
	public static void  main(String[]agrs){
		int a[][]=new int[14][14];
		while(sc.hasNext()){
		String m=sc.nextLine();
		String[] mm=m.split(",");
		 //System.out.println(mm[0]);
		 int x=Integer.parseInt(mm[0]);
		 int y=Integer.parseInt(mm[1]);
		 int size=Integer.parseInt(mm[2]);
		// System.out.println(x);//
		// System.out.println(y);
		// System.out.println(size);
		 int kx=x+2;
		 int ky=y+2;
		 //System.out.println(kx);
		// System.out.println(ky);
			a[kx][ky]++;
			a[kx+1][ky]++;
			a[kx][ky+1]++;
			a[kx-1][ky]++;
			a[kx][ky-1]++;
		 if(size>=2){
			 a[kx+1][ky+1]++;
			 a[kx-1][ky+1]++;
			 a[kx+1][ky-1]++;
			 a[kx-1][ky-1]++;
		 }
		 if(size>=3){
			 a[kx+2][ky]++;
			 a[kx-2][ky]++;
			 a[kx][ky+2]++;
			 a[kx][ky-2]++;
		}
		}
		int cnt0=0;
		int max=0;
		for(int i=2;i<12;i++){
			for(int j=2;j<12;j++){
			if(a[i][j]==0)cnt0++;
			if(a[i][j]>max)max=a[i][j];
			}
		}
		System.out.println(cnt0);
		System.out.println(max);
		
	
	}
}

Measured memory_bytes: 17184
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]


N, K = LI()
ab = LIR(N-1)

utov = [[] for i in range(N+1)]

for a, b in ab:
    utov[a].append(b)
    utov[b].append(a)

q = deque()
bfs = [-1]*(N+1)

bfs[1] = K

child = 0
for v in utov[1]:
    if (bfs[v] == -1):
        child += 1
        bfs[v] = K - child
        q.append(v)

while q:
    u = q.popleft()
    child = 1
    for v in utov[u]:
        if (bfs[v] == -1):
            child += 1
            bfs[v] = K - child
            q.append(v)

ans = 1

for pattern in bfs[1:]:
    ans = ans*pattern % mod

print(ans%mod)


Measured memory_bytes: 74972
#include <stdio.h>  
#include <string.h>  
#include <stdlib.h>  
#include <iostream>  
#include <algorithm>  
#include <time.h>  
#include<cstdio>
#include<vector>
#include<functional>
 
 
using namespace std;
 
int t[9]={0};
 
int main() {
	int n;
	int x;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (x <= 399)t[0]++;
		else if (x <= 799)t[1]++;
		else if (x <= 1199)t[2]++;
		else if (x <= 1599)t[3]++;
		else if (x <= 1999)t[4]++;
		else if (x <= 2399)t[5]++;
		else if (x <= 2799)t[6]++;
		else if (x <= 3199)t[7]++;
		else t[8]++;
	}
	int num=0;
	for (int i = 0; i < 8; i++) {
		if (t[i]!= 0)num++;
	}
	if(num!=0){
	
		printf("%d ", num);
		num += t[8];
		printf("%d", num);	
	}
	else{
		printf("1 %d",t[8]);
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    long long x, y; cin >> x >> y;
    cout << min(y / 2, (2 * x + y) / 4) << endl;
}

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

using namespace std;

const int inf=1e9+5;
const int MOD=1e9+7;
const int MAX=1e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define vl vector<vector<ll> >
#define eb emplace_back

int n;
ll a[3005],dp[3005][3005]={};

long long solve(){
    for(int i=0;i<n;i++){
        dp[i][i]=a[i];
    }
    for(int l=n-1;l>=0;l--){
        for(int r=l;r<n;r++){
            dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
        }
    }
    cout<<dp[0][n-1];
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 70016
#include<bits/stdc++.h>
#include<ctime>
#include<random>
#include<unordered_map>
using namespace std;

int main(){
	string s;
	cin >> s;
	if (s.size() < 4){
		puts("No");
		return 0;
	}
	if (s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I'){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}

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

const int INF = 0x3f3f3f3f;
const int MAXN = 2e2+50;
const int COIN_NUM = 5;
const int coin[COIN_NUM] = {1, 5, 10, 25, 50};
int dp[MAXN];
int min_path[MAXN];

int main()
{
	int *nums = new int[10];
	fill(nums, nums+10, 0);
	int a,b,c; cin>>a>>b>>c;
	nums[a]++;
	nums[b]++;
	nums[c]++;
	for(int i = 0; i < 10; ++i) {
		if(nums[i] == 2) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0; 
}

Measured memory_bytes: 256
from collections import Counter
from math import sqrt

n, p = map(int, input().split())
c = Counter()

for i in range(2, int(sqrt(p))+1):
	while p % i == 0:
		c[i] += 1
		p = p // i
c[p] += 1

#print(c)
ans = 1
for key, value in c.items():
	if value >= n:
		ans *= key ** (value // n)

print(ans)

Measured memory_bytes: 3444
import sys
import collections
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    D=list(map(int,input().split()))
    c=collections.Counter(D)
    k=list(c.keys())
    v=list(c.values())
    ans=1 if c[0] == 1 and D[0] == 0 else 0
    for i in range(max(k)):
        ans*=c[i]**c[i+1]
        ans%=998244353
        if ans == 0:
            break
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62772
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<int> a(n);
	cin >> a;

	bool zero = 0;
	int num = 0;
	for(auto& i : a){
		zero += i == 0;
		num += i < 0;
		i = abs(i);
	}

	int sum = accumulate(all(a), 0LL);
	if(num % 2) sum -= *min_element(all(a)) * 2;
	cout << sum << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

ll h, w;
vector<string> v;

ll cnt(ll y, ll x){
    ll ans = 0;
    rep(i, 8){
        ll ny = y + ddy[i], nx = x + ddx[i];
        if(0 <= ny && ny < h && 0 <= nx && nx < w && v[ny][nx] == '#') ans++;
    }
    return ans;
}


int main(){
    cin >> h >> w;
    v.resize(h);
    rep(i, h) cin >> v[i];
    rep(i, h){
        rep(j, w){
            if(v[i][j] == '#') cout << '#';
            else cout << cnt(i, j);
        }
        cout << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int n = i, count = 0;
    while (n != 0)
      n /= 10, ++count;
    if (count % 2 == 1)
      ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int MOD = 1000 * 1000 * 1000 + 7, N = 3001;
int dp[N][N], last[N][N], a[N], pw[N];
int cur = 0;
inline int get(int i, int j) {
    dp[i][j] = (dp[i][j] * pw[cur - last[i][j] - 1]) % MOD;
    last[i][j] = cur;
    return dp[i][j];
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    pw[0] = 1;
    for (int i = 1; i < N; ++i) pw[i] = (pw[i - 1] << 1) % MOD;
    int n, q; cin >> n >> q;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) last[i][j] = -1;
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) dp[i][j] = a[i] < a[j];
    while (q--) {
        int i, j; cin >> i >> j; --i; --j;        
        dp[i][j] = dp[j][i] = (get(i, j) + get(j, i)) % MOD;
        for (int k = 0; k < n; ++k) {
            if (k != i && k != j) {
                dp[i][k] = dp[j][k] = (get(i, k) + get(j, k)) % MOD;
                dp[k][i] = dp[k][j] = (get(k, i) + get(k, j)) % MOD;
            }   
        }   
        ++cur;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) for (int j = 0; j < i; ++j) ans = (ans + get(i, j)) % MOD;
    cout << ans << '\n';
}

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

int n,ans=0,res[100010];
vector<int>g[100010];
vector<int>w[100010];

void dfs(int x,int par,int nos)
{
	int cnt=0;
	for(int i=0; i<g[x].size(); i++)
		if(g[x][i]!=par)
		{
			cnt++;
			if(cnt==nos)
				cnt++;
			res[w[x][i]]=cnt;
			dfs(g[x][i],x,cnt);
		}
}
int main()
{
	cin>>n;
	for(int i=0; i<n-1; i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
		w[x].push_back(i),w[y].push_back(i);
	}
	for(int i=1; i<=n; i++)
		ans=max(ans,(int)g[i].size());
	cout<<ans<<"\n";
	dfs(1,-1,-1);
	for(int i=0; i<n-1; i++)
		cout<<res[i]<<"\n";
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    vi b(n-1);
    rep(i,n-1) cin >> b[i];
    int ans = b[0] + b[n-2];
    if(n==2) cout << ans << endl;
    else {
        for(int i = 1; i < n-1; i++) {
            ans += min(b[i-1], b[i]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n) {
        mp[a[i]]++;
        mp[a[i]+1]++;
        mp[a[i]-1]++;
    }
    int ans = 0;
    for(auto& p : mp) {
        ans = max(ans, p.se);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector <int> p(n);
  for (int i=0; i<n; i++){
    cin >> p.at(i);
  }
  int count = 0;
  for (int i=1; i<n-1; i++){
    if ((p.at(i-1)< p.at(i) && p.at(i) <= p.at(i+1)) || (p.at(i+1)<p.at(i) && p.at(i)<=p.at(i-1))){
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import math

A,B,H,M = map(int,input().split())

ha = 30 * H + 0.5 * M
if M == 0 :
    ma = 360
else:
    ma = 6 * M

if ha > ma:
    an = ha - ma
    print((A**2 + B**2 - (2 * A * B * round(math.cos(math.radians(an)),20)))**0.5)
elif ma > ha:
    an = ma - ha
    print((A**2 + B**2 - (2 * A * B * round(math.cos(math.radians(an)),20)))**0.5)
else:
    if H == 6 and M == 0:
        print(A+B)
    else:
        print(B-A)

Measured memory_bytes: 9532
a, b, k = map(int, input().split())

if k > a + b:
    ans_a = 0
    ans_b = 0
elif a >= k:
    ans_a = a - k
    ans_b = b
else:
    ans_a = 0
    ans_b = b - (k - a)

print(ans_a, ans_b)


Measured memory_bytes: 2940
import java.util.*;

public class Main {

	public static void main(String[] args) {
		String w, temp;
		int counter = 0;
		Scanner sc = new Scanner(System.in);
		w = sc.next().toLowerCase();
		while (true) {
			temp = sc.next();
			if(temp.toLowerCase().equals(w))
				counter++;
			if(temp.equals("END_OF_TEXT"))
				break;
		}
		System.out.println(counter);
	}

}

Measured memory_bytes: 18000
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000000000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), s(m), pref = {0};
    for (int q = 0; q < n; q++){
        cin >> a[q];
    }
    for (int q = 0; q < m; q++){
        cin >> s[q];
        pref.push_back(pref.back()+s[q]);
    }
    int ans = 0, now = k;
    for (int q = 0; q <= n; q++){
        int l = 0, r = m+1;
        while (r-l > 1){
            int m1 = (l+r)/2;
            if (pref[m1] > now){
                r = m1;
            }else{
                l = m1;
            }
        }
        ans = max(ans, q+l);
        if (q == n){
            break;
        }
        now -= a[q];
        if (now < 0){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8456
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

int n;
int bill[2][102];
bool mem[2][102];
const int INF = 1000000000;
int count;

int DFS(int i,int j)
{
	mem[i][j] = true;
	while(bill[i][j] == 1 && bill[i][j+1] == 1)
		j++;
	while(bill[i][j] == 2)
		j--;
	if(j >= n-1)
		return count;		
	if(i==0){
		if(mem[1][j+2] == false){
			count++;
			return DFS(1,j+2);
		}
	}else{
		if(mem[0][j+2] == false){
			count++;
			return DFS(0,j+2);
		}
	}
	return INF;
}
int main()
{
	while(cin >> n){
		if(!n)
			break;
		for(int i=0;i<2;i++){
			for(int j=0;j<n;j++){
				cin >> bill[i][j];
			}
		}
		memset(mem,false,sizeof(mem));
		count = 0;
		int ans = DFS(0,0);
		memset(mem,false,sizeof(mem));
		count = 0;
		ans = min(ans,DFS(1,0));
		if(ans == INF)
			cout << "NA" << endl;
		else
			cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int flag;
    
    if(b <= c || d <= a){
        flag = 3;
    }else if(a <= c){
        flag = 1;
    }else{
        flag = 2;
    }
    //cout << flag << endl;
    
    int time, end;
    
    switch(flag){
        case 1:
            end = min(b, d);
            time = end - c;
            break;
        case 2:
            end = min(b, d);
            time = end - a;
            break;
        case 3:
            time = 0;
            break;
    }
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
  int n;
  int input;
  int p[100001];
	
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> input;
    p[i] = input;
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i == p[i]) {
      swap(p[i],p[i+1]);
      ans++;
    }
  }

  cout << ans << endl;

  	
	return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    map<string, int> s;
    rep(i, n) {
        string a;
        cin >> a;
        s.emplace(a, 1);
    }

    int ans = 0;

    for(auto i : s) {
        ans += i.second;
    }

    cout << ans;
}

Measured memory_bytes: 19204
#include <iostream>
#include <array>
#include <algorithm>

int main(int, char**) {
  long long n;
  std::array<long long, 5> arr;

  std::cin >> n;
  for(int i{}; i < 5; ++i) {
    std::cin >> arr[i];
  }
  std::sort(begin(arr), end(arr));

  std::cout << 4 + n / arr[0] + (n % arr[0] == 0 ? 0 : 1) << std::endl;

  return 0;
}


Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())

base_y = y2-y1
base_x = x2-x1

y3 = y2 + base_x
x3 = x2 - base_y

y4 = y1 + base_x
x4 = x1 - base_y


print(x3,y3,x4,y4)

Measured memory_bytes: 2940
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def nnn(a):
    res = 1
    for i in range(1,a+1):
        res *= i
        res %= mod
    return res

n,m = inpl()
if n == m:
    print((nnn(n) **2 *2)%mod)
elif abs(n-m) == 1:
    print((nnn(n) * nnn(m))%mod)
else:
    print(0)     


Measured memory_bytes: 39020
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	tuple<int,int,int> a, b, now;
	int x, y, z;
	cin >> x >> y >> z; a = tie(x, y, z);
	cin >> x >> y >> z; b = tie(x, y, z);
	if(a > b) swap(a, b);
	if(a == b){
		cout << 0 << endl;
		return 0;
	}
	auto inc = [](tuple<int,int,int> &x){
		auto numd = [](int y, int m){
			const int a[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
			if(m != 2) return a[m - 1];
			if(y % 400 == 0 || y % 4 == 0 && y % 100) return 29;
			return 28;
		};
		
		int y, m, d; tie(y, m, d) = x;
		if(++d > numd(y, m)){
			d = 1;
			if(++m > 12) m = 1, y++;
		}
		x = tie(y, m, d);
	};
	auto ok = [](tuple<int,int,int> b, tuple<int,int,int> a){
		if(get<1>(a) == get<1>(b) && get<2>(a) == get<2>(b)) return 1;
		if(get<1>(a) == 2 && get<2>(a) == 29 && 
			get<1>(b) == 3 && get<2>(b) == 1 &&
			!(get<0>(b) % 400 == 0 || get<0>(b) % 4 == 0 && get<0>(b) % 100))
		return 1;
		return 0;
	};
	
	now = a;
	int ya = 0, yb = 0, ans = 0;
	while(now < b){
		inc(now);
		if(ok(now, a)) ya++;
		ans = max(ans, ya - yb);
	}
	//dbg(get<0>(now),get<1>(now),get<2>(now));
	rep(it, 365 * 4400){
		inc(now);
		if(ok(now, a)) ya++;
		if(ok(now, b)) yb++;
		ans = max(ans, ya - yb);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3160