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

const int dh[4] = {1, -1, 0, 0};
const int dw[4] = {0, 0, 1, -1};

int main(){
    while(1){
        int H, W;
        cin >> W >> H;
        if(W == 0 && H == 0) break;
        vector<vector<int>> block_h(H);
        vector<vector<int>> block_w(H-1);
        for(int i = 0; i < 2*H-1; i++){
            if(i % 2 == 0){
                for(int j = 0; j < W - 1; j++){
                    int p;
                    cin >> p;
                    block_h[i/2].push_back(p);
                }
            }
            else{
                for(int j = 0; j < W; j++){
                    int p;
                    cin >> p;
                    block_w[i/2].push_back(p);
                }
            }
        }

        vector<vector<int>> dist(H, vector<int>(W, -1));
        dist[0][0] = 1;

        queue<pair<int, int>> que;
        que.push(make_pair(0, 0));

        while(!que.empty()){
            pair<int, int> current_pos = que.front();
            int h = current_pos.first;
            int w = current_pos.second;
            que.pop();

            for(int d = 0; d < 4; d++){
                int next_h = h + dh[d];
                int next_w = w + dw[d];
                if(next_h < 0 || next_h >= H || next_w < 0 || next_w >= W) continue;
                if(d == 0 && block_w[h][next_w] == 1) continue;
                if(d == 1 && block_w[next_h][next_w] == 1) continue;
                if(d == 2 && block_h[next_h][w] == 1) continue;
                if(d == 3 && block_h[next_h][next_w] == 1) continue;

                if(dist[next_h][next_w] == -1){
                    dist[next_h][next_w] = dist[h][w] + 1;
                    que.push(make_pair(next_h, next_w));
                }
            }
        }
        if(dist[H-1][W-1] == -1) cout << 0 << endl;
        else cout << dist[H-1][W-1] << endl;
    }
}


Measured memory_bytes: 3108
/*///////////////////////////////////////////*/
/*/ root@NULLCT$(´・ω・｀)<<"Be accept!!"  /*/
/*///////////////////////////////////////////*/
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  int maxto = 0;
  int maxnum = 0;
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n-1) {
    if (maxto < a[i + 1] - a[i]) {
      maxto = a[i + 1] - a[i];
      maxnum = i;
    }
  }
  if (maxto < k - a[n - 1] + a[0]) {
    maxto = k - a[n - 1] + a[0];
    maxnum = n - 1;
  }
  if (maxnum == n - 1) {
    cout << a[n - 1] - a[0] << endl;
    return 0;
  }
  else {
    cout << k - a[maxnum + 1] + a[maxnum] << endl;
  }

  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> l;
  l.push_back(a[0]);
  for (int i = 1; i < n; i++) {
    if (lower_bound(l.begin(), l.end(), a[i]) == l.end()) {
      l.push_back(a[i]);
    }
    else {
      int p = lower_bound(l.begin(), l.end(), a[i]) - l.begin();
      l[p] = a[i];
    }
  }
  cout << l.size() << endl;
  return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int A,B,C,cnt=0;
  cin>>A>>B>>C;
  if(A+B>=C) cnt=C+B;
  else if(A+B<C) cnt=A+2*B+1;
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
k = int(input())

if k <= 9:
    print(k)
    exit()
    
l = list(map(str, list(range(1,10))))
x = 0
for i in range(k):
    for j in (-1, 0, 1):
        if int(l[x][-1]) + j in (-1, 10):
            continue
        l.append(l[x] + str(int(l[x][-1]) + j))
    x += 1

print(l[k-1])

Measured memory_bytes: 75996
import numpy as np
number = np.arange(10**5+1)
primes = np.ones(10**5+1)
 
for i in range(int(np.sqrt(10**5+1))):
  if i <= 1:
    primes[i] = 0
    continue
  if primes[i] == 1:
    primes[number%i==0]=0
    primes[i] = 1
    
c = np.zeros(10**5+1)
for j in range(1, 10**5+1):
  if primes[j] == 1 and primes[int((j+1)/2)] == 1:
    c[j] = c[j-1] + 1
  else:
    c[j] = c[j-1]

