akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

using namespace std;
const int Max_N(305);
const int Max_K(305);

int N, K, MOD, C[Max_N][Max_N], F[Max_N][Max_K], Suf[Max_N][Max_K];

inline int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

inline int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

int main()
{
	scanf("%d%d%d", &N, &K, &MOD);
	C[0][0] = 1;
	for (int i = 1;i <= N;++i)
	{
		C[i][0] = C[i][i] = 1;
		for (int j = 1;j < i;++j)
			C[i][j] = Add(C[i - 1][j - 1], C[i - 1][j]);
	}
	for (int w = K;w >= 0;--w)
		upd(Suf[1][w] = Suf[1][w + 1], F[1][w] = 1);
	for (int n = 2;n <= N + 1;++n)
		for (int w = K;w >= 0;--w)
		{
			for (int x = 1;x <= n - 1;++x)
				upd(F[n][w], Mult(Mult(Suf[x][w + 1], C[n - 2][x - 1]), F[n - x][w]));
			upd(Suf[n][w] = Suf[n][w + 1], F[n][w]);
		}
	printf("%d", F[N + 1][0]);
	return 0;
}

Measured memory_bytes: 1280
def inpl():
    return list(map(int, input().split()))


a, b = inpl()

if a <= 0 and b >= 0:
    print('Zero')
elif a > 0:
    print('Positive')
else:
    print('Positive' if (b - a + 1) % 2 == 0 else 'Negative')


Measured memory_bytes: 2940
#include "math.h"
#include<stdio.h>
#include<map>
#include<string>
#include<iostream>
#include<vector>

using namespace std;

