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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  int p = 0;
  rep(i, n) p += s[i] == 'p';
  cout << n / 2 - p << endl;
}


Measured memory_bytes: 512
n = int(input())
pairs = []
for i in range(0, n):
  pairs.append(list(map(int, input().split())))

def canFinishJobs(arr):
  arr.sort(key=lambda x: x[1])
  sum = 0
  for i in arr:
    sum += i[0]
    if sum > i[1]:
      return "No"
  return "Yes"

result = canFinishJobs(pairs)
print(result)
  
 


Measured memory_bytes: 53652
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if (b % a == 0) {
    cout << a+b;
  } else {
    cout << b-a;
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
n=gets.to_i
d=1
for i in 1..n do
  d=d*i
end
print("#{d}\n")


#d=d*i は　d*=i とも書ける


=begin

def f(n)
    n == 1 ? 1 : n*f(n-1)
end
puts f(gets.to_i)



a=1
gets.to_i.times{|i|
  a*=i+1
}
puts a


n = gets.to_i
f = 1
1.upto(n) do |i|
  f *= i
end
puts f
 

n の階乗 n ! は、
1 から n までのすべての整数の積である。

例えば、. 6 ! = 6 × 5 × 4 × 3 × 2 × 1 = 720



【Ruby】複数行コメントアウトする

=begin

=end

#で囲まれた部分はコメントアウトされる。


#一行コメントアウトは、

# の後ろはコメントアウトされる。







Measured memory_bytes: 6832
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

const double pie = acos(-1.0);

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a * b / gcd(a, b);
}

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

void solve() {
    ll n, m; cin >> n >> m;
    ll a = max(n, m), b = min(n, m);
    if(b == 1 && a == 1) cout << 1 << endl;// 1*1
    else if(b == 1 && a == 2) cout << 0 << endl; // 1*2
    else if(b == 1) cout << a-2 << endl; // 1*3~
    else if(b == 2) cout << 0 << endl; // 2*~
    else cout << (b-2)*(a-2) << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
    //freopen("test.in", "r", stdin);
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(a%2 == 1 || b%2 == 1 || c%2 == 1)
    {
        printf("0\n");
        return 0;
    }
    if(a == b && b == c)
    {
        printf("-1\n");
        return 0;
    }
    int ans = 0;
    while(a%2 == 0 && b%2 == 0 && c%2 == 0)
    {
        int a1 = (b+c)/2;
        int b1 = (a+c)/2;
        int c1 = (a+b)/2;
        a = a1; b = b1; c = c1;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const llong inf = 1e16;
int n, e, t;
int x[100002];
llong seg1[1 << 18];
llong seg2[1 << 18];

void update(llong seg[], int i, int s, int e, int x, llong v) {
    if (s == e) {
        seg[i] = v;
        return;
    }
    int m = (s + e) / 2;
    if (x <= m) update(seg, i << 1, s, m, x, v);
    else update(seg, i << 1 | 1, m + 1, e, x, v);
    seg[i] = min(seg[i << 1], seg[i << 1 | 1]);
}

llong query(llong seg[], int i, int s, int e, int x, int y) {
    if (e < x || y < s) return inf;
    if (x <= s && e <= y) return seg[i];
    int m = (s + e) / 2;
    return min(query(seg, i << 1, s, m, x, y)
               , query(seg, i << 1 | 1, m + 1, e, x, y));
}

int main() {
    for (int i = 0; i < (1 << 18); ++i) seg1[i] = seg2[i] = inf;
    scanf("%d%d%d", &n, &e, &t);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", x + i);
    }
    llong dp;
    update(seg1, 1, 0, n, 0, 0);
    update(seg2, 1, 0, n, 0, -2 * x[1]);
    for (int i = 1; i <= n; ++i) {
        int j = lower_bound(x + 1, x + (n + 1), x[i] - t / 2) - x;
        llong dp1 = query(seg1, 1, 0, n, j - 1, i - 1) + t;
        llong dp2 = query(seg2, 1, 0, n, 0, j - 2) + 2 * x[i];
        dp = min(dp1, dp2);
        update(seg1, 1, 0, n, i, dp);
        update(seg2, 1, 0, n, i, dp - 2 * x[i + 1]);
    }
    
    printf("%lld\n", dp + e);
	return 0;
}


Measured memory_bytes: 4736
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var K = input[1];

            var S = Console.ReadLine().ToCharArray();
            S[K - 1] = char.ToLower(S[K - 1]);
            Console.WriteLine(S);
        }
    }
}