N = int(input())
for i in range(N):
  s, e = list(map(int, input().split()))
  print(int(c[e]-c[s-1]))

Measured memory_bytes: 15276
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;
using Graph = vector<vector<int>>;

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; }

vector<bool> seen;

void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int abs_B(long long num, long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

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

bool permutation(vector<int>& vec, vector<int>& P) {
    bool ok = true;
    for (int i = 0; i < vec.size(); i++) {
        //cout << vec.at(i);
        if (vec.at(i) != P.at(i)) {
            ok = false;
        }
    }
    return ok;
}

/*bool nibu(vector<int>& retu,int key) {

}*/

const long long MOD = 1000000007;
const int INF = 1001001001;

int main() {
    string S;
    cin >> S;
    vector<char> c;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == '0') c.push_back('0');
        else if (S.at(i) == '1') c.push_back('1');
        else if (S.at(i) == 'B' && c.size() != 0) c.pop_back();
    }
    for (int i = 0; i < c.size(); i++) {
        cout << c.at(i);
    }
    cout << endl;
}


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

int main() {
  ll n,k,s,MAX=1e9;
  cin >> n >> k >> s;
  if(s==1000000000)MAX--;
  if(n==k){
    r(i,n){
      cout<<s;
      if(i==n-1)cout<<endl;
      else cout<<" ";
    }
  }
  else{
    r(i,k)cout<<s<<" ";
    r(i,n-k){
      cout<<MAX;
      if(i==n-k-1)cout<<endl;
      else cout<<" ";
    }
  }
}

Measured memory_bytes: 1280
n = gets.to_i
array_p = gets.split(" ").map!{|i | i.to_i}

swap = 0

array_p.each_with_index do |num, index|
    unless num == (index + 1)
    swap = swap + 1

    if swap == 3
      break
    end
  end
end

(swap == 0 || swap == 2) ? result = "YES" : result = "NO"

puts result


Measured memory_bytes: 1788
import sys
import bisect

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

C1 = rs()
C2 = rs()
print('YES' if C1[::-1] == C2 else 'NO')


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;

long long n, m;

int main()
{
	while (~scanf("%lld%lld", &n, &m)) {
		if (m < 2 * n) printf("%lld\n", m / 2);
		else printf("%lld\n", n + (m - 2 * n) / 4);
	}
	return 0;
}

Measured memory_bytes: 128
from math import ceil,sqrt
def main():
    
    # for _ in range(ii()):
    
    # t=int(input())
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    b=[0]*n
    for i in range(n):
        if(i==0):
            b[i]=(a[n-1]-a[i])
        else:
            b[i]=(a[n-1]-a[i])+(k-a[n-1])+a[i-1]
    a1=[(k-i) for i in a]
    a1.reverse()
    b1=[0]*n
    for i in range(n):
        if(i==0):
            b1[i]=(a1[n-1]-a1[i])
        else:
            b1[i]=(a1[n-1]-a1[i])+(k-a1[n-1])+a1[i-1]
    b1.reverse()
    ans=1e9+7
    # print(b,b1)
    for i in range(n):
        ans=min(ans,min(b[i],b1[i]))
    print(int(ans))
    
    
    
    
    
    
    
    
    
    




    