int main(void){
    int A,P;
    int result;

    cin >> A >> P;

    result = ((A*3)+P)/2;
    
    cout << result << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>

inline int nxt(){
     int n;
     scanf("%d", &n);
     return n;
 }
int main(){
    int a = nxt(), b = nxt(), c = nxt();
    if(a==b)printf("%d\n",c);
    else if(a==c)printf("%d\n",b);
    else printf("%d\n", a);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

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


int main(){
	double maxp=numeric_limits<double>::min();
	double minp=numeric_limits<double>::max();

	double peak;
	while(~scanf("%lf",&peak)){
		maxp = max(peak,maxp);
		minp = min(peak,minp);
	}

	printf("%lf\n",maxp-minp);
}

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

using namespace std;

int main(){
  int N;
  long long D;
  cin >> N >> D;
  
  int num = 0;
  for(int i = 0; i < N; i++){
    long long X, Y;
    cin >> X >> Y;
    if(X * X + Y * Y <= D * D) ++num;
  }
  
  cout << num << endl;
  
  return 0;
}

Measured memory_bytes: 3632
n=int(input())
a=list(input().split())
cnt=0
f=int(a[0])
for i in range(1,n):
    if int(f)<=int(a[i]):
        f=a[i]
    else:
        b=int(f)-int(a[i])
        f=int(a[i])+b
        cnt+=b
print(cnt)

Measured memory_bytes: 25220
// AOJ 0321: Investigation of Club Activities
// 2017.9.29 bal4u@uu
// 2017.11.14

#include <stdio.h>

#define MAX 100003

/* UNION-FIND library */
int p[MAX], rank[MAX];

void make_set(int x) { p[x] = x, rank[x] = 0; }
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

int joined[MAX];

char buf[30], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, m, k, i, c, a, b, ga, gb, x;

	fgets(bp=buf, 30, stdin);
	n = getint(), bp++, m = getint(), bp++, k = getint();
	for (i = 1; i <= n; i++) p[i] = i;
	for (i = 1; i <= k; i++) {
		fgets(buf, 30, stdin);
		c = *buf, bp = buf+2, a = getint(), bp++, b = getint();
		if (c == '1') {		// cmd: 1 a b
			a = find_set(a);
			b = find_set(b);
			ga = joined[a], gb = joined[b];
			if (ga > 0 && gb > 0 && ga != gb) break;
			union_set(a, b);
			x = find_set(a);
			if (ga == 0) ga = gb;
			if (ga > 0) {
				if (joined[x] == 0) joined[x] = ga;
				else if (joined[x] != ga) break;
			}
		}
		else {  // cmd: 2 a b
			a = find_set(a);
			if (!joined[a]) joined[a] = b;
			else if (joined[a] != b) break;
		}
	}
	if (i > k) puts("0");
	else printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 3004
# diff 693
n, m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
# indに気を付ける
ans = 0

# judについて0:red 1:white
jud = [0] + [1] * (n - 1)
num = [1] * n

for i in xy:
    if num[i[0] - 1] >= 2 and jud[i[0] - 1] == 0:
        jud[i[1] - 1] = 0
        num[i[0] - 1] -= 1
        num[i[1] - 1] += 1
    elif num[i[0] - 1] < 2 and jud[i[0] - 1] == 0:
        jud[i[1] - 1] = 0
        jud[i[0] - 1] = 1
        num[i[0] - 1] -= 1
        num[i[1] - 1] += 1
    else:
        num[i[0] - 1] -= 1
        num[i[1] - 1] += 1

print(jud.count(0))

Measured memory_bytes: 28964
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
int N;
ll R, C;
 
struct ST {
  int n;
  ll l, r;
};
 
bool operator<(const ST& a, const ST&b){
  return a.l < b.l;
}
 
ll trans(ll x, ll y){
  if(y==0){
    return x;
  }
  if(x==R){
    return y+R;
  }
  if(y==C){
    return (R-x)+R+C;
  }
  if(x==0){
    return (C-y)+R+C+R;
  }
  return 0;
}
 
 
int main(){
 
  cin >> R >> C >> N;
 
  vector<ST> v;
  rep(i,N){
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    bool flg1 = false, flg2 = false;
    if(x1==0 || x1==R || y1==0 || y1==C) flg1 = true;
    if(x2==0 || x2==R || y2==0 || y2==C) flg2 = true;
    if(flg1 && flg2){
      ST st;
      st.n = i+1;
      st.l = trans(x1, y1);
      st.r = trans(x2, y2);
      if(st.l > st.r) swap(st.l, st.r);
      v.push_back(st);
    }
  }
  sort(ALLOF(v));
 
  stack<ll> st;
  st.push(R+R+C+C);
  int i=0;
  while(i<v.size()){
    ll l = v[i].l;
    ll r = v[i].r;
    ll pr = st.top(); st.pop();
    if(pr < l) continue;
    if(r<pr){
      st.push(pr);
      st.push(r);
    }
    else if(pr<r){
      cout << "NO" << endl;
      return 0;
    }
    i++;
  }
  
  cout << "YES" << endl;
  
  return 0;
}


Measured memory_bytes: 4980
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
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; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

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

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


using Graph = vector<vector<int>>;
using pint = pair<int,int>;

int N, M;
Graph G;
int s, t;


long long solve() {
    vector<vector<long long>> dist(N, vector<long long>(3, -1));
    dist[s][0] = 0;
    queue<pint> que;
    que.push({s, 0});
    while (!que.empty()) {
        pint cur = que.front(); que.pop();
        int v = cur.first;
        int parity = cur.second;

        //cout << v << ", " << parity << endl;
        for (auto nv : G[v]) {
            int np = (parity + 1) % 3;
            if (dist[nv][np] == -1) {
                dist[nv][np] = dist[v][parity] + 1;
                que.push({nv, np});
            }
        }
    }
    if (dist[t][0] == -1) return -1;
    else return dist[t][0] / 3;
}

int main() {
    while (cin >> N >> M) {
        G.assign(N, vector<int>());
        for (int i = 0; i < M; ++i) {
            int u, v; cin >> u >> v; --u, --v;
            G[u].push_back(v);
            //G[v].push_back(u);
        }
        cin >> s >> t;
        --s, --t;
        cout << solve() << endl;
    }            
}


















Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<pair<int,int>>v(n);
	for(auto& a:v){
		cin>>a.first>>a.second;
	}
	double sum=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			auto pi=v[i],pj=v[j];
			sum+=sqrt((pi.first-pj.first)*(pi.first-pj.first)+(pi.second-pj.second)*(pi.second-pj.second));
		}
	}
	int divide=1;
	for(int i=2;i<=n;i++){
		divide*=i;
	}
	cout<<fixed<<setprecision(10)<<sum*2/n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s,w;
    cin>>n>>s>>w;
    vector<int> v;
    REP(i,n){
        if(s[i]==w[i]) v.push_back(0);
        else v.push_back(1),i++;
    }
    ll ans=(v[0]?6:3);
    REP(i,v.size()-1){
        if(v[i] && v[i+1]) ans*=3;
        else if(v[i] && !v[i+1]) ans*=1;
        else if(!v[i] && v[i+1]) ans*=2;
        else if(!v[i] && !v[i+1]) ans*=2;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 500010
ll n,k,q,d[N],v[N],u[N];
int main(){
    cin>>n>>k;
    lol(i,n){
	v[i]=k;
	scanf("%lld",&d[i]);
	k=min(k,abs(k-d[i]));
    }
    if(k){
	cin>>q;
	while(q--){
	    cin>>n;
	    printf("YES\n");
	}
	return 0;
    }
    k=1;
    for(int i=n-1;i>=0;i--){
	u[i]=k;
	if(k*2>d[i])k+=d[i];
    }
    cin>>q;
    while(q--){
	ll i;cin>>i;i--;
	if(v[i]>=u[i])printf("YES\n");
	else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 13696
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

struct Prime {
  int max_check;
  int max_prime;
  int prime_number;
  vector<int> primes;
  map<int, int> prime_id;
  Prime() {};
  Prime(int m) {
    initialize(m);
  };
  void initialize(int m) {
    sieve(m);
    prime_number = (int)primes.size();
    max_check = m;
  }

  void sieve(int m) {
    max_prime = 2;
    deque<bool> is_prime(m+1, true);
    is_prime[0] = is_prime[1] = false;
    int i;
    for (i = 2; i <= m; ++i) {
      if (!is_prime[i]) {
        continue;
      }
      if (i * i > m) {
        break;
      }
      for (int j = i*2; j <= m; j += i) {
        is_prime[j] = false;
      }
      prime_id[i] = (int)primes.size();
      primes.push_back(i);
      max_prime = i;
    }
    for (int j = i; j <= m; ++j) {
      if (!is_prime[j]) {
        continue;
      }
      prime_id[j] = (int)primes.size();
      primes.push_back(j);
      max_prime = j;
    }
  }

  map<int, int> prime_factor(ll x) {
    map<int, int> ret;
    if ((ll)max_check * (ll)max_check < x) {
      return ret;
    }
    for (int i = 0; i < prime_number; ++i) {
      while (x % primes[i] == 0) {
        x /= primes[i];
        ret[primes[i]] += 1;
      }
    }
    if (x != 1) {
      ret[x] += 1;
    }
    return ret;
  }
};

int mod = 1e9+7;

ll po(ll k, ll x) {
  if (x == 0) {
    return 1;
  }
  if (x == 1) {
    return k % mod;
  }
  ll y = po(k, x/2);
  y = y * y % mod;
  if (x % 2 == 1) {
    y = y * k % mod;
  }
  return y;
}

int main() {
  int n;
  scanf("%d", &n);
  Prime pr(32);
  /*
  rep (i, (int)pr.primes.size()) {
    printf("%3d : %d\n", i, pr.primes[i]);
  }
  */

  map<int, int> mps;
  FOR (i, 2, n+1) {
    auto appends = pr.prime_factor(i);
    for (auto append : appends) {
      mps[append.first] += append.second;
    }
  }

  /*
    debug(pr.max_prime);
    auto appends = pr.prime_factor(997);
    for (auto append : appends) {
      printf("%3d : %d\n", append.first, append.second);
    }
    */

  ll ans = 1;
  for (auto m : mps) {
    ans = ans * (m.second + 1) % mod;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
 
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();  	
}

bool is_prime(int num) {
    if (num == 1) {
        return true;
    }

    int d = 2;
    while (d * d <= num) {
        if (num % d == 0) {
            return false;
        }
        d++;
    }

    return true;
}

void solve() {
    int a, b;
    cin >> a >> b;

    vector<int> div1, div2;
    int d = 1;
    while (d * d < a) {
        if (a % d == 0) {
            div1.push_back(d);
            div1.push_back(a / d);
        }
        d++;
    }
    d = 1;
    if (d * d == a) {
        div1.push_back(d);
    }
    while (d * d < b) {
        if (b % d == 0) {
            div2.push_back(d);
            div2.push_back(b / d);
        }
        d++;
    }
    if (d * d == b) {
        div2.push_back(d);
    }

    set<int> s, s1, s2;
    for (auto it : div1) {
        s1.insert(it);
    }
    for (auto it : div2) {
        s2.insert(it);
    }

    for (auto it : s1) {
        if (s2.count(it)) {
            s.insert(it);
        }
    }

    int cnt = 0;
    for (auto it : s) {
        if (is_prime(it)) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1280
#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 int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int m = min(X, Y);
    int money = 0;
    money += min(m*(A+B),2*m*C);
    X -= m;
    Y -= m;
    if(X < Y){
        money += min(Y*B, 2*Y*C);
    }else{
        money += min(X*A, 2*X*C);
    }
    cout << money << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

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

int P, Q, R;
const char *p;

int formula() {
  
  p++;

  switch( *p ) {
  case '-':
    switch( formula() ) {
    case 2: return 0;
    case 1: return 1;
    case 0: return 2;
    }
  case 'P':
    return P;
  case 'Q':
    return Q;
  case 'R':
    return R;
  case '0':
    return 0;
  case '1':
    return 1;
  case '2':
    return 2;
    
  case '(':
    int form1 = formula();
    int form2;
    p++;
    switch( *p ) {
    case '*':
      form2 = formula();
      p ++;
      if( form1 == 0 || form2 == 0 ) return 0;
      if( form1 == 1 || form2 == 1 ) return 1;
      else return 2;
    case '+':
      form2 = formula();
      p++;
      if( form1 == 2 || form2 == 2 ) return 2;
      if( form1 == 1 || form2 == 1 ) return 1;
      else return 0;
    }
  }
  
  return 0;
}

int main() {
  string str;
  
  while(getline(cin, str)) {
    int cnt = 0;
    if( str == "." ) break;
    for(int i=0; i<3; i++) {
      for(int j=0; j<3; j++) {
	for(int k=0; k<3; k++) {
	  P = i, Q = j, R = k;
	  p = &str[0]-1;
	  if( formula() == 2 ) cnt ++;
	}
      }
    }

    cout << cnt << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1184
'''n,l=map(int,input().split( ))
f=[0]*(n+1)
for i in range(1,n+1):
	f[i]=l+i-1
p=[0]*(n+1)
s=[0]*(n+1)
sum=0
for i in range(1,n+1):
	p[i]=sum+f[i]
	sum=p[i]
sum=0
for i in range(n,0,-1):
	s[i]=sum+f[i]
	sum=s[i]
ans=10**9+7
total=s[1]
for i in range(1,n+1):
	if i==n:
		temp=total-f[i]
		if temp<ans:
			ans=temp
	else:
		temp=total-(p[i-1]+s[i+1])
		if temp<ans:
			ans=temp
print(ans)
print(total-ans)

'''
n,l=map(int,input().split( ))
f=[0]*(n+1)
for i in range(1,n+1):
	f[i]=l+i-1
total=sum(f)
x=10**9+7
for i in range(1,n+1):
	r=total-f[i]
	c=abs(total-r)
	if c<x:
		ans=r
		x=c
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  vector<bool> is_height(N, true);
  rep(i, N)
  {
    cin >> H[i];
  }
  rep(i, M)
  {
    int A, B;
    cin >> A >> B;
    if(H[A - 1] > H[B - 1])
      is_height[B - 1] = false;
    else if(H[A - 1] < H[B - 1])
      is_height[A - 1] = false;
    else if(H[A - 1] == H[B - 1])
    {
      is_height[A - 1] = false;
      is_height[B - 1] = false;
    }

  }
  int ans = 0;
  rep(i, N)
  {
    if(is_height[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3788
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @n = gets.to_s.to_i
    @a = gets.to_s.split.map{ |v| v.to_i }
    @b = compact
    @m = @b.size
    @money = 1000
    @stock = 0
  end

  def compact
    ans = []
    @a.each { |v| ans << v if ans.empty? || ans[-1] != v }
    ans
  end

  def solve
    return @money if m == 1
    
    m.times do |i|
      case judge(i)
      when 1
        buy(i)
      when 2
        sell(i)
      end
    end
    @money
  end

  def judge(i)
    return 1 if i == 0 && b[i] < b[i+1]
    return 2 if i == m - 1
    return 1 if b[i-1] > b[i] && b[i] < b[i+1]
    return 2 if b[i-1] < b[i] && b[i] > b[i+1]
  end

  def buy(i)
    unit = @money / b[i]
    @stock += unit
    @money -= unit * b[i]
  end

  def sell(i)
    @money += @stock * b[i]
    @stock = 0
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14368
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n;
    cin >> n;
    int x = n/200;
    int m = 10 - x;
    cout << m << '\n';
}

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


Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> a(N, 0);
    ll far = 0;
    Rep (i, N) {
        cin >> a[i];
        if (abs(a[i]) > abs(a[far])) {
            far = i;
        }
    }

    ll m = 2 * N - 1;
    cout << m << "\n";
    Rep (i, N) {
        cout << far+1 << " " << i+1 << "\n";
    }

    if (a[far] > 0) {
        Rep (i, N-1) {
            cout << i+1 << " " << i+2 << "\n";
        }
    } else {
        Rep (i, N-1) {
            cout << N-i << " " << N-i-1 << "\n";
        }
    }

    cout << flush;
}

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

int main() {
    unsigned long long N, X;
    cin >> N;
    for (X = N; X > 0; X--) {
        if ((unsigned long long)(X * 1.08) == N) {
            cout << X << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
from operator import itemgetter

def sub(prefers, canceled):
    res = Counter()
    for pref in prefers:
        p = pref[-1]
        while p in canceled:
            pref.pop()
            p = pref[-1]
        res[p] += 1
    return max(res.items(), key=itemgetter(1))

def solve(m, prefers):
    canceled = set()
    ans = float('inf')
    for _ in [0] * m:
        s, c = sub(prefers, canceled)
        canceled.add(s)
        ans = min(ans, c)
    return ans

if __name__ == '__main__':
    N, M = map(int, input().split())
    A = [list(map(int, input().split()))[::-1] for _ in [0] * N]
    print(solve(M, A))

Measured memory_bytes: 4580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class294
    {
        static void Main()
        {
            var abcd = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int a = abcd[0], b = abcd[1], c = abcd[2], d = abcd[3];
            while (true)
            {
                c -= b;
                if (c <= 0) { Console.WriteLine("Yes");return; }
                a -= d;
                if (a <= 0) { Console.WriteLine("No");return; }
            }
        }
    }
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll n,k;
ll ans;

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

    for (int a=1; a<=n; a++) {
	ll b = k - a;
	if (b<=0) {
	    b%=k;
	    b+=k;
	}
	if ((b+b)%k == 0) {
	    ll cnt = (n-b)/k + 1;
	    ll cur = cnt*cnt;
	    //cerr<<a<<": "<<cur<<endl;
	    ans += cur;
	    
	}
    }

    cout<<ans<<endl;  

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

long long int grundy(long long int a, long long int k){
	if(a<k){
		return 0;
	}else if(a%k==0){
		return a/k;
	}else{
		long long int r=a%k, m=a/k;
		return grundy(a-((r+m)/(m+1))*(m+1), k);
	}
}

int main()
{
	int n;
	scanf("%d", &n);
	long long int ans=0;
	for(int i=0; i<n; i++){
		long long int a, k;
		scanf("%lld %lld", &a, &k);
		ans^=grundy(a, k);
	}
	if(ans==0){
		printf("%s\n", "Aoki");
	}else{
		printf("%s\n", "Takahashi");
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
using namespace std;
int main(){
string S,T;
getline(cin,S);
getline(cin,T);
if(S.substr(0,(S.length())) == T.substr(0,(T.length()-1))){
 
cout<<"Yes";
}  
   else{
   cout<<"No";
   }
 
 
return 0;
}

Measured memory_bytes: 3604
#include<iostream>

using namespace std;

int main(){

    ios::sync_with_stdio(false);

    int n,l,x;
    int d=0,cont=1;;

    cin>>n>>x;

    while(n--){
        cin>>l;
        d += l;
        if(d<=x){
            cont++;
        }
        else break;
    }

    cout<<cont<<endl;

    return 0;
}

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

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

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

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

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

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

void solve(void)
{
  int N, L; cin >> N >> L;
  vector<string> S(N);
  for (auto& s : S) { cin >> s; }
  boost::sort(S);
  for (const auto& s : S) {
    cout << s;
  }
  cout << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
s=input()
if s == s[::-1] and s[0:(len(s)-1)//2-1] == s[(len(s)-1)//2-1:0:-1] and s[len(s)//2+1:len(s)] == s[len(s):len(s)//2:-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N = int(input())
hlist = list(map(int, input().split()))
def count_island(height):
    res = 0
    sink = True
    for h in hlist:
        if sink and h > height:
            res += 1
            sink = False
        if h <= height:
            sink = True
    return res

ans = 0
for height in range(max(hlist)):
    ans += count_island(height)
print(ans)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

mat, q, b = [list(map(int, input().split())) for i in range(3)], int(
    input()), [[False, False, False] for i in range(3)]
s = [int(input()) for i in range(q)]
for i in range(q):
    x = s[i]
    for j in range(3):
        for k in range(3):
            if mat[j][k] == x:
                b[j][k] = True
    # Check
    for l in b:
        if l == [True, True, True]:
            print('Yes')
            exit()
    for j in range(3):
        if [b[i][j] for i in range(3)] == [True, True, True]:
            print('Yes')
            exit()
    if [b[0][0], b[1][1], b[2][2]] == [True, True, True]:
        print('Yes')
        exit()
    if [b[0][2], b[1][1], b[2][0]] == [True, True, True]:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 61772
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#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 de(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

const int MAX_N = 1e5 + 7;
const int MOD = 1e9 + 7;
///----------------------------------------------
int qpow(int a,int b) {
	int ret=1;
	for (; b; b>>=1) {
		if (b&1) ret=1ll*ret*a%MOD;
		a=1ll*a*a%MOD;
	}
	return ret;
}
int odd[MAX_N];
int eve[MAX_N];
int main() {

	//read
	int n; cin>>n;
	int ok=0;
	rep(i,0,n) {
		int dig; scanf("%d",&dig);
		if (dig&1) odd[dig/2]++;
			else eve[dig/2]++;
		if (dig&1) ok|=1;
			else ok|=2;
	}

	///work
	if (ok==3) { puts("0"); return 0; }
	if (ok==1) rep(i,0,(n+1)/2) if (odd[i]!=2) { puts("0"); return 0; }
	if (ok==2) rep(i,1,(n+1)/2) if (eve[i]!=2) { puts("0"); return 0; }
	if (ok==2 && eve[0]!=1) { puts("0"); return 0; }

	printf("%d",qpow(2,n/2));
	




}


Measured memory_bytes: 640
def sum_digit(b, n):
    if n < b:
        return n
    return sum_digit(b, n // b) + n % b

N = int(input())
S = int(input())

if S > N:
    print(-1)
elif S == N:
    print(N + 1)
else:
    sqrt = int(pow(N, 0.5))
    for b in range(2, sqrt + 1):
        if sum_digit(b, N) == S:
            print(b)
            quit()
    for k in reversed(range(1, sqrt + 1)):
        if (N - S) % k == 0:
            b = (N - S) // k + 1
            if sum_digit(b, N) == S:
                print(b)
                quit()
    print(-1)


Measured memory_bytes: 3064
n, m = map(int, input().split())
a = []
for _ in range(n):
    a += list(map(int, input().split()))[1:]

ans = 0
for i in range(m):
    _a = sum([x == i+1 for x in a])
    if _a == n:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MAXN 105
using namespace std;

int n, m;
char a[MAXN][MAXN];
bool allWRows[MAXN], allWCols[MAXN];

int main() {
    ios::sync_with_stdio(0);

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

    for (int i = 1; i <= n; ++i) {
        allWRows[i] = 1;
        for (int j = 1; j <= m; ++j) {
            if (a[i][j] == '#') {
                allWRows[i] = 0;
                break;
            }
        }
    }

    for (int j = 1; j <= m; ++j) {
        allWCols[j] = 1;
        for (int i = 1; i <= n; ++i) {
            if (a[i][j] == '#') {
                allWCols[j] = 0;
                break;
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        if (allWRows[i])
            continue;
        for (int j = 1; j <= m; ++j) {
            if (allWCols[j])
                continue;
            cout << a[i][j];
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 2e5 + 1;
int ad(ll a , ll b){
	return(a + b)%M;
}
int mult(ll a , ll b){
	return(a*b)%M;
}
int cs[N] , a[N] , n;
int main(){
	cin >> n;
	for (int i = 0; i < n; ++i){
		scanf("%d",a+i);
	}
	for (int i = n-1; i >= 0; --i){
		cs[i] = ad(cs[i+1] , a[i]);
	}
	int ans = 0;
	for (int i = 0; i < n; ++i){
		ans = ad(ans , mult(a[i] , cs[i+1]));
	}
	printf("%d\n",ans);
}	

Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1LL << 60;


int main() {
  int c[5][5];
  for(int i=0;i<3;i++){
     for(int j=0;j<3;j++){
        cin>>c[i][j];
     }
  }
  
  int dis1=c[0][1]-c[0][0];
  int dis2=c[0][2]-c[0][1];

  for(int i=1;i<3;i++){
      if((c[i][1]-c[i][0])!=dis1||(c[i][2]-c[i][1])!=dis2){
       cout<<"No"<<endl;return 0;
      }
     }
   cout<<"Yes"<<endl;
   return 0;
  }

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int m,f,r;

	while (1)
	{
		scanf("%d %d %d", &m, &f, &r);

		if (m == -1 && f == -1 && r == -1)break;

		if (m == -1 || f == -1)
		{
			printf("F\n");
		}

		else if (m + f >= 80)
		{
			printf("A\n");
		}

		else if (m + f >= 65)
		{
			printf("B\n");
		}

		else if (m + f >= 50)
		{
			printf("C\n");
		}

		else if (m + f >= 30)
		{
			if (r >= 50)
			{
				printf("C\n");
			}

			else
			{
				printf("D\n");
			}
		}

		else if (m + f < 30)
		{
			printf("F\n");
		}

	}

	return 0;
}


Measured memory_bytes: 2052
#include <algorithm>
#include <cstdio>
#include <numeric>

int n, k, a[1010];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    std::sort(a + 1, a + n + 1);
    int ans = std::accumulate(a + 1, a + k + 1, 0);
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define int long long
using namespace std;

signed main() {
	int a;
	cin >> a;
	for (int b = 1; b <=a; b++) {
		if (b % 3 == 0) { cout << " " << b; continue; }
		string c = to_string(b);
		for (int d = 0; d < c.length(); d++) {
			if (c[d] == '3') { cout << " " << b; break; }
		}
	}
	cout << endl;
}

Measured memory_bytes: 3260
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int D = sc.nextInt();
		int per = (H*W)%D;
		int[] hl = new int[H*W];
		int[] wl = new int[H*W];

		//ArrayList<Integer> data = new ArrayList<Integer>();
		/*for(int i =0;i<H*W;i++){
			data.add(sc.nextInt());
		}*/

		for(int h=0;h<H;h++){
			for(int w =0;w<W;w++){
				int A =sc.nextInt();
				hl[A-1] = h;
				wl[A-1] = w;
			}
		}

		ArrayList<ArrayList<Integer>> costarray = new ArrayList<ArrayList<Integer>>();
		for(int d=1;d<=D;d++){
			ArrayList<Integer> cost = new ArrayList<Integer>();
			cost.add(0);
			int mp = 0;
			int hoge=-1;
			int x=0;
			int y=0;
			int i=0;
			int j=0;
			if(d <= per){
				hoge =0;
			}
			for(int a =0;a<(H*W)/D+hoge;a++){
				int num = d+a*D;
				/*if(a==0){
					x = data.lastIndexOf(num)/W+1;
					y = data.lastIndexOf(num)%W+1;
				}
				i = data.lastIndexOf(num+D)/W+1;
				j = data.lastIndexOf(num+D)%W+1;*/
				if(a==0){
					x =hl[num-1];
					y =wl[num-1];
				}
				i = hl[num+D-1];
				j = wl[num+D-1];
				mp = mp + Math.abs(x-i) + Math.abs(y-j);
				cost.add(mp);
				x = i;
				y = j;
			}
			costarray.add(cost);
		}

		int Q = sc.nextInt();
		for(int i=0;i<Q;i++){
			int L=sc.nextInt();
			int R=sc.nextInt();
			int LL=(L-1)%D;
			int ans = costarray.get(LL).get((R-1)/D)-costarray.get(LL).get((L-1)/D);
			System.out.println(ans);
		}
		sc.close();
	}
}


Measured memory_bytes: 103008
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;




int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int tot=m2-m1+60*(h2-h1);
	cout<<max(0,tot-k);
	
	

    return 0;
}

Measured memory_bytes: 3652
/*Bismillahir Rahmanir Raheem*/

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

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;

// defined for taking input
#define gl(x) getline(cin, x)
#define sf scanf
#define sfi(x) scanf("%d", &x)
#define sfc(x) scanf("%c", &x)
#define sfl(x) scanf("%lld", &x)
#define sflu(x) scanf("%llu", &x)
#define sfii(x, y) scanf("%d %d", &x, &y)
#define sfll(x, y) scanf("%lld %lld", &x, &y)
#define sfiii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sflll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)

//defined for printing
#define pf printf
#define pfn pf("\n")
#define pfcas pf("Case %d: ", cas)
#define pfyes pf("YES");
#define pfno pf("NO");
#define pfi(x) pf("%d", x)
#define pfl(x) pf("%lld", x)
#define pflu(x) pf("%llu", x)

//defined for loop

//increament
#define loopi(i, j, k) for (int i = j; i < k; i++)
#define loopl(i, j, k) for (ll i = j; i < k; i++)
#define loopc(i, j, k) for (char i = j; i < k; i++)
#define looplu(i, j, k) for (ull i = j; i < k; i++)
//decreament
#define loopri(i, j, k) for (int i = j; i > k; i--)
#define looprl(i, j, k) for (ll i = j; i > k; i--)
#define looprlu(i, j, k) for (ull i = j; i > k; i--)
#define looprc(i, j, k) for (char i = j; i > k; i--)
#define wa(t) while (t--)

//testcases
#define testc(t) for (char cas = 1; cas <= t; cas++)
#define testi(t) for (int cas = 1; cas <= t; cas++)
#define testl(t) for (ll cas = 1; cas <= t; cas++)

//some cmd
#define pb push_back
#define ppb pop_back
#define mp make_pair

//code start
ull ans(ull n)
{
    ull x = 0, num = 10;
    while (num <= n)
    {
        x += n / num;
        num *= 5;
    }
    return x;
}
int main()
{
    // freopen("/home/grimfirefly/Programming/input.txt", "r", stdin);
    // freopen("/home/grimfirefly/Programming/output.txt", "w", stdout);

    ull n;
    sflu(n);
    // if(!n)
    // n=12;
    pf("%llu\n", n & 1 ? 0 : ans(n));

    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		ArrayList<Integer> array = new ArrayList<Integer>();

		for(int i=0;i<n;i++) {
			array.add(sc.nextInt());
		}
		int min=100000;
		int t=0;
		int sum1=0;
		int sum2=0;
		int i,j;
		while(true) {
			for(i=0;i<t;i++) {
				sum1+=array.get(i);
			}
			for(j=array.size()-1;j>=i;j--) {
				sum2+=array.get(j);
			}
			if(min>=Math.abs(sum1-sum2)) min=Math.abs(sum1-sum2);
			t++;

			sum1=0;
			sum2=0;
			if(t==n)break;
		}
		System.out.println(min);
	}
}



Measured memory_bytes: 23764
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	
	vector<int> a(5);
	trav(i,a){i=in();}
	int ans=accumulate(all(a),0LL);
	int t;int mx=0;
	for(auto i:a)
	{
		t=(i+9)/10;
		t*=10;
		ans+=t-i;
		mx=max(mx,t-i);
	}
	cout<<ans-mx;
	
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int N,D;
	cin>>N>>D;
	cout<<(N+2*D) / (2*D+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N,M,C=map(int,input().split())
B=np.array(list(map(int,input().split())))
A=[]
count=0
for i in range(N):
    A.append(list(map(int,input().split())))
for i in range(N):
    numlist=A[i]
    numlist=np.array(numlist)
    numlist=numlist*B
    if np.sum(numlist)+C>0:
        count+=1
print(count)

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

int main() {
  string s;
  cin >> s;
    if(s == "SSS")cout << 0 << endl;
    if(s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR")cout << 1 << endl;
    if(s == "RRS" || s == "SRR")cout << 2 << endl;
    if(s == "RRR")cout << 3 << endl;
}



Measured memory_bytes: 3624
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size){
        data=vector<int>(size,-1);
    }
    bool union_set(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];
            data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    string s=get_str();
    int R=0,B=0;
    FOR(i,N){
        if(s[i]=='R'){
            R++;
        }else{
            B++;
        }
    }
    print(R>B?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
def r;gets.split.map &:to_i;end

N,W = r
DP = [[0,0]] # weight, value

N.times do
  w,v = r
  DP.size.times do |i|
    next if DP[i][0] + w > W
    DP << [DP[i][0] + w, DP[i][1] + v]
  end

  DP.sort!

  i = 0
  while i < DP.size - 1
    unless DP[i][1] < DP[i+1][1]
      DP.delete_at(i+1)
    else
      i += 1
    end
  end
end

p DP[-1][1]

Measured memory_bytes: 2680
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M;
	cin >> N >> M;

	vector<lint> cum(N + 1, 0);
	map<lint, lint> count;

	count[0]++;
	for (int i = 0; i < N; i++)
	{
		lint tmp;
		cin >> tmp;
		cum[i + 1] = (cum[i] + tmp) % M;
		count[cum[i + 1]]++;
	}

	lint ans = 0;
	for (auto out : count)
	{
		ans += out.second * (out.second - 1) / 2;
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;


int a[200010];
int b[200010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    map<string, int> mp;
    REP(i, n){
        ll a, c; string b; cin >> a;
        if(a==0){
            cin >> b >> c;
            mp[b] = c;
        }else if(a==1){
            cin >> b;
            cout << mp[b] << endl;
        }else if(a==2){
            cin >> b;
            mp[b]=0;
        }
    }
	return 0;
}


Measured memory_bytes: 25904
#include<bits/stdc++.h>
#define ll long long
#define mx 200005
#define mod 1000000007
#define mxm 999999999999
using namespace std;

ll dp[200][mx];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    
    ll n,p,w[200],v[200],i,j;
    cin>>n>>p;
    for(i=1;i<n+1;i++)
    {
        cin>>w[i]>>v[i];
       // dp[i][0]=0;
    }
    for(i=1;i<n+1;i++){
        
        for(j=1;j<p+1;j++){
            
            if(j<w[i])
            dp[i][j]=dp[i-1][j];
            else{
                dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
            }
        }
    }
    
    ll ans=dp[n][p];
    cout<<ans;
	return 0;
}

Measured memory_bytes: 156416