Measured memory_bytes: 13268
s = input()
t = input()

if t in s:
    print(0)
    exit()

lt = len(t)
ans = lt
for i in range(len(s)-(lt-1)):
    ss = s[i:]
    cnt = 0
    for j in range(lt):
        if ss[j] != t[j]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 8992
N = int(input())
S = [input() for _ in range(N)]

ans = 0
for n in range(N):
    m = S[n:]+S[:n]
    flg = True
    for i in range(N):
        for j in range(N):
            if m[i][j] != m[j][i]:
                flg = False

    if flg:
        ans += N

print(ans)


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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while (b<=a)
	{
		b*=2;
		k--;
	}
    while (c<=b)
	{
		c*=2;
		k--;
	}
    cout<<((k>=0)?"Yes":"No")<<endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void){

  int s,m,h;

  scanf("%d",&s);

  h=s/3600;
  m=(s-h*3600)/60;
  s=s-h*3600-m*60;

  printf("%d:%d:%d\n",h,m,s);

  return 0;

}

Measured memory_bytes: 592
#include<stdio.h>
int main()
{
 int A,B,X;
  int num;
  int i;
  scanf("%d", &X);
  scanf("%d", &A);
  scanf("%d", &B);
  num=X-A;
 do{
    num=num-B;
  }  while(num>=0);
  if(num<0)
      num=num+B;
  printf("%d", num);
    return 0;
}

Measured memory_bytes: 128
r, c = gets.split( " " ).map { | val | val.to_i }

csums = Array.new( c, 0)
rsum = 0
r.times {
	matrix = gets.split( " " ).map { | val | val.to_i }

	rsum = 0
	for i in ( 0 ... c )
		rsum += matrix[i]
		print( "#{matrix[i]} " )
		csums[i] += matrix[i]
	end
	puts( rsum )
}

rsum = 0
csums.each { |val|
	rsum += val
	print( "#{val} " )
}
puts( rsum )

Measured memory_bytes: 6120
import kotlin.math.min

fun main() {
    val n = readLine()!!.toInt()
    val xN = readLine()!!.split(" ").map { it.toInt() }
    val sumTotal = xN.sum()
    
    var ans1 = 0
    var ans2 = 0
    for (i in 0..(n-1)) {
        val t1 = (sumTotal + n - 1) / n - xN[i]
        val t2 = sumTotal / n - xN[i]
        ans1 += t1 * t1
        ans2 += t2 * t2
    }
    val answer = min(ans1, ans2)
    println("$answer")
}

Measured memory_bytes: 36640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int inf = 1e9;
const long double PI = acos(-1);

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss >> v[i];
    return ss;
}

template <class T> 
ostream& operator<<(ostream& ss, const vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
    return ss;
}

ll binpow(ll a, ll n, ll m) {
    ll res = 1;
    while (n) {
        if (n & 1) {
            res *= a;
            res %= m;
        }
        a *= (a % m);
        a %= m;
        n >>= 1;
    }
    return res % m;
}

ll gcd(ll a, ll b) {
    return b ? gcd (b, a % b) : a;
}

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

void solve() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double d1 = h / 12 * 360 + m / 60 * 30;
    double d2 = m / 60 * 360;
    double d = abs(d2 - d1);
    cout << fixed << setprecision(10) << sqrt(a * a + b * b - 2.0 * a * b * cos(d * PI / 180.0));
}

int main() {
    speed;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}

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

