akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a_list=list(map(int,input().split()))
a_list.sort()
import bisect
x=bisect.bisect_left(a_list,0)
y=bisect.bisect_right(a_list,0)
neg=a_list[:x]
pos=a_list[y:]
zero=y-x
if zero==n:
    print(0)
    for i in range(n-1):
        print(0,0)
else:
    if neg==[]:
        if zero==0:
            m=sum(pos[1:])-pos[0]
            print(m)
            now=pos[0]
            for i in pos[1:-1]:
                print(now,i)
                now=now-i
            print(pos[-1],now)
        else:
            m=sum(pos)
            print(m)
            for i in range(zero-1):
                print(0,0)
            now=0
            for i in pos[:-1]:
                print(now,i)
                now=now-i
            print(pos[-1],now)
    elif pos==[]:
        if zero==0:
            m=abs(sum(neg[:-1])-neg[-1])
            print(m)
            now=neg[-1]
            for i in neg[:-1]:
                print(now,i)
                now=now-i
        else:
            m=abs(sum(neg))
            print(m)
            for i in range(zero-1):
                print(0,0)
            now=0
            for i in neg:
                print(now,i)
                now=now-i
    else:
        if zero==0:
            m=-sum(neg)+sum(pos)
            print(m)
            now=neg[0]
            for i in pos[1:]:
                print(now,i)
                now=now-i
            print(pos[0],now)
            now=pos[0]-now
            for i in neg[1:]:
                print(now,i)
                now=now-i
        else:
            m=-sum(neg)+sum(pos)
            print(m)
            for i in range(zero-1):
                print(0,0)
            now=neg[0]
            for i in pos:
                print(now,i)
                now=now-i
            print(0,now)
            now=-now
            for i in neg[1:]:
                print(now,i)
                now=now-i


Measured memory_bytes: 61708
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
	while(1){
	
		int n=0;
		int j[650000];
		long long G=0;
		long long A=0;
		long long JG=0;
		cin>>n;
		if(n==0){
			break;
		}
		for(int i=0;i<n;i++){
			int p=0;
			cin>>p;
			G=G+p;
		}
		for(int i=0;i<n-1;i++){
			cin>>j[i];
		}
		sort(j,j+(n-1));
		A=G*n;
		for(int i=0;i<n-1;i++){
			JG=JG+(j[n-i-2]);
			A=max(A,(G+JG)*(n-i-1));
		}
		cout<<A<<endl;
	}
	return 0;
}

Measured memory_bytes: 1428
#include <stdio.h>
typedef long long ll;
int main(){
    ll n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if     ( a >  b ){ printf("0\n"); return 0; }
    else if( a == b ){ printf("1\n"); return 0; }
    else if( n == 1 ){ printf("0\n"); return 0; } 
    printf("%lld\n", a + (n-1)*b - ((n-1)*a + b) +1 );
    return 0;
}

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