if __name__ =="__main__":
    main()

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

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

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if (b % a == 0)
  {
    cout << a + b << endl;
  }
  else
  {
    cout << b - a << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define llint long long
#define mod 1000000007

using namespace std;

llint n, k;
bool prime[100005];
vector<llint> pvec, fvec, vec;
llint cnt[1505], cnt2[1505];
map<llint, llint> mp;

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

llint moebius(llint x)
{
	llint ret = 1;
	for(int i = 0; i < fvec.size(); i++){
		bool flag = false;
		llint p = fvec[i];
		while(x % p == 0){
			x /= p;
			if(flag) return 0;
			flag = true;
			ret *= mod-1, ret %= mod;
		}
	}
	return ret;
}

int main(void)
{
	cin >> n >> k;
	
	for(int i = 2; i < 4005; i++){
		if(prime[i]) continue;
		for(int j = 2*i; j < 100005; j+=i) prime[j] = true;
	}
	for(int i = 2; i < 100005; i++){
		if(!prime[i]) pvec.push_back(i);
	}
	
	llint t = n;
	for(int i = 0; i < pvec.size(); i++){
		llint p = pvec[i];
		while(t % p == 0){
			t /= p;
			fvec.push_back(p);
		}
	}
	if(t > 1) fvec.push_back(t);
	sort(fvec.begin(), fvec.end());
	fvec.erase(unique(fvec.begin(), fvec.end()), fvec.end());
	
	for(llint i = 1; i*i <= n; i++){
		if(n%i) continue;
		vec.push_back(i);
		vec.push_back(n/i);
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	
	llint m = vec.size();
	for(int i = 0; i < m; i++) mp[vec[i]] = i;
	for(int i = 0; i < m; i++){
		cnt[i] = modpow(k, (vec[i]+1)/2);
	}
	
	for(int i = 0; i < m; i++){
		for(int j = 0; j < m; j++){
			if(vec[i] % vec[j]) continue;
			cnt2[i] += moebius(vec[j]) * cnt[mp[vec[i]/vec[j]]] % mod;
			cnt2[i] %= mod;
		}
	}
	
	llint ans = 0;
	for(int i = 0; i < m; i++){
		llint p = vec[i];
		if(p % 2) ans += p * cnt2[i] % mod, ans %= mod;
		else ans += p/2 * cnt2[i] % mod, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;

int main(){
  ll l,r,i,j,ans=2000000000;
  cin  >>  l  >>  r;
  if(r-l>=2019)ans=0;
  else{
      for(i=l;i<r;i++)
          for(j=l+1;j<=r;j++)
              ans=min(ans,i*j%2019);
  }
  cout  <<  ans  <<  endl;
}


Measured memory_bytes: 256
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    m = 10**100
    for i in range(1, N//2+1):
        A = i
        B = N-i
        Da = sum(int(a) for a in str(A))
        Db = sum(int(b) for b in str(B))
        m = min(m, Da+Db)
    print(m)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9432
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	int n, m;
	cin >> n >> m;
	int a[n];
	int ans = 0;
	int sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	rep(i, n) {
		if (a[i]* (4 * m) >= sum  ) {
			ans++;
		}
	}
	if (ans >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V b(n, 0);
	rep(i, n - 1) {
		int a;
		cin >> a;
		a--;
		b[a]++;
	}
	rep(i, n) {
		cout << b[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4048
// 21
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef LOCAL
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}
// 3
void _main(int tc) {
  int n;
  cin >> n;
  vector<li> v(n);
  rep(i, n) cin >> v[i];
  const li inf = 2e18;
  vector<li> pref = v;
  rep(i, 1, n) pref[i] += pref[i - 1];
  /************* Recursive *************
  vector<vector<li>> mem(n, vector<li>(n, inf));
  function<li(int, int)> f = [&](int L, int R) -> li {
    if (L == R) return 0;
    if (mem[L][R] != inf) return mem[L][R];
    li sum = pref[R] - (L == 0 ? 0 : pref[L - 1]);
    rep(pivot, L, R) {
      mem[L][R] = min(mem[L][R], f(L, pivot) + f(pivot + 1, R) + sum);
    }
    return mem[L][R];
  };
  cout << f(0, n - 1) << endl;
  *********** End Recursive ***********/
  vector<vector<li>> mem(n, vector<li>(n, inf));
  rep(R, n) {
    rep(L, R, -1) {
      if (L == R) {
        mem[L][R] = 0;
        continue;
      }
      li sum = pref[R] - (L == 0 ? 0 : pref[L - 1]);
      rep(pivot, L, R) {
        mem[L][R] = min(mem[L][R], mem[L][pivot] + mem[pivot + 1][R] + sum);
      }
    }
  }
  cout << mem[0][n - 1] << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    int n,k,rank = 0;
    cin>>n>>k;
    while(pow(k,rank) <= n)rank++;
    cout<<rank<<endl;

}

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3e6 + 5;
int a[N], dp[N];
//memset(dp, 0, sizeof(dp));
int n;
int help(int i)
{
	if (i >= n - 1) return 0;
	if (dp[i] != -1) return dp[i];
	int a1 = INT_MAX, b = INT_MAX;
	if (i < n - 1)
	{
		int x = a[i] - a[i + 1];
		a1 = abs(x) + help(i + 1);
	}
	if (i < n - 2)
	{
		int x = a[i] - a[i + 2];
		b = abs(x) + help(i + 2);
	}
	//bug(a1, b);
	return dp[i] = min(a1, b);
}
void solve()
{

	cin >> n;
	loop(i, 0, n)
	{
		cin >> a[i];
	}
  memset(dp,-1,sizeof(dp));
	cout << help(0);


	return;

}

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


	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	

	return 0;
}


Measured memory_bytes: 27904
#include<bits/stdc++.h>
#define m 1000000007
using namespace std;
 
double dp[3000][3000];
 
double f(double *a, int i, int k, int n)
{
    if(i==n)
    {
        return 1.0;
    }
    if(dp[i][k]!=-1.0)
    {
        return dp[i][k];
    }
    if(k==0)
    {
        dp[i][k]=(1.0-a[i])*f(a, i+1, k, n);
    }
else if((i+k)==n)
{
    dp[i][k]=a[i]*f(a, i+1, k-1, n);
}
else
{
    dp[i][k]=(a[i]*f(a, i+1, k-1, n))+((1.0-a[i])*f(a, i+1, k, n));
}
return dp[i][k];
}
 
int main()
{
    for(int i=0;i<3000;i++)
    {
        for(int j=0;j<3000;j++)
        {
            dp[i][j]=-1.0;
        }
    }
    int n, k;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++)cin>>p[i];
    k=n/2;
    k++;
    double ans=0.0;
    for(int i=k;i<=n;i++)
    {
        ans+=f(p, 0, i, n);
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <string.h>
int main(void) {
    int x, y;
    scanf("%d" ,& x);
    y = x % 10;
    if (y == 0|| y == 1|| y == 6|| y == 8) {
        printf("pon\n");
    }
    else if (y == 3) {
        printf("bon\n");
    }
    else {
        printf("hon\n");
    }
    return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	char a, b; cin >> a >> b;
	if (a == b)cout << "=" << endl;
	else cout << (a > b ? ">" : "<") << endl;
	return 0;
}

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

int a,b,num,ans;
cin>>a>>b;

if(b<10) num=10;
if(10<=b and b<100) num=100;
if(b==100) num=1000;
ans=a*num+b;
for(int i=0;i*i<=ans;i++)
    if(i*i==ans) {cout<<"Yes";
                 return 0;}
cout<<"No";

system("pause");
return 0;
}

Measured memory_bytes: 504
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		int n,m,sum,count;
		
		while(true){
			list.clear();
			n = sc.nextInt();
			m = sc.nextInt();
			if(n == 0 && m == 0)break;
			
			for(int i = 0; i < n; i++)
				list.add(sc.nextInt());
			
			Collections.sort(list);
			
			sum = count = 1;
			for(int i = n; i > 0; i--){
				if(count != m)
					sum += list.get(i-1);
				else
					count = 0;
				count++;
			}
				
			System.out.println(sum-1);
		}
		sc.close();
	}
}

Measured memory_bytes: 66636
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    if (N == M){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

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

using namespace std;

int main()
{   int n,sum=0,m;
   scanf("%d %d",&n,&m);
   for(int i=0;i<m;i++)
   {   int a;
     scanf("%d",&a);
     sum+=a;
   }
   if(sum>=n)printf("Yes");
   else printf("No");


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n;
  cin>>n;
  int ans=0;
  int now_max = 0;
  rep(i,n){
    if (i==0){
      cin>>now_max;
      ans++;
      continue;
    }
    int buf;
    cin>>buf;
    if(now_max<=buf){
      ans++;
      now_max = buf;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
i64 a,b,h,w;
cin>>a>>b;
cin>>h>>w;
cout<<a*b-(h*b+w*a-h*w);

    return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;
#define pp pair<ll,ll>
bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    ll a[n];
    map<ll,ll> mp;
    ll sum=0;
    REP(i,n)
    {
        cin>>a[i];
        mp[a[i]]++;
        sum+=a[i];
    }
    sort(a,a+n);
    ll ans=1;
    for(int i=n-2;i>=0;i--)
    {
        sum-=a[i+1];
        if(sum*2 < a[i+1])break;
        ans++;
    }
    cout<<ans;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N; 
    string S; cin >> N >> S;
    ll cnt = 0;
    for(int i = 0; i < N; i++) if(S[i] == 'R') cnt++;
    ll cnt2 = 0;
    for(int i = 0; i < cnt; i++) if(S[i] == 'R') cnt2++;
    cout << cnt - cnt2 << endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll check(ll n)
{
    set<ll> se;
    ll num = 0;
    ll i = 1;
    while (num < n)
    {
        num += i;
        se.insert(num);
        i++;
    }
    if (num != n)
    {
        return -1;
    }
    return i - 1;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll num = check(n);
    if (num == -1)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << num + 1 << endl;
    vector<vector<ll>> ans(num + 1);
    ll a = 0;
    ll b = 1;
    for (ll i = 1; i <= n; i++)
    {
        ans[a].push_back(i);
        ans[a + b].push_back(i);
        if (a + b == num)
        {
            a++;
            b = 1;
        }
        else
        {
            b++;
        }
    }
    for (ll i = 0; i < num + 1; i++)
    {
        cout << ans[i].size() << " ";
        for (auto t : ans[i])
        {
            cout << t << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

char a[801][801];
int h,w,k;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

bool isvalid(int x, int y)
{
	return (x>=0&&x<h&&y>=0&&y<w);
}

bool isexit(int x, int y)
{
	return (x==0||x==h-1||y==0||y==w-1);
}

int dist[801][801];
const int INF = int(1e9);

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>h>>w>>k;
	ii s;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='S') s=mp(i,j);
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			dist[i][j]=INF;
		}
	}
	queue<ii> q;
	q.push(s);
	dist[s.fi][s.se]=0;
	while(!q.empty())
	{
		ii tmp=q.front(); q.pop();
		for(int i=0;i<4;i++)
		{
			int x=tmp.fi+dx[i]; int y=tmp.se+dy[i];
			if(isvalid(x,y))
			{
				if(a[x][y]=='#') continue;
				if(dist[x][y]>=INF)
				{
					dist[x][y]=dist[tmp.fi][tmp.se]+1;
					q.push(mp(x,y));
				}
			}
		}
	}
	int ans=INF;
	vector<ii> vec;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(isexit(i,j)) ans=min(ans,dist[i][j]);
			if(dist[i][j]<=k)
			{
				vec.pb(mp(i,j));
			}
		}
	}
	if(ans<=k)
	{
		cout<<1<<'\n';
		return 0;
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			dist[i][j]=INF;
			if(isexit(i,j))
			{
				dist[i][j]=0;
				q.push(mp(i,j));
			}
		}
	}
	while(!q.empty())
	{
		ii tmp=q.front(); q.pop();
		for(int i=0;i<4;i++)
		{
			int x=tmp.fi+dx[i]; int y=tmp.se+dy[i];
			if(isvalid(x,y))
			{
				if(dist[x][y]>=INF)
				{
					dist[x][y]=dist[tmp.fi][tmp.se]+1;
					q.push(mp(x,y));
				}
			}
		}
	}
	for(int i=0;i<vec.size();i++)
	{
		ans=min(ans,dist[vec[i].fi][vec[i].se]);
	}
	cout<<(ans+k-1)/k+1<<'\n';
}


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

typedef long long ll;

int main()
{
	ll a;
	string b;
	cin>>a>>b;
	ll sum=(ll)(a*(ll)((ll)(b[0]-'0')*100+(ll)(b[2]-'0')*10+(ll)(b[3]-'0')));
	sum/=100;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    n = len(s)
    res = 0
    for i in range(n - 1):
        if s[i] != s[i + 1]:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3188
n = int(input())
a = [int(i) for i in input().split()]
if n == 1:
    print(1)
elif n == 2:
    if abs(a[0] - a[1]) <= 2:
        print(2)
    else:
        print(1)
else:
    d = {}
    for i in range(max(a) + 3):
        d[i] = 0
    for i in a:
        d[i] += 1
    ans = 1
    pre = 0
    for i in range(max(a) + 1):
        pre = d[i] + d[i + 1] + d[i + 2]
        if ans < pre:
            ans = pre
    print(ans)

Measured memory_bytes: 24252
import sys

def solve():
    S = input()
    mod = 7 + 10 ** 9
    DP = [[0 for _ in range(13)] for _ in range(len(S))]
    if S[0] == "?":
        for i in range(10): DP[0][i] = 1
    else: DP[0][int(S[0])] = 1

    for i in range(1, len(S)):
        if S[i] == "?":
            for j in range(13):
                for k in range(10):
                    DP[i][(j * 10 + k) % 13] += DP[i-1][j]
                    DP[i][(j * 10 + k) % 13] %= mod
        else:
            k = int(S[i])
            for j in range(13):
                DP[i][(j * 10 + k) % 13] += DP[i-1][j]
                DP[i][(j * 10 + k) % 13] %= mod
    print(DP[len(S) - 1][5])

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 65884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(m);
    vector<int> p(m);
    rep(i, m)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int ss;
            cin >> ss;
            ss--;
            s[i] += (1 << ss);
        }
    }
    rep(i, m) cin >> p[i];

    int ans = 0;
    rep(i, 1 << n)
    {
        bool on = true;
        rep(j, m)
        {
            int pc = __builtin_popcount(s[j] & i);
            if ((pc % 2) != p[j])
            {
                on = false;
                break;
            }
        }
        if (on)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>


using namespace std;

const int maxn = 1e5 + 5;

struct Edge{
    int u,v,cost;
    Edge(int u = 0,int v = 0,int cost = 0):u(u),v(v),cost(cost){}
    
}e[maxn * 10];

bool cmp2(Edge a,Edge b){
    return a.cost < b.cost;
}

struct Point{
    int x,y;
    int id;
    Point(int x = 0,int y = 0):x(x),y(y){}
    bool operator < (const Point & rhs)const{
        return x < rhs.x;
    }
}p[maxn];

bool cmp(Point a,Point b){
    return a.y < b.y;
}

int x[maxn],y[maxn];
int fa[maxn];

int find(int x){
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

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

void Union(int x,int y){
    int fx = find(x);
    int fy = find(y);
    fa[fx] = fy;
}

int main(){
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        scanf("%d%d",x + i,y + i);
        p[i].x = x[i];
        p[i].y = y[i];
        p[i].id = i;
    }
    int tot = 0;
    sort(p + 1, p + 1 + n);
    for(int i = 1;i < n;i++){
        int j = i + 1;
        e[tot++] = Edge(p[i].id,p[j].id,p[j].x - p[i].x);
    }
    sort(p + 1,p + 1 + n,cmp);
    for(int i = 1;i < n;i++){
        int j = i + 1;
        e[tot++] = Edge(p[i].id,p[j].id,p[j].y - p[i].y);
    }
    for(int i = 1;i <= n;i++){
        fa[i] = i;
    }
    long long ans = 0;
    sort(e,e + tot,cmp2);
    for(int i = 0;i < tot;i++){
        if(s(e[i].u,e[i].v)) continue;
        Union(e[i].u,e[i].v);
        ans += e[i].cost;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14336
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	//ios::sync_with_stdio(false);
  int N;
  vector<vii> adjList;
  vi colors;
  scanf("%d", &N);
  adjList.assign(N + 5, vii());
  colors.assign(N + 5, -1);
  for(int i = 0; i < N-1; i++) {
    int u,v,w;
    scanf("%d %d %d", &u, &v, &w);
    adjList[u].pb(mp(v, w));
    adjList[v].pb(mp(u, w));
  }
  queue<int> q;
  q.push(1);
  colors[1] = 0;
  while(!q.empty()) {
    int pos = q.front();
    q.pop();
    for(int i = 0; i < (int)adjList[pos].size(); i++) {
      int v = adjList[pos][i].first;
      int w = adjList[pos][i].second;
      if(colors[v] == -1) {
        if(w % 2 == 0) colors[v] = colors[pos];
        else colors[v] = 1-colors[pos];

        q.push(v);
      }
    }
  }
  for(int i = 1; i <= N; i++) {
    printf("%d\n", colors[i]);
  }
  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    string S;cin >> S;
    int ct = 0;
    rep(i,1000){
        int a = i / 100;
        int b = (i / 10)%10;
        int c = i % 10;
        bool o = false;
        bool k = false;
        rep(j,N){
            int t = S[j] - '0';
            if(k)if(t == c){
                ct++;
                break;
            }
            if(o)if(t == b)k = true;
            if(t == a)o = true;
        }
    }
    cout << ct << endl;
}



Measured memory_bytes: 256
x = gets
y = x.split(" ")
d = y[0].to_i
w = y[1].to_i
h = y[2].to_i
until d == 0 && w == 0 && h == 0
    s = (d * d) + (h * h)
    rr = s**(1/2.0)
    rr1 = rr / 2
    s = (d * d) + (w * w)
    rr = s**(1/2.0)
    rr2 = rr / 2
    s = (w * w) + (h * h)
    rr = s**(1/2.0)
    rr3 = rr / 2 
n = gets.to_i
n.times do
    r = gets.to_i
    if r > rr1
        puts "OK"
    elsif r > rr2
        puts "OK"
    elsif r > rr3
        puts "OK"
    else
        puts "NA"
    end
end

x = gets
y = x.split(" ")
d = y[0].to_i
w = y[1].to_i
h = y[2].to_i
end


Measured memory_bytes: 6916
using System;
class Program
{    
    static void Main(String[] args){
    int count = 0;
    int i = 0;
   String cha = Console.ReadLine();
  for(i=0;i<4;i++){
    if (cha[i]=='+'){
      count++;
    }else{
        count--;
    }
  }
   Console.WriteLine(count);
}
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<limits.h>
#define NIL -1
static const int MAX = 500;
static const int INFTY = (1<<21);
main(){
  int n, i, j, e, v, sum, u , minV, A[MAX];
  /*your code*/
  int M[MAX][MAX], key[MAX], p[MAX];
  
  scanf("%d", &n);
  
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
  /*
    your code
  */
  for(i = 0; i < n; i++){
    key[i] = INT_MAX;
    p[i] = NIL;
    A[i] = NIL;
  }
  
  key[0]=0;
  
  while(1){
    
    u = NIL;
    
    minV = INT_MAX;
    
    for(i = 0;  i < n; i++){
      
      if(key[i] < minV && A[i] == NIL){
	
	u = i;
	
	minV = key[i];
	
      }
      
    }  
    if(u == NIL)break;
    
    A[u] = u; 
    
    for(v = 0; v < n; v++){
      if(M[u][v] < key[v] && A[v] == NIL){
	key[v] = M[u][v];
	p[v] = u;
      }
    }
  }
  
  sum = 0;
  
  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum +=M[p[i]][i];
  }
  
  printf("%d\n", sum);
  
  
  return 0;
}

Measured memory_bytes: 804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	string s;
	cin >> s;
	if(s == "Sunny") cout << "Cloudy" << endl;
	else if(s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//template <typename... T> void read(T& ... t){ ((cin >> t), ...); }
//template <typename... T> void write(T ... t){ ((cout << t), ...); }
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define __ ' '
#define LL long long
#define pii pair<int,int>
const int INF = 2e9;
const int NN = 1<<18;
int n;
int a[NN+1];
set<pii> ans[NN+1];

set<pii> merge(set<pii> &v1, set<pii> &v2){
	set<pii> res;
	for(pii x: v1) res.insert(x);
	for(pii x: v2) res.insert(x);
	while(size(res) > 2) res.erase(begin(res));
	assert(size(res) == 2);
	return res;
}

signed main(){ FAST
	cin>>n;
	for(int i=0; i<(1<<n); ++i) cin>>a[i];

	for(int i=0; i<(1<<n); ++i) ans[i] = set<pii>({pii(a[i],i)});

	for(int i=0; i<(1<<n); ++i) for(int b=0; b<n; ++b){
		if(!((1<<b)&i)) ans[(1<<b)|i] = merge(ans[i], ans[(1<<b)|i]);
	}

	int sum = 0;
	for(int i=1; i<(1<<n); ++i){
		sum = max(sum, begin(ans[i])->first + rbegin(ans[i])->first);
		cout<<sum<<ln;
	}
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define DBG printf("Hi\n")
#define i64 long long int
#define ui64 unsigned long long int
#define eps (1e-10)
#define xx first
#define yy second
#define ln 17
#define off 2

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;

#define log 20
#define mod 998244353LL
#define maxn 200005
#define INF 1000000000

char s[55] ;

int main()
{
    scanf("%s",s) ;
    s[3] = '\0' ;

    printf("%s\n",s) ;

    return 0 ;
}


Measured memory_bytes: 3692
#include<stdio.h>
#include<string.h>
int main(void){
    int i, j, n, m, k;
    char s[100000], c[100000], S[100000];
    scanf("%d", &n);
    while ( n ) {
    for ( i = 0; i < n; i++ ) {
        scanf(" %c %c", &s[i], &S[i]);
    }
    scanf("%d", &m);
    for ( i = 0; i < m; i++ ){
        scanf(" %c", &c[i]);
        for ( j = 0; j < strlen(s); j++ ) {
            if (c[i] == s[j]) {c[i] = S[j]; break;}
        }
    }
    for ( i = 0; i < m; i++ ) printf("%c", c[i]);
    printf("\n");
    scanf("%d", &n);
    }
    return 0;
}

Measured memory_bytes: 1748
#include <iostream>
#include <array>

int main() {
  std::array<unsigned long long,5> Five;
  unsigned long long N;
  std::cin >> N;
  for(auto &f: Five)
    std::cin >> f;
  unsigned long long bn = Five[0];
  for(int i=1;i<5;i++) {
    if(Five[i] < bn)
      bn = Five[i];
  }
  unsigned long long ans = (N+bn-1)/bn + 4;
  std::cout << ans << std::endl;
  return 0;
}

/*
10000000007
2
3
5
7
11
*/

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

#define N 10000
#define Q 500

main(){
  int n,q,i,S[N],T[Q],U[Q],j,k=0,m;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&T[i]);

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      
      if(S[j]==T[i]){
	U[k]=S[j];	
	k++;
	for(m=0;m<k-1;m++){
	  if(U[m]==S[j]) k--;
	}
      }
    }
  }
  printf("%d\n",k);

  return 0;

}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ul;

const int iinf = 1 << 29;
const long long linf = 1l << 61;

typedef pair<int, int> P;
P edge[60];
vector<int> v[60];
int N, M;

int main(int argc, char* argv[])
{
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; i++)
	{
		scanf("%d %d", &edge[i].first, &edge[i].second);
		edge[i].first--;
		edge[i].second--;
		v[edge[i].first].push_back(edge[i].second);
		v[edge[i].second].push_back(edge[i].first);
	}

	int ans = 0;
	for(int i = 0; i < M; i++)
	{
		int count = 1;
		bool visit[60] = { true };
		queue<int> q;
		q.push(0);
		while(!q.empty())
		{
			int c = q.front(); q.pop();
			for(int j = 0; j < (int)v[c].size(); j++)
			{
				int next = v[c][j];
				if((c == edge[i].first && next == edge[i].second) || (c == edge[i].second && next == edge[i].first)) continue;
				if(visit[next]) continue;
				q.push(next);
				visit[next] = true;
				count++;
			}
		}
		if(count != N) ans++;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256