int main() {
  string s,t;
  cin >> s >> t;
  bool flag = true;
  for(int i=0; i<s.size(); i++) {
    if(s[i] != t[i]) flag = false;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long double d,t,s;
	cin>>d>>t>>s;
	long double tu=d/s;
	if(tu<=t)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

using namespace std;


typedef long long ll;
const int maxn=2e5+10;
ll a[maxn];
vector<ll> ve;
int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	ll len=n;
//	for(int i=0;i<n;i++){
//		cout<<a[i]<<endl;
//	}
//cout<<len;
	while(true){
//		cout<<len<<endl;
		for(int i=1;i<len;i++){
			int t=a[i]%a[0];
			if(t>0) ve.push_back(t);
		}
		ve.push_back(a[0]);
		len=ve.size();
//		cout<<len<<endl;
		sort(ve.begin(),ve.end());
//		for(int i=0;i<len;i++){
//			cout<<ve[i]<<endl;
//		}
//		cout<<endl;
		for(int i=0;i<len;i++){
			a[i]=ve[i];
		}
//		cout<<len<<endl;
		if(len==1) break;
		ve.clear();
	}
	cout<<a[0]<<endl;
	return 0;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int64_t X;
  ll k, d;
  cin >> X >> k >> d;
  int64_t x = abs(X);
  ll q = x/d;
  ll r = x%d;
  if (k < q) {
    x -= d*k;
    cout << x << endl;
  } else {
    ll last = k - q;
    if (last%2 == 0) {
      cout << r << endl;
    } else {
      int64_t v = abs(r-d);
      cout << v << endl;
    }
  }
}

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

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll l=-1, r=2000001;
    while (r-l>1) {
        ll c = (l+r)/2;
        ll t = 0;
        for (int i = 0; i < N; i++) {
            auto it = lower_bound(A.begin(), A.end(), c-A[i]);
            t += distance(it, A.end());
        }
        if (t < M) r = c;
        else l = c;
    }
    vector<ll> sum(N);
    sum[N-1] = A[N-1];
    for (int i = N-2; i >= 0; i--) {
        sum[i] = sum[i+1]+A[i];
    }
    ll u = 0;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        auto it = lower_bound(A.begin(), A.end(), l-A[i]);
        u += distance(it, A.end());
        ll v = (ll)distance(A.begin(), it);
        if (v == N) continue;
        ans += sum[v];
        ans += A[i]*(int)distance(it, A.end());
    }
    cout << ans - l*(u-M) << endl;
    return 0;
}


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

int main(){
  int i,j,k,N;
  int a[100];
  cin >> N;
  for(i=0;i<N;++i){
    std::cin >> a[i];
  }
  for(i =0;i<N;++i) cout << (i==0 ? "" : " ") << a[i]; cout << endl;
  for (i=1; i<N; ++i){
    k = a[i];
    j = i-1;
    while(j >= 0 && a[j] > k){
      a[j+1] = a[j];
      --j;
    }
    a[j+1] = k;
    for(k =0;k<N;++k) cout << (k==0 ? "" : " ") << a[k]; cout << endl;
  }
}

Measured memory_bytes: 1160
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

bingo = [list(mapint()) for _ in range(3)]
N = int(input())
card = [[0]*3 for _ in range(3)]
for _ in range(N):
    n = int(input())
    for i in range(3):
        for j in range(3):
            if n==bingo[i][j]:
                card[i][j] = 1

for i in range(3):
    if sum(card[i])==3:
        print('Yes')
        exit()

for i in range(3):
    if card[0][i]+card[1][i]+card[2][i]==3:
        print('Yes')
        exit()

if card[0][0]+card[1][1]+card[2][2]==3 or card[2][0]+card[1][1]+card[0][2]==3:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 62124
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N,x;
  cin >> N >> x;


  int a[N] = {};
  for(int i = 0; i < N; i++)
  {
    /* code */
    cin >> a[i];
  }
  sort(a,a+N);

  int res = 0;
  for(int i = 0; i < N; i++)
  {
    //cout << a[i] << endl;
    /* code */

    x = x - a[i];
    if(x >= 0){
      //cout << "x:" << x <<endl;
      res++;
    }else{
      break;
    }

  }
  if(x > 0){
    res--;
  }
  cout << res << endl;

}

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

typedef long long ll;
typedef unsigned long long ull;

const int N = 5010;
const ull base = 13131;
char s[N];
int n;
ull h[N], pw[N];

ull gh(int l, int r) {
	return h[r] - h[l - 1] * pw[r - l + 1];
}

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	pw[0] = 1;
	for(int i = 1; i <= n; ++i) h[i] = h[i - 1] * base + s[i], pw[i] = pw[i - 1] * base;
	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		for(int j = i + 1; j <= n; ++j) {
			if(i + ans <= j) {
				while(i + ans + 1 <= j && j + ans <= n && gh(i, i + ans) == gh(j, j + ans)) {
					++ans;
//					printf("%d %d %d\n", i, j, ans);
				}
			}
		}
	}
	printf("%d\n", ans);
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}