int main(){
  string S;
  cin>>S;
  int max=0;
  for(int i=0;i<S.size();++i){
    int count=0;
    while(i<S.size() && (S.at(i)=='A' || S.at(i)=='C' || S.at(i)=='G' || S.at(i)=='T')){
      ++i;
      ++count;
    }
    if(max<count){
      max=count;
    }
  }

  cout<<max<<endl;
}


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<long long, int>> d(n);
  for (int i = 0; i < n; ++i) {
    cin >> d[i].first;
    d[i].second = i;
  }
  sort(d.begin(), d.end());
  vector<pair<int, int>> ans;
  vector<long long> sum(n);
  vector<int> sz(n, 1);
  for (int i = n - 1; i; --i) {
    long long v = d[i].first - n + 2 * sz[i];
    int p = lower_bound(d.begin(), d.end(), make_pair(v, 0)) - d.begin();
    if (p == n || d[p].first != v) {
      cout << -1 << "\n";
      return 0;
    }
    sum[p] += sum[i] + sz[i];
    sz[p] += sz[i];
    ans.emplace_back(d[i].second, d[p].second);
  }
  if (sum[0] != d[0].first) {
    cout << -1 << "\n";
    return 0;
  }
  for (auto p : ans) {
    cout << p.first + 1 << " " << p.second + 1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 5108
#include<stdio.h>
int main(){
  long int n,m,a[100000],shukudai_day=0;
  scanf("%ld %ld",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%ld",&a[i]);
    shukudai_day=shukudai_day+a[i];
  }
  if(n<shukudai_day)
    printf("-1\n");
  else
    printf("%ld\n",n-shukudai_day);
}


Measured memory_bytes: 1788
#silver fox
n,d,a=map(int,input().split())
from collections import deque
import math
data=[]
for i in range(n):
    x,h=map(int,input().split())
    data.append((x,h))
data=sorted(data,key=lambda x:x[0])
#data を位置の順番にソートしておく
add=0
damage_sum=0
damage_map=deque([])
for i in range(n):
    if damage_map:
        while damage_map and damage_map[0][0]<data[i][0]:
            k=damage_map.popleft()
            damage_sum-=k[1]
            
    if damage_sum<data[i][1]:
        p=math.ceil((data[i][1]-damage_sum)/a)
        damage_sum+=p*a
        add+=p
        #少なくともp回の攻撃を加えなくてはならない
        damage_map.append((data[i][0]+2*d,p*a))
        #data[i][0]+2*dのところまではp*aのダメージがプラスとして加算される
print(add)

Measured memory_bytes: 44628
#include <bits/stdc++.h>
using namespace std;
int main () {
  long K, N;
  cin >> K >> N;
  vector<long> data(N);
  long sum = 0, a, b;
  cin >> b;
  data.at(N - 1) += b;
  for(int i = 0; i < N - 1; i++){
    cin >> a;
    data.at(i) = a - b;
    sum += data.at(i);
    b = a;
  }
  data.at(N - 1) += K - a;
  sum += data.at(N - 1);
  sort(data.begin(), data.end());
  cout << sum - data.at(N - 1) << endl;
  return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

ll A, B, C, D;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll CorD(ll x) {
    ll c = x / C + 1;
    ll d = x / D + 1;
    ll cd = x / (C * D / gcd(C, D)) + 1;
    return c + d - cd;
}

int main() {
    cin >> A >> B >> C >> D;

    write((B - A + 1) - (CorD(B) - CorD(A - 1)));
}

Measured memory_bytes: 256
N=int(input())
L=[]
for i in range(N) :
  S,P=input().split()
  P=int(P)
  l=[S,P,i+1]
  L.append(l)
L=sorted(L,key=lambda x: x[1],reverse=True)
L=sorted(L,key=lambda x: x[0])
for i in range(N) :
  L[i].append(i+1)
L=sorted(L,key=lambda x: x[3])
for i in range(N) :
  print(L[i][2])

Measured memory_bytes: 3064
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

deq = deque()
for a in A:
    deq.append(a)

ans1 = 0
left = right = deq.pop()
flag = 1
while len(deq) >= 2:
    if flag:
        l, r = deq.popleft(), deq.popleft()
    else:
        l, r = deq.pop(), deq.pop()
    ans1 += abs(left + right - l - r)
    flag ^= 1
    left, right = l, r
if len(deq):
    v = deq.pop()
    ans1 += max(abs(left - v), abs(right - v))

deq = deque()
for a in A:
    deq.append(a)

ans2 = 0
left = right = deq.popleft()
flag = False
while len(deq) >= 2:
    if flag:
        l, r = deq.popleft(), deq.popleft()
    else:
        l, r = deq.pop(), deq.pop()
    flag ^= 1
    ans2 += abs(left + right - l - r)
    left, right = l, r
if len(deq):
    v = deq.pop()
    ans2 += max(abs(left - v), abs(right - v))

print(max(ans1, ans2))


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

using namespace std;
typedef long long ll;

bool wrong[10];

int check(int n){
    while(n){
        if(wrong[n%10]){
            return 0;
            break;
        }
        n/=10;
    }
    return 1;
}

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

    /*int t;
    cin>>t;
    while(t--)
        solve();
    */
    int N,K;
    cin>>N>>K;
    for(int i=0;i<K;++i){
        int x;
        cin>>x;
        wrong[x]=1;
    }
    for(int i=N;i>0;++i){
        if(check(i)){
            cout<<i;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int []po=new int[n];
        for(int i=0;i<n;i++)po[i]=sc.nextInt();
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-k+1;i++){
            int sum=0;
            for(int j=1;j<k;j++)
                sum+=po[i+j]-po[i+j-1];
            sum+=Math.min(Math.abs(po[i]),Math.abs(po[i+k-1]));
            ans=Math.min(ans,sum);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 52232
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll m;
    cin >> m;
    ll d[200003], c[200003];
    ll k = 0, s = 0;
    for(int i = 0; i < m; i++){
        cin >> d[i] >> c[i];
        k += c[i];
        s += d[i] * c[i];
    }
    cout << k - 1 + (s - 1) / 9 << endl;
}


Measured memory_bytes: 3328
N, K = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(N-1)]
mod = 10**9+7
nodes = [[] for i in range( N)]

for edge in edges:
    a, b = edge
    a -= 1
    b -= 1
    nodes[a].append(b)
    nodes[b].append(a)

visited = [False for i in range(N)]

ans = K
stack = []
visited[0] = True
cnt = 0
for i in range(len(nodes[0])):
    child = nodes[0][i]
    if visited[child]:
        continue
    ans *= ((K - 1 - cnt) % mod)
    ans %= mod
    stack.append(child)
    cnt += 1
while len(stack) > 0:
    node = stack.pop()
    visited[node] = True
    cnt = 0
    for i in range(len(nodes[node])):
        child = nodes[node][i]
        if visited[child]:
            continue
        ans *= (K-2-cnt)%mod
        ans %= mod
        stack.append(child)
        cnt += 1
print(ans)


Measured memory_bytes: 43356
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll n,m,d;
  cin >> n >> m >> d;


  double x = (n-d)*(m-1);
  if(d!=0){
    x*=2;
  }
  double ans=x/(n*n);
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3756
#include<iostream>
using namespace std;
int n,k; 
int T[100001];
typedef long long llong;
llong p;
int check(llong p){
    int i=0;
    for(int j=0;j<k;j++){
        int s=0;
        while(s+T[i]<=p){
            s+=T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}
llong keisan(){
    llong max=10000*100000;
    llong left=0,right=max,mid;
    while(right-left>1){
        mid=(right+left)/2;
        int x=check(mid);
        if(x>=n) right =mid;
        else left =mid;
    }
    return right;
}
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>T[i];
    p=keisan();
    cout<<p<<endl;

}


Measured memory_bytes: 3448
import sys

def main():
    N = int(input())
    D = list(map(lambda i: int(i), input().split(' ')))
    # N = 100000
    # D = [0]
    # for i in range(1, N):
    #     D.append(i)

    if D[0] != 0:
        print(0)
        sys.exit()

    ary = [0] * N
    for d in D:
        ary[d] = ary[d] + 1

    # 続いてなかったらNG
    zero = False
    for i in range(len(ary)):
        if ary[i] != 0 and zero is True:
            print(0)
            sys.exit()
        if ary[i] == 0 and zero is False:
            zero = True

    # 距離0は頂点1だけ
    if ary[0] != 1:
        print(0)
        sys.exit()

    answer = 1
    for i in range(1, len(ary)):
        for j in range(ary[i]):
            answer = (answer * ary[i - 1]) % 998244353
    print(answer)

main()


Measured memory_bytes: 14036
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  cin >> s;
  if (s.size()==3)
  cout << s.at(2)<<s.at(1)<<s.at(0)<<endl;
    if (s.size()==2)
  cout << s <<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

//#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt(s) cout<<s,exit(0)IFD(,cout<<"\n\nTIME: "<<runtime<<" sec\n\n")
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)
#define loop(n) for0(LOOP_COUNTER,n)
#define runtime (clock()*1.0/CLOCKS_PER_SEC)
#define x first
#define y second

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define int ll

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

template
<
    class key,
    class val=null_type, /// null_mapped_type
    class comp=less<key>
>
using ord_set=tree /// find_by_order(), order_of_key()
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

typedef trie
<
    string,
    null_type,
    trie_string_access_traits<>,
    pat_trie_tag,
    trie_prefix_search_node_update
>
pref_trie; /// insert(), prefix_range()

template<class T,class U>
ostream&operator<<(ostream&out,pair<T,U> p)
{
    return out<<"("<<p.x<<","<<p.y<<")";
}

template<class Iter>
struct rng
{
    Iter from,to;
    rng(Iter from,Iter to):from(from),to(to){}
};

template<class Iter>
rng<Iter> range(Iter from,Iter to)
{
    return rng<Iter>(from,to);
}

template<class Iter>
ostream&operator<<(ostream&out,rng<Iter> r)
{
    out<<distance(r.from,r.to)<<":";
    for(Iter i=r.from;i!=r.to;i++)
        out<<" "<<*i;
    return out;
}

ll ppow(ll x,ll y,ll mod)
{
    ll res=1;
    while(y)
    {
        if(y&1)
            res=res*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return res;
}

const int M=1e5+100;

pii v[M];

signed main()
{
    IFN
    (
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    )

    int n,m;
    cin>>n>>m;
    for0(i,m)
        cin>>v[i].y>>v[i].x;
    sort(v,v+m);
    for0(i,m)
        swap(v[i].x,v[i].y);
    int last=0,ans=0;
    for0(i,m)
        if(last<=v[i].x)
            last=v[i].y,ans++;
    cout<<ans<<"\n";

    IFD(cout<<"\n\nTIME: "<<runtime<<" sec\n\n";)
}


Measured memory_bytes: 1792
class SegTree:
    
    __slots__ = ["n", "data", "f", "id"]
    
    def __init__(self, li, func, identity):
        self.n = len(li)
        self.f = func
        self.id = identity
        self.data = [self.id]*self.n + li
        for i in range(self.n - 1, 0, -1):
            self.data[i] = self.f(self.data[2*i], self.data[2*i+1])
    
    def get(self, i):
        return self.data[i+self.n]
    
    def update(self, i, a):
        i += self.n
        self.data[i] = a
        while i > 1:
            i //= 2
            self.data[i] = self.f(self.data[2*i], self.data[2*i+1])
    
    def add(self, i, a):
        i += self.n
        self.data[i] += a
        while i > 1:
            i //= 2
            self.data[i] = self.f(self.data[2*i], self.data[2*i+1])
    
    def fold(self, l, r):
        l += self.n
        r += self.n
        res = self.id
        while l < r:
            if l % 2:
                res = self.f(self.data[l], res)
                l += 1
            if r % 2:
                r -= 1
                res = self.f(res, self.data[r])
            l //= 2
            r //= 2
        return res
    
    def max_right(self, l, r, check):
        l += self.n
        r += self.n
        left_li = []
        right_li = []
        while l < r:
            if l % 2:
                left_li.append(l)
                l += 1
            if r % 2:
                r -= 1
                right_li.append(r)
            l //= 2
            r //= 2
        temp = self.id
        for idx in (left_li + right_li[::-1]):
            if not check(self.f(temp, self.data[idx])):
                temp = self.f(temp, self.data[idx])
            else:
                break
        else:
            return -1
        while idx < self.n:
            if check(self.f(temp, self.data[2*idx])):
                idx = 2*idx
            else:
                temp = self.f(temp, self.data[2*idx])
                idx = 2*idx+1
        return idx - self.n
    
    def min_left(self, l, r, check):
        l += self.n
        r += self.n
        left_li = []
        right_li = []
        while l < r:
            if l % 2:
                left_li.append(l)
                l += 1
            if r % 2:
                r -= 1
                right_li.append(r)
            l //= 2
            r //= 2
        temp = self.id
        for idx in (right_li + left_li[::-1]):
            if not check(self.f(self.data[idx], temp)):
                temp = self.f(self.data[idx], temp)
            else:
                break
        else:
            return -1
        while idx < self.n:
            if check(self.f(self.data[2*idx+1], temp)):
                idx = 2*idx+1
            else:
                temp = self.f(temp, self.data[2*idx+1], temp)
                idx = 2*idx
        return idx - self.n

import sys
input = sys.stdin.readline
U = 3*10**5+1
n, k = map(int, input().split())
A = [int(input()) for _ in range(n)]
seg = SegTree([0]*U, max, -1)
for i, a in enumerate(A):
  t = seg.fold(max(0, a-k), min(a+k+1, U))
  seg.update(a, t+1)
ans = seg.fold(0, U)
print(ans)

Measured memory_bytes: 94844
N = int(input())
A =list(map(int,input().split()))

Ans = []
pre = -10**9
maxi = A.index(max(A))
mini= A.index(min(A))

if abs(A[maxi]) > abs(A[mini]):
    for i in range(N):
        if i != maxi:
            Ans.append([maxi+1,i+1])
    for i in range(1,N):
        Ans.append([i,i+1])
else:
    for i in range(N):
        if i != mini:
            Ans.append([mini+1,i+1])
    for i in range(N-1,0,-1):
        Ans.append([i+1,i])
print(len(Ans))
for ans in Ans:
    print(*ans, sep = " ")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <exception>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
void File()
{
	#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

int main()
{
	fast();
	//File();
	ll a,b;
	cin>>a>>b;
	if(a<=b)
		cout<<min(a,abs(a-b));
	else
	{
		if(a%b==0)
			cout<<0<<endl;
		else
		{
			a%=b;
			cout<<min(a,abs(a-b));
		}
	}
	return 0;
}

Measured memory_bytes: 256
// C - Skill Up
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VL = vector<ll>;
using VVL = vector<VL>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N,M,X; cin>>N>>M>>X;
	VL C(N);
	VVL A(N);
	rep(i, N){
		cin>>C[i];
		A[i].resize(M);
		rep(j, M) cin>>A[i][j];
	}
	ll inf, ans = inf = 1e18;
	rep(bit, 1<<N){ // [0,(2^N)-1] full search
		ll cost = 0;
		VL a(M,0);
		rep(book, N) // [0,N-1] book no.
			if(bit>>book & 1){ // buy
				cost += C[book];
				rep(j, M) a[j] += A[book][j]; // skill get
			}
		bool ok = true; // skill check
		rep(i, M) if(a[i] < X){ ok = false; break; }
		if(ok) ans = min(ans, cost); // min cost
	}
	if(ans == inf) ans=-1; // exist?
	cout<< ans <<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include "cmath"
using namespace std;

int main(int argc, const char * argv[]) {
    double n,m,x;
    cin >>n>>m;
    x=n-m;
    double sum=0;
    double tmp=1900*m+x*100;
    double hhh=(pow(2.0,m)-1)/pow(2.0,m);
    for(double i=1;i<10000;i++){
        sum+=i*pow(hhh,i-1);
    }
    cout<<tmp*sum/(pow(2.0,m))<<endl;
    return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    int n;
    LL s=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0 or i%5==0)continue;
        s+=i;
    }
    cout<<s;

}


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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int num = 0;
    while (a >= b) {
        b *= 2;
        num++;
    }
    while (b >= c) {
        c *= 2;
        num++;
    }
    if (num <= k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    /*cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);*/
    ll h, w;
    cin >> h >> w;
    ll g[4];
    for(int i=0;i<4;i++){
        cin >> g[i];
        g[i]--;
    }
    string s[h];    
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    vector<vector<ll> > dis(h, vector<ll> (w, INF));
    deque<pair<ll, pair<ll, ll> > > q;
    pair<ll, pair<ll, ll> > niko;
    q.push_back({0LL, {g[0], g[1]}});
    ll dy[24] = {0, 0, -1, 1, -2, -2, -2, -2, -2, 2, 2, 2, 2, 2, 1, 1, 1, 1, -1, -1, -1, -1, 0, 0};
    ll dx[24] = {-1, 1, 0, 0, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, -1, 1, 2, -2, 2};
    while(!q.empty()){
        niko = q.front();
        ll y = niko.second.first;
        ll x = niko.second.second;
        ll d = niko.first;
        q.pop_front();
        if(d > dis[y][x]) continue;
        for(int k=0;k<4;k++){
            ll nowy = y + dy[k];
            ll nowx = x + dx[k];
            if(nowy < 0 || nowy >= h || nowx < 0 || nowx >= w || s[nowy][nowx] == '#') continue;
            if(dis[nowy][nowx] > d){
                dis[nowy][nowx] = d;
                q.push_front({d, {nowy, nowx}});
            } 
        }
        for(int k=4;k<24;k++){
            ll nowy = y + dy[k];
            ll nowx = x + dx[k];
            if(nowy < 0 || nowy >= h || nowx < 0 || nowx >= w || s[nowy][nowx] == '#') continue;
            if(dis[nowy][nowx] > d + 1){
                dis[nowy][nowx] = d + 1;
                q.push_back({d + 1, {nowy, nowx}});
            }
        }
    }
    ll ans = dis[g[2]][g[3]];
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13548
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 105;
const int MAXN = 1e5 + 5;
int val[N], w[N];
int dp[N][MAXN];
int32_t main(){
    int n, W;
    cin >> n >> W;
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> val[i];
    }
    for(int i = 0; i < n; i++) dp[i][0] = 0;
    for(int i = 0; i < W; i++) dp[0][i] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= W; j++){
            if(w[i] <= j){
                dp[i][j] = max(val[i] + dp[i - 1][j - w[i]], dp[i - 1][j]);
            }
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[n][W] << '\n';
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	string a[n];For(i,0,n) cin>>a[i];
	ll count=0;
	For(i,0,n){
		For(j,1,a[i].size()){
			if(a[i][j]=='B' && a[i][j-1]=='A') count++;
		}
	}
	set<ll> A,B,special;
	For(i,0,n){
		if(a[i].back()=='A' && a[i][0]=='B'){
			special.insert(i);
			continue;
		}
		if(a[i].back()=='A') A.insert(i);
		else if(a[i][0]=='B') B.insert(i);
	}

	ll c1 = A.size() , c2 = B.size();
	if(special.size()>0){
		ll final = special.size()-1+count;
		if(c1>0){
			final++;
			c1--;
		}
		if(c2>0){
			final++;
			c2--;
		}
		final += min(c1,c2);
		cout<<final<<endl;
	}else{
		ll final = min(c1,c2)+count;
		cout<<final<<endl;
	}






	
}

Measured memory_bytes: 1280
N, M = map(int, input().split())
ans = 1
if N == 1:
    print(M)
    exit()

for i in range(2, int(M ** .5) + 1):
    p, q = divmod(M, i)
    if q == 0:
        if p >= N:
            ans = max(ans, i)
        if i >= N:
            ans = max(ans, p)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int ct = 0;

void bubbleSort(int A[], int N){
    bool flag = 1;
    while(flag){
        flag = 0;
        for(int i=N-1;i>=1;i--){
            if(A[i] < A[i-1]){
                swap(A[i],A[i-1]);
                ct++;
                flag = 1;
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    bubbleSort(a,n);
    rep(i,n){
        if(i == n-1){
            cout << a[i];
        }else{
            cout << a[i] << ' ';    
        }
    }
    cout << endl;
    cout << ct << endl;

}


Measured memory_bytes: 3088
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	
	int H, W;
	cin >> H >> W;
	
	string s[100];
	int cnt = 0;
	for(int i = 0; i < H; i++){
		cin >> s[i];
		for(int j = 0; j < W; j++){
			if(s[i][j] == '#'){
				cnt += 1;
			}
		}
	}
	
	queue<P> que;
	que.push(P(0, 0));
	
	long long int dist[100][100];
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			dist[i][j] = -INF;
		}
	}
	
	for(int d = 0; d < 1000000; d++){
		if(que.empty()){
			break;
		}
		int sz = que.size();
		for(int loop = 0; loop < sz; loop++){
			P p = que.front();
			int y = p.first, x = p.second;
			que.pop();
			if(y < 0 || x < 0 || y >= H || x >= W){
				continue;
			}
			if(dist[y][x] >= 0 || s[y][x] == '#'){
				continue;
			}
			dist[y][x] = d;
			que.push(P(y - 1, x));
			que.push(P(y + 1, x));
			que.push(P(y, x - 1));
			que.push(P(y, x + 1));
		}
	}
	
	if(dist[H - 1][W - 1] == -INF){
		cout << -1 << endl;
	}else{
		cout << H * W - cnt - dist[H - 1][W - 1] - 1 << endl;
	}
	
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	vector<int>B(N);
	vector<int>C(N + 1);
	vector<int>D(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		C[A[i]]++;
	}
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
		D[B[i]]++;
	}
	for (int i = 1; i <= N; ++i) {
		if (C[i] + D[i] > N) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 1; i <= N; i++) {
		C[i] += C[i - 1];
		D[i] += D[i - 1];
	}
	int x = -1;
	for (int i = 1; i <= N; ++i) {
		x = max(x, C[i] - D[i - 1]);
	}
	cout << "Yes" << endl;
	for (int i = 0; i < N; ++i) {
		if (0 != i) {
			cout << " ";
		}
		cout << B[(i + N - x)%N];
	}
	cout << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll LNF = __LONG_LONG_MAX__;

int N,M;
vector<vector<int> > c;
vector<bool> f;
vector<set<int>> st;
vector<int> res;
void dfs(int v,int ret){
    f[v] = true;
    res[ret]++;
    for(auto s : st[v]){
        if(f[s]) continue;
        dfs(s,ret);
    }
}
int main(){
    cin >> N >> M;
    f = vector<bool>(N,false);
    st = vector<set<int>>(N);
    for(int i=0;i<M;i++){
        int A,B; cin >> A >> B;
        A--;B--;
        st[A].insert(B);
        st[B].insert(A);
    }
    
    int out=0;
    int sss=0;
    for(int i=0;i<N;i++){
        if(f[i]) continue;
        res.push_back(0);
        dfs(i,sss);
        sss++;
    }
    for(int i=0;i<sss;i++){
        out = max(res[i],out);
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 40648
using System;

namespace ALDS1_5_A
{
    class Program
    {
        static bool[,] vis = new bool[2001, 2001];
        static bool[,] ans = new bool[2001, 2001];
        static void Main(string[] args)
        {
            Console.ReadLine();
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.ReadLine();
            var m = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            for (int i = 0; i < 2001; i++) vis[i, 0] = true;
            foreach (var q in m) Console.WriteLine(Solve(q, a.Length, a) ? "yes" : "no");
        }

        static bool Solve(int q, int n, int[] a)
        {
            if (q < 0) return false;
            if (q == 0) return true;
            if (vis[q, n]) return ans[q, n];
            for (int i = 0; i < n; i++)
            {
                var flag = Solve(q - a[i], i, a);
                if (flag)
                {
                    ans[q, n] = true;
                    break;
                }
            }
            vis[q, n] = true;
            return ans[q,n];
        }
    }
}

Measured memory_bytes: 16664
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const ll mod = 1000000007;
int n, a, b, c, d;
string s;

map<P, int> mp;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

ll gcd(ll x, ll y)
{
	if (y == 0)
	{
		return x;
	}
	else
	{
		return gcd(y, x % y);
	}
}

int main(void)
{
	cin >> n >> a >> b >> c >> d >> s;
	if (d < c)
	{
		bool ans = true;
		for (int i = a; i < c - 1; i++)
		{
			if (s[i] == '#' && s[i + 1] == '#')
			{
				ans = false;
			}
		}
		bool res = false;
		for (int i = b - 1; i <= d - 1; i++)
		{
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
			{
				res = true;
			}
		}
		if (res && ans)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else
	{
		bool ans = true;
		for (int i = a; i < c - 1; i++)
		{
			if (s[i] == '#' && s[i + 1] == '#')
			{
				ans = false;
			}
		}
		for (int i = b; i < d - 1; i++)
		{
			if (s[i] == '#' && s[i + 1] == '#')
			{
				ans = false;
			}
		}
		if (ans)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	int www;
	cin >> www;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(){
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		string bef;
		string aft;
		for (int i = 0; i < n; i++) {
			char a, b;
			cin >> a >> b;
			bef.push_back(a);
			aft.push_back(b);
		}
		int m;
		cin >> m;
		string s_bef;
		for (int i = 0; i < m; i++) {
			char a;
			cin >> a;
			s_bef.push_back(a);
			for (int j = 0; j < n; ++j) {
				if (s_bef[i] == bef[j]) {
					s_bef[i] = aft[j];
					break;
				}
			}
		}
		cout << s_bef << endl;
	}
	return 0;
}

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

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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    rep(i,s.size()){
        if((s[i] + n) > 'Z') s[i] = s[i] - 26 + n;
        else s[i] = s[i] + n;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	nQueries := nextInt()
	m := map[string]int{}
	for iQuery := 0; iQuery < nQueries; iQuery++ {
		queryType := nextInt()
		key := nextString()
		if queryType == 0 {
			x := nextInt()
			m[key] = x
		} else if queryType == 1 {
			fmt.Println(m[key])
		}
	}
}



Measured memory_bytes: 18552
#include <iostream>
using namespace std;
int main(){
	int data[4][3][10];
	for(int x=0;x<4;x++){
		for(int y=0;y<3;y++){
			for(int z=0;z<10;z++){
				data[x][y][z] = 0;
			}
		}
	}
	//initialization
	int n,b,f,r,v;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> b>> f >>r >>v;
		data[b-1][f-1][r-1] +=v;
	}
	//input end
	//out put phase
	for(int x=0;x<4;x++){
		for(int y=0;y<3;y++){
			for(int z=0;z<10;z++){
				cout<<" "<<data[x][y][z];
			}
			cout<<endl;
		}
		if(x<3){
			for(int k=0;k<20;k++){
				cout<<"#";
			}
			cout<<endl;
		}
		
	}

	return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    string S;
    cin >> S;
    int N = S.size();

    lint cnt[20][2][2][2][2][2] = {};
    cnt[0][0][0][0][0][1]       = 1;

    for (int i = 0; i < N; i++) {
        int p = S[i] - '0';
        for (int less = 0; less < 2; less++) {
            for (int wit_7 = 0; wit_7 < 2; wit_7++) {
                for (int wit_5 = 0; wit_5 < 2; wit_5++) {
                    for (int wit_3 = 0; wit_3 < 2; wit_3++) {
                        for (int zero = 0; zero < 2; zero++) {
                            for (int x = 0; x <= (less ? 9 : p); x++) {
                                if (!(x == 7 or x == 5 or x == 3) &&
                                    !(zero && x == 0)) {
                                    continue;
                                }
                                cnt[i + 1][less | (x != p)][wit_7 | (x == 7)]
                                   [wit_5 | (x == 5)][wit_3 | (x == 3)]
                                   [zero & (x == 0)] +=
                                    cnt[i][less][wit_7][wit_5][wit_3][zero];
                            }
                        }
                    }
                }
            }
        }
    }

    cout << cnt[N][0][1][1][1][0] + cnt[N][1][1][1][1][0] << endl;

    return 0;
}

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

int main(){
    string s,t = "";
    cin >> s;
    string u = s;
    s += " ";
    int i = 0;
    //cout << "01234567890123456789" << endl;
    //cout << s << ":" << endl;
    while(1){
        if(s.substr(i,5) == "dream"){
            i += 5;
            if(s.substr(i,2) == "er"){
                if(s.substr(i+2,1) == "d"){
                    i += 2;
                    t += "dreamer";
                }else if(s.substr(i+2,1) == "e"){
                    i += 2;
                    t += "dreamer";
                }else if(s.substr(i+2,1) == "a"){
                    t += "dream";
                }else if(s.substr(i+2,1) == " "){
                    i += 2;
                    t += "dreamer";
                }
            }else if(s.substr(i,1) == "d"){
                t += "dream";
            }else if(s.substr(i,1) == " "){
                t += "dream";
            }
        }

        else if(s.substr(i,5) == "erase"){
            i += 5;
            if(s.substr(i,1) == "r"){
                i += 1;
                t += "eraser";
            }else if(s.substr(i,1) == "e"){
                t += "erase";
            }else if(s.substr(i,1) == "d"){
                t += "erase";
            }else if(s.substr(i,1) == " "){
                t += "erase";
            }
        }
        else break;
        if(s.substr(i,1) == " ")break;
    }
    //cout << t << ":" << endl;
    //cout << u << ":" << endl;

    if(u == t)cout << "YES" <<endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
Int mod = 1e9+7;
//Int mod = 1e6+3;

int main() {
    Int n;
    cin >> n;
    Int a, b, c, d;
    cin >> a >> b >> c >> d;
    string s;
    cin >> s;
    // assert(c < d);
    if (c < d) {
        bool x = true;
        for (Int i = b - 1; i < d - 1; i++) {
            if (s[i] == s[i + 1] && s[i] == '#') x = false;
        }
        if (!x) {
            dump("No");
            return 0;
        }
        //s[d - 1] = '#';
        x = true;
        for (Int i = a - 1; i < c - 1; i++) {
            if (s[i] == s[i + 1] && s[i] == '#') x = false;
        }
        if (!x) {
            dump("No");
            return 0;
        }
        dump("Yes");
    }
    else {
        bool x = false;
        for (Int i = b - 2; i < d - 1; i++) {
            if (s[i] == '.' && s[i] == s[i + 1] && s[i + 1] == s[i + 2]) {
                x = true;
                // dump(i);
                break;
            }
        }
        if (!x) {
            dump("No");
            return 0;
        }
        x = true;
        for (Int i = a - 1; i < c - 1; i++) {
            if (s[i] == '#' && s[i] == s[i + 1]) {
                x = false;
                break;
            }
        }
        if (!x) {
            dump("No");
            return 0;
        }
        dump("Yes");
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vd vector<double> 
#define vvd vector<vector<double>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, h, w; cin >> n >> h >> w;
	int ans = 0;
	rep(i, n)
	{
		int a, b;
		cin >> a >> b;
		if (h <= a && w <= b)ans++;
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
ave1=int(sum(x)//n)
ave2=int((sum(x)//n)+1)
tol1=0
tol2=0
for i in range(n):
  tol1+=(x[i]-ave1)**2
  tol2+=(x[i]-ave2)**2
print(min(tol1,tol2))



Measured memory_bytes: 38384
import math

def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    pt = []
    time = 0
    
    while True:
        prime = min(A)
        
        if prime > math.sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)

    for p in P:
        if p%5 ==1:
            pt.append(p)
     
    return pt

limit = 55555
P = eratosthenes(limit)

n = int(input())
print(*P[:n])


Measured memory_bytes: 11060
#include <iostream>
#include <string>
#include <cstdio>
#define ULL unsigned long long
using namespace std;

int main() {
    int a, z, cnt = 0;
    char ch;
    bool flag = false;
    while ((ch = getchar()) != '\n') {
        cnt++;
        if (flag == false && ch == 'A') {
            a = cnt;
            flag = true;
        }
        if (flag == true && ch == 'Z') {
            z = cnt;
        }
    }
    cout << z - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

#define P pair<int, int>

const int N_MAX = 1e5;
vector<int> pref[N_MAX + 1];

void make_city(int y, int p) {
    pref[p].push_back(y);
}

int main() {
    int n, m;
    cin >> n >> m;
    P py[m], t[m];
    for (int i = 0, p, y; i < m; i++) {
        cin >> p >> y;
        t[i] = py[i] = P(y, p);
    }
    sort(t, t+m);
    for (int i = 0; i < m; i++) {
        make_city(t[i].first, t[i].second);
    }
    for (int i = 0; i < m; i++) {
        int tp = py[i].second;
        int idx = lower_bound(pref[tp].begin(), pref[tp].end(), py[i].first) - pref[tp].begin();
        idx++;
        int dgt_l = 1, tmp_l = tp;
        while (tmp_l / 10) {
            tmp_l /= 10;
            dgt_l++;
        }
        int dgt_r = 1, tmp_r = idx;
        while (tmp_r / 10) {
            tmp_r /= 10;
            dgt_r++;
        }
        for (int j = 6 - dgt_l; j > 0; j--) cout << 0;
        cout << tp;
        for (int j = 6 - dgt_r; j > 0; j--) cout << 0;
        cout << idx << endl;
    }
}

Measured memory_bytes: 8576
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	int r,d;
	long long int x;
	cin>>r>>d>>x;
	rep(i,10){
		x=r*x-d;
		cout<<x<<endl;
	}

	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double l;
  cin >> l;
  double ans = (l * l * l) / 27;
  cout << setprecision(6) << fixed << ans << endl;
  return 0;
}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int N, M;
vector<long long> A;

int main() {
    while (cin >> N >> M) {
        A.resize(N);
        long long s = 0;
        for (int i = 0; i < N; ++i) cin >> A[i], s += A[i];
        int res = 0;
        for (int i = 0; i < N; ++i) {
            if (A[i] * M * 4 >= s) ++res;
        }
        if (res >= M) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

















Measured memory_bytes: 256