akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll MAX = 1000000007;

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

    if (M==0 && N!=1) {
        vector<int> ans(N, 0);
        int res = 0;
        for(int i=0; i<N; ++i) {
            if(i==0) {
                res = res*10 + 1;
            }
            else res = res*10; 
        }
        cout << res << endl;
        return 0;
    }
    else if(M==0 && N==1) {
        cout << 0 << endl;
        return 0;
    }

    map<int, int> m;

    for (int i=0; i<M; ++i) {
        int s, c;
        cin >> s >> c;
        if(s==1 && c==0 && N!=1) {
            cout << -1 << endl;
            return 0;           
        }
        else if(s==1 && c==0 && N==1) {
            cout << 0 << endl;
            return 0;           
        }

        if(m.find(s)==m.end()) {
            m[s]=c;
        }
        else {
            if(m[s]!=c) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    vector<int> ans(N, 0);
    for(int i=0; i<N; ++i) {
        // if(i==0 && m[i+1]==0){
        //     cout << "called" << endl;
        //     cout << -1 << endl;
        //     return 0;
        // }
        ans[i] = m[i+1];
    }

    int res = 0;
    for(int i=0; i<N; ++i) {
        if (i==0 && ans[i]==0) res = res*10 + 1;
        else res = res*10 + ans[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}

class comb{
  vector<ll> f,fr;
  ll MOD_;
  public:
  //a^(p-1) = 1 (mod p)(p->Prime numbers)
  //a^(p-2) = a^(-1)
  ll calc(ll a,ll b,ll p){//a^(b) mod p   
    if(b==0)return 1;
    ll y = calc(a,b/2,p);y=(y*y)%p;
    if(b & 1) y = (y * a) % p;
    return y;
  }
  void init(ll n,ll mod){//input max_n
    MOD_ = mod;
    f.resize(n+1);
    fr.resize(n+1);
    f[0]=fr[0]=1;
    for(ll i=1;i<n+1;i++){
      f[i] = (f[i-1] * i) % mod;
    }
    fr[n] = calc(f[n],mod-2,mod);
    for(ll i=n-1;i>=0;i--){
      fr[i] = fr[i+1] * (i+1) % mod;
    }
  }
  ll nCr(ll n,ll r){
    if(n<0||r<0||n<r)return 0;
    return f[n] * fr[r] % MOD_ * fr[n-r] % MOD_;
  }//nHr = n+r-1Cr
};


int main(){

  ll x,y;
  cin >> x >> y;

  if((x+y)%3){
    cout << 0 << endl;
    return 0;
  }

  ll k = (x+y)/3;

  x -= k;
  y -= k;
  comb co;
  co.init(x+y+1,MOD);

  cout << co.nCr(x+y,x) << endl;


}


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

using namespace std;

int main(){
	int inputNumber;
  	int count = 0;
  	cin >> inputNumber;
  
  	for (;inputNumber > 0; inputNumber /= 10) {
      	int single = inputNumber % 10;
    	if (single) {
        	count++;
        }
    }
  
  cout << count << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    //解説あり
    int Q;
    cin >> Q;
    rep(i, 0, Q) {
        ll A, B;
        cin >> A >> B;
        ll X = A*B;
        if (A>B) swap(A, B);

        ll l = 0, r = A+B-1;
        while (r-l>1) {
            ll m = (r+l)/2;
            ll k = (m+1)/2;
            ll mx = 0;
            
             ll x, y, p, q, _r, s;
             
             x = 2*k-B+(m%2==0), y = B+1;
             if (x>=A) x++;
             p = x*y;
             
             x = k, y = k+(m%2==0);
             if (x>=A) x++;
             if (y>=B) y++;
             q = x*y;
             
             x = k+(m%2==0), y = k;
             if (x>=A) x++;
             if (y>=B) y++;
             _r = x*y;
             
             x = A+1, y = 2*k-A+(m%2==0);
             if (y>=B) y++;
             s = x*y;
             
             mx = max(max(p, q), max(_r, s));
             
            

            if (mx<A*B) l = m;
            else r = m;
            
        }

       
      
        cout << l << endl;
    }

    return 0;
}





Measured memory_bytes: 3612
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := Scanner(), Scanner(), Scanner()
	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1772
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;
LL t[101010], d[101010];
LL cnt[101010];
LL x;
vector<pair<LL, LL>> v;

int main(){
    cin >> n >> k;
    REP(i, n){
        cin >> t[i] >> d[i];
        v.emplace_back(make_pair(d[i], t[i]));
    }
    sort(ALL(v));
    reverse(ALL(v));
    priority_queue<pair<LL, LL>, vector<pair<LL, LL>>, greater<pair<LL, LL>>> pq;
    LL ans = 0, sum = 0;
    REP(i, k){
        pq.push(v[i]);
        sum += v[i].first;
        cnt[v[i].second]++;
        if(cnt[v[i].second] == 1)x++;
    }
    ans = sum + x*x;
    for(int i = k;i < n;i++){
        if(cnt[v[i].second])continue;
        LL num = -1;
        while(!pq.empty()){
            auto p = pq.top();
            pq.pop();
            if(cnt[p.second] >= 2){
                cnt[p.second]--;
                num = p.first;
                break;
            }
        }
        if(num == -1)break;
        x++;
        cnt[v[i].second]++;
        sum += v[i].first;
        sum -= num;
        ans = max(ans, sum + x*x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7280
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    tmp = 1
    for i in range(n):
        if a[i] == tmp:
            tmp +=1
        else:
            ans += 1
    if ans == n and n != 1:
        print(-1)
    else:
        print(ans)
    
      
if __name__ == '__main__':
    main()

Measured memory_bytes: 24744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a[55],b[55],c[55],d[55];
int A[15];
int ans,ANS;
int main(void){
    int n,m,q; cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    for(int i1=1;i1<=m;i1++){
        for(int i2=i1;i2<=m;i2++){
            for(int i3=i2;i3<=m;i3++){
                for(int i4=i3;i4<=m;i4++){
                    for(int i5=i4;i5<=m;i5++){
                        for(int i6=i5;i6<=m;i6++){
                            for(int i7=i6;i7<=m;i7++){
                                for(int i8=i7;i8<=m;i8++){
                                    for(int i9=i8;i9<=m;i9++){
                                        for(int i10=i9;i10<=m;i10++){
                                            A[1]=i1;
                                            A[2]=i2;
                                            A[3]=i3;
                                            A[4]=i4;
                                            A[5]=i5;
                                            A[6]=i6;
                                            A[7]=i7;
                                            A[8]=i8;
                                            A[9]=i9;
                                            A[10]=i10;
                                            ANS=0;
                                            for(int i=0;i<q;i++){
                                                if(A[b[i]]-A[a[i]]==c[i]){
                                                    ANS+=d[i];
                                                }
                                            }
                                            ans=max(ans,ANS);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>

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

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

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << a[K - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
vl li;
vl memo = {3,5,7};
void dfs(ll a,ll n){
  if(a*10<=n){
    rep(i,3){
      ll x = a*10+memo[i];
      li.push_back(x);
      dfs(x,n);
    }
  }
}
int main(){
  ll n;
  cin>>n;
  dfs(0,n);
  
  for(int i = li.size()-1;i>=0;i--){
    bool f3 = false;
    bool f5=false;
    bool f7=false;
    string  s = to_string(li[i]);
    rep(j,s.length()){
      if(s[j]=='3')f3=true;
      if(s[j]=='5')f5=true;
      if(s[j]=='7')f7=true;
    }
    if(!f3||!f5||!f7){
      li.erase(li.begin()+i);
    }

  }
  sort(been(li));
  //rep(i,li.size())cout<<li[i]<<endl;
  int ans=upper_bound(been(li),n)-li.begin();
  cout<<ans<<endl;
  

}

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

typedef long long ll;

int main() {
    ll K, X, Y; cin >> K >> X >> Y;
    if (K % 2 == 0 && (abs(X) + abs(Y)) % 2 == 1) {
        cout << -1 << endl; return 0;
    }

    ll curX = 0, curY = 0;

    ll ans = (abs(X) + abs(Y) +K-1)/K;
    if (ans == 1 && (abs(X)+abs(Y)) != K) ans++;
    while ((ans*K-abs(X)-abs(Y))%2 != 0) ans++;

    ll waste = ans*K; waste -= (abs(X)+abs(Y)); waste /= 2;
    cout << ans << endl;
    bool loX = abs(X) < abs(Y);
    while (waste > 0) {
        if (loX && X >= 0) {
            curX -= min(waste, K);
        } else if (loX) {
            curX += min(waste, K);
        } else if (Y >= 0) {
            curY -= min(waste, K);
        } else {
            curY += min(waste, K);
        }
        ll leftover = K - min(waste, K);
        //cout << leftover << endl;
        if (loX) {
            //adjust Y
            if (curY < Y) {
                curY += leftover;
            } else {
                curY -= leftover;
            }
        } else {
            if (curX < X) {
                curX += leftover;
            } else curX -= leftover;
        }

        waste -= min(waste, K);
        cout << curX << " " << curY << endl;
        loX = abs(X-curX) < abs(Y-curY);
    }

    while (curX != X || curY != Y) {
        ll rem = K;
        if (curX != X) {
            ll todo = min(K, abs(X-curX));
            if (curX < X) {
                curX += todo;
            } else {
                curX -= todo;
            }
            rem -= todo;
        }
        if (curY != Y) {
            ll todo = min(rem, abs(Y-curY));
            if (curY < Y) {
                curY += todo;
            } else curY -= todo;
        }

        cout << curX << " " << curY << endl;
    }

    return 0;
}


Measured memory_bytes: 2304
import itertools
def ANS(n, s):
    A = list(range(10))
    count = 0
    A_pair = list(itertools.combinations(A,n))
    for i in range(len(A_pair)):
        Sum = sum(A_pair[i])
        if Sum==s:
            count += 1
    return count

while True:
    n, s = map(int, input().split())
    if n==0 and s==0:
        break
    print(ANS(n, s))


Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 8e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 5e5+100;
const int LOG = 19;
const ll mod = 998244353;
const int MX = 5e5+100;

void bad(){
    cout <<"impossible";
    exit(0);
}
#define int ll
void solve() {
    int k,a,b;
    cin >> k >> a >> b;
    int ans = k+1;
    if(b > a && k>=a){
        int val = a;
        int cnt = k - a + 1;
        val+=cnt/2 * (b-a);
        dout <<val<<endl;
        if(cnt%2==1){
            val++;
        }
        ans =max(ans, val);
    }
    cout << ans<<endl;
}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
   // freopen("../output.txt","w",stdout);
#else
#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);


    int t = 1;
    while (t--)
        solve();
}

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

#define endl '\n'

const int N = (int) 1e5;

int A[N + 9];

bool isP(int n) {
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) return false;
    }
    return true;
}

int main() {

    A[0] = A[1] = 0;
    for(int i = 2; i <= N; i++) {
        if(i % 2 == 1) {
            A[i] = A[i - 1] + (isP((i + 1) / 2) && isP(i) ? 1 : 0);
        }
        else {
            A[i] = A[i - 1];
        }
    }

    int q;
    scanf("%d", &q);
    while(q--) {
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%d\n", A[r] - A[l - 1]);
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> S(h), T(h), TT(h);
  for (int i = 0; i < h; ++i) cin >> S[i], T[i] = S[i], TT[i] = S[i];
  int res = 0;
  for (int i = 0; i < (1 << h); ++i) {
    for (int a = 0; a < h; ++a)
      for (int b = 0; b < w; ++b) T[a][b] = S[a][b];
    for (int a = 0; a < h; ++a)
      if (i >> a & 1) {
        for (int b = 0; b < w; ++b) T[a][b] = '.';
      }
    for (int j = 0; j < (1 << w); ++j) {
      for (int a = 0; a < h; ++a)
        for (int b = 0; b < w; ++b) TT[a][b] = T[a][b];
      for (int a = 0; a < w; ++a)
        if (j >> a & 1) {
          for (int b = 0; b < h; ++b) TT[b][a] = '.';
        }
      int cnt = 0;
      for (int a = 0; a < h; ++a)
        for (int b = 0; b < w; ++b) cnt += TT[a][b] == '#';
      if (cnt == k) res++;
    }
  }
  cout << res << "\n";

  return 0;
}
//2020.07.05 20:06:08


Measured memory_bytes: 3644
#encoding:utf-8
def search_leap_year array
 leap_year = []
 while array[0] <= array[1]
  if array[0]%4 == 0 && array[0]%100 != 0 || array[0]%400 == 0
   leap_year.push array[0]
  end
  array[0] += 1
 end

 if leap_year.length == 0
  puts "NA"
 else
  puts leap_year
 end
end

years = []
while true
 year = gets.chomp.split
 if year == %w(0 0)
  break
 end
 year.length.times do |i|
  year[i] = year[i].to_i
 end
 years.push year
end

i = 0
while i < years.length
 unless i == years.length - 1
  search_leap_year years[i]
  puts
 else
  search_leap_year years[i]
 end
 i += 1
end

Measured memory_bytes: 6112
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll h, w, n;
	cin >> h >> w >> n;
	map<P, ll> mp;
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		for (ll y = -1; y <= 1; y++) {
			for (ll x = -1; x <= 1; x++) {
				mp[make_pair(a + y,b + x)]++;
			}
		}
	}
	
	Array num(10, 0);

	ll sum = 0;
	for (auto i : mp) {
		ll y = i.first.first;
		ll x = i.first.second;
		ll j = i.second;
		if (x > 1 && x < w && y > 1 && y < h) {
			num[j]++;
			sum++;
		}
	}

	num[0] = (w-2) * (h-2) - sum;

	for (auto j : num) {
		cout << j << endl;
	}

	return 0;
}

Measured memory_bytes: 56576
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
aaa = na()
b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(aaa[i])
    else:
        b.appendleft(aaa[i])
if n % 2 == 1:
    b.reverse()
print(*b)


Measured memory_bytes: 27084
#include <random>
#include <vector>
#include <cassert>

struct rolling_hash {
    using ull = unsigned long long;
    static constexpr ull MASK30 = (1ULL << 30) - 1;
    static constexpr ull MASK31 = (1ULL << 31) - 1;
    static constexpr ull MOD = (1ULL << 61) - 1;
    static constexpr ull POSITIVIZER = MOD << 2;
    static std::vector<ull> pow_base;
    int n;
    std::vector<ull> hash;
    static void push_hash(int n) {
        int cn = pow_base.size();
        if (cn >= n + 1) { return; }
        pow_base.resize(n + 1);
        for (int i = cn - 1; i < n; i++) { pow_base[i + 1] = calc_mod(mul(pow_base[i], pow_base[1])); }
    }
    static ull rng() {
        std::random_device rd;
        return std::uniform_int_distribution<ull>(MOD >> 1, MOD - 1)(rd);
    }
    static ull mul(ull a, ull b) {
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        return (au * bu << 1) + (mid >> 30) + ((mid & MASK30) << 31) + ad * bd;
    }
    static ull calc_mod(ull val) {
        val = (val & MOD) + (val >> 61);
        if (val >= MOD) { val -= MOD; }
        return val;
    }
    static ull connect(ull lhs, ull rhs, int rn) {
        push_hash(rn);
        return calc_mod(mul(lhs, pow_base[rn]) + rhs);
    }
    template<typename T> rolling_hash(const std::vector<T> &src) : n(src.size()), hash(n + 1) {
        for (int i = 0; i < src.size(); i++) { hash[i + 1] = calc_mod(mul(hash[i], pow_base[1]) + src[i]); }
        push_hash(n);
    }
    ull get_hash(int l, int r) const {
        assert(0 <= l && l < n);
        assert(0 < r && r <= n);
        return calc_mod(POSITIVIZER - mul(hash[l], pow_base[r - l]) + hash[r]);
    }
};
std::vector<rolling_hash::ull> rolling_hash::pow_base{1, rng()};

#include<bits/stdc++.h>
using namespace std;

int main() {
    string T, P;
    cin >> T >> P;
    int Tn = T.length(), Pn = P.length();
    vector<char> Tv(Tn), Pv(Pn);
    copy(T.begin(), T.end(), Tv.begin()), copy(P.begin(), P.end(), Pv.begin());
    rolling_hash Th(Tv), Ph(Pv);
    for (int i = 0; i < Tn - Pn + 1; i++) {
        if (Th.get_hash(i, i + P.length()) == Ph.get_hash(0, P.length())) { cout << i << endl; }
    }
}


Measured memory_bytes: 20624
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 1e5 + 5 ;
const int mod = 1e9 + 5 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;
#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#define AaryanS 0 
#endif

#define debug(x) mycout << #x << " "  << x << endl ;

//17:54 stop
// 19:08 start
//19:16 stop
pii arr[105] ;
int dp[105][(int)1e5+5] , n, W;
int knap(int curr, int w){
	if(curr >= n || w >= W)
		return 0 ;
	if(dp[curr][w] != -1)
		return dp[curr][w] ;
	int res =  knap(curr+1,w) ;
	if(arr[curr].ff + w <= W)
		res = max(res, arr[curr].ss + knap(curr+1,arr[curr].ff + w)) ; 
	return dp[curr][w] = res ;
}
void solve()
{
	cin >> n  >> W ;
	repA(i,0,n-1){
		cin >> arr[i].ff >> arr[i].ss ;
	}
	repA(i,0,n+2){
		repA(j,0,W+2){
			dp[i][j] = -1 ;
		}
	}
	sort(arr,arr+n) ;
	//reverse(arr+1,arr+n+1) ;
	// repD(i,n-1,0){
	// 	repA(j,0,w){
	// 		if(j+arr[i+1].ff > w)
	// 			break ;
	// 		dp[i][j] += max(dp[i+1][j], arr[i].ss + dp[i+1][j+arr[i].ff]) ;//take i+1 or not.
	// 	}
	// }
	cout << knap(0,0) << endl ;
	rep(i,n+1){
		rep(j,W+1)
			mycout << dp[i][j] << " " ;
		mycout << endl ; 
	}
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
   // cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case " << t << ":\n" ;
        solve();
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 82176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
ll f1[500005], f2[500005];
ll pow2(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b%2 == 1) ans = ans*a%mod;
        a = a*a%mod;
        b/=2;
    }
    return ans;
}
ll nCr(int a, int b){
    return f1[a]*1ll*f2[b]%mod*f2[a-b]%mod;
}
ll dp[500005][2];
int main(){
    f1[0] = f2[0] = 1;
    for(int i=1;i<=500000;i++){
        f1[i] = f1[i-1]*i%mod;
        f2[i] = pow2(f1[i], mod-2);
    }
    int n, m;
    scanf("%d%d", &n, &m);

    ll ans = nCr(m, n)*1ll*f1[n]%mod;
    ans = ans*ans%mod;
    for(int i=1;i<=n;i++){
        ll res = nCr(n, i)*1ll*nCr(m, i)%mod*f1[i]%mod;
        int l = n-i;
        res = res*1ll*nCr(m-i, l)%mod*f1[l]%mod;
        res = res*1ll*nCr(m-i, l)%mod*f1[l]%mod;
        if(i%2 == 1) ans = (ans - res + mod)%mod;
        else ans = (ans + res)%mod;
    }


    // for(int i=1;i<=n;i++) ans = ans*1ll*(m-i)%mod;
    printf("%d\n", ans);
}

Measured memory_bytes: 11636
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,a[10],i,sum=0;
    cin >> n;
    for(i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    a[n-1] = a[n-1]/2;
    for(i=0;i<n;i++) sum+=a[i];
    cout << sum;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        scanner.nextLine();
        final String s = scanner.nextLine();
        final char[] array = s.toCharArray();
        final List<Integer> lrs = new ArrayList<>();

        char lr = array[0];
        int count = 1;

        for (int i = 1; i < n; i++) {
            if (array[i] == lr) {
                count++;
                continue;
            }

            lrs.add(count);
            count = 1;
            lr = array[i];
        }

        lrs.add(count);

        int answer = lrs.get(0) - 1;
        for (int i = 1; i < lrs.size(); i++) {
            if (i <= 2 * k) {
                answer += lrs.get(i);
            } else {
                answer += lrs.get(i) - 1;
            }
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 27588
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	vi a(n);
	int sum = 0;
	rep(i, n) cin >> a[i], sum += a[i];
	int ans = 0;
	rep(i, n){
		if(a[i] * 4 * m >= sum) ans++;
	}
	cout << (ans >= m ? "Yes" : "No") << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int) 1e9 + 7;

void solve() {
	int n , x, t;
	cin >> n >> x >> t;
	int d = (int) ceil(n * 1.0 / x);
	cout << d * t << "\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3608
from collections import deque
N=int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
q = deque([A[0]])
ans = 0
for i in range(1,N):
  ans += q.popleft()
  q.append( A[i] )
  q.append( A[i] )
print(ans)


Measured memory_bytes: 32344
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define MOD2 998244353
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();
#include<map>

int main()
{
    INT n,ans;
    cin>>n;
    INT D[n];
    REP(i,n)cin>>D[i];
    INT L=0;
    REP(i,n) L = max(L,D[i]);

    INT counter[n+10];
    REP(i,n+10)counter[i]=0;
    REP(i,n){
        counter[D[i]]++;
    }
    if (D[0]!=0 || counter[0]>1){
        cout<<0<<endl;
        return 0;
    }
    ans = 1;
    INT tmp=1;
    for(int i=1;i<L;++i){
        tmp = 1;
        REP(j,counter[i+1]){
            tmp *= counter[i];
            tmp %= MOD2;
        }
        ans *= tmp;
        ans %= MOD2;
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second


int main() {
	ll n;
	cin>>n;
	ll a[n];
	rep(i,n) cin>>a[i];
	ll dp[n];
	dp[0] = 0;
	dp[1] = abs(a[0]-a[1]);
	FOR(i,2,n){
		dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
	}
	//rep(i,n) cout<<dp[i]<<" ";
	cout<<dp[n-1];
	
	
}

Measured memory_bytes: 1792
from sys import stdin
import bisect
from itertools import accumulate
import numpy as np

n = int(stdin.readline().rstrip())

li = [1]

for i in range(2,34):
    for s in range(2,10):
        if i**s <= 1000:
            li.append(i**s)
        else:
            break
    
li = list(set(li))

li.sort()

print(li[bisect.bisect(li,n)-1])

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

//非負整数ｎに対し、ｎが平方数かどうか判定する
bool isSquare (int n) {
   for (int i = 0; i < n+1; i++) {
     if (i*i == n)
       return true;
     
     else if (i == n)
       return false;
   }
}

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

  string s = to_string (a);
  string t = to_string (b);
  int n = stoi (s+t) ;

  bool ans = isSquare (n);
  
  if (ans)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}

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

long long abss(long long x) {
    if (x > 0)
        return x;
    else
        return -x;
}

int main()
{
    long long X, K, D;
    long long ans = 0;

    cin >> X >> K >> D;


    if (abss(X)/ (double)D >K)
        ans = abss(X) - K * D;
    else
        if ((K-abss(X)/ D)%2==0)
            ans = abss(X) % D;
        else
            ans = D - abss(X) % D;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
int n; cin>>n;
  if(n%2==0){
    cout << (n/2)*(n/2) << endl;}
  else{
    cout << (n/2)*(n/2+1) << endl;
  }
}

Measured memory_bytes: 3540
/*Enter your code here. Read input from STDIN. Print your output to STDOUT*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
const int mod = 1e9 + 7;

void add_self(int &a, int b){
    a += b;
    if(a >= mod){
        a -= mod;
    }
}

int32_t main()
{
    fastio;
    
    int n; cin >> n;
    int can[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin >> can[i][j];


    vector<int> dp(1<<n);
    dp[0] = 1;
    for(int mask=0; mask<(1<<n); mask++){
        int a = __builtin_popcount(mask);
        for(int b=0; b<n; b++){
            if(can[a][b] && !(mask & (1<<b))){
                int msk = mask ^ (1<<b);
                add_self(dp[msk], dp[mask]);
            }
        }
    }

    cout << dp[(1<<n)-1] << endl;
    return 0;   
}
    


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int a=0,b=0,c=0;
	cin >> s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i] == 'a') 
			a++;
		if(s[i] == 'b')
			b++;
		if(s[i] == 'c')
			c++;	 
	}
	if(a == 1 && b == 1 && c == 1)
	{
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cmath>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>

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

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, T& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

void solution()
{
    int n,m;
    cin >> n >> m;
    priority_queue<int> items;
    rep(i,n){
        int a;
        cin >> a;
        items.push(a);
    }
    rep(i,m){
        items.push(peak_and_pop(items) / 2);
    }
    int64_t sum = 0;
    while (!items.empty()){
        sum += peak_and_pop(items);
    }
    cout << sum << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	int a, b, c,d;
	cin >> a >> b >> c;
	if (c >= a && c <= a + b)
		cout << "YES" << endl;
	else
	cout << "NO" << endl;
	return 0;
}

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

void trace(int A[], int N) {
	int i;
	for (int i = 0; i < N; i++) {
		if (i > 0) {
			printf(" ");
		}
			printf("%d", A[i]);
	}
	printf("\n");
}

void insertSort(int A[], int N) {
	int j, i, v;
	for (int i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}
int main() {
	int j, i, N;
	int A[100];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	trace(A, N);
	insertSort(A, N);
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N];

int main()
{
	cin>>n;
	int Max=1,Min=1;
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		if (a[i]>a[Max]) Max=i;
		if (a[i]<a[Min]) Min=i;
	}
	if (Max==Min) Max=2;
	
	long long sum=0;
	for (int i=1;i<=n;i++)
		if (i!=Max && i!=Min) sum+=abs(a[i]);
	cout<<(long long)a[Max]-a[Min]+sum<<endl;	
	
	for (int i=1;i<=n;i++)
		if (i!=Max && i!=Min && a[i]>=0) printf("%d %d\n",a[Min],a[i]),a[Min]-=a[i];
	for (int i=1;i<=n;i++)
		if (i!=Max && i!=Min && a[i]<0) printf("%d %d\n",a[Max],a[i]),a[Max]-=a[i];		
	printf("%d %d\n",a[Max],a[Min]);	
	return 0;
} 

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A), q(B), r(C);
    for (int i=0; i<A; ++i) cin >> p[i];
    for (int i=0; i<B; ++i) cin >> q[i];
    for (int i=0; i<C; ++i) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());

    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int i=0; i<X; ++i) pq.push(p[i]);
    for (int i=0; i<Y; ++i) pq.push(q[i]);
    
    for (int i=0; i<C; ++i) {
        if (pq.top() < r[i]) {
            pq.pop();
            pq.push(r[i]);
        }
    }

    ll sum = 0;
    while ( ! pq.empty()) {
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	int ans = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'g')
			ans++;
		else
			ans--;
	}
	cout << (ans >> 1) << "\n";
	return 0;
}

Measured memory_bytes: 512
import numpy as np

H, W = map(int, input().split())
A = np.array([list(input()) for _ in range(H)])

delete_row = []
for i in range(H):
    if '#' not in A[i, :]:
        delete_row.append(i)

delete_column = []
for j in range(W):
    if '#' not in A[:, j]:
        delete_column.append(j)

ans = np.delete(np.delete(A, delete_row, 0), delete_column, 1)

for i in range(len(ans[:, 0])):
    print(''.join(ans[i, :]))

Measured memory_bytes: 12548
/*input
6
)))())
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
string s;
int pre[maxn];

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

	pre[0]=0;
	REP(i,n)
		if(s[i]==')') pre[i+1]=pre[i]-1;
		else pre[i+1]=pre[i]+1;

	int tmp=*min_element(pre,pre+n+1);

	while(pre[n]>tmp){
		s.pb(')');
		pre[n]--;
	}
	while(pre[0]>tmp){
		cout<<'(';
		pre[0]--;
	}
	cout<<s<<'\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main () {

  int n,b,sum,e[1000];
  double m,a,c=0;

  while(1){

    sum=0,c=0;

    cin >>n;

    if( n == 0 ) break;

    for( int i=0 ; i < n ; i++ ){
      cin >>b;
      sum+=b; 
      e[i]=b;
    }

    m=(double)sum/(double)n;
    
    for( int j=0 ; j < n ; j++ ){
      c+=(e[j]-m)*(e[j]-m);
    }

    a=c/n;

    printf("%.8f\n",sqrt(a));

  }

  return 0;

}

Measured memory_bytes: 1196
#include<stdio.h>

int main(){
	
	long long a,b,c;
	scanf("%lld %lld %lld",&a,&b,&c);
	int suma = a+b, sumb = b+c, sumc = c+a;
	if(suma<=sumb && suma<=sumc) printf("%lld\n", suma);
	else if(sumb<=suma && sumb<=sumc) printf("%lld\n", sumb);
	else printf("%lld\n", sumc);
	return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
	return a * b / my_gcd(a, b);	
}

struct UF {
    vector<int> par, sz;

    UF(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

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

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
};

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

    string s;
    cin >> s;
    int n = s.size();

    vector<char> S;

    for (int i = 0; i < n; ++i) {
        if (S.size() == 0) {
            S.push_back(s[i]);
        } else {
            if (S[S.size() - 1] == '0' && s[i] == '1' || S[S.size() - 1] == '1' && s[i] == '0') {
                S.pop_back();
            } else {
                S.push_back(s[i]);
            }
        }
    }

    cout << n - S.size() << endl;

    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int len(int x){
    int res=0;
    while(x){
        res++;
        x/=10;
    }
    return res;
}
int n;

int main(){
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(len(i)%2){
            ans++;
        }
    }
    cout<<ans<<endl;
}
/*
    Good Luck
        -Lucina
*/


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

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

Measured memory_bytes: 3628
// AtCoder ABC121: B - Can you solve this?
// 2019.9.9 bal4u
// Template for Online Contest

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef long long ll;

#define gc() getchar()
#define pc(c) putchar(c)

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

ll inL() {  // long long 整数の入力
	ll n = 0; int c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

void outL(ll n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int ins(char *s) { // 文字列の入力
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

void outs(char *s) {  // 文字列の表示
	while (*s) pc(*s++);
}

#define MIN(a,b)  ((a)<=(b)?(a):(b))
#define MAX(a,b)  ((a)>=(b)?(a):(b))
#define ABS(a)    ((a)>=0?(a):-(a))
inline static int chmax(int *a, int b) { if (*a < b) *a = b; }
inline static ll  chmaxL(ll *a, int b) { if (*a < b) *a = b; }
inline static int chmin(int *a, int b) { if (*a > b) *a = b; }
inline static ll  chminL(ll *a, int b) { if (*a > b) *a = b; }

int cmp_int(const void *u, const void *v) { return *(int *)u - *(int *)v; }

int N, M;
int A, C;
int B[25];
int ans;

int main()
{
	int i, j, s;

	N = in(), M = in(), C = in();
	for (i = 1; i <= M; i++) B[i] = in();
	for (j = 1; j <= N; j++) {
		s = 0; for (i = 1; i <= M; i++) s += in()*B[i];
		if (s + C > 0) ans++;
	}
	out(ans);
	return 0;
}


Measured memory_bytes: 128