void solve()
{
  // ll n, k; cin >> n >> k;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  string s; cin >> s;
  // vector<ll> a(n); rep(i, n) cin >> a[i];
  // bool ok = false;
  rep(i, s.size()) {
    if(s[i] == '?') s[i] = 'D';
  }
  
  cout << s << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 3760
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        m: usize,
        b: [(usize, usize); m]
    };
    let mut cnt_h = vec![0; h+1];
    let mut cnt_w = vec![0; w+1];
    for &p in &b {
        cnt_h[p.0] += 1;
        cnt_w[p.1] += 1;
    }
    let max_h = cnt_h.iter().max().unwrap();
    let max_w = cnt_w.iter().max().unwrap();
    let mut overlap = cnt_h.iter().filter(|&x| x == max_h).count() * cnt_w.iter().filter(|&x| x == max_w).count();
    for &p in &b {
        if cnt_h[p.0] == *max_h && cnt_w[p.1] == *max_w { overlap -= 1; }
    }
    println!("{}", max_h + max_w - if overlap == 0 { 1 } else { 0 });
}


Measured memory_bytes: 12980
#include<bits/stdc++.h>
#define V vector
#define W V<long>
using namespace std;long E,M=2e17,a,b;W S(V<W>p){if(!E)return{1,0};V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1)T[x[1]&1].push_back({x[0]/2,++x[1]/2});}for(long i;i<2;i++){a=0;for(W x:T[!i])a^=(2*x[0]+x[1])%3+1;if(!a){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p)v[0]++;W A=S(p);A[0]--;return A;}int main(){cin>>E;V<W>p(E);while(E--,cin>>a>>b)p[E]={a+M,b+M};E=70;W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

Measured memory_bytes: 62908
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,a,b[100010],i;
  long long m;
  scanf("%d %lld",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b[R]);
    hin(a);
  }
  while(m>0){
    i=hout();
    m-=b[i];
  }
  printf("%d\n",N[i]);
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

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

    ll sum=0;
    for(int i=1;i<n;i++) sum += i;
    cout << sum << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

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

    int n;
    cin >> n;
    int ans = 0, mn = n + 1, x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x < mn) ans++, mn = x;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque

inf = 10 ** 15
mod = 10 ** 9 + 7

h,w = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
for a in range(10):
    for i in range(10):
        for j in range(10):
            if i != j:
                for k in range(10):
                    c[i][j] = min(c[i][j], c[i][k]+c[k][j])
a = [list(map(int, input().split())) for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans+=c[a[i][j]][1]
print(ans)



Measured memory_bytes: 41564
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> v(5, 0);
    for(int i = 0; i < n; i++) {
        string s; cin >> s;
        if(s[0] == 'M') v[0]++;
        if(s[0] == 'A') v[1]++;
        if(s[0] == 'R') v[2]++;
        if(s[0] == 'C') v[3]++;
        if(s[0] == 'H') v[4]++;
    }

    int idx1[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
    int idx2[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
    int idx3[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

    int ans = 0;
    for(int i = 0; i < 10; i++) {
        int tmp = v[idx1[i]] * v[idx2[i]] * v[idx3[i]];
        ans += tmp;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define endl "\n"
#define with_tests int t; cin >> t; while(t--){ solve(); cout << endl; }
#define without_tests solve(); cout << endl;
#define CEIL(x, y) (ll)ceil((long double)(x)/(long double)(y))
#define epsilon 1e-9 
typedef long long ll;
const int mod = 1e9+7;
const int N = 3e3+1;

// vector<int> adj[N];
// int vis[N];
// int dp[N];
// int n, u, v;

// // int dp[N][N];

// int dfs(int u){

//     if(vis[u] == 1){
//         return dp[u];
//     }
//     vis[u] = 1;
//     for(int v: adj[u]){
//         dp[u] = max(dp[u], dfs(v)+1);
//     }
//     return dp[u];
// }

char a[N][N];
double dp[N][N];
double p[N];
void solve(){
    
    int n;
    cin >> n;
    // vector<double> p(n+1);
    for(int i=1; i<=n; i++){
        cin >> p[i];
        // cout 
    }
    dp[1][1] = p[1];
    dp[1][0] = 1.0-p[1];
    for(int i=2; i<=n; i++){
        dp[i][0] = dp[i-1][0]*(1.0-p[i]);
        for(int j=1; j<=i; j++){
            dp[i][j] = dp[i-1][j]*(1.0-p[i]) + dp[i-1][j-1]*p[i];
        }
    }
    double ans = 0.0;
    for(int i=(n+1)/2; i<=n; i++){
        ans += dp[n][i];
        // cout << i << " " << dp[n][i] << endl;
    }
    cout << fixed << setprecision(12) << ans;
}

int32_t main(){

    fast_cin;
    // with_tests;
    without_tests;

    return 0;
}


Measured memory_bytes: 49928
n = gets.to_i
s = gets.chomp

result = 0

max =
  if n > 52
    26
  else
    n/2+1
  end

(1..(n-1)).each do |z|
  x = s.slice(0, z)
  y = s.slice(z, n)

  if n-z < result
    break
  end

  x_h = {}
  x.each_char do |c|
    x_h[c] = true
  end

  y_h = {}
  y.each_char do |c|
    y_h[c] = true
  end

  keys = x_h.keys & y_h.keys
  cnt = keys.length
  if cnt > result
    result = cnt
  end

  if cnt >= max
    break
  end
end

puts result

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

int main () 
{
  string s ,t; cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if (s<t) cout << "Yes" << endl;
  else  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int A, B; cin >> A >> B;

  int ans = -1;
  for (int i = 0; i <= 1000000; ++i) {
    auto a = i * 8 / 100;
    auto b = i * 10 / 100;
    if (a == A && b == B) {
      ans = i;
      break;
    }
  }

  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

int main() {
	int x;
	cin >> x;
	int A[x];
	for (int i=0; i<x; i++) cin >> A[i];
	int sum=0;
	for (int i=0; i<x-1; i++){
	    for (int j=i+1; j<x; j++){
	        sum+=A[i]*A[j];
	    }
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;


map<char, bool> mp;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
   // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        string s;
        cin >> s;
        int n = s.length();
        for(int i = 0; i < n; i++){
            mp[s[i]] = true;
        }
        for(char ch = 'a'; ch <= 'z'; ch++){
            if(mp[ch] == false){
                cout << s<<ch<<endl;
                return 0;
            }
        }
        for(int i = (int)s.length() - 2; i >= 0;  i--){
            if(s[i] < s[i+1]){
                n = i;
                break;
            }
        }
        if(n == 26){
            cout << "-1\n";
            return 0;
        }
        else{
            string ans = s.substr(0,n);
            int idx = n + 1;
            for(int i = n + 1; i <(int) s.length(); i++){
                if(s[i] < s[idx] && s[i] > s[n]){
                    idx = i;
                }
            }
            ans += s[idx];
            cout << ans << endl;
        }

    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<int> > act(N,vector<int>(3,0));

    for(int i=0; i<N; i++){
        cin >> act[i][0] >> act[i][1] >> act[i][2];
    }

    vector<vector<int> > dp(N,vector<int>(3,0));
    dp[0][0]=act[0][0]; dp[0][1]=act[0][1]; dp[0][2]=act[0][2];

    for(int i=1; i<N; i++){
        for(int j=0; j<3; j++){
            int x=(j+1)%3;
            int y=(j+2)%3;
            dp[i][j]=max(dp[i-1][x]+act[i][j], dp[i-1][y]+act[i][j]);
        }
    }
    int ans=0;
    for(int i=0; i<3; i++){
        if(ans<dp[N-1][i]){
            ans=dp[N-1][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;

void HW() {
	using std::endl;
	out << "Hello World" << endl;
}
void AB() {
	int a, b;
	in >> a >> b;
	using std::endl;
	out << a+b << endl;
}
void(*const solve[3])() = {
	nullptr,HW,AB
};

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	solve[N]();

	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M;
	int last = 1;
	for (int i = 1; i*i <= M; ++i)
	{
		if (M%i!=0) {
			continue;
		}

		if (i >= N) {
			out << M / i << endl;
			return 0;
		}

		if (M / i < N) {
			out << last << endl;
			return 0;
		}
		last = i;
	}

	out << last << endl;
	return 0;
}
#endif


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define INF (int(1e9)+7)//1e9+7进制
#define maxn (int(1e6)+5)
typedef long long ll;
ll node[maxn];
ll res[15];
int main(void)
{
	ll H, W, N;
	scanf("%lld %lld %lld", &H, &W, &N);
	int cnt = 0;
	while (N--)
	{
		ll a, b;
		scanf("%lld %lld", &a, &b);
		for (int i = -1; i <= 1; i++)
			for (int j = -1; j <= 1; j++)
				if (a + i >= 2 && a + i <= H - 1 && b + j >= 2 && b + j <= W - 1)
					node[cnt++] = (a + i) * INF + (b + j);
	}
	sort(node, node + cnt);
	ll temp = node[0];
	ll sum = 1;
	for (int i = 1; i < cnt; i++) {
		if (node[i] == temp)
			sum++;
		else
			res[sum]++, sum = 1, temp = node[i];
	}
	if(cnt)res[sum]++;
	res[0] = (H - 2) * (W - 2);
	for (int i = 1; i <= 9; i++)
		res[0] -= res[i];
	for (int i = 0; i <= 9; i++)
		printf("%lld\n", res[i]);
	return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, ans; cin >> N;
int A[N], B[N], C[N];
for(int i=0; i<N; i++){ cin >> A[i]; }
for(int i=0; i<N; i++){ cin >> B[i]; }
for(int i=0; i<N; i++){ cin >> C[i]; }
ans=B[A[0]-1];
for(int i=1; i<N; i++){
ans+=B[A[i]-1];
if(A[i]==A[i-1]+1){ans+=C[A[i-1]-1];}
}
cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fstream>
#include <chrono>
#include <iomanip>
#include <cstdarg>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <sstream>
#include <numeric>
#include <iterator>
#include <utility>
#include <stack>
#include <functional>
#include <deque>
#include <complex>
#include <bitset>
#include <list>
#include <array>
#include <regex>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
#include <typeinfo>
#include <bits/stdc++.h>
using namespace std;
void solve() {
	int x;
	cin >> x;
	if (x == 1) cout << 0;
	else cout << 1;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;

int main(){
   int x,y,z,k;
   cin>>x>>y>>z>>k;
   vector<long long>A(x),B(y),C(z);
   for(int i=0;i<x;i++){
     cin>>A[i];
   }
   for(int i=0;i<y;i++){
     cin>>B[i];
   }
   for(int i=0;i<z;i++){
     cin>>C[i];
   }
   sort(C.begin(),C.end(),greater<long long>());
   vector<long long>sumAB;
   for(int i=0;i<x;i++){
     for(int j=0;j<y;j++){
       sumAB.push_back(A[i]+B[j]);
     }
   }
   vector<long long>sum;
   sort(sumAB.begin(),sumAB.end(),greater<long long>());
   for(int i=0;i<min(k,(int)sumAB.size());i++){
     for(int j=0;j<z;j++){
       sum.push_back(sumAB[i]+C[j]);
     }
   }
   sort(sum.begin(),sum.end(),greater<long long>());
   for(int i=0;i<k;i++){
     cout<<sum[i]<<endl;
   }
   return 0;
}


Measured memory_bytes: 43112
#include <bits/stdc++.h>  // ver2.1.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  Vi a(n),b(n);
  rep(i,0,n) {
    cin >> a[i];
  }
  rep(i,0,n) cin >> b[i];
  int bpl=0,lim=0;
  rep(i,0,n){
    bpl += max(a[i]-b[i],0LL);
    lim += max((b[i]-a[i])/2,0LL);
  }
  if(lim >= bpl) cYes;
  else cNo;
  return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.buffer.readline

N, M, K = map(int, input().split())
A = list(map(int, (input().split())))
B = list(map(int, (input().split())))
t = sum(B)
# 尺取法
j = M   # bはmから減らしていく
ans = 0
for i in range(N+1):    # aは0からnまで増やしていく
    if i: t += A[i-1]   # i個までの累計になるように足す 0個は0
    while (j>0 and t>K):    # t<=k または j==0 で抜ける
        j -= 1
        t -= B[j]
    if t>K: break   # bが0番まで行っても　t>k の場合はだめ
    ans = max(ans, i+j)
print(ans)


Measured memory_bytes: 38632
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x, k, z, w, g, c, key, l, r, n, m, t;
    ll t2, t3, t4, t1;
    string s;
    cin >> s;
    ll ans = 0;
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
        ans = 3;
    else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))
        ans = 2;
    else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
        ans = 1;

    cout << ans;




    return 0;
}

Measured memory_bytes: 3632
#include<set>
#include<map>
#include<stdio.h>	
using namespace std;
set<int>Se;
map<int,int>mmp;
int main()
{
	int N,K;
	int max=-1,min=100001;
	scanf("%d%d",&N,&K);
	while(N--)
	{
		int num;
		scanf("%d",&num);
		max=num>max ? num : max;
		min=num<min ? num : min;
		Se.insert(num);	
		mmp[num]++;
	}
	set<int> :: iterator it=Se.begin(); 
	if(K>max)
		printf("IMPOSSIBLE");
	else
	{
		int Size=Se.size();
		while(1)
		{
			if(mmp[K]!=0)
				break;
			set<int> :: iterator it=Se.begin(); 
			int n=*it;
			for(it++;it!=Se.end();it++)
			{
				int value=(*it)-n;
				min= min < value ? min :value;
				mmp[value]++;
				if(K%min == value %min)
				{
					mmp[K]++;
					break;
				}
				Se.insert((*it)-n);
				n=*it;
			}
			if(Size==Se.size())
				break;
			Size=Se.size();
		}
		if(mmp[K]!=0)
			printf("POSSIBLE");
		else
			printf("IMPOSSIBLE");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main() {
  int N;
  cin>>N;
  
  vector<int> v(N);
  for(int i=0;i<N;++i){
    cin>>v[i];
  }
  
  int ans=0;
  for(int i=1;i<N-1;++i){
    if((v[i-1]<v[i] && v[i]<v[i+1])||(v[i-1]>v[i] && v[i]>v[i+1]))
      ++ans;
  }
  
  cout<<ans<<endl;
  
}

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

long long cnt[26];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    long long n = s.length();
    long long ans = 1+n*(n-1)/2;
    for( auto i:s ){
        cnt[i-'a']++;
    }
    for(int i=0; i<26; i++){
        ans -= cnt[i]*(cnt[i]-1)/2;    
    }
    cout << ans << "\n";
    return 0;
}


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


int main(){
  ll N;
  cin>>N;
  int digit[1000]={0};
  ll d=0;
  if(N==0){
    cout<<0<<endl;
    return 0;
  }
  while(N!=0){
    if(N% (ll)pow(-2,d+1)!=0){
      digit[d]=1;
      N-=(ll)pow(-2,d);
    }
    d++;
  }
	for(int i=0;i<d;i++){
    cout<<digit[d-1-i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 384
#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 debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const long long sqrtN = 512;

class sqdiv{
    public:
        long long N, K;
        vector<long long> data;
        vector<long long> sum_bkt;
        vector<long long> add_bkt;
        sqdiv(long long n){ //?????±???????????????????????´
            N = n;
            K = (N + sqrtN - 1) / sqrtN;
            data.assign(K * sqrtN, 0);
            sum_bkt.assign(K, 0);
            add_bkt.assign(K, 0);
        }
        void add(long long x, long long y, long long a){
            rep(k,K){
                long long l = k * sqrtN, r = (k + 1) * sqrtN;
                if(r <= x || y <= l) continue;
                if(x <= l && r <= y){
                    add_bkt[k] += a;
                }else{
                    for(long long i = max(x, l); i < min(y, r); i++){
                        data[i] += a;
                        sum_bkt[k] += a;
                    }
                }
            }
        }
        long long getSum(long long x, long long y){
            long long sum = 0;
            rep(k,K){
                long long l = k * sqrtN, r = (k + 1) * sqrtN;
                if(r <= x || y <= l) continue;
                if(x <= l && r <= y){
                    sum += sum_bkt[k] + add_bkt[k] * sqrtN;
                }else{
                    for(long long i = max(x, l); i < min(y, r); i++){
                        sum += data[i] + add_bkt[k];
                    }
                }
            }
            return sum;
        }
};

int main(){
    int n,q;
    cin >> n >> q;
    sqdiv ob(n);
    rep(i,q){
        bool com;
        long long a, b, c;
        cin >> com;
        if(com){
            cin >> a >> b;
            cout << ob.getSum(a,b + 1) << endl;
        }else{
            cin >> a >> b >> c;
            ob.add(a,b + 1,c);
        }
    }
}

Measured memory_bytes: 3572
#include <iostream>
#include <stack>

using namespace std;

int main()
{
	stack<int> stack;
	
	int input;
	while(cin >> input)
	{
		if(input)
			stack.push(input);
		else
		{
			cout << stack.top() << endl;
			stack.pop();
		}

	}

	return 0;
}

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

int main()
{
    int n;
    scanf("%d",&n);
    ll a, b, pr ,sqq;
    ll ans;
    while(n--)
    {
        scanf("%lld%lld",&a,&b);
        pr=a*b;
        sqq=sqrt(pr);
        //printf("%lld\n",sqq);
        ans=sqq*2;
        if(sqq*sqq==pr){
            if(a==sqq&&b==a){
                ans-=2;
            }
            else{
                ans-=3;
            }
        }
        else{
            if((pr-1)/sqq==sqq){
                ans--;
            }
            ans--;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
AB = []
for i in range(M):
    a, b = list(map(int, input().split()))
    AB.append([a, b])

AB.sort(key=lambda x:x[1])

cnt = 1
s = AB[0][1]
for a, b in AB[1:]:
    if s <= a:
        cnt += 1
        s = b
print(cnt)



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

int main(){
	int i, j, k ,n,m,l,f;
	cin >> i >> j >> k;
	f = 0;
	if(i+j == k) f = 1;
	if(i+k == j) f = 1;
	if(k+j == i) f = 1;
	if(f == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i, n, v[100];

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &v[i]);
	}
	for (i = n - 1; i >= 0; i--)
	{
		printf("%d", v[i]);
		if (i != 0)
			printf(" ");
	}
	printf("\n");


	return(0);
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;
 
 
 
int main(){
    int n,m;
    cin>>n>>m;
    int temo=0,ac=0,wa=0;
    long int kl=100010;
    int v[kl]{0},w[kl]{0};
    vi b;
    for(int i=0;i<m;i++){
        int p;
        string s="";
        cin>>p>>s;

        if(s=="AC" ){
            if(v[p]==0) {
                v[p]++;
                ac++;
            }
        }
        else if(s=="WA" ){
            if(v[p]==0){
                w[p]++;
            }
        }
    }
    for(int q=0;q<kl;q++){
            if(v[q]!=0){ 
                wa+=w[q];
                //cout<<w[q]<<endl;
            }
    }
    cout<<ac<<" "<<wa;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        int N = sc.nextInt(); 
        int goodsPrices[] = new int[N];
        
        for (int i = 0; i < N; i++) {
        	goodsPrices[i] = sc.nextInt();
        }
        
        int maxPrice = goodsPrices[0];
        int totalPrice = 0;
        
        for (int i = 0; i < N; i++) {
        	if (goodsPrices[i] > maxPrice) {
        		maxPrice = goodsPrices[i];
        	}
        	
        	totalPrice += goodsPrices[i];
        }
        
        System.out.println(totalPrice - (maxPrice / 2));
		
	}
}

Measured memory_bytes: 21844
N, M = map(int, input().split())
dict = {}
for i in range(M):
    l = list(map(int, input().split()))
    for j in range(l[0]):
        if l[j+1] in dict:
            dict[l[j+1]].append(i)
        else:
            dict[l[j+1]] = [i]
ps = list(map(int, input().split()))
n = 1 << N
ans = 0
while n:
    cnt = 0
    ks =[0]*M
    for i in range(N):
        if n >> i & 1:
            if i+1 in dict:
                for k in dict[i+1]:
                    ks[k] += 1
    for j in range(M):
        if ks[j] % 2 == ps[j]:
            cnt += 1
    if cnt == M:
        ans += 1
    n -= 1
print(ans)

Measured memory_bytes: 3064
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, h = MAP()
a = [0]*n
b = [0]*n

for i in range(n):
    a[i], b[i] = MAP()

a.sort(reverse=True)
b.sort(reverse=True)

ans = 0
i = 0
while i < n and b[i] > a[0] and h > 0:
    ans += 1
    h -= b[i]
    i += 1

if h > 0:
    ans += (h+a[0]-1)//a[0]

print(ans)

Measured memory_bytes: 17960
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
signed main() {
	int n; cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << endl;
}

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

int main() {
  long long int n,sum,x,y,min;
  cin>>n;
  vector<long long int> a(n);
  sum=x=0;
  min=100000000000;
  for(long int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  for(long int i=0;i<n-1;i++){
    x+=a[i];
    y=abs(sum-2*x);
    if(min>y)
      min=y;
  }
  cout<<min<<endl;
}


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

int main() {
	int x,y;
	cin>>x>>y;
	
	if(x==2 && y==2){
		cout<<"Yes"<<endl;
	}else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
		cout<<"Yes"<<endl;
	}else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
		cout<<"Yes"<<endl;
	}else{cout<<"No"<<endl;}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
 
xy = []
for _ in range (N):
  x, y = map(int, input().split())
  xy.append([x, y])
 
nu = 0
for i in range (N):
  for j in range (i,N):
    nu += ((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5
    
answer = nu * (2/N)
 
print(answer)

Measured memory_bytes: